diff options
| -rw-r--r-- | core/jni/android_util_AssetManager.cpp | 27 | ||||
| -rw-r--r-- | libs/utils/ResourceTypes.cpp | 20 |
2 files changed, 36 insertions, 11 deletions
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp index 562cc8feb429..e83d2e25004b 100644 --- a/core/jni/android_util_AssetManager.cpp +++ b/core/jni/android_util_AssetManager.cpp @@ -17,6 +17,8 @@ #define LOG_TAG "asset" +#define DEBUG_STYLES(x) //x + #include <android_runtime/android_util_AssetManager.h> #include "jni.h" @@ -894,6 +896,9 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla return JNI_FALSE; } + DEBUG_STYLES(LOGI("APPLY STYLE: theme=0x%x defStyleAttr=0x%x defStyleRes=0x%x xml=0x%x", + themeToken, defStyleAttr, defStyleRes, xmlParserToken)); + ResTable::Theme* theme = (ResTable::Theme*)themeToken; const ResTable& res = theme->getResTable(); ResXMLParser* xmlParser = (ResXMLParser*)xmlParserToken; @@ -991,6 +996,8 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla for (jsize ii=0; ii<NI; ii++) { const uint32_t curIdent = (uint32_t)src[ii]; + DEBUG_STYLES(LOGI("RETRIEVING ATTR 0x%08x...", curIdent)); + // Try to find a value for this attribute... we prioritize values // coming from, first XML attributes, then XML style, then default // style, and finally the theme. @@ -1010,6 +1017,8 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla xmlParser->getAttributeValue(ix, &value); ix++; curXmlAttr = xmlParser->getAttributeNameResID(ix); + DEBUG_STYLES(LOGI("-> From XML: type=0x%x, data=0x%08x", + value.dataType, value.data)); } // Skip through the style values until the end or the next possible match. @@ -1022,6 +1031,8 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla block = styleEnt->stringBlock; typeSetFlags = styleTypeSetFlags; value = styleEnt->map.value; + DEBUG_STYLES(LOGI("-> From style: type=0x%x, data=0x%08x", + value.dataType, value.data)); } styleEnt++; } @@ -1036,37 +1047,43 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla block = defStyleEnt->stringBlock; typeSetFlags = defStyleTypeSetFlags; value = defStyleEnt->map.value; + DEBUG_STYLES(LOGI("-> From def style: type=0x%x, data=0x%08x", + value.dataType, value.data)); } defStyleEnt++; } - //printf("Attribute 0x%08x: type=0x%x, data=0x%08x\n", curIdent, value.dataType, value.data); 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 = theme->resolveAttributeReference(&value, block, &resid, &typeSetFlags, &config); if (newBlock >= 0) block = newBlock; + DEBUG_STYLES(LOGI("-> Resolved attr: type=0x%x, data=0x%08x", + value.dataType, value.data)); } else { // If we still don't have a value for this attribute, try to find // it in the theme! - //printf("Looking up in theme\n"); ssize_t newBlock = theme->getAttribute(curIdent, &value, &typeSetFlags); if (newBlock >= 0) { - //printf("Resolving resource reference\n"); + DEBUG_STYLES(LOGI("-> From theme: type=0x%x, data=0x%08x", + value.dataType, value.data)); newBlock = res.resolveReference(&value, block, &resid, &typeSetFlags, &config); if (newBlock >= 0) block = newBlock; + DEBUG_STYLES(LOGI("-> Resolved theme: type=0x%x, data=0x%08x", + value.dataType, value.data)); } } // Deal with the special @null value -- it turns back to TYPE_NULL. if (value.dataType == Res_value::TYPE_REFERENCE && value.data == 0) { + DEBUG_STYLES(LOGI("-> Setting to @null!")); value.dataType = Res_value::TYPE_NULL; } - //printf("Attribute 0x%08x: final type=0x%x, data=0x%08x\n", curIdent, value.dataType, value.data); + DEBUG_STYLES(LOGI("Attribute 0x%08x: type=0x%x, data=0x%08x", + curIdent, value.dataType, value.data)); // Write the final value back to Java. dest[STYLE_TYPE] = value.dataType; diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp index 872b2bc70f55..450af8df093d 100644 --- a/libs/utils/ResourceTypes.cpp +++ b/libs/utils/ResourceTypes.cpp @@ -42,6 +42,7 @@ #define TABLE_GETENTRY(x) //x #define TABLE_SUPER_NOISY(x) //x #define LOAD_TABLE_NOISY(x) //x +#define TABLE_THEME(x) //x namespace android { @@ -1447,18 +1448,23 @@ ssize_t ResTable::Theme::getAttribute(uint32_t resID, Res_value* outValue, const uint32_t t = Res_GETTYPE(resID); const uint32_t e = Res_GETENTRY(resID); - TABLE_NOISY(LOGV("Looking up attr 0x%08x in theme %p", resID, this)); + TABLE_THEME(LOGI("Looking up attr 0x%08x in theme %p", resID, this)); if (p >= 0) { const package_info* const pi = mPackages[p]; + TABLE_THEME(LOGI("Found package: %p", pi)); if (pi != NULL) { + TABLE_THEME(LOGI("Desired type index is %ld in avail %d", t, pi->numTypes)); if (t < pi->numTypes) { const type_info& ti = pi->types[t]; + TABLE_THEME(LOGI("Desired entry index is %ld in avail %d", e, ti.numEntries)); if (e < ti.numEntries) { const theme_entry& te = ti.entries[e]; - if (outTypeSpecFlags != NULL) { - *outTypeSpecFlags |= te.typeSpecFlags; - } + if (outTypeSpecFlags != NULL) { + *outTypeSpecFlags |= te.typeSpecFlags; + } + TABLE_THEME(LOGI("Theme value: type=0x%x, data=0x%08x", + te.value.dataType, te.value.data)); const uint8_t type = te.value.dataType; if (type == Res_value::TYPE_ATTRIBUTE) { if (cnt > 0) { @@ -1492,6 +1498,8 @@ ssize_t ResTable::Theme::resolveAttributeReference(Res_value* inOutValue, if (inOutValue->dataType == Res_value::TYPE_ATTRIBUTE) { uint32_t newTypeSpecFlags; blockIndex = getAttribute(inOutValue->data, inOutValue, &newTypeSpecFlags); + TABLE_THEME(LOGI("Resolving attr reference: blockIndex=%d, type=0x%x, data=%p\n", + (int)blockIndex, (int)inOutValue->dataType, (void*)inOutValue->data)); if (inoutTypeSpecFlags != NULL) *inoutTypeSpecFlags |= newTypeSpecFlags; //printf("Retrieved attribute new type=0x%x\n", inOutValue->dataType); if (blockIndex < 0) { @@ -1911,8 +1919,8 @@ ssize_t ResTable::resolveReference(Res_value* value, ssize_t blockIndex, uint32_t newFlags = 0; const ssize_t newIndex = getResource(value->data, value, true, &newFlags, outConfig); - //LOGI("Resolving reference d=%p: newIndex=%d, t=0x%02x, d=%p\n", - // (void*)lastRef, (int)newIndex, (int)value->dataType, (void*)value->data); + TABLE_THEME(LOGI("Resolving reference %p: newIndex=%d, type=0x%x, data=%p\n", + (void*)lastRef, (int)newIndex, (int)value->dataType, (void*)value->data)); //printf("Getting reference 0x%08x: newIndex=%d\n", value->data, newIndex); if (inoutTypeSpecFlags != NULL) *inoutTypeSpecFlags |= newFlags; if (newIndex < 0) { |