blob: 46eeb8e6ac80b61e512dd326131389675bbc778f [file] [log] [blame]
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -07001/*
2 * Copyright (C) 2019 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 "idmap2/ResourceMapping.h"
18
19#include <map>
20#include <memory>
21#include <set>
22#include <string>
23#include <utility>
24#include <vector>
25
26#include "android-base/stringprintf.h"
Winson62ac8b52019-12-04 08:36:48 -080027#include "androidfw/ResourceTypes.h"
28#include "idmap2/PolicyUtils.h"
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070029#include "idmap2/ResourceUtils.h"
30
31using android::base::StringPrintf;
Winson62ac8b52019-12-04 08:36:48 -080032using android::idmap2::utils::BitmaskToPolicies;
Ryan Mitchell5035d662020-01-22 13:19:41 -080033using android::idmap2::utils::IsReference;
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070034using android::idmap2::utils::ResToTypeEntryName;
Winson62ac8b52019-12-04 08:36:48 -080035using PolicyBitmask = android::ResTable_overlayable_policy_header::PolicyBitmask;
36using PolicyFlags = android::ResTable_overlayable_policy_header::PolicyFlags;
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070037
38namespace android::idmap2 {
39
40namespace {
41
Ryan Mitchellee4a5642019-10-16 08:32:55 -070042#define REWRITE_PACKAGE(resid, package_id) \
43 (((resid)&0x00ffffffU) | (((uint32_t)(package_id)) << 24U))
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070044#define EXTRACT_PACKAGE(resid) ((0xff000000 & (resid)) >> 24)
45
46std::string ConcatPolicies(const std::vector<std::string>& policies) {
47 std::string message;
48 for (const std::string& policy : policies) {
49 if (!message.empty()) {
50 message.append("|");
51 }
52 message.append(policy);
53 }
54
55 return message;
56}
57
58Result<Unit> CheckOverlayable(const LoadedPackage& target_package,
59 const OverlayManifestInfo& overlay_info,
60 const PolicyBitmask& fulfilled_policies,
61 const ResourceId& target_resource) {
62 static constexpr const PolicyBitmask sDefaultPolicies =
Winson62ac8b52019-12-04 08:36:48 -080063 PolicyFlags::ODM_PARTITION | PolicyFlags::OEM_PARTITION | PolicyFlags::SYSTEM_PARTITION |
Zoran Jovanovic0f942f92020-06-09 18:51:57 +020064 PolicyFlags::VENDOR_PARTITION | PolicyFlags::PRODUCT_PARTITION | PolicyFlags::SIGNATURE |
65 PolicyFlags::CONFIG_SIGNATURE;
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070066
67 // If the resource does not have an overlayable definition, allow the resource to be overlaid if
Zoran Jovanovic0f942f92020-06-09 18:51:57 +020068 // the overlay is preinstalled, signed with the same signature as the target or signed with the
69 // same signature as reference package defined in SystemConfig under 'overlay-config-signature'
70 // tag.
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070071 if (!target_package.DefinesOverlayable()) {
72 return (sDefaultPolicies & fulfilled_policies) != 0
73 ? Result<Unit>({})
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +000074 : Error(
75 "overlay must be preinstalled, signed with the same signature as the target,"
76 " or signed with the same signature as the package referenced through"
77 " <overlay-config-signature>.");
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -070078 }
79
80 const OverlayableInfo* overlayable_info = target_package.GetOverlayableInfo(target_resource);
81 if (overlayable_info == nullptr) {
82 // Do not allow non-overlayable resources to be overlaid.
83 return Error("target resource has no overlayable declaration");
84 }
85
86 if (overlay_info.target_name != overlayable_info->name) {
87 // If the overlay supplies a target overlayable name, the resource must belong to the
88 // overlayable defined with the specified name to be overlaid.
89 return Error(R"(<overlay> android:targetName "%s" does not match overlayable name "%s")",
90 overlay_info.target_name.c_str(), overlayable_info->name.c_str());
91 }
92
93 // Enforce policy restrictions if the resource is declared as overlayable.
94 if ((overlayable_info->policy_flags & fulfilled_policies) == 0) {
95 return Error(R"(overlay with policies "%s" does not fulfill any overlayable policies "%s")",
96 ConcatPolicies(BitmaskToPolicies(fulfilled_policies)).c_str(),
97 ConcatPolicies(BitmaskToPolicies(overlayable_info->policy_flags)).c_str());
98 }
99
100 return Result<Unit>({});
101}
102
103// TODO(martenkongstad): scan for package name instead of assuming package at index 0
104//
105// idmap version 0x01 naively assumes that the package to use is always the first ResTable_package
106// in the resources.arsc blob. In most cases, there is only a single ResTable_package anyway, so
107// this assumption tends to work out. That said, the correct thing to do is to scan
108// resources.arsc for a package with a given name as read from the package manifest instead of
109// relying on a hard-coded index. This however requires storing the package name in the idmap
110// header, which in turn requires incrementing the idmap version. Because the initial version of
111// idmap2 is compatible with idmap, this will have to wait for now.
112const LoadedPackage* GetPackageAtIndex0(const LoadedArsc& loaded_arsc) {
113 const std::vector<std::unique_ptr<const LoadedPackage>>& packages = loaded_arsc.GetPackages();
114 if (packages.empty()) {
115 return nullptr;
116 }
117 int id = packages[0]->GetPackageId();
118 return loaded_arsc.GetPackageById(id);
119}
120
121Result<std::unique_ptr<Asset>> OpenNonAssetFromResource(const ResourceId& resource_id,
122 const AssetManager2& asset_manager) {
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +0000123 auto value = asset_manager.GetResource(resource_id);
124 if (!value.has_value()) {
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700125 return Error("failed to find resource for id 0x%08x", resource_id);
126 }
127
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +0000128 if (value->type != Res_value::TYPE_STRING) {
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700129 return Error("resource for is 0x%08x is not a file", resource_id);
130 }
131
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +0000132 auto string_pool = asset_manager.GetStringPoolForCookie(value->cookie);
133 auto file = string_pool->string8ObjectAt(value->data);
134 if (!file.has_value()) {
135 return Error("failed to find string for index %d", value->data);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700136 }
137
138 // Load the overlay resource mappings from the file specified using android:resourcesMap.
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +0000139 auto asset = asset_manager.OpenNonAsset(file->c_str(), Asset::AccessMode::ACCESS_BUFFER);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700140 if (asset == nullptr) {
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +0000141 return Error("file \"%s\" not found", file->c_str());
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700142 }
143
144 return asset;
145}
146
147} // namespace
148
149Result<ResourceMapping> ResourceMapping::CreateResourceMapping(const AssetManager2* target_am,
150 const LoadedPackage* target_package,
151 const LoadedPackage* overlay_package,
152 size_t string_pool_offset,
Mårten Kongstadd7e8a532019-10-11 08:32:04 +0200153 const XmlParser& overlay_parser,
154 LogInfo& log_info) {
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700155 ResourceMapping resource_mapping;
156 auto root_it = overlay_parser.tree_iterator();
157 if (root_it->event() != XmlParser::Event::START_TAG || root_it->name() != "overlay") {
158 return Error("root element is not <overlay> tag");
159 }
160
Ryan Mitchellee4a5642019-10-16 08:32:55 -0700161 const uint8_t target_package_id = target_package->GetPackageId();
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700162 const uint8_t overlay_package_id = overlay_package->GetPackageId();
163 auto overlay_it_end = root_it.end();
164 for (auto overlay_it = root_it.begin(); overlay_it != overlay_it_end; ++overlay_it) {
165 if (overlay_it->event() == XmlParser::Event::BAD_DOCUMENT) {
166 return Error("failed to parse overlay xml document");
167 }
168
169 if (overlay_it->event() != XmlParser::Event::START_TAG) {
170 continue;
171 }
172
173 if (overlay_it->name() != "item") {
174 return Error("unexpected tag <%s> in <overlay>", overlay_it->name().c_str());
175 }
176
177 Result<std::string> target_resource = overlay_it->GetAttributeStringValue("target");
178 if (!target_resource) {
179 return Error(R"(<item> tag missing expected attribute "target")");
180 }
181
182 Result<android::Res_value> overlay_resource = overlay_it->GetAttributeValue("value");
183 if (!overlay_resource) {
184 return Error(R"(<item> tag missing expected attribute "value")");
185 }
186
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +0000187 auto target_id_result =
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700188 target_am->GetResourceId(*target_resource, "", target_package->GetPackageName());
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +0000189 if (!target_id_result.has_value()) {
Mårten Kongstadd7e8a532019-10-11 08:32:04 +0200190 log_info.Warning(LogMessage() << "failed to find resource \"" << *target_resource
191 << "\" in target resources");
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700192 continue;
193 }
194
Ryan Mitchellee4a5642019-10-16 08:32:55 -0700195 // Retrieve the compile-time resource id of the target resource.
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +0000196 uint32_t target_id = REWRITE_PACKAGE(*target_id_result, target_package_id);
Ryan Mitchellee4a5642019-10-16 08:32:55 -0700197
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700198 if (overlay_resource->dataType == Res_value::TYPE_STRING) {
199 overlay_resource->data += string_pool_offset;
200 }
201
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700202 if (IsReference(overlay_resource->dataType)) {
203 // Only rewrite resources defined within the overlay package to their corresponding target
204 // resource ids at runtime.
205 bool rewrite_reference = overlay_package_id == EXTRACT_PACKAGE(overlay_resource->data);
206 resource_mapping.AddMapping(target_id, overlay_resource->data, rewrite_reference);
207 } else {
208 resource_mapping.AddMapping(target_id, overlay_resource->dataType, overlay_resource->data);
Ryan Mitchelle753ffe2019-09-23 09:47:02 -0700209 }
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700210 }
211
212 return resource_mapping;
213}
214
215Result<ResourceMapping> ResourceMapping::CreateResourceMappingLegacy(
216 const AssetManager2* target_am, const AssetManager2* overlay_am,
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +0000217 const LoadedPackage* target_package, const LoadedPackage* overlay_package, LogInfo& log_info) {
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700218 ResourceMapping resource_mapping;
Ryan Mitchellee4a5642019-10-16 08:32:55 -0700219 const uint8_t target_package_id = target_package->GetPackageId();
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700220 const auto end = overlay_package->end();
221 for (auto iter = overlay_package->begin(); iter != end; ++iter) {
222 const ResourceId overlay_resid = *iter;
223 Result<std::string> name = utils::ResToTypeEntryName(*overlay_am, overlay_resid);
224 if (!name) {
225 continue;
226 }
227
228 // Find the resource with the same type and entry name within the target package.
229 const std::string full_name =
230 base::StringPrintf("%s:%s", target_package->GetPackageName().c_str(), name->c_str());
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +0000231 auto target_resource_result = target_am->GetResourceId(full_name);
232 if (!target_resource_result.has_value()) {
Ryan Mitchell0699f1d2020-12-03 15:41:42 -0800233 log_info.Warning(LogMessage()
234 << "failed to find resource \"" << full_name << "\" in target resources");
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700235 continue;
236 }
237
Ryan Mitchellee4a5642019-10-16 08:32:55 -0700238 // Retrieve the compile-time resource id of the target resource.
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +0000239 ResourceId target_resource = REWRITE_PACKAGE(*target_resource_result, target_package_id);
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700240 resource_mapping.AddMapping(target_resource, overlay_resid,
241 false /* rewrite_overlay_reference */);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700242 }
243
244 return resource_mapping;
245}
246
247void ResourceMapping::FilterOverlayableResources(const AssetManager2* target_am,
248 const LoadedPackage* target_package,
249 const LoadedPackage* overlay_package,
250 const OverlayManifestInfo& overlay_info,
Mårten Kongstadd7e8a532019-10-11 08:32:04 +0200251 const PolicyBitmask& fulfilled_policies,
252 LogInfo& log_info) {
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700253 std::set<ResourceId> remove_ids;
254 for (const auto& target_map : target_map_) {
255 const ResourceId target_resid = target_map.first;
256 Result<Unit> success =
257 CheckOverlayable(*target_package, overlay_info, fulfilled_policies, target_resid);
258 if (success) {
259 continue;
260 }
261
262 // Attempting to overlay a resource that is not allowed to be overlaid is treated as a
263 // warning.
264 Result<std::string> name = utils::ResToTypeEntryName(*target_am, target_resid);
265 if (!name) {
266 name = StringPrintf("0x%08x", target_resid);
267 }
268
Mårten Kongstadd7e8a532019-10-11 08:32:04 +0200269 log_info.Warning(LogMessage() << "overlay \"" << overlay_package->GetPackageName()
270 << "\" is not allowed to overlay resource \"" << *name
271 << "\" in target: " << success.GetErrorMessage());
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700272
273 remove_ids.insert(target_resid);
274 }
275
276 for (const ResourceId target_resid : remove_ids) {
277 RemoveMapping(target_resid);
278 }
279}
280
281Result<ResourceMapping> ResourceMapping::FromApkAssets(const ApkAssets& target_apk_assets,
282 const ApkAssets& overlay_apk_assets,
283 const OverlayManifestInfo& overlay_info,
284 const PolicyBitmask& fulfilled_policies,
Mårten Kongstadd7e8a532019-10-11 08:32:04 +0200285 bool enforce_overlayable,
286 LogInfo& log_info) {
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700287 AssetManager2 target_asset_manager;
Ryan Mitchell14e8ade2021-01-11 16:01:35 -0800288 if (!target_asset_manager.SetApkAssets({&target_apk_assets})) {
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700289 return Error("failed to create target asset manager");
290 }
291
292 AssetManager2 overlay_asset_manager;
Ryan Mitchell14e8ade2021-01-11 16:01:35 -0800293 if (!overlay_asset_manager.SetApkAssets({&overlay_apk_assets})) {
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700294 return Error("failed to create overlay asset manager");
295 }
296
297 const LoadedArsc* target_arsc = target_apk_assets.GetLoadedArsc();
298 if (target_arsc == nullptr) {
299 return Error("failed to load target resources.arsc");
300 }
301
302 const LoadedArsc* overlay_arsc = overlay_apk_assets.GetLoadedArsc();
303 if (overlay_arsc == nullptr) {
304 return Error("failed to load overlay resources.arsc");
305 }
306
307 const LoadedPackage* target_pkg = GetPackageAtIndex0(*target_arsc);
308 if (target_pkg == nullptr) {
309 return Error("failed to load target package from resources.arsc");
310 }
311
312 const LoadedPackage* overlay_pkg = GetPackageAtIndex0(*overlay_arsc);
313 if (overlay_pkg == nullptr) {
314 return Error("failed to load overlay package from resources.arsc");
315 }
316
317 size_t string_pool_data_length = 0U;
318 size_t string_pool_offset = 0U;
319 std::unique_ptr<uint8_t[]> string_pool_data;
320 Result<ResourceMapping> resource_mapping = {{}};
321 if (overlay_info.resource_mapping != 0U) {
Ryan Mitchell5035d662020-01-22 13:19:41 -0800322 // Use the dynamic reference table to find the assigned resource id of the map xml.
323 const auto& ref_table = overlay_asset_manager.GetDynamicRefTableForCookie(0);
324 uint32_t resource_mapping_id = overlay_info.resource_mapping;
325 ref_table->lookupResourceId(&resource_mapping_id);
326
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700327 // Load the overlay resource mappings from the file specified using android:resourcesMap.
Ryan Mitchell5035d662020-01-22 13:19:41 -0800328 auto asset = OpenNonAssetFromResource(resource_mapping_id, overlay_asset_manager);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700329 if (!asset) {
330 return Error("failed opening xml for android:resourcesMap: %s",
331 asset.GetErrorMessage().c_str());
332 }
333
334 auto parser =
335 XmlParser::Create((*asset)->getBuffer(true /* wordAligned*/), (*asset)->getLength());
336 if (!parser) {
337 return Error("failed opening ResXMLTree");
338 }
339
340 // Copy the xml string pool data before the parse goes out of scope.
341 auto& string_pool = (*parser)->get_strings();
342 string_pool_data_length = string_pool.bytes();
343 string_pool_data.reset(new uint8_t[string_pool_data_length]);
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +0000344
345 // Overlays should not be incrementally installed, so calling unsafe_ptr is fine here.
346 memcpy(string_pool_data.get(), string_pool.data().unsafe_ptr(), string_pool_data_length);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700347
348 // Offset string indices by the size of the overlay resource table string pool.
349 string_pool_offset = overlay_arsc->GetStringPool()->size();
350
351 resource_mapping = CreateResourceMapping(&target_asset_manager, target_pkg, overlay_pkg,
Mårten Kongstadd7e8a532019-10-11 08:32:04 +0200352 string_pool_offset, *(*parser), log_info);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700353 } else {
354 // If no file is specified using android:resourcesMap, it is assumed that the overlay only
355 // defines resources intended to override target resources of the same type and name.
356 resource_mapping = CreateResourceMappingLegacy(&target_asset_manager, &overlay_asset_manager,
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +0000357 target_pkg, overlay_pkg, log_info);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700358 }
359
360 if (!resource_mapping) {
361 return resource_mapping.GetError();
362 }
363
364 if (enforce_overlayable) {
365 // Filter out resources the overlay is not allowed to override.
366 (*resource_mapping)
367 .FilterOverlayableResources(&target_asset_manager, target_pkg, overlay_pkg, overlay_info,
Mårten Kongstadd7e8a532019-10-11 08:32:04 +0200368 fulfilled_policies, log_info);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700369 }
370
371 resource_mapping->target_package_id_ = target_pkg->GetPackageId();
372 resource_mapping->overlay_package_id_ = overlay_pkg->GetPackageId();
373 resource_mapping->string_pool_offset_ = string_pool_offset;
374 resource_mapping->string_pool_data_ = std::move(string_pool_data);
375 resource_mapping->string_pool_data_length_ = string_pool_data_length;
376 return std::move(*resource_mapping);
377}
378
379OverlayResourceMap ResourceMapping::GetOverlayToTargetMap() const {
380 // An overlay resource can override multiple target resources at once. Rewrite the overlay
381 // resource as the first target resource it overrides.
382 OverlayResourceMap map;
383 for (const auto& mappings : overlay_map_) {
384 map.insert(std::make_pair(mappings.first, mappings.second));
385 }
386 return map;
387}
388
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700389Result<Unit> ResourceMapping::AddMapping(ResourceId target_resource, ResourceId overlay_resource,
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700390 bool rewrite_overlay_reference) {
391 if (target_map_.find(target_resource) != target_map_.end()) {
392 return Error(R"(target resource id "0x%08x" mapped to multiple values)", target_resource);
393 }
394
395 // TODO(141485591): Ensure that the overlay type is compatible with the target type. If the
396 // runtime types are not compatible, it could cause runtime crashes when the resource is resolved.
397
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700398 target_map_.insert(std::make_pair(target_resource, overlay_resource));
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700399
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700400 if (rewrite_overlay_reference) {
401 overlay_map_.insert(std::make_pair(overlay_resource, target_resource));
402 }
403 return Unit{};
404}
405
406Result<Unit> ResourceMapping::AddMapping(ResourceId target_resource,
407 TargetValue::DataType data_type,
408 TargetValue::DataValue data_value) {
409 if (target_map_.find(target_resource) != target_map_.end()) {
410 return Error(R"(target resource id "0x%08x" mapped to multiple values)", target_resource);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700411 }
412
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700413 // TODO(141485591): Ensure that the overlay type is compatible with the target type. If the
414 // runtime types are not compatible, it could cause runtime crashes when the resource is resolved.
415
416 target_map_.insert(std::make_pair(target_resource, TargetValue{data_type, data_value}));
417 return Unit{};
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700418}
419
420void ResourceMapping::RemoveMapping(ResourceId target_resource) {
421 auto target_iter = target_map_.find(target_resource);
422 if (target_iter == target_map_.end()) {
423 return;
424 }
425
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700426 const auto value = target_iter->second;
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700427 target_map_.erase(target_iter);
428
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700429 const ResourceId* overlay_resource = std::get_if<ResourceId>(&value);
430 if (overlay_resource == nullptr) {
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700431 return;
432 }
433
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700434 auto overlay_iter = overlay_map_.equal_range(*overlay_resource);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700435 for (auto i = overlay_iter.first; i != overlay_iter.second; ++i) {
436 if (i->second == target_resource) {
437 overlay_map_.erase(i);
438 return;
439 }
440 }
441}
442
443} // namespace android::idmap2