Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 39b1fcd5 authored by Andy Mast's avatar Andy Mast
Browse files

Allow icons in shared restables to be themed

Example
Google Drive's package  name: com.google.android.apps.docs
Google Drive's restable name: com.google.android.apps.docs.common

Before this patch we used resource table name to get the package info. For
app's like google drive this return a null package info and the icon would not be themed.

So instead of usnig the restable name, this patch creates a package name
in AssetManager that is set by getTopLevelResources.

Change-Id: Ic51b93f6c7ea0a32197682998c6d0aa36d774845
parent 3b534ed3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1540,8 +1540,8 @@ public final class ActivityThread {
     */
    Resources getTopLevelResources(String resDir, String[] overlayDirs,
            int displayId, Configuration overrideConfiguration,
            LoadedApk pkgInfo, Context context) {
        return mResourcesManager.getTopLevelResources(resDir, overlayDirs, displayId, pkgInfo.mPackageName,
            LoadedApk pkgInfo, Context context, String pkgName) {
        return mResourcesManager.getTopLevelResources(resDir, overlayDirs, displayId, pkgName,
                overrideConfiguration, pkgInfo.getCompatibilityInfo(), null, context);
    }

+2 −1
Original line number Diff line number Diff line
@@ -774,7 +774,8 @@ final class ApplicationPackageManager extends PackageManager {

        Resources r = mContext.mMainThread.getTopLevelResources(
                app.uid == Process.myUid() ? app.sourceDir : app.publicSourceDir,
                app.resourceDirs, Display.DEFAULT_DISPLAY, null, mContext.mPackageInfo, mContext);
                app.resourceDirs, Display.DEFAULT_DISPLAY, null, mContext.mPackageInfo, mContext,
                app.packageName);
        if (r != null) {
            return r;
        }
+1 −1
Original line number Diff line number Diff line
@@ -493,7 +493,7 @@ public final class LoadedApk {
    public Resources getResources(ActivityThread mainThread) {
        if (mResources == null) {
            mResources = mainThread.getTopLevelResources(mResDir, mOverlayDirs,
                    Display.DEFAULT_DISPLAY, null, this, mainThread.getSystemContext());
                    Display.DEFAULT_DISPLAY, null, this, mainThread.getSystemContext(), mPackageName);
        }
        return mResources;
    }
+2 −9
Original line number Diff line number Diff line
@@ -193,6 +193,7 @@ public class ResourcesManager {
        //}

        AssetManager assets = new AssetManager();
        assets.setAppName(packageName);
        assets.setThemeSupport(compatInfo.isThemeable);
        if (assets.addAssetPath(resDir) == 0) {
            return null;
@@ -268,18 +269,10 @@ public class ResourcesManager {
     */
    private void setActivityIcons(Resources r) {
        SparseArray<PackageItemInfo> iconResources = new SparseArray<PackageItemInfo>();
        String pkgName = null;
        String pkgName = r.getAssets().getAppName();
        PackageInfo pkgInfo = null;
        ApplicationInfo appInfo = null;

        int count = r.getAssets().getBasePackageCount();
        if (count > 1) {
            pkgName = r.getAssets().getBasePackageName(1);
        } else if (count <= 1) {
            return;
        }


        try {
            pkgInfo = getPackageManager().getPackageInfo(pkgName, PackageManager.GET_ACTIVITIES, UserHandle.myUserId());
        } catch (RemoteException e1) {
+8 −0
Original line number Diff line number Diff line
@@ -785,6 +785,14 @@ public final class AssetManager {
        mThemeCookies.add(cookie);
    }

    public String getAppName() {
        return mAppName;
    }

    public void setAppName(String pkgName) {
        mAppName = pkgName;
    }

    /**
     * Determine whether the state in this asset manager is up-to-date with
     * the files on the filesystem.  If false is returned, you need to