diff options
-rw-r--r-- | api/current.txt | 1 | ||||
-rw-r--r-- | api/system-current.txt | 1 | ||||
-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 | ||||
-rw-r--r-- | core/jni/android_util_AssetManager.cpp | 9 | ||||
-rw-r--r-- | include/androidfw/ResourceTypes.h | 7 | ||||
-rw-r--r-- | libs/androidfw/ResourceTypes.cpp | 10 |
8 files changed, 63 insertions, 3 deletions
diff --git a/api/current.txt b/api/current.txt index 2bbe2f1..f3737c1 100644 --- a/api/current.txt +++ b/api/current.txt @@ -9833,6 +9833,7 @@ package android.content.res { public final class Resources.Theme { method public void applyStyle(int, boolean); method public void dump(int, java.lang.String, java.lang.String); + method public int getChangingConfigurations(); method public android.graphics.drawable.Drawable getDrawable(int) throws android.content.res.Resources.NotFoundException; method public android.content.res.Resources getResources(); method public android.content.res.TypedArray obtainStyledAttributes(int[]); diff --git a/api/system-current.txt b/api/system-current.txt index 0cc763b..5a529b7c 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -10127,6 +10127,7 @@ package android.content.res { public final class Resources.Theme { method public void applyStyle(int, boolean); method public void dump(int, java.lang.String, java.lang.String); + method public int getChangingConfigurations(); method public android.graphics.drawable.Drawable getDrawable(int) throws android.content.res.Resources.NotFoundException; method public android.content.res.Resources getResources(); method public android.content.res.TypedArray obtainStyledAttributes(int[]); 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. diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp index daf5a61..db495dd 100644 --- a/core/jni/android_util_AssetManager.cpp +++ b/core/jni/android_util_AssetManager.cpp @@ -999,6 +999,13 @@ static jint android_content_AssetManager_loadThemeAttributeValue( return block >= 0 ? copyValue(env, outValue, &res, value, ref, block, typeSpecFlags) : block; } +static jint android_content_AssetManager_getThemeChangingConfigurations(JNIEnv* env, jobject clazz, + jlong themeHandle) +{ + ResTable::Theme* theme = reinterpret_cast<ResTable::Theme*>(themeHandle); + return theme->getChangingConfigurations(); +} + static void android_content_AssetManager_dumpTheme(JNIEnv* env, jobject clazz, jlong themeHandle, jint pri, jstring tag, jstring prefix) @@ -2103,6 +2110,8 @@ static JNINativeMethod gAssetManagerMethods[] = { (void*) android_content_AssetManager_copyTheme }, { "loadThemeAttributeValue", "(JILandroid/util/TypedValue;Z)I", (void*) android_content_AssetManager_loadThemeAttributeValue }, + { "getThemeChangingConfigurations", "(J)I", + (void*) android_content_AssetManager_getThemeChangingConfigurations }, { "dumpTheme", "(JILjava/lang/String;Ljava/lang/String;)V", (void*) android_content_AssetManager_dumpTheme }, { "applyStyle","(JIIJ[I[I[I)Z", diff --git a/include/androidfw/ResourceTypes.h b/include/androidfw/ResourceTypes.h index df278c8..587e7fa 100644 --- a/include/androidfw/ResourceTypes.h +++ b/include/androidfw/ResourceTypes.h @@ -1662,6 +1662,12 @@ public: uint32_t* inoutTypeSpecFlags = NULL, ResTable_config* inoutConfig = NULL) const; + /** + * Returns a bit mask of configuration changes that will impact this + * theme (and thus require completely reloading it). + */ + uint32_t getChangingConfigurations() const; + void dumpToLog() const; private: @@ -1688,6 +1694,7 @@ public: const ResTable& mTable; package_info* mPackages[Res_MAXPACKAGE]; + uint32_t mTypeSpecFlags; }; void setParameters(const ResTable_config* params); diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp index 04ebe70..19a5beb 100644 --- a/libs/androidfw/ResourceTypes.cpp +++ b/libs/androidfw/ResourceTypes.cpp @@ -3147,6 +3147,7 @@ struct ResTable::bag_set ResTable::Theme::Theme(const ResTable& table) : mTable(table) + , mTypeSpecFlags(0) { memset(mPackages, 0, sizeof(mPackages)); } @@ -3205,6 +3206,8 @@ status_t ResTable::Theme::applyStyle(uint32_t resID, bool force) return N; } + mTypeSpecFlags |= bagTypeSpecFlags; + uint32_t curPackage = 0xffffffff; ssize_t curPackageIndex = 0; package_info* curPI = NULL; @@ -3323,6 +3326,8 @@ status_t ResTable::Theme::setTo(const Theme& other) } } + mTypeSpecFlags = other.mTypeSpecFlags; + if (kDebugTableTheme) { ALOGI("Final theme:"); dumpToLog(); @@ -3417,6 +3422,11 @@ ssize_t ResTable::Theme::resolveAttributeReference(Res_value* inOutValue, inoutTypeSpecFlags, inoutConfig); } +uint32_t ResTable::Theme::getChangingConfigurations() const +{ + return mTypeSpecFlags; +} + void ResTable::Theme::dumpToLog() const { ALOGI("Theme %p:\n", this); |