blob: 0362529c4f3b508c32ed9521807cc08730aa7595 [file] [log] [blame]
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -07001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <cstdio> // fclose
18#include <fstream>
19#include <memory>
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070020#include <string>
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070021
Winson62ac8b52019-12-04 08:36:48 -080022#include "R.h"
Ryan Mitchell30dc2e02020-12-02 11:43:18 -080023#include "TestConstants.h"
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070024#include "TestHelpers.h"
Winson62ac8b52019-12-04 08:36:48 -080025#include "androidfw/ResourceTypes.h"
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070026#include "gmock/gmock.h"
27#include "gtest/gtest.h"
Mårten Kongstadd7e8a532019-10-11 08:32:04 +020028#include "idmap2/LogInfo.h"
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070029#include "idmap2/ResourceMapping.h"
30
Ryan Mitchelle753ffe2019-09-23 09:47:02 -070031using android::Res_value;
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070032using android::idmap2::utils::ExtractOverlayManifestInfo;
33
Winson62ac8b52019-12-04 08:36:48 -080034using PolicyFlags = android::ResTable_overlayable_policy_header::PolicyFlags;
35
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070036namespace android::idmap2 {
37
38#define ASSERT_RESULT(r) \
39 do { \
40 auto result = r; \
41 ASSERT_TRUE(result) << result.GetErrorMessage(); \
42 } while (0)
43
Ryan Mitchell30dc2e02020-12-02 11:43:18 -080044Result<ResourceMapping> TestGetResourceMapping(const std::string& local_target_apk_path,
45 const std::string& local_overlay_apk_path,
46 const std::string& overlay_name,
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070047 const PolicyBitmask& fulfilled_policies,
48 bool enforce_overlayable) {
Ryan Mitchell30dc2e02020-12-02 11:43:18 -080049 auto overlay_info =
50 ExtractOverlayManifestInfo(GetTestDataPath() + local_overlay_apk_path, overlay_name);
51 if (!overlay_info) {
52 return overlay_info.GetError();
53 }
54
55 const std::string target_apk_path(GetTestDataPath() + local_target_apk_path);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070056 std::unique_ptr<const ApkAssets> target_apk = ApkAssets::Load(target_apk_path);
57 if (!target_apk) {
58 return Error(R"(Failed to load target apk "%s")", target_apk_path.data());
59 }
60
Ryan Mitchell30dc2e02020-12-02 11:43:18 -080061 const std::string overlay_apk_path(GetTestDataPath() + local_overlay_apk_path);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070062 std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
63 if (!overlay_apk) {
64 return Error(R"(Failed to load overlay apk "%s")", overlay_apk_path.data());
65 }
66
Mårten Kongstadd7e8a532019-10-11 08:32:04 +020067 LogInfo log_info;
Ryan Mitchell30dc2e02020-12-02 11:43:18 -080068 return ResourceMapping::FromApkAssets(*target_apk, *overlay_apk, *overlay_info,
69 fulfilled_policies, enforce_overlayable, log_info);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070070}
71
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -070072Result<Unit> MappingExists(const ResourceMapping& mapping, ResourceId target_resource,
73 ResourceId overlay_resource, bool rewrite) {
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070074 auto target_map = mapping.GetTargetToOverlayMap();
75 auto entry_map = target_map.find(target_resource);
76 if (entry_map == target_map.end()) {
77 return Error("Failed to find mapping for target resource");
78 }
79
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -070080 auto actual_overlay_resource = std::get_if<ResourceId>(&entry_map->second);
81 if (actual_overlay_resource == nullptr) {
82 return Error("Target resource is not mapped to an overlay resource id");
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070083 }
84
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -070085 if (*actual_overlay_resource != overlay_resource) {
86 return Error(R"(Expected id: "0x%02x" Actual id: "0x%02x")", overlay_resource,
87 *actual_overlay_resource);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070088 }
89
90 auto overlay_map = mapping.GetOverlayToTargetMap();
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -070091 auto overlay_iter = overlay_map.find(overlay_resource);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070092 if ((overlay_iter != overlay_map.end()) != rewrite) {
93 return Error(R"(Expected rewriting: "%s")", rewrite ? "true" : "false");
94 }
95
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -070096 if (rewrite && overlay_iter->second != target_resource) {
97 return Error(R"(Expected rewrite id: "0x%02x" Actual id: "0x%02x")", target_resource,
98 overlay_iter->second);
99 }
100
101 return Result<Unit>({});
102}
103
104Result<Unit> MappingExists(const ResourceMapping& mapping, const ResourceId& target_resource,
105 const uint8_t type, const uint32_t value) {
106 auto target_map = mapping.GetTargetToOverlayMap();
107 auto entry_map = target_map.find(target_resource);
108 if (entry_map == target_map.end()) {
109 return Error("Failed to find mapping for target resource");
110 }
111
112 auto actual_overlay_value = std::get_if<TargetValue>(&entry_map->second);
113 if (actual_overlay_value == nullptr) {
114 return Error("Target resource is not mapped to an inline value");
115 }
116
117 if (actual_overlay_value->data_type != type) {
118 return Error(R"(Expected type: "0x%02x" Actual type: "0x%02x")", type,
119 actual_overlay_value->data_type);
120 }
121
122 if (actual_overlay_value->data_value != value) {
123 return Error(R"(Expected value: "0x%08x" Actual value: "0x%08x")", type,
124 actual_overlay_value->data_value);
125 }
126
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700127 return Result<Unit>({});
128}
129
130TEST(ResourceMappingTests, ResourcesFromApkAssetsLegacy) {
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800131 auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay-legacy.apk", "",
132 PolicyFlags::PUBLIC, /* enforce_overlayable */ false);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700133
134 ASSERT_TRUE(resources) << resources.GetErrorMessage();
135 auto& res = *resources;
136 ASSERT_EQ(res.GetTargetToOverlayMap().size(), 4U);
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700137 ASSERT_RESULT(
138 MappingExists(res, R::target::integer::int1, R::overlay::integer::int1, false /* rewrite */));
139 ASSERT_RESULT(
140 MappingExists(res, R::target::string::str1, R::overlay::string::str1, false /* rewrite */));
141 ASSERT_RESULT(
142 MappingExists(res, R::target::string::str3, R::overlay::string::str3, false /* rewrite */));
143 ASSERT_RESULT(
144 MappingExists(res, R::target::string::str4, R::overlay::string::str4, false /* rewrite */));
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700145}
146
147TEST(ResourceMappingTests, ResourcesFromApkAssetsNonMatchingNames) {
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800148 auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk", "SwapNames",
Winson62ac8b52019-12-04 08:36:48 -0800149 PolicyFlags::PUBLIC,
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700150 /* enforce_overlayable */ false);
151
152 ASSERT_TRUE(resources) << resources.GetErrorMessage();
153 auto& res = *resources;
154 ASSERT_EQ(res.GetTargetToOverlayMap().size(), 3U);
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700155 ASSERT_RESULT(
156 MappingExists(res, R::target::string::str1, R::overlay::string::str4, true /* rewrite */));
157 ASSERT_RESULT(
158 MappingExists(res, R::target::string::str3, R::overlay::string::str1, true /* rewrite */));
159 ASSERT_RESULT(
160 MappingExists(res, R::target::string::str4, R::overlay::string::str3, true /* rewrite */));
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700161}
162
Ryan Mitchelle753ffe2019-09-23 09:47:02 -0700163TEST(ResourceMappingTests, DoNotRewriteNonOverlayResourceId) {
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800164 auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk",
165 "DifferentPackages", PolicyFlags::PUBLIC,
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700166 /* enforce_overlayable */ false);
167
168 ASSERT_TRUE(resources) << resources.GetErrorMessage();
169 auto& res = *resources;
170 ASSERT_EQ(res.GetTargetToOverlayMap().size(), 2U);
171 ASSERT_EQ(res.GetOverlayToTargetMap().size(), 1U);
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700172 ASSERT_RESULT(MappingExists(res, R::target::string::str1, 0x0104000a,
Winson62ac8b52019-12-04 08:36:48 -0800173 false /* rewrite */)); // -> android:string/ok
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800174 ASSERT_RESULT(
175 MappingExists(res, R::target::string::str3, R::overlay::string::str3, true /* rewrite */));
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700176}
177
178TEST(ResourceMappingTests, InlineResources) {
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800179 auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk", "Inline",
180 PolicyFlags::PUBLIC, /* enforce_overlayable */ false);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700181
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800182 constexpr size_t overlay_string_pool_size = 10U;
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700183 ASSERT_TRUE(resources) << resources.GetErrorMessage();
184 auto& res = *resources;
185 ASSERT_EQ(res.GetTargetToOverlayMap().size(), 2U);
186 ASSERT_EQ(res.GetOverlayToTargetMap().size(), 0U);
Winson62ac8b52019-12-04 08:36:48 -0800187 ASSERT_RESULT(MappingExists(res, R::target::string::str1, Res_value::TYPE_STRING,
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700188 overlay_string_pool_size + 0U)); // -> "Hello World"
189 ASSERT_RESULT(MappingExists(res, R::target::integer::int1, Res_value::TYPE_INT_DEC, 73U));
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700190}
191
192TEST(ResourceMappingTests, CreateIdmapFromApkAssetsPolicySystemPublic) {
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800193 auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk",
194 TestConstants::OVERLAY_NAME_ALL_POLICIES,
Winson62ac8b52019-12-04 08:36:48 -0800195 PolicyFlags::SYSTEM_PARTITION | PolicyFlags::PUBLIC,
196 /* enforce_overlayable */ true);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700197
198 ASSERT_TRUE(resources) << resources.GetErrorMessage();
199 auto& res = *resources;
200 ASSERT_EQ(res.GetTargetToOverlayMap().size(), 3U);
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700201 ASSERT_RESULT(MappingExists(res, R::target::string::policy_public,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800202 R::overlay::string::policy_public, true /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700203 ASSERT_RESULT(MappingExists(res, R::target::string::policy_system,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800204 R::overlay::string::policy_system, true /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700205 ASSERT_RESULT(MappingExists(res, R::target::string::policy_system_vendor,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800206 R::overlay::string::policy_system_vendor, true /* rewrite */));
207}
208
209// Resources that are not declared as overlayable and resources that a protected by policies the
210// overlay does not fulfill must not map to overlay resources.
211TEST(ResourceMappingTests, CreateIdmapFromApkAssetsPolicySystemPublicInvalid) {
212 auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk",
213 TestConstants::OVERLAY_NAME_ALL_POLICIES,
214 PolicyFlags::SYSTEM_PARTITION | PolicyFlags::PUBLIC,
215 /* enforce_overlayable */ true);
216
217 ASSERT_TRUE(resources) << resources.GetErrorMessage();
218 auto& res = *resources;
219 ASSERT_EQ(res.GetTargetToOverlayMap().size(), 3U);
220 ASSERT_RESULT(MappingExists(res, R::target::string::policy_public,
221 R::overlay::string::policy_public, true /* rewrite */));
222 ASSERT_RESULT(MappingExists(res, R::target::string::policy_system,
223 R::overlay::string::policy_system, true /* rewrite */));
224 ASSERT_RESULT(MappingExists(res, R::target::string::policy_system_vendor,
225 R::overlay::string::policy_system_vendor, true /* rewrite */));
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700226}
227
228// Resources that are not declared as overlayable and resources that a protected by policies the
229// overlay does not fulfilled can map to overlay resources when overlayable enforcement is turned
230// off.
231TEST(ResourceMappingTests, ResourcesFromApkAssetsPolicySystemPublicInvalidIgnoreOverlayable) {
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800232 auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk",
233 TestConstants::OVERLAY_NAME_ALL_POLICIES,
Winson62ac8b52019-12-04 08:36:48 -0800234 PolicyFlags::SYSTEM_PARTITION | PolicyFlags::PUBLIC,
235 /* enforce_overlayable */ false);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700236
237 ASSERT_TRUE(resources) << resources.GetErrorMessage();
238 auto& res = *resources;
Zoran Jovanovic0f942f92020-06-09 18:51:57 +0200239 ASSERT_EQ(res.GetTargetToOverlayMap().size(), 11U);
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700240 ASSERT_RESULT(MappingExists(res, R::target::string::not_overlayable,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800241 R::overlay::string::not_overlayable, true /* rewrite */));
242 ASSERT_RESULT(
243 MappingExists(res, R::target::string::other, R::overlay::string::other, true /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700244 ASSERT_RESULT(MappingExists(res, R::target::string::policy_actor,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800245 R::overlay::string::policy_actor, true /* rewrite */));
246 ASSERT_RESULT(MappingExists(res, R::target::string::policy_odm, R::overlay::string::policy_odm,
247 true /* rewrite */));
248 ASSERT_RESULT(MappingExists(res, R::target::string::policy_oem, R::overlay::string::policy_oem,
249 true /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700250 ASSERT_RESULT(MappingExists(res, R::target::string::policy_product,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800251 R::overlay::string::policy_product, true /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700252 ASSERT_RESULT(MappingExists(res, R::target::string::policy_public,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800253 R::overlay::string::policy_public, true /* rewrite */));
Zoran Jovanovic0f942f92020-06-09 18:51:57 +0200254 ASSERT_RESULT(MappingExists(res, R::target::string::policy_config_signature,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800255 R::overlay::string::policy_config_signature, true /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700256 ASSERT_RESULT(MappingExists(res, R::target::string::policy_signature,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800257 R::overlay::string::policy_signature, true /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700258 ASSERT_RESULT(MappingExists(res, R::target::string::policy_system,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800259 R::overlay::string::policy_system, true /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700260 ASSERT_RESULT(MappingExists(res, R::target::string::policy_system_vendor,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800261 R::overlay::string::policy_system_vendor, true /* rewrite */));
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700262}
263
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800264// Overlays that do not target an <overlayable> tag can overlay any resource if overlayable
265// enforcement is disabled.
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700266TEST(ResourceMappingTests, ResourcesFromApkAssetsNoDefinedOverlayableAndNoTargetName) {
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800267 auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay-legacy.apk", "",
Winson62ac8b52019-12-04 08:36:48 -0800268 PolicyFlags::PUBLIC,
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700269 /* enforce_overlayable */ false);
270
271 ASSERT_TRUE(resources) << resources.GetErrorMessage();
272 auto& res = *resources;
273 ASSERT_EQ(res.GetTargetToOverlayMap().size(), 4U);
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700274 ASSERT_RESULT(
275 MappingExists(res, R::target::integer::int1, R::overlay::integer::int1, false /* rewrite */));
276 ASSERT_RESULT(
277 MappingExists(res, R::target::string::str1, R::overlay::string::str1, false /* rewrite */));
278 ASSERT_RESULT(
279 MappingExists(res, R::target::string::str3, R::overlay::string::str3, false /* rewrite */));
280 ASSERT_RESULT(
281 MappingExists(res, R::target::string::str4, R::overlay::string::str4, false /* rewrite */));
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700282}
283
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700284// Overlays that are neither pre-installed nor signed with the same signature as the target cannot
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700285// overlay packages that have not defined overlayable resources.
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700286TEST(ResourceMappingTests, ResourcesFromApkAssetsDefaultPoliciesPublicFail) {
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800287 auto resources =
288 TestGetResourceMapping("/target/target-no-overlayable.apk", "/overlay/overlay.apk",
289 "NoTargetName", PolicyFlags::PUBLIC,
290 /* enforce_overlayable */ true);
Ryan Mitchellaf93f5d2020-05-26 14:29:03 -0700291
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700292 ASSERT_TRUE(resources) << resources.GetErrorMessage();
293 ASSERT_EQ(resources->GetTargetToOverlayMap().size(), 0U);
294}
295
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700296// Overlays that are pre-installed or are signed with the same signature as the target or are
297// signed with the same signature as the reference package can overlay packages that have not
298// defined overlayable resources.
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700299TEST(ResourceMappingTests, ResourcesFromApkAssetsDefaultPolicies) {
300 auto CheckEntries = [&](const PolicyBitmask& fulfilled_policies) -> void {
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800301 auto resources =
302 TestGetResourceMapping("/target/target-no-overlayable.apk", "/overlay/overlay.apk",
303 TestConstants::OVERLAY_NAME_ALL_POLICIES, fulfilled_policies,
304 /* enforce_overlayable */ true);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700305
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700306 ASSERT_TRUE(resources) << resources.GetErrorMessage();
307 auto& res = *resources;
Zoran Jovanovic0f942f92020-06-09 18:51:57 +0200308 ASSERT_EQ(resources->GetTargetToOverlayMap().size(), 11U);
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700309 ASSERT_RESULT(MappingExists(res, R::target::string::not_overlayable,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800310 R::overlay::string::not_overlayable, true /* rewrite */));
311 ASSERT_RESULT(MappingExists(res, R::target::string::other, R::overlay::string::other,
312 true /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700313 ASSERT_RESULT(MappingExists(res, R::target::string::policy_actor,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800314 R::overlay::string::policy_actor, true /* rewrite */));
315 ASSERT_RESULT(MappingExists(res, R::target::string::policy_odm, R::overlay::string::policy_odm,
316 true /* rewrite */));
317 ASSERT_RESULT(MappingExists(res, R::target::string::policy_oem, R::overlay::string::policy_oem,
318 true /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700319 ASSERT_RESULT(MappingExists(res, R::target::string::policy_product,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800320 R::overlay::string::policy_product, true /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700321 ASSERT_RESULT(MappingExists(res, R::target::string::policy_public,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800322 R::overlay::string::policy_public, true /* rewrite */));
Zoran Jovanovic0f942f92020-06-09 18:51:57 +0200323 ASSERT_RESULT(MappingExists(res, R::target::string::policy_config_signature,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800324 R::overlay::string::policy_config_signature, true /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700325 ASSERT_RESULT(MappingExists(res, R::target::string::policy_signature,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800326 R::overlay::string::policy_signature, true /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700327 ASSERT_RESULT(MappingExists(res, R::target::string::policy_system,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800328 R::overlay::string::policy_system, true /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700329 ASSERT_RESULT(MappingExists(res, R::target::string::policy_system_vendor,
Ryan Mitchell30dc2e02020-12-02 11:43:18 -0800330 R::overlay::string::policy_system_vendor, true /* rewrite */));
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700331 };
332
333 CheckEntries(PolicyFlags::SIGNATURE);
Zoran Jovanovic0f942f92020-06-09 18:51:57 +0200334 CheckEntries(PolicyFlags::CONFIG_SIGNATURE);
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700335 CheckEntries(PolicyFlags::PRODUCT_PARTITION);
336 CheckEntries(PolicyFlags::SYSTEM_PARTITION);
337 CheckEntries(PolicyFlags::VENDOR_PARTITION);
338 CheckEntries(PolicyFlags::ODM_PARTITION);
339 CheckEntries(PolicyFlags::OEM_PARTITION);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700340}
341
342} // namespace android::idmap2