am 4a207c4f: am 261208e0: Merge "Add API for obtaining changing configurations bitmask from Theme" into mnc-dev
* commit '4a207c4f91ee474793eba98dc28289d26d6accf9': Add API for obtaining changing configurations bitmask from Theme
This commit is contained in:
@@ -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[]);
|
||||
|
||||
@@ -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[]);
|
||||
|
||||
@@ -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<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];
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -1730,6 +1730,19 @@ public class Resources {
|
||||
return Resources.this.getDrawable(id, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user