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

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

Remove unnecessary code.

This change removes code which recreated AssetManager
on theme change. This is unnecessary, since we extended
AssetManager by allowing it to modify the ResTable on
fly. This change allows us to take advantage of
new AssetManager features and should improve performance
during theme change.

CR:JoshG.
parent 309a23a3
Loading
Loading
Loading
Loading
+6 −17
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ import android.content.ComponentCallbacks;
import android.content.ComponentName;
import android.content.ContentProvider;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.IContentProvider;
import android.content.Intent;
import android.content.ServiceConnection;
@@ -3495,9 +3494,8 @@ public final class ActivityThread {
                     * object anyway.  Similarly, each Application will need
                     * to refresh its internal resources object. */
                    if (r != null) {
                        if ((diff & ActivityInfo.CONFIG_THEME_RESOURCE) == 0) {
                            r.updateConfiguration(config, dm);
                        } else {
                        boolean themeChanged = (diff & ActivityInfo.CONFIG_THEME_RESOURCE) != 0;
                        if (themeChanged) {
                            AssetManager am = r.getAssets();
                            if (originalThemePackageName != null) {
//                                Log.i(TAG, "============ Dump resources BEFORE removeAssetPath");
@@ -3512,8 +3510,10 @@ public final class ActivityThread {
//                                Log.i(TAG, "============ Dump resources AFTER addAssetPath");
//                                am.dumpResources();
                            }
                            r.clearCaches();
                            r.getConfiguration().customTheme = config.customTheme;
                        }
                        r.updateConfiguration(config, dm);
                        if (themeChanged) {
                            r.updateStringCache();
                        }
                        //Log.i(TAG, "Updated app resources " + v.getKey()
                        //        + " " + r + ": " + r.getConfiguration());
@@ -3531,17 +3531,6 @@ public final class ActivityThread {
        for (int i=0; i<N; i++) {
            ComponentCallbacks cb = callbacks.get(i);
            performConfigurationChanged(cb, config);
            
            // We removed the old resources object from the mActiveResources
            // cache, now we need to trigger an update for each application.
            if ((diff & ActivityInfo.CONFIG_THEME_RESOURCE) != 0) {
                if (cb instanceof Activity || cb instanceof Application) {
                    Context context = ((ContextWrapper)cb).getBaseContext();
                    if (context instanceof ApplicationContext) {
                        ((ApplicationContext)context).refreshResourcesIfNecessary();
                    }
                }
            }
        }
    }

+0 −16
Original line number Diff line number Diff line
@@ -212,22 +212,6 @@ class ApplicationContext extends Context {
        return mResources;
    }

    /**
     * Refresh resources object which may have been changed by a theme
     * configuration change.
     */
    /* package */ void refreshResourcesIfNecessary() {
        if (mResources == Resources.getSystem()) {
            /* FIXME: refreshResources called on system resources! */
            return;
        }

        if (mPackageInfo.mApplicationInfo.isThemeable) {
            mResources = mPackageInfo.getResources(mMainThread, true, true);
            mTheme = null;
        }
    }

    @Override
    public PackageManager getPackageManager() {
        if (mPackageManager != null) {
+1 −5
Original line number Diff line number Diff line
@@ -1604,12 +1604,8 @@ public class Resources {
    /**
     * {@hide}
     */
    public final void clearCaches() {
    public final void updateStringCache() {
        synchronized (mTmpValue) {
            mCachedStyledAttributes = null;
            mDrawableCache.clear();
            mColorStateListCache.clear();
            flushLayoutCache();
            mAssets.recreateStringBlocks();
        }
    }