blob: 185e9292346d0fa7188b46623cf66435a91cb543 [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>
20#include <sstream>
21#include <string>
22#include <utility>
23#include <vector>
24
Winson62ac8b52019-12-04 08:36:48 -080025#include "R.h"
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070026#include "TestHelpers.h"
Winson62ac8b52019-12-04 08:36:48 -080027#include "androidfw/ResourceTypes.h"
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070028#include "gmock/gmock.h"
29#include "gtest/gtest.h"
Mårten Kongstadd7e8a532019-10-11 08:32:04 +020030#include "idmap2/LogInfo.h"
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070031#include "idmap2/ResourceMapping.h"
32
Ryan Mitchelle753ffe2019-09-23 09:47:02 -070033using android::Res_value;
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070034using android::idmap2::utils::ExtractOverlayManifestInfo;
35
Winson62ac8b52019-12-04 08:36:48 -080036using PolicyFlags = android::ResTable_overlayable_policy_header::PolicyFlags;
37
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070038namespace android::idmap2 {
39
40#define ASSERT_RESULT(r) \
41 do { \
42 auto result = r; \
43 ASSERT_TRUE(result) << result.GetErrorMessage(); \
44 } while (0)
45
46Result<ResourceMapping> TestGetResourceMapping(const android::StringPiece& local_target_apk_path,
47 const android::StringPiece& local_overlay_apk_path,
48 const OverlayManifestInfo& overlay_info,
49 const PolicyBitmask& fulfilled_policies,
50 bool enforce_overlayable) {
51 const std::string target_apk_path(GetTestDataPath() + local_target_apk_path.data());
52 std::unique_ptr<const ApkAssets> target_apk = ApkAssets::Load(target_apk_path);
53 if (!target_apk) {
54 return Error(R"(Failed to load target apk "%s")", target_apk_path.data());
55 }
56
57 const std::string overlay_apk_path(GetTestDataPath() + local_overlay_apk_path.data());
58 std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
59 if (!overlay_apk) {
60 return Error(R"(Failed to load overlay apk "%s")", overlay_apk_path.data());
61 }
62
Mårten Kongstadd7e8a532019-10-11 08:32:04 +020063 LogInfo log_info;
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070064 return ResourceMapping::FromApkAssets(*target_apk, *overlay_apk, overlay_info, fulfilled_policies,
Mårten Kongstadd7e8a532019-10-11 08:32:04 +020065 enforce_overlayable, log_info);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070066}
67
68Result<ResourceMapping> TestGetResourceMapping(const android::StringPiece& local_target_apk_path,
69 const android::StringPiece& local_overlay_apk_path,
70 const PolicyBitmask& fulfilled_policies,
71 bool enforce_overlayable) {
72 auto overlay_info = ExtractOverlayManifestInfo(GetTestDataPath() + local_overlay_apk_path.data());
73 if (!overlay_info) {
74 return overlay_info.GetError();
75 }
76 return TestGetResourceMapping(local_target_apk_path, local_overlay_apk_path, *overlay_info,
77 fulfilled_policies, enforce_overlayable);
78}
79
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -070080Result<Unit> MappingExists(const ResourceMapping& mapping, ResourceId target_resource,
81 ResourceId overlay_resource, bool rewrite) {
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070082 auto target_map = mapping.GetTargetToOverlayMap();
83 auto entry_map = target_map.find(target_resource);
84 if (entry_map == target_map.end()) {
85 return Error("Failed to find mapping for target resource");
86 }
87
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -070088 auto actual_overlay_resource = std::get_if<ResourceId>(&entry_map->second);
89 if (actual_overlay_resource == nullptr) {
90 return Error("Target resource is not mapped to an overlay resource id");
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070091 }
92
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -070093 if (*actual_overlay_resource != overlay_resource) {
94 return Error(R"(Expected id: "0x%02x" Actual id: "0x%02x")", overlay_resource,
95 *actual_overlay_resource);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070096 }
97
98 auto overlay_map = mapping.GetOverlayToTargetMap();
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -070099 auto overlay_iter = overlay_map.find(overlay_resource);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700100 if ((overlay_iter != overlay_map.end()) != rewrite) {
101 return Error(R"(Expected rewriting: "%s")", rewrite ? "true" : "false");
102 }
103
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700104 if (rewrite && overlay_iter->second != target_resource) {
105 return Error(R"(Expected rewrite id: "0x%02x" Actual id: "0x%02x")", target_resource,
106 overlay_iter->second);
107 }
108
109 return Result<Unit>({});
110}
111
112Result<Unit> MappingExists(const ResourceMapping& mapping, const ResourceId& target_resource,
113 const uint8_t type, const uint32_t value) {
114 auto target_map = mapping.GetTargetToOverlayMap();
115 auto entry_map = target_map.find(target_resource);
116 if (entry_map == target_map.end()) {
117 return Error("Failed to find mapping for target resource");
118 }
119
120 auto actual_overlay_value = std::get_if<TargetValue>(&entry_map->second);
121 if (actual_overlay_value == nullptr) {
122 return Error("Target resource is not mapped to an inline value");
123 }
124
125 if (actual_overlay_value->data_type != type) {
126 return Error(R"(Expected type: "0x%02x" Actual type: "0x%02x")", type,
127 actual_overlay_value->data_type);
128 }
129
130 if (actual_overlay_value->data_value != value) {
131 return Error(R"(Expected value: "0x%08x" Actual value: "0x%08x")", type,
132 actual_overlay_value->data_value);
133 }
134
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700135 return Result<Unit>({});
136}
137
138TEST(ResourceMappingTests, ResourcesFromApkAssetsLegacy) {
139 OverlayManifestInfo info{};
140 info.target_package = "test.target";
141 info.target_name = "TestResources";
142 info.resource_mapping = 0U; // no xml
143 auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk", info,
Winson62ac8b52019-12-04 08:36:48 -0800144 PolicyFlags::PUBLIC,
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700145 /* enforce_overlayable */ false);
146
147 ASSERT_TRUE(resources) << resources.GetErrorMessage();
148 auto& res = *resources;
149 ASSERT_EQ(res.GetTargetToOverlayMap().size(), 4U);
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700150 ASSERT_RESULT(
151 MappingExists(res, R::target::integer::int1, R::overlay::integer::int1, false /* rewrite */));
152 ASSERT_RESULT(
153 MappingExists(res, R::target::string::str1, R::overlay::string::str1, false /* rewrite */));
154 ASSERT_RESULT(
155 MappingExists(res, R::target::string::str3, R::overlay::string::str3, false /* rewrite */));
156 ASSERT_RESULT(
157 MappingExists(res, R::target::string::str4, R::overlay::string::str4, false /* rewrite */));
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700158}
159
160TEST(ResourceMappingTests, ResourcesFromApkAssetsNonMatchingNames) {
161 OverlayManifestInfo info{};
162 info.target_package = "test.target";
163 info.target_name = "TestResources";
164 info.resource_mapping = 0x7f030003; // xml/overlays_swap
165 auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk", info,
Winson62ac8b52019-12-04 08:36:48 -0800166 PolicyFlags::PUBLIC,
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700167 /* enforce_overlayable */ false);
168
169 ASSERT_TRUE(resources) << resources.GetErrorMessage();
170 auto& res = *resources;
171 ASSERT_EQ(res.GetTargetToOverlayMap().size(), 3U);
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700172 ASSERT_RESULT(
173 MappingExists(res, R::target::string::str1, R::overlay::string::str4, true /* rewrite */));
174 ASSERT_RESULT(
175 MappingExists(res, R::target::string::str3, R::overlay::string::str1, true /* rewrite */));
176 ASSERT_RESULT(
177 MappingExists(res, R::target::string::str4, R::overlay::string::str3, true /* rewrite */));
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700178}
179
Ryan Mitchelle753ffe2019-09-23 09:47:02 -0700180TEST(ResourceMappingTests, DoNotRewriteNonOverlayResourceId) {
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700181 OverlayManifestInfo info{};
182 info.target_package = "test.target";
183 info.target_name = "TestResources";
184 info.resource_mapping = 0x7f030001; // xml/overlays_different_packages
185 auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk", info,
Winson62ac8b52019-12-04 08:36:48 -0800186 PolicyFlags::PUBLIC,
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700187 /* enforce_overlayable */ false);
188
189 ASSERT_TRUE(resources) << resources.GetErrorMessage();
190 auto& res = *resources;
191 ASSERT_EQ(res.GetTargetToOverlayMap().size(), 2U);
192 ASSERT_EQ(res.GetOverlayToTargetMap().size(), 1U);
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700193 ASSERT_RESULT(MappingExists(res, R::target::string::str1, 0x0104000a,
Winson62ac8b52019-12-04 08:36:48 -0800194 false /* rewrite */)); // -> android:string/ok
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700195 ASSERT_RESULT(MappingExists(res, R::target::string::str3, 0x7f020001, true /* rewrite */));
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700196}
197
198TEST(ResourceMappingTests, InlineResources) {
199 OverlayManifestInfo info{};
200 info.target_package = "test.target";
201 info.target_name = "TestResources";
202 info.resource_mapping = 0x7f030002; // xml/overlays_inline
203 auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay.apk", info,
Winson62ac8b52019-12-04 08:36:48 -0800204 PolicyFlags::PUBLIC,
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700205 /* enforce_overlayable */ false);
206
207 constexpr size_t overlay_string_pool_size = 8U;
208 ASSERT_TRUE(resources) << resources.GetErrorMessage();
209 auto& res = *resources;
210 ASSERT_EQ(res.GetTargetToOverlayMap().size(), 2U);
211 ASSERT_EQ(res.GetOverlayToTargetMap().size(), 0U);
Winson62ac8b52019-12-04 08:36:48 -0800212 ASSERT_RESULT(MappingExists(res, R::target::string::str1, Res_value::TYPE_STRING,
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700213 overlay_string_pool_size + 0U)); // -> "Hello World"
214 ASSERT_RESULT(MappingExists(res, R::target::integer::int1, Res_value::TYPE_INT_DEC, 73U));
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700215}
216
217TEST(ResourceMappingTests, CreateIdmapFromApkAssetsPolicySystemPublic) {
218 auto resources =
219 TestGetResourceMapping("/target/target.apk", "/system-overlay/system-overlay.apk",
Winson62ac8b52019-12-04 08:36:48 -0800220 PolicyFlags::SYSTEM_PARTITION | PolicyFlags::PUBLIC,
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700221 /* enforce_overlayable */ true);
222
223 ASSERT_TRUE(resources) << resources.GetErrorMessage();
224 auto& res = *resources;
225 ASSERT_EQ(res.GetTargetToOverlayMap().size(), 3U);
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700226 ASSERT_RESULT(MappingExists(res, R::target::string::policy_public,
Winson62ac8b52019-12-04 08:36:48 -0800227 R::system_overlay::string::policy_public, false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700228 ASSERT_RESULT(MappingExists(res, R::target::string::policy_system,
Winson62ac8b52019-12-04 08:36:48 -0800229 R::system_overlay::string::policy_system, false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700230 ASSERT_RESULT(MappingExists(res, R::target::string::policy_system_vendor,
231 R::system_overlay::string::policy_system_vendor,
232 false /* rewrite */));
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700233}
234
235// Resources that are not declared as overlayable and resources that a protected by policies the
236// overlay does not fulfill must not map to overlay resources.
237TEST(ResourceMappingTests, CreateIdmapFromApkAssetsPolicySystemPublicInvalid) {
Winson62ac8b52019-12-04 08:36:48 -0800238 auto resources = TestGetResourceMapping("/target/target.apk",
239 "/system-overlay-invalid/system-overlay-invalid.apk",
240 PolicyFlags::SYSTEM_PARTITION | PolicyFlags::PUBLIC,
241 /* enforce_overlayable */ true);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700242
243 ASSERT_TRUE(resources) << resources.GetErrorMessage();
244 auto& res = *resources;
245 ASSERT_EQ(res.GetTargetToOverlayMap().size(), 3U);
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700246 ASSERT_RESULT(MappingExists(res, R::target::string::policy_public,
Winson62ac8b52019-12-04 08:36:48 -0800247 R::system_overlay_invalid::string::policy_public,
248 false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700249 ASSERT_RESULT(MappingExists(res, R::target::string::policy_system,
Winson62ac8b52019-12-04 08:36:48 -0800250 R::system_overlay_invalid::string::policy_system,
251 false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700252 ASSERT_RESULT(MappingExists(res, R::target::string::policy_system_vendor,
253 R::system_overlay_invalid::string::policy_system_vendor,
254 false /* rewrite */));
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700255}
256
257// Resources that are not declared as overlayable and resources that a protected by policies the
258// overlay does not fulfilled can map to overlay resources when overlayable enforcement is turned
259// off.
260TEST(ResourceMappingTests, ResourcesFromApkAssetsPolicySystemPublicInvalidIgnoreOverlayable) {
Winson62ac8b52019-12-04 08:36:48 -0800261 auto resources = TestGetResourceMapping("/target/target.apk",
262 "/system-overlay-invalid/system-overlay-invalid.apk",
263 PolicyFlags::SYSTEM_PARTITION | PolicyFlags::PUBLIC,
264 /* enforce_overlayable */ false);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700265
266 ASSERT_TRUE(resources) << resources.GetErrorMessage();
267 auto& res = *resources;
Zoran Jovanovic0f942f92020-06-09 18:51:57 +0200268 ASSERT_EQ(res.GetTargetToOverlayMap().size(), 11U);
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700269 ASSERT_RESULT(MappingExists(res, R::target::string::not_overlayable,
Winson62ac8b52019-12-04 08:36:48 -0800270 R::system_overlay_invalid::string::not_overlayable,
271 false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700272 ASSERT_RESULT(MappingExists(res, R::target::string::other,
Winson62ac8b52019-12-04 08:36:48 -0800273 R::system_overlay_invalid::string::other, false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700274 ASSERT_RESULT(MappingExists(res, R::target::string::policy_actor,
Winsonf56ade32019-12-04 11:32:41 -0800275 R::system_overlay_invalid::string::policy_actor,
276 false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700277 ASSERT_RESULT(MappingExists(res, R::target::string::policy_odm,
Winson62ac8b52019-12-04 08:36:48 -0800278 R::system_overlay_invalid::string::policy_odm, false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700279 ASSERT_RESULT(MappingExists(res, R::target::string::policy_oem,
Winson62ac8b52019-12-04 08:36:48 -0800280 R::system_overlay_invalid::string::policy_oem, false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700281 ASSERT_RESULT(MappingExists(res, R::target::string::policy_product,
Winson62ac8b52019-12-04 08:36:48 -0800282 R::system_overlay_invalid::string::policy_product,
283 false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700284 ASSERT_RESULT(MappingExists(res, R::target::string::policy_public,
Winson62ac8b52019-12-04 08:36:48 -0800285 R::system_overlay_invalid::string::policy_public,
286 false /* rewrite */));
Zoran Jovanovic0f942f92020-06-09 18:51:57 +0200287 ASSERT_RESULT(MappingExists(res, R::target::string::policy_config_signature,
Zoran Jovanovic0f942f92020-06-09 18:51:57 +0200288 R::system_overlay_invalid::string::policy_config_signature,
289 false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700290 ASSERT_RESULT(MappingExists(res, R::target::string::policy_signature,
Winson62ac8b52019-12-04 08:36:48 -0800291 R::system_overlay_invalid::string::policy_signature,
292 false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700293 ASSERT_RESULT(MappingExists(res, R::target::string::policy_system,
Winson62ac8b52019-12-04 08:36:48 -0800294 R::system_overlay_invalid::string::policy_system,
295 false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700296 ASSERT_RESULT(MappingExists(res, R::target::string::policy_system_vendor,
297 R::system_overlay_invalid::string::policy_system_vendor,
298 false /* rewrite */));
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700299}
300
301// Overlays that do not target an <overlayable> tag can overlay resources defined within any
302// <overlayable> tag.
303TEST(ResourceMappingTests, ResourcesFromApkAssetsNoDefinedOverlayableAndNoTargetName) {
304 auto resources = TestGetResourceMapping("/target/target.apk", "/overlay/overlay-no-name.apk",
Winson62ac8b52019-12-04 08:36:48 -0800305 PolicyFlags::PUBLIC,
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700306 /* enforce_overlayable */ false);
307
308 ASSERT_TRUE(resources) << resources.GetErrorMessage();
309 auto& res = *resources;
310 ASSERT_EQ(res.GetTargetToOverlayMap().size(), 4U);
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700311 ASSERT_RESULT(
312 MappingExists(res, R::target::integer::int1, R::overlay::integer::int1, false /* rewrite */));
313 ASSERT_RESULT(
314 MappingExists(res, R::target::string::str1, R::overlay::string::str1, false /* rewrite */));
315 ASSERT_RESULT(
316 MappingExists(res, R::target::string::str3, R::overlay::string::str3, false /* rewrite */));
317 ASSERT_RESULT(
318 MappingExists(res, R::target::string::str4, R::overlay::string::str4, false /* rewrite */));
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700319}
320
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700321// Overlays that are neither pre-installed nor signed with the same signature as the target cannot
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700322// overlay packages that have not defined overlayable resources.
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700323TEST(ResourceMappingTests, ResourcesFromApkAssetsDefaultPoliciesPublicFail) {
324 auto resources = TestGetResourceMapping("/target/target-no-overlayable.apk",
325 "/overlay/overlay-no-name.apk", PolicyFlags::PUBLIC,
326 /* enforce_overlayable */ true);
Ryan Mitchellaf93f5d2020-05-26 14:29:03 -0700327
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700328 ASSERT_TRUE(resources) << resources.GetErrorMessage();
329 ASSERT_EQ(resources->GetTargetToOverlayMap().size(), 0U);
330}
331
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700332// Overlays that are pre-installed or are signed with the same signature as the target or are
333// signed with the same signature as the reference package can overlay packages that have not
334// defined overlayable resources.
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700335TEST(ResourceMappingTests, ResourcesFromApkAssetsDefaultPolicies) {
336 auto CheckEntries = [&](const PolicyBitmask& fulfilled_policies) -> void {
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700337 auto resources = TestGetResourceMapping("/target/target-no-overlayable.apk",
338 "/system-overlay-invalid/system-overlay-invalid.apk",
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700339 fulfilled_policies,
340 /* enforce_overlayable */ true);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700341
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700342 ASSERT_TRUE(resources) << resources.GetErrorMessage();
343 auto& res = *resources;
Zoran Jovanovic0f942f92020-06-09 18:51:57 +0200344 ASSERT_EQ(resources->GetTargetToOverlayMap().size(), 11U);
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700345 ASSERT_RESULT(MappingExists(res, R::target::string::not_overlayable,
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700346 R::system_overlay_invalid::string::not_overlayable,
347 false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700348 ASSERT_RESULT(MappingExists(res, R::target::string::other,
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700349 R::system_overlay_invalid::string::other, false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700350 ASSERT_RESULT(MappingExists(res, R::target::string::policy_actor,
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700351 R::system_overlay_invalid::string::policy_actor,
352 false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700353 ASSERT_RESULT(MappingExists(res, R::target::string::policy_odm,
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700354 R::system_overlay_invalid::string::policy_odm,
355 false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700356 ASSERT_RESULT(MappingExists(res, R::target::string::policy_oem,
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700357 R::system_overlay_invalid::string::policy_oem,
358 false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700359 ASSERT_RESULT(MappingExists(res, R::target::string::policy_product,
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700360 R::system_overlay_invalid::string::policy_product,
361 false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700362 ASSERT_RESULT(MappingExists(res, R::target::string::policy_public,
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700363 R::system_overlay_invalid::string::policy_public,
364 false /* rewrite */));
Zoran Jovanovic0f942f92020-06-09 18:51:57 +0200365 ASSERT_RESULT(MappingExists(res, R::target::string::policy_config_signature,
Zoran Jovanovic0f942f92020-06-09 18:51:57 +0200366 R::system_overlay_invalid::string::policy_config_signature,
367 false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700368 ASSERT_RESULT(MappingExists(res, R::target::string::policy_signature,
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700369 R::system_overlay_invalid::string::policy_signature,
370 false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700371 ASSERT_RESULT(MappingExists(res, R::target::string::policy_system,
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700372 R::system_overlay_invalid::string::policy_system,
373 false /* rewrite */));
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700374 ASSERT_RESULT(MappingExists(res, R::target::string::policy_system_vendor,
375 R::system_overlay_invalid::string::policy_system_vendor,
376 false /* rewrite */));
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700377 };
378
379 CheckEntries(PolicyFlags::SIGNATURE);
Zoran Jovanovic0f942f92020-06-09 18:51:57 +0200380 CheckEntries(PolicyFlags::CONFIG_SIGNATURE);
Ryan Mitchelle88ef742020-06-03 12:55:02 -0700381 CheckEntries(PolicyFlags::PRODUCT_PARTITION);
382 CheckEntries(PolicyFlags::SYSTEM_PARTITION);
383 CheckEntries(PolicyFlags::VENDOR_PARTITION);
384 CheckEntries(PolicyFlags::ODM_PARTITION);
385 CheckEntries(PolicyFlags::OEM_PARTITION);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700386}
387
388} // namespace android::idmap2