Merge "IDMAP: Warn when RROs overlay non-overlayable resources"

This commit is contained in:
Adam Lesinski
2017-12-20 00:50:58 +00:00
committed by Android (Google) Code Review
10 changed files with 37 additions and 9 deletions

View File

@@ -6880,6 +6880,9 @@ status_t ResTable::createIdmap(const ResTable& overlay,
return UNKNOWN_ERROR;
}
// The number of resources overlaid that were not explicitly marked overlayable.
size_t forcedOverlayCount = 0u;
KeyedVector<uint8_t, IdmapTypeMap> map;
// overlaid packages are assumed to contain only one package group
@@ -6919,6 +6922,7 @@ status_t ResTable::createIdmap(const ResTable& overlay,
continue;
}
uint32_t typeSpecFlags = 0u;
const String16 overlayType(resName.type, resName.typeLen);
const String16 overlayName(resName.name, resName.nameLen);
uint32_t overlayResID = overlay.identifierForName(overlayName.string(),
@@ -6926,14 +6930,23 @@ status_t ResTable::createIdmap(const ResTable& overlay,
overlayType.string(),
overlayType.size(),
overlayPackage.string(),
overlayPackage.size());
overlayPackage.size(),
&typeSpecFlags);
if (overlayResID == 0) {
// No such target resource was found.
if (typeMap.entryMap.isEmpty()) {
typeMap.entryOffset++;
}
continue;
}
// Now that we know this is being overlaid, check if it can be, and emit a warning if
// it can't.
if ((dtohl(typeConfigs->typeSpecFlags[entryIndex]) &
ResTable_typeSpec::SPEC_OVERLAYABLE) == 0) {
forcedOverlayCount++;
}
if (typeMap.overlayTypeId == -1) {
typeMap.overlayTypeId = Res_GETTYPE(overlayResID) + 1;
}
@@ -7012,6 +7025,10 @@ status_t ResTable::createIdmap(const ResTable& overlay,
typeData += entryCount * 2;
}
if (forcedOverlayCount > 0) {
ALOGW("idmap: overlaid %zu resources not marked overlayable", forcedOverlayCount);
}
return NO_ERROR;
}

View File

@@ -19,11 +19,15 @@ set -e
PATH_TO_FRAMEWORK_RES=${ANDROID_BUILD_TOP}/prebuilts/sdk/current/android.jar
aapt package \
-M AndroidManifest.xml \
-S res \
-A assets \
aapt2 compile --dir res -o compiled.flata
aapt2 link \
-I $PATH_TO_FRAMEWORK_RES \
--split hdpi --split xhdpi --split xxhdpi --split fr,de \
-F basic.apk \
-f
--manifest AndroidManifest.xml \
-A assets \
--split basic_hdpi-v4.apk:hdpi \
--split basic_xhdpi-v4.apk:xhdpi \
--split basic_xxhdpi-v4.apk:xxhdpi \
--split basic_de_fr.apk:de,fr \
-o basic.apk \
compiled.flata
rm compiled.flata

View File

@@ -60,4 +60,9 @@
<item>2</item>
<item>3</item>
</integer-array>
<overlayable>
<item type="string" name="test2" />
<item type="array" name="integerArray1" />
</overlayable>
</resources>

View File

@@ -17,4 +17,6 @@
set -e
aapt package -M AndroidManifest.xml -S res -F overlay.apk -f
aapt2 compile --dir res -o compiled.flata
aapt2 link --manifest AndroidManifest.xml -o overlay.apk compiled.flata
rm compiled.flata