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

Commit b85fb980 authored by Andy Mast's avatar Andy Mast
Browse files

Clear Theme in System UI

When SystemUI first starts an android theme object is created
which contains references to the currently applied CM theme.

When the theme is changed to system, the theme remains in memory
with old references to the prior applied theme. (See mPackages in ResTable::Theme)

This patch introduces a recreate theme method into Context so that
SystemUI can recreate its own theme object.

Change-Id: I086a76afa6f456a69c0390573bc8af2eafa4fb4e
parent 31fb0160
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -873,6 +873,13 @@ class ContextImpl extends Context {
        return mTheme;
    }

    @Override
    public void recreateTheme() {
        Resources.Theme newTheme = mResources.newTheme();
        newTheme.applyStyle(mThemeResource, true);
        mTheme.setTo(newTheme);
    }

    @Override
    public ClassLoader getClassLoader() {
        return mPackageInfo != null ?
+3 −0
Original line number Diff line number Diff line
@@ -424,6 +424,9 @@ public abstract class Context {
    @ViewDebug.ExportedProperty(deepExport = true)
    public abstract Resources.Theme getTheme();

    /** @hide */
    public abstract void recreateTheme();

    /**
     * Retrieve styled attribute information in this Context's theme.  See
     * {@link Resources.Theme#obtainStyledAttributes(int[])}
+6 −0
Original line number Diff line number Diff line
@@ -121,6 +121,12 @@ public class ContextWrapper extends Context {
        return mBase.getTheme();
    }

    /** @hide */
    @Override
    public void recreateTheme() {
        mBase.recreateTheme();
    }

    @Override
    public ClassLoader getClassLoader() {
        return mBase.getClassLoader();
+1 −2
Original line number Diff line number Diff line
@@ -3912,13 +3912,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
     * meantime, just update the things that we know change.
     */
    void updateResources(Configuration newConfig) {
        final Context context = mContext;

        // detect theme change.
        ThemeConfig newTheme = newConfig != null ? newConfig.themeConfig : null;
        final boolean updateStatusBar = shouldUpdateStatusbar(mCurrentTheme, newTheme);
        if (newTheme != null) mCurrentTheme = (ThemeConfig) newTheme.clone();
        if (updateStatusBar) {
            mContext.recreateTheme();
            recreateStatusBar();
        } else {
            loadDimens();
+5 −0
Original line number Diff line number Diff line
@@ -96,6 +96,11 @@ public class MockContext extends Context {
        throw new UnsupportedOperationException();
    }

    @Override
    public void recreateTheme() {
        throw new UnsupportedOperationException();
    }

    @Override
    public ClassLoader getClassLoader() {
        throw new UnsupportedOperationException();
Loading