Loading libs/androidfw/AssetManager2.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -427,7 +427,6 @@ ApkAssetsCookie AssetManager2::ResolveReference(ApkAssetsCookie cookie, Res_valu ATRACE_CALL(); constexpr const int kMaxIterations = 20; *out_last_reference = 0u; for (size_t iteration = 0u; in_out_value->dataType == Res_value::TYPE_REFERENCE && in_out_value->data != 0u && iteration < kMaxIterations; iteration++) { Loading libs/androidfw/include/androidfw/AssetManager2.h +1 −1 Original line number Diff line number Diff line Loading @@ -210,7 +210,7 @@ class AssetManager2 { // are OR'd together with `in_out_flags`. // `in_out_config` is populated with the configuration for which the resolved value was defined. // `out_last_reference` is populated with the last reference ID before resolving to an actual // value. // value. This is only initialized if the passed in `in_out_value` is a reference. // Returns the cookie of the APK the resolved resource was defined in, or kInvalidCookie if // it was not found. ApkAssetsCookie ResolveReference(ApkAssetsCookie cookie, Res_value* in_out_value, Loading libs/androidfw/tests/AssetManager2_test.cpp +21 −2 Original line number Diff line number Diff line Loading @@ -319,7 +319,7 @@ TEST_F(AssetManager2Test, ResolveReferenceToResource) { EXPECT_EQ(Res_value::TYPE_REFERENCE, value.dataType); EXPECT_EQ(basic::R::integer::ref2, value.data); uint32_t last_ref; uint32_t last_ref = 0u; cookie = assetmanager.ResolveReference(cookie, &value, &selected_config, &flags, &last_ref); ASSERT_NE(kInvalidCookie, cookie); EXPECT_EQ(Res_value::TYPE_INT_DEC, value.dataType); Loading @@ -342,7 +342,7 @@ TEST_F(AssetManager2Test, ResolveReferenceToBag) { EXPECT_EQ(Res_value::TYPE_REFERENCE, value.dataType); EXPECT_EQ(basic::R::array::integerArray1, value.data); uint32_t last_ref; uint32_t last_ref = 0u; cookie = assetmanager.ResolveReference(cookie, &value, &selected_config, &flags, &last_ref); ASSERT_NE(kInvalidCookie, cookie); EXPECT_EQ(Res_value::TYPE_REFERENCE, value.dataType); Loading @@ -350,6 +350,25 @@ TEST_F(AssetManager2Test, ResolveReferenceToBag) { EXPECT_EQ(basic::R::array::integerArray1, last_ref); } TEST_F(AssetManager2Test, KeepLastReferenceIdUnmodifiedIfNoReferenceIsResolved) { AssetManager2 assetmanager; assetmanager.SetApkAssets({basic_assets_.get()}); ResTable_config selected_config; memset(&selected_config, 0, sizeof(selected_config)); uint32_t flags = 0u; // Create some kind of Res_value that is NOT a reference. Res_value value; value.dataType = Res_value::TYPE_STRING; value.data = 0; uint32_t last_ref = basic::R::string::test1; EXPECT_EQ(1, assetmanager.ResolveReference(1, &value, &selected_config, &flags, &last_ref)); EXPECT_EQ(basic::R::string::test1, last_ref); } static bool IsConfigurationPresent(const std::set<ResTable_config>& configurations, const ResTable_config& configuration) { return configurations.count(configuration) > 0; Loading Loading
libs/androidfw/AssetManager2.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -427,7 +427,6 @@ ApkAssetsCookie AssetManager2::ResolveReference(ApkAssetsCookie cookie, Res_valu ATRACE_CALL(); constexpr const int kMaxIterations = 20; *out_last_reference = 0u; for (size_t iteration = 0u; in_out_value->dataType == Res_value::TYPE_REFERENCE && in_out_value->data != 0u && iteration < kMaxIterations; iteration++) { Loading
libs/androidfw/include/androidfw/AssetManager2.h +1 −1 Original line number Diff line number Diff line Loading @@ -210,7 +210,7 @@ class AssetManager2 { // are OR'd together with `in_out_flags`. // `in_out_config` is populated with the configuration for which the resolved value was defined. // `out_last_reference` is populated with the last reference ID before resolving to an actual // value. // value. This is only initialized if the passed in `in_out_value` is a reference. // Returns the cookie of the APK the resolved resource was defined in, or kInvalidCookie if // it was not found. ApkAssetsCookie ResolveReference(ApkAssetsCookie cookie, Res_value* in_out_value, Loading
libs/androidfw/tests/AssetManager2_test.cpp +21 −2 Original line number Diff line number Diff line Loading @@ -319,7 +319,7 @@ TEST_F(AssetManager2Test, ResolveReferenceToResource) { EXPECT_EQ(Res_value::TYPE_REFERENCE, value.dataType); EXPECT_EQ(basic::R::integer::ref2, value.data); uint32_t last_ref; uint32_t last_ref = 0u; cookie = assetmanager.ResolveReference(cookie, &value, &selected_config, &flags, &last_ref); ASSERT_NE(kInvalidCookie, cookie); EXPECT_EQ(Res_value::TYPE_INT_DEC, value.dataType); Loading @@ -342,7 +342,7 @@ TEST_F(AssetManager2Test, ResolveReferenceToBag) { EXPECT_EQ(Res_value::TYPE_REFERENCE, value.dataType); EXPECT_EQ(basic::R::array::integerArray1, value.data); uint32_t last_ref; uint32_t last_ref = 0u; cookie = assetmanager.ResolveReference(cookie, &value, &selected_config, &flags, &last_ref); ASSERT_NE(kInvalidCookie, cookie); EXPECT_EQ(Res_value::TYPE_REFERENCE, value.dataType); Loading @@ -350,6 +350,25 @@ TEST_F(AssetManager2Test, ResolveReferenceToBag) { EXPECT_EQ(basic::R::array::integerArray1, last_ref); } TEST_F(AssetManager2Test, KeepLastReferenceIdUnmodifiedIfNoReferenceIsResolved) { AssetManager2 assetmanager; assetmanager.SetApkAssets({basic_assets_.get()}); ResTable_config selected_config; memset(&selected_config, 0, sizeof(selected_config)); uint32_t flags = 0u; // Create some kind of Res_value that is NOT a reference. Res_value value; value.dataType = Res_value::TYPE_STRING; value.data = 0; uint32_t last_ref = basic::R::string::test1; EXPECT_EQ(1, assetmanager.ResolveReference(1, &value, &selected_config, &flags, &last_ref)); EXPECT_EQ(basic::R::string::test1, last_ref); } static bool IsConfigurationPresent(const std::set<ResTable_config>& configurations, const ResTable_config& configuration) { return configurations.count(configuration) > 0; Loading