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

Commit c32892a3 authored by Sergey Ten's avatar Sergey Ten
Browse files

Add get/set ThemePackageName to AssetManager.

These methods will be used in two different scenarios:
1. By a context to check/verify that its asset manager
includes theme apk resources.
2. By a widget to retrieve theme package name.

CR:JoshG.
parent dfc2d5c6
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -185,7 +185,9 @@ public final class ActivityThread {
                    PackageInfo pi = getPackageInfo(config.customTheme.getThemePackageName(), 0);
                    if (pi != null) {
                        String resDir = pi.getResDir();
                        if (assets.addAssetPath(resDir) == 0) {
                        if (assets.addAssetPath(resDir) != 0) {
                            assets.setThemePackageName(config.customTheme.getThemePackageName());
                        } else {
                            Log.e(TAG, "Unable to add theme resdir=" + resDir);
                        }
                    }
@@ -3498,6 +3500,7 @@ public final class ActivityThread {
                        if (themeChanged) {
                            AssetManager am = r.getAssets();
                            if (originalThemePackageName != null) {
                                am.setThemePackageName(null);
//                                Log.i(TAG, "============ Dump resources BEFORE removeAssetPath");
//                                am.dumpResources();
                                am.removeAssetPath(originalThemePackageName, getPackageResDir(originalThemePackageName));
@@ -3506,6 +3509,7 @@ public final class ActivityThread {
                            }
                            String resDir = getPackageResDir(config.customTheme.getThemePackageName());
                            if (resDir != null) {
                                am.setThemePackageName(config.customTheme.getThemePackageName());
                                am.updateResourcesWithAssetPath(resDir);
//                                Log.i(TAG, "============ Dump resources AFTER addAssetPath");
//                                am.dumpResources();
+18 −0
Original line number Diff line number Diff line
@@ -74,6 +74,8 @@ public final class AssetManager {
    private String mAssetDir;
    private String mAppName;

    private String mThemePackageName;

    /**
     * Create a new AssetManager containing only the basic system assets.
     * Applications will not generally use this method, instead retrieving the
@@ -615,6 +617,22 @@ public final class AssetManager {
     */
    public native final void dumpResources();

    /**
     * Get package name of current theme (may return null).
     * {@hide}
     */
    public final String getThemePackageName() {
        return mThemePackageName;
    }

    /**
     * Sets package name for current theme (null is allowed).
     * {@hide}
     */
    public final void setThemePackageName(String packageName) {
        mThemePackageName = packageName;
    }

    /**
     * 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
+1 −0
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ public class ContextThemeWrapper extends ContextWrapper {
            AssetManager assets = new AssetManager();
            assets.addAssetPath(getPackageResDir(getPackageName()));
            assets.addAssetPath(getPackageResDir(themePackage));
            assets.setThemePackageName(themePackage);

            DisplayMetrics metrics = new DisplayMetrics();
            WindowManager wm = (WindowManager)getSystemService(WINDOW_SERVICE);