@TargetApi(Build.VERSION_CODES.M)
    public Icon getIcon(String resName, Transform<Bitmap> bitmapTransform) {
        if (!PkgUtils.isPkgInstalled(this.context, appPackageName)) {
            return Icon.createWithResource(this.context.getResources(), android.R.drawable.stat_sys_warning);
        }
        if (DEBUG) {
            Log.d(LOG_TAG, "getIcon, resName: " + resName);
        }
        try {
            Context appContext = getAppContext();
            if (appContext != null) {
                Resources res = appContext.getResources();
                if (DEBUG) {
                    Log.d(LOG_TAG, "getIcon, res: " + res);
                }
                if (res != null) {
                    int id = res.getIdentifier(resName, "drawable", appPackageName);
                    if (DEBUG) {
                        Log.d(LOG_TAG, "getIcon, id: " + id);
                    }
                    if (id > 0) {
                        Icon ic = null;
                        // Create with res directly.
                        if (bitmapTransform == null) {
                            ic = Icon.createWithResource(res, id);
                        } else {
                            // Create bitmap and transform.
                            try {
                                Bitmap icb = BitmapFactory.decodeResource(res, id);
                                if (icb != null) {
                                    icb = bitmapTransform.onTransform(icb);
                                    if (icb != null) {
                                        ic = Icon.createWithBitmap(icb);
                                    }
                                }
                            } catch (Exception e) {
                                Log.e(LOG_TAG, "getIcon, bitmap transform err: " + e);
                            } finally {
                                // Back to res.
                                if (ic == null) {
                                    ic = Icon.createWithResource(res, id);
                                }
                            }
                        }
                        if (DEBUG) {
                            Log.d(LOG_TAG, "getIcon, ic: " + ic);
                        }
                        if (ic != null) {
                            return ic;
                        }
                    }
                }
            }
        } catch (Throwable e) {
            Log.e(LOG_TAG, "Fail getIcon: " + Log.getStackTraceString(e));
        }
        return Icon.createWithResource(getContext(), android.R.drawable.stat_sys_warning);
    }
Created by Tornaco on 2018/4/4 10:56.
God bless no bug!
android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/app/AppResources.java