summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Mast <andy@cyngn.com>2015-03-19 11:55:35 -0700
committerClark Scheff <clark@cyngn.com>2015-10-27 18:00:57 -0700
commitdee67f00fd0766ef5d690b13070244ae97016502 (patch)
treedf6efc71d9efb374b8b80c132bbe0290c6f641ac
parentc06da0e983e97a6b08d395d7c709b536dc4f8f0a (diff)
downloadframeworks_base-dee67f00fd0766ef5d690b13070244ae97016502.zip
frameworks_base-dee67f00fd0766ef5d690b13070244ae97016502.tar.gz
frameworks_base-dee67f00fd0766ef5d690b13070244ae97016502.tar.bz2
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
-rw-r--r--core/java/android/app/ContextImpl.java7
-rw-r--r--core/java/android/content/Context.java3
-rw-r--r--core/java/android/content/ContextWrapper.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java3
-rw-r--r--test-runner/src/android/test/mock/MockContext.java5
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java5
6 files changed, 27 insertions, 2 deletions
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 514ca4d..321437e 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -272,6 +272,13 @@ class ContextImpl extends Context {
}
@Override
+ public void recreateTheme() {
+ Resources.Theme newTheme = mResources.newTheme();
+ newTheme.applyStyle(mThemeResource, true);
+ mTheme.setTo(newTheme);
+ }
+
+ @Override
public ClassLoader getClassLoader() {
return mPackageInfo != null ?
mPackageInfo.getClassLoader() : ClassLoader.getSystemClassLoader();
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index cd3df9b..1692920 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -497,6 +497,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 android.content.res.Resources.Theme#obtainStyledAttributes(int[])}
diff --git a/core/java/android/content/ContextWrapper.java b/core/java/android/content/ContextWrapper.java
index 5f57d73..795b9ae 100644
--- a/core/java/android/content/ContextWrapper.java
+++ b/core/java/android/content/ContextWrapper.java
@@ -123,6 +123,12 @@ public class ContextWrapper extends Context {
return mBase.getTheme();
}
+ /** @hide */
+ @Override
+ public void recreateTheme() {
+ mBase.recreateTheme();
+ }
+
@Override
public ClassLoader getClassLoader() {
return mBase.getClassLoader();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 95b395f..2acfdd8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -3470,13 +3470,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();
diff --git a/test-runner/src/android/test/mock/MockContext.java b/test-runner/src/android/test/mock/MockContext.java
index b1b4d04..602cdc9 100644
--- a/test-runner/src/android/test/mock/MockContext.java
+++ b/test-runner/src/android/test/mock/MockContext.java
@@ -99,6 +99,11 @@ public class MockContext extends Context {
}
@Override
+ public void recreateTheme() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public ClassLoader getClassLoader() {
throw new UnsupportedOperationException();
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index 1f3802e..9895161 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -496,6 +496,11 @@ public final class BridgeContext extends Context {
}
@Override
+ public void recreateTheme() {
+ throw new UnsupportedOperationException("recreateTheme is unsupported");
+ }
+
+ @Override
public ClassLoader getClassLoader() {
// The documentation for this method states that it should return a class loader one can
// use to retrieve classes in this package. However, when called by LayoutInflater, we do