Revert "libandroidfw hardening for IncFs"
Revert "Move map_ptr to incfs namspace"
Revert submission 12787270
Reason for revert: b/173250495
Reverted Changes:
I5cd1bc8a2:libandroidfw hardening for IncFs
Ice5dbcfb2:Move map_ptr to incfs namspace
I29ccdc8ed:Do not cache bag parent stack until requested
I1e9e9acaa:Cache resolved theme values
Change-Id: Ib90ef68339710086df41e9abe0833a542d03a74f
diff --git a/tools/aapt2/cmd/Link.cpp b/tools/aapt2/cmd/Link.cpp
index f92c602..118a76f 100644
--- a/tools/aapt2/cmd/Link.cpp
+++ b/tools/aapt2/cmd/Link.cpp
@@ -732,6 +732,22 @@
return true;
}
+static android::ApkAssetsCookie FindFrameworkAssetManagerCookie(
+ const android::AssetManager2& assets) {
+ using namespace android;
+
+ // Find the system package (0x01). AAPT always generates attributes with the type 0x01, so
+ // we're looking for the first attribute resource in the system package.
+ Res_value val{};
+ ResTable_config config{};
+ uint32_t type_spec_flags;
+ ApkAssetsCookie idx = assets.GetResource(0x01010000, true /** may_be_bag */,
+ 0 /** density_override */, &val, &config,
+ &type_spec_flags);
+
+ return idx;
+}
+
class Linker {
public:
Linker(LinkContext* context, const LinkOptions& options)
@@ -744,12 +760,8 @@
void ExtractCompileSdkVersions(android::AssetManager2* assets) {
using namespace android;
- // Find the system package (0x01). AAPT always generates attributes with the type 0x01, so
- // we're looking for the first attribute resource in the system package.
- android::ApkAssetsCookie cookie;
- if (auto value = assets->GetResource(0x01010000, true /** may_be_bag */); value.has_value()) {
- cookie = value->cookie;
- } else {
+ android::ApkAssetsCookie cookie = FindFrameworkAssetManagerCookie(*assets);
+ if (cookie == android::kInvalidCookie) {
// No Framework assets loaded. Not a failure.
return;
}