diff --git a/api/current.txt b/api/current.txt index e3bb0b8dc4aa4..c8057db567649 100644 --- a/api/current.txt +++ b/api/current.txt @@ -9828,6 +9828,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 535bfc7b7e80d..5222a0375249a 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -10122,6 +10122,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 16f6b1e633297..43cc63b4a3c85 100644 --- a/core/java/android/content/pm/ActivityInfo.java +++ b/core/java/android/content/pm/ActivityInfo.java @@ -570,19 +570,37 @@ 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= 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(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 df278c8bd0f68..587e7fa761d64 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 04ebe70304a64..19a5bebfc14d7 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);