diff options
Diffstat (limited to 'core/jni/android_util_AssetManager.cpp')
-rw-r--r-- | core/jni/android_util_AssetManager.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp index 59f4067..66b2506 100644 --- a/core/jni/android_util_AssetManager.cpp +++ b/core/jni/android_util_AssetManager.cpp @@ -74,12 +74,13 @@ static void doThrow(JNIEnv* env, const char* exc, const char* msg = NULL) } enum { - STYLE_NUM_ENTRIES = 5, + STYLE_NUM_ENTRIES = 6, STYLE_TYPE = 0, STYLE_DATA = 1, STYLE_ASSET_COOKIE = 2, STYLE_RESOURCE_ID = 3, - STYLE_CHANGING_CONFIGURATIONS = 4 + STYLE_CHANGING_CONFIGURATIONS = 4, + STYLE_DENSITY = 5 }; static jint copyValue(JNIEnv* env, jobject outValue, const ResTable* table, @@ -896,6 +897,7 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla ResTable::Theme* theme = (ResTable::Theme*)themeToken; const ResTable& res = theme->getResTable(); ResXMLParser* xmlParser = (ResXMLParser*)xmlParserToken; + ResTable_config config; Res_value value; const jsize NI = env->GetArrayLength(attrs); @@ -995,6 +997,7 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla value.dataType = Res_value::TYPE_NULL; value.data = 0; typeSetFlags = 0; + config.density = 0; // Skip through XML attributes until the end or the next possible match. while (ix < NX && curIdent > curXmlAttr) { @@ -1042,7 +1045,8 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla if (value.dataType != Res_value::TYPE_NULL) { // Take care of resolving the found resource to its final value. //printf("Resolving attribute reference\n"); - ssize_t newBlock = theme->resolveAttributeReference(&value, block, &resid, &typeSetFlags); + ssize_t newBlock = theme->resolveAttributeReference(&value, block, + &resid, &typeSetFlags, &config); if (newBlock >= 0) block = newBlock; } else { // If we still don't have a value for this attribute, try to find @@ -1051,7 +1055,8 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla ssize_t newBlock = theme->getAttribute(curIdent, &value, &typeSetFlags); if (newBlock >= 0) { //printf("Resolving resource reference\n"); - newBlock = res.resolveReference(&value, block, &resid, &typeSetFlags); + newBlock = res.resolveReference(&value, block, &resid, + &typeSetFlags, &config); if (newBlock >= 0) block = newBlock; } } @@ -1070,6 +1075,7 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla block != kXmlBlock ? (jint)res.getTableCookie(block) : (jint)-1; dest[STYLE_RESOURCE_ID] = resid; dest[STYLE_CHANGING_CONFIGURATIONS] = typeSetFlags; + dest[STYLE_DENSITY] = config.density; if (indices != NULL && value.dataType != Res_value::TYPE_NULL) { indicesIdx++; @@ -1108,6 +1114,7 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job } const ResTable& res(am->getResources()); ResXMLParser* xmlParser = (ResXMLParser*)xmlParserToken; + ResTable_config config; Res_value value; const jsize NI = env->GetArrayLength(attrs); @@ -1160,6 +1167,7 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job value.dataType = Res_value::TYPE_NULL; value.data = 0; typeSetFlags = 0; + config.density = 0; // Skip through XML attributes until the end or the next possible match. while (ix < NX && curIdent > curXmlAttr) { @@ -1179,7 +1187,8 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job if (value.dataType != Res_value::TYPE_NULL) { // Take care of resolving the found resource to its final value. //printf("Resolving attribute reference\n"); - ssize_t newBlock = res.resolveReference(&value, block, &resid, &typeSetFlags); + ssize_t newBlock = res.resolveReference(&value, block, &resid, + &typeSetFlags, &config); if (newBlock >= 0) block = newBlock; } @@ -1197,6 +1206,7 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job block != kXmlBlock ? (jint)res.getTableCookie(block) : (jint)-1; dest[STYLE_RESOURCE_ID] = resid; dest[STYLE_CHANGING_CONFIGURATIONS] = typeSetFlags; + dest[STYLE_DENSITY] = config.density; if (indices != NULL && value.dataType != Res_value::TYPE_NULL) { indicesIdx++; @@ -1250,6 +1260,7 @@ static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject claz return JNI_FALSE; } const ResTable& res(am->getResources()); + ResTable_config config; Res_value value; ssize_t block; @@ -1276,13 +1287,15 @@ static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject claz while (i < NV && arrayEnt < endArrayEnt) { block = arrayEnt->stringBlock; typeSetFlags = arrayTypeSetFlags; + config.density = 0; value = arrayEnt->map.value; uint32_t resid = 0; if (value.dataType != Res_value::TYPE_NULL) { // Take care of resolving the found resource to its final value. //printf("Resolving attribute reference\n"); - ssize_t newBlock = res.resolveReference(&value, block, &resid, &typeSetFlags); + ssize_t newBlock = res.resolveReference(&value, block, &resid, + &typeSetFlags, &config); if (newBlock >= 0) block = newBlock; } @@ -1299,6 +1312,7 @@ static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject claz dest[STYLE_ASSET_COOKIE] = (jint)res.getTableCookie(block); dest[STYLE_RESOURCE_ID] = resid; dest[STYLE_CHANGING_CONFIGURATIONS] = typeSetFlags; + dest[STYLE_DENSITY] = config.density; dest += STYLE_NUM_ENTRIES; i+= STYLE_NUM_ENTRIES; arrayEnt++; |