// Path: app/src/main/java/ooo/oxo/apps/materialize/AppInfo.java
// public class AppInfo {
// 
//     private static final String TAG = "AppInfo";
// 
//     private static int[] DENSITIES = new int[]{
//             DisplayMetricsCompat.DENSITY_XXXHIGH,
//             DisplayMetricsCompat.DENSITY_XXHIGH,
//             DisplayMetricsCompat.DENSITY_XHIGH,
//             DisplayMetricsCompat.DENSITY_HIGH   // 这都没有狗带吧
//     };
// 
//     public final ActivityInfo activityInfo;
// 
//     public ComponentName component;
// 
//     public String label;
// 
//     public Pinyin labelPinyin;
// 
//     public Resources res;
// 
//     public int iconResId;
// 
//     public TypedValue iconValue = new TypedValue();
// 
//     public Bitmap icon = null;
// 
//     public Uri cache = null;
// 
//     private AppInfo(ActivityInfo activityInfo) {
//         this.activityInfo = activityInfo;
//     }
// 
//     /**
//      * Wraps and resolve an {@link ActivityInfo}
//      *
//      * @param activityInfo   The {@link ActivityInfo} object to resolve
//      * @param packageManager A {@link PackageManager} instance to resolve the {@link ActivityInfo}
//      * @return An {@link AppInfo} instance with its {@link #label} and icon resolved
//      */
//     @Nullable
//     public static AppInfo from(ActivityInfo activityInfo, PackageManager packageManager) {
//         AppInfo app = new AppInfo(activityInfo);
//         return app.resolve(packageManager) ? app : null;
//     }
// 
//     @Nullable
//     public static AppInfo from(ActivityInfo activityInfo, PackageManager packageManager, IconCacheManager iconCacheManager) {
//         AppInfo app = from(activityInfo, packageManager);
// 
//         if (app != null) {
//             app.resolveCache(iconCacheManager);
//         }
// 
//         return app;
//     }
// 
//     public boolean resolve(PackageManager packageManager) {
//         component = new ComponentName(activityInfo.packageName, activityInfo.name);
// 
//         label = activityInfo.loadLabel(packageManager).toString();
//         labelPinyin = Pinyin.from(label);
// 
//         String app = activityInfo.applicationInfo.packageName;
// 
//         try {
//             res = packageManager.getResourcesForApplication(activityInfo.applicationInfo);
//         } catch (PackageManager.NameNotFoundException e) {
//             Log.e(TAG, "Failed to get resources from " + app, e);
//             return false;
//         }
// 
//         iconResId = activityInfo.getIconResource();
// 
//         if (iconResId == 0) {
//             Log.e(TAG, "No icon found in " + app);
//             return false;
//         }
// 
//         if (!resolveIconValue()) {
//             Log.e(TAG, "Failed to resolve icon drawable for " + app);
//             return false;
//         }
// 
//         return true;
//     }
// 
//     private boolean resolveIconValue() {
//         for (int density : DENSITIES) {
//             try {
//                 res.getValueForDensity(iconResId, density, iconValue, true);
//                 return true;
//             } catch (Exception ignored) {
//             }
//         }
// 
//         return false;
//     }
// 
//     public boolean resolveIcon() {
//         if (iconResId == 0) {
//             return false;
//         }
// 
//         icon = BitmapFactory.decodeStream(res.openRawResource(iconResId, iconValue));
// 
//         return icon != null;
//     }
// 
//     public boolean resolveCache(IconCacheManager iconCacheManager) {
//         cache = iconCacheManager.get(this);
//         return cache != null;
//     }
// 
//     public Intent getIntent() {
//         return new Intent(Intent.ACTION_MAIN)
//                 .putExtra("__materialize_nonce__", System.currentTimeMillis())
//                 .setComponent(component)
//                 .setFlags(activityInfo.flags);
//     }
// 
//     @Override
//     public String toString() {
//         return "AppInfo{" + (component == null ? "(not resolved)" : component.flattenToShortString()) + "}";
//     }
// 
//     public static class Pinyin {
// 
//         public final String pinyinLong;
// 
//         public final String pinyinShort;
// 
//         private Pinyin(String[] source) {
//             StringBuilder builderLong = new StringBuilder();
//             StringBuilder builderShort = new StringBuilder();
// 
//             for (String s : source) {
//                 s = s.trim();
//                 if (TextUtils.isGraphic(s)) {
//                     builderLong.append(s);
//                     builderShort.append(s.charAt(0));
//                 }
//             }
// 
//             this.pinyinLong = builderLong.toString();
//             this.pinyinShort = builderShort.toString();
//         }
// 
//         public static Pinyin from(String source) {
//             return new Pinyin(PinyinHelper.convertToPinyinString(source, " ", PinyinFormat.WITHOUT_TONE)
//                     .toLowerCase()
//                     .split(" "));
//         }
// 
//     }
// 
// }


