diff options
author | Alan Viverette <alanv@google.com> | 2015-05-05 09:49:03 -0700 |
---|---|---|
committer | Alan Viverette <alanv@google.com> | 2015-05-05 09:49:03 -0700 |
commit | c1d527926e1c82828e42bdc0c7abf50f6decc0a7 (patch) | |
tree | 48cfc47946a00d3c2126aa62fbf8e47e89e3dbf9 /core/java/android/content | |
parent | 5551aca2b8ec9fe7ab5ffda8dad82ee104556962 (diff) | |
download | frameworks_base-c1d527926e1c82828e42bdc0c7abf50f6decc0a7.zip frameworks_base-c1d527926e1c82828e42bdc0c7abf50f6decc0a7.tar.gz frameworks_base-c1d527926e1c82828e42bdc0c7abf50f6decc0a7.tar.bz2 |
Add API for obtaining changing configurations bitmask from Theme
Required to know when to reload the system context's theme in response
to configuration changes, and thus needed to support the DayNight theme.
Bug: 20267825
Change-Id: I7df5e28b7a6d8b611ea030032544cf4800788514
Diffstat (limited to 'core/java/android/content')
-rw-r--r-- | core/java/android/content/pm/ActivityInfo.java | 24 | ||||
-rw-r--r-- | core/java/android/content/res/AssetManager.java | 1 | ||||
-rw-r--r-- | core/java/android/content/res/Resources.java | 13 |
3 files changed, 35 insertions, 3 deletions
diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java index 16f6b1e..43cc63b 100644 --- a/core/java/android/content/pm/ActivityInfo.java +++ b/core/java/android/content/pm/ActivityInfo.java @@ -570,13 +570,16 @@ public class ActivityInfo extends ComponentInfo Configuration.NATIVE_CONFIG_DENSITY, // DENSITY Configuration.NATIVE_CONFIG_LAYOUTDIR, // LAYOUT DIRECTION }; - /** @hide + + /** * Convert Java change bits to native. + * + * @hide */ public static int activityInfoConfigToNative(int input) { int output = 0; - for (int i=0; i<CONFIG_NATIVE_BITS.length; i++) { - if ((input&(1<<i)) != 0) { + for (int i = 0; i < CONFIG_NATIVE_BITS.length; i++) { + if ((input & (1 << i)) != 0) { output |= CONFIG_NATIVE_BITS[i]; } } @@ -584,6 +587,21 @@ public class ActivityInfo extends ComponentInfo } /** + * Convert native change bits to Java. + * + * @hide + */ + public static int activityInfoConfigNativeToJava(int input) { + int output = 0; + for (int i = 0; i < CONFIG_NATIVE_BITS.length; i++) { + if ((input & CONFIG_NATIVE_BITS[i]) != 0) { + output |= (1 << i); + } + } + return output; + } + + /** * @hide * Unfortunately some developers (OpenFeint I am looking at you) have * compared the configChanges bit field against absolute values, so if we diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java index a176593..525059f 100644 --- a/core/java/android/content/res/AssetManager.java +++ b/core/java/android/content/res/AssetManager.java @@ -789,6 +789,7 @@ public final class AssetManager implements AutoCloseable { TypedValue outValue, boolean resolve); /*package*/ native static final void dumpTheme(long theme, int priority, String tag, String prefix); + /*package*/ native static final int getThemeChangingConfigurations(long theme); private native final long openXmlAssetNative(int cookie, String fileName); diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index 6e77e33..ae41b69 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -1731,6 +1731,19 @@ public class Resources { } /** + * Returns a bit mask of configuration changes that will impact this + * theme (and thus require completely reloading it). + * + * @return a bit mask of configuration changes, as defined by + * {@link ActivityInfo} + * @see ActivityInfo + */ + public int getChangingConfigurations() { + final int nativeChangingConfig = AssetManager.getThemeChangingConfigurations(mTheme); + return ActivityInfo.activityInfoConfigNativeToJava(nativeChangingConfig); + } + + /** * Print contents of this theme out to the log. For debugging only. * * @param priority The log priority to use. |