diff options
author | 2018-02-09 11:02:13 -0800 | |
---|---|---|
committer | 2018-02-09 12:43:17 -0800 | |
commit | 2a447172a5b8c4fdb8527602144691802c492c2e (patch) | |
tree | abbd3839e76a0c55628c3c905a9b30f90133e56d | |
parent | 56c82be0d4075a434217a0d56be8e6544fb05a96 (diff) |
Revert "libandroidfw: Make sure to set the 'app as lib' flag"
This reverts commit 9ad287c828a116f844e5c03346c618d83727e4ae.
Bug: 73134570
Change-Id: If930d3a7c17fc2f7ffaebd31281ad5a5d120144f
-rw-r--r-- | libs/androidfw/AssetManager2.cpp | 19 | ||||
-rw-r--r-- | libs/androidfw/include/androidfw/ResourceUtils.h | 2 | ||||
-rw-r--r-- | libs/androidfw/tests/AssetManager2_test.cpp | 21 | ||||
-rw-r--r-- | libs/androidfw/tests/AttributeResolution_test.cpp | 36 |
4 files changed, 5 insertions, 73 deletions
diff --git a/libs/androidfw/AssetManager2.cpp b/libs/androidfw/AssetManager2.cpp index 20dba37fbe66..2fc8e952707b 100644 --- a/libs/androidfw/AssetManager2.cpp +++ b/libs/androidfw/AssetManager2.cpp @@ -74,9 +74,7 @@ void AssetManager2::BuildDynamicRefTable() { if (idx == 0xff) { package_ids_[package_id] = idx = static_cast<uint8_t>(package_groups_.size()); package_groups_.push_back({}); - DynamicRefTable& ref_table = package_groups_.back().dynamic_ref_table; - ref_table.mAssignedPackageId = package_id; - ref_table.mAppAsLib = package->IsDynamic() && package->GetPackageId() == 0x7f; + package_groups_.back().dynamic_ref_table.mAssignedPackageId = package_id; } PackageGroup* package_group = &package_groups_[idx]; @@ -107,15 +105,7 @@ void AssetManager2::BuildDynamicRefTable() { void AssetManager2::DumpToLog() const { base::ScopedLogSeverity _log(base::INFO); - LOG(INFO) << base::StringPrintf("AssetManager2(this=%p)", this); - std::string list; - for (const auto& apk_assets : apk_assets_) { - base::StringAppendF(&list, "%s,", apk_assets->GetPath().c_str()); - } - LOG(INFO) << "ApkAssets: " << list; - - list = ""; for (size_t i = 0; i < package_ids_.size(); i++) { if (package_ids_[i] != 0xff) { base::StringAppendF(&list, "%02x -> %d, ", (int) i, package_ids_[i]); @@ -126,12 +116,9 @@ void AssetManager2::DumpToLog() const { for (const auto& package_group: package_groups_) { list = ""; for (const auto& package : package_group.packages_) { - base::StringAppendF(&list, "%s(%02x%s), ", package->GetPackageName().c_str(), - package->GetPackageId(), (package->IsDynamic() ? " dynamic" : "")); + base::StringAppendF(&list, "%s(%02x), ", package->GetPackageName().c_str(), package->GetPackageId()); } - LOG(INFO) << base::StringPrintf("PG (%02x): ", - package_group.dynamic_ref_table.mAssignedPackageId) - << list; + LOG(INFO) << base::StringPrintf("PG (%02x): ", package_group.dynamic_ref_table.mAssignedPackageId) << list; } } diff --git a/libs/androidfw/include/androidfw/ResourceUtils.h b/libs/androidfw/include/androidfw/ResourceUtils.h index d94779bf5225..c2eae855bb7b 100644 --- a/libs/androidfw/include/androidfw/ResourceUtils.h +++ b/libs/androidfw/include/androidfw/ResourceUtils.h @@ -28,7 +28,7 @@ bool ExtractResourceName(const StringPiece& str, StringPiece* out_package, Strin StringPiece* out_entry); inline uint32_t fix_package_id(uint32_t resid, uint8_t package_id) { - return (resid & 0x00ffffffu) | (static_cast<uint32_t>(package_id) << 24); + return resid | (static_cast<uint32_t>(package_id) << 24); } inline uint8_t get_package_id(uint32_t resid) { diff --git a/libs/androidfw/tests/AssetManager2_test.cpp b/libs/androidfw/tests/AssetManager2_test.cpp index eaf79cb12901..92462a6cfadf 100644 --- a/libs/androidfw/tests/AssetManager2_test.cpp +++ b/libs/androidfw/tests/AssetManager2_test.cpp @@ -59,7 +59,7 @@ class AssetManager2Test : public ::testing::Test { libclient_assets_ = ApkAssets::Load(GetTestDataPath() + "/libclient/libclient.apk"); ASSERT_NE(nullptr, libclient_assets_); - appaslib_assets_ = ApkAssets::LoadAsSharedLibrary(GetTestDataPath() + "/appaslib/appaslib.apk"); + appaslib_assets_ = ApkAssets::Load(GetTestDataPath() + "/appaslib/appaslib.apk"); ASSERT_NE(nullptr, appaslib_assets_); system_assets_ = ApkAssets::Load(GetTestDataPath() + "/system/system.apk", true /*system*/); @@ -233,25 +233,6 @@ TEST_F(AssetManager2Test, FindsBagResourceFromSharedLibrary) { assetmanager.SetApkAssets( {lib_two_assets_.get(), lib_one_assets_.get(), libclient_assets_.get()}); - const ResolvedBag* bag = assetmanager.GetBag(fix_package_id(lib_one::R::style::Theme, 0x03)); - ASSERT_NE(nullptr, bag); - ASSERT_GE(bag->entry_count, 2u); - - // First two attributes come from lib_one. - EXPECT_EQ(1, bag->entries[0].cookie); - EXPECT_EQ(0x03, get_package_id(bag->entries[0].key)); - EXPECT_EQ(1, bag->entries[1].cookie); - EXPECT_EQ(0x03, get_package_id(bag->entries[1].key)); -} - -TEST_F(AssetManager2Test, FindsStyleResourceWithParentFromSharedLibrary) { - AssetManager2 assetmanager; - - // libclient is built with lib_one and then lib_two in order. - // Reverse the order to test that proper package ID re-assignment is happening. - assetmanager.SetApkAssets( - {lib_two_assets_.get(), lib_one_assets_.get(), libclient_assets_.get()}); - const ResolvedBag* bag = assetmanager.GetBag(libclient::R::style::Theme); ASSERT_NE(nullptr, bag); ASSERT_GE(bag->entry_count, 2u); diff --git a/libs/androidfw/tests/AttributeResolution_test.cpp b/libs/androidfw/tests/AttributeResolution_test.cpp index c8dbe205fee2..cc3053798e7b 100644 --- a/libs/androidfw/tests/AttributeResolution_test.cpp +++ b/libs/androidfw/tests/AttributeResolution_test.cpp @@ -22,7 +22,6 @@ #include "android-base/logging.h" #include "android-base/macros.h" #include "androidfw/AssetManager2.h" -#include "androidfw/ResourceUtils.h" #include "TestHelpers.h" #include "data/styles/R.h" @@ -65,41 +64,6 @@ class AttributeResolutionXmlTest : public AttributeResolutionTest { ResXMLTree xml_parser_; }; -TEST(AttributeResolutionLibraryTest, ApplyStyleWithDefaultStyleResId) { - AssetManager2 assetmanager; - auto apk_assets = ApkAssets::LoadAsSharedLibrary(GetTestDataPath() + "/styles/styles.apk"); - ASSERT_NE(nullptr, apk_assets); - assetmanager.SetApkAssets({apk_assets.get()}); - - std::unique_ptr<Theme> theme = assetmanager.NewTheme(); - - std::array<uint32_t, 2> attrs{ - {fix_package_id(R::attr::attr_one, 0x02), fix_package_id(R::attr::attr_two, 0x02)}}; - std::array<uint32_t, attrs.size() * STYLE_NUM_ENTRIES> values; - std::array<uint32_t, attrs.size() + 1> indices; - ApplyStyle(theme.get(), nullptr /*xml_parser*/, 0u /*def_style_attr*/, - fix_package_id(R::style::StyleOne, 0x02), attrs.data(), attrs.size(), values.data(), - indices.data()); - - const uint32_t public_flag = ResTable_typeSpec::SPEC_PUBLIC; - - const uint32_t* values_cursor = values.data(); - EXPECT_EQ(Res_value::TYPE_INT_DEC, values_cursor[STYLE_TYPE]); - EXPECT_EQ(1u, values_cursor[STYLE_DATA]); - EXPECT_EQ(0u, values_cursor[STYLE_RESOURCE_ID]); - EXPECT_EQ(1u, values_cursor[STYLE_ASSET_COOKIE]); - EXPECT_EQ(0u, values_cursor[STYLE_DENSITY]); - EXPECT_EQ(public_flag, values_cursor[STYLE_CHANGING_CONFIGURATIONS]); - - values_cursor += STYLE_NUM_ENTRIES; - EXPECT_EQ(Res_value::TYPE_INT_DEC, values_cursor[STYLE_TYPE]); - EXPECT_EQ(2u, values_cursor[STYLE_DATA]); - EXPECT_EQ(0u, values_cursor[STYLE_RESOURCE_ID]); - EXPECT_EQ(1u, values_cursor[STYLE_ASSET_COOKIE]); - EXPECT_EQ(0u, values_cursor[STYLE_DENSITY]); - EXPECT_EQ(public_flag, values_cursor[STYLE_CHANGING_CONFIGURATIONS]); -} - TEST_F(AttributeResolutionTest, Theme) { std::unique_ptr<Theme> theme = assetmanager_.NewTheme(); ASSERT_TRUE(theme->ApplyStyle(R::style::StyleTwo)); |