import android.content.Context;
import android.net.Uri;
import android.support.annotation.Nullable;
import android.util.Log;
import java.io.File;
import java.io.IOException;
import ooo.oxo.apps.materialize.AppInfo;
        if (file == null || !file.isFile()) {
            return null;
        } else {
            return Uri.fromFile(file);
        }
    }

    @Nullable
    @Override
    protected File makeIconFile(AppInfo app) {
        File dir = makeIconDirectory(app);
        return dir == null ? null : new File(dir, app.component.getClassName());
    }

    @Nullable
    private File makeIconDirectory(AppInfo app) {
        File dir = new File(root, app.component.getPackageName());

        if (!dir.mkdirs() && !dir.isDirectory()) {
            Log.e(TAG, "Failed to create icon directory for package at " + dir.getAbsolutePath());
            return null;
        }

        createNoMediaFile(dir);

        return dir;
    }

    private boolean createNoMediaFile(File dir) {
        try {
// Path: app/src/main/java/ooo/oxo/apps/materialize/AppInfo.java
// public class AppInfo {
// 
//     private static final String TAG = "AppInfo";
// 
//     private static int[] DENSITIES = new int[]{
//             DisplayMetricsCompat.DENSITY_XXXHIGH,
//             DisplayMetricsCompat.DENSITY_XXHIGH,
//             DisplayMetricsCompat.DENSITY_XHIGH,
//             DisplayMetricsCompat.DENSITY_HIGH   // 这都没有狗带吧
//     };
// 
//     public final ActivityInfo activityInfo;
// 
//     public ComponentName component;
// 
//     public String label;
// 
//     public Pinyin labelPinyin;
// 
//     public Resources res;
// 
//     public int iconResId;
// 
//     public TypedValue iconValue = new TypedValue();
// 
//     public Bitmap icon = null;
// 
//     public Uri cache = null;
// 
//     private AppInfo(ActivityInfo activityInfo) {
//         this.activityInfo = activityInfo;
//     }
// 
//     /**
//      * Wraps and resolve an {@link ActivityInfo}
//      *
//      * @param activityInfo   The {@link ActivityInfo} object to resolve
//      * @param packageManager A {@link PackageManager} instance to resolve the {@link ActivityInfo}
//      * @return An {@link AppInfo} instance with its {@link #label} and icon resolved
//      */
//     @Nullable
//     public static AppInfo from(ActivityInfo activityInfo, PackageManager packageManager) {
//         AppInfo app = new AppInfo(activityInfo);
//         return app.resolve(packageManager) ? app : null;
//     }
// 
//     @Nullable
//     public static AppInfo from(ActivityInfo activityInfo, PackageManager packageManager, IconCacheManager iconCacheManager) {
//         AppInfo app = from(activityInfo, packageManager);
// 
//         if (app != null) {
//             app.resolveCache(iconCacheManager);
//         }
// 
//         return app;
//     }
// 
//     public boolean resolve(PackageManager packageManager) {
//         component = new ComponentName(activityInfo.packageName, activityInfo.name);
// 
//         label = activityInfo.loadLabel(packageManager).toString();
//         labelPinyin = Pinyin.from(label);
// 
//         String app = activityInfo.applicationInfo.packageName;
// 
//         try {
//             res = packageManager.getResourcesForApplication(activityInfo.applicationInfo);
//         } catch (PackageManager.NameNotFoundException e) {
//             Log.e(TAG, "Failed to get resources from " + app, e);
//             return false;
//         }
// 
//         iconResId = activityInfo.getIconResource();
// 
//         if (iconResId == 0) {
//             Log.e(TAG, "No icon found in " + app);
//             return false;
//         }
// 
//         if (!resolveIconValue()) {
//             Log.e(TAG, "Failed to resolve icon drawable for " + app);
//             return false;
//         }
// 
//         return true;
//     }
// 
//     private boolean resolveIconValue() {
//         for (int density : DENSITIES) {
//             try {
//                 res.getValueForDensity(iconResId, density, iconValue, true);
//                 return true;
//             } catch (Exception ignored) {
//             }
//         }
// 
//         return false;
//     }
// 
//     public boolean resolveIcon() {
//         if (iconResId == 0) {
//             return false;
//         }
// 
//         icon = BitmapFactory.decodeStream(res.openRawResource(iconResId, iconValue));
// 
//         return icon != null;
//     }
// 
//     public boolean resolveCache(IconCacheManager iconCacheManager) {
//         cache = iconCacheManager.get(this);
//         return cache != null;
//     }
// 
//     public Intent getIntent() {
//         return new Intent(Intent.ACTION_MAIN)
//                 .putExtra("__materialize_nonce__", System.currentTimeMillis())
//                 .setComponent(component)
//                 .setFlags(activityInfo.flags);
//     }
// 
//     @Override
//     public String toString() {
//         return "AppInfo{" + (component == null ? "(not resolved)" : component.flattenToShortString()) + "}";
//     }
// 
//     public static class Pinyin {
// 
//         public final String pinyinLong;
// 
//         public final String pinyinShort;
// 
//         private Pinyin(String[] source) {
//             StringBuilder builderLong = new StringBuilder();
//             StringBuilder builderShort = new StringBuilder();
// 
//             for (String s : source) {
//                 s = s.trim();
//                 if (TextUtils.isGraphic(s)) {
//                     builderLong.append(s);
//                     builderShort.append(s.charAt(0));
//                 }
//             }
// 
//             this.pinyinLong = builderLong.toString();
//             this.pinyinShort = builderShort.toString();
//         }
// 
//         public static Pinyin from(String source) {
//             return new Pinyin(PinyinHelper.convertToPinyinString(source, " ", PinyinFormat.WITHOUT_TONE)
//                     .toLowerCase()
//                     .split(" "));
//         }
// 
//     }
// 
// }


// Path: app/src/main/java/ooo/oxo/apps/materialize/io/IconCacheManager.java
import android.content.Context;
import android.net.Uri;
import android.support.annotation.Nullable;
import android.util.Log;
import java.io.File;
import java.io.IOException;
import ooo.oxo.apps.materialize.AppInfo;

        if (file == null || !file.isFile()) {
            return null;
        } else {
            return Uri.fromFile(file);
        }
    }

    @Nullable
    @Override
    protected File makeIconFile(AppInfo app) {
        File dir = makeIconDirectory(app);
        return dir == null ? null : new File(dir, app.component.getClassName());
    }

    @Nullable
    private File makeIconDirectory(AppInfo app) {
        File dir = new File(root, app.component.getPackageName());

        if (!dir.mkdirs() && !dir.isDirectory()) {
            Log.e(TAG, "Failed to create icon directory for package at " + dir.getAbsolutePath());
            return null;
        }

        createNoMediaFile(dir);

        return dir;
    }

    private boolean createNoMediaFile(File dir) {
        try {
            File noMedia = new File(dir, NO_MEDIA);