blob: d777cbfa9a14caf62acd3448a87ce5bf7730983a [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 Mitchellc75c2e02020-08-17 08:42:48 -070074 : 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 Mitchellc75c2e02020-08-17 08:42:48 -0700123 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 Mitchellc75c2e02020-08-17 08:42:48 -0700128 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 Mitchellc75c2e02020-08-17 08:42:48 -0700132 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 Mitchellc75c2e02020-08-17 08:42:48 -0700139 auto asset = asset_manager.OpenNonAsset(file->c_str(), Asset::AccessMode::ACCESS_BUFFER);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700140 if (asset == nullptr) {
Ryan Mitchellc75c2e02020-08-17 08:42:48 -0700141 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 Mitchellc75c2e02020-08-17 08:42:48 -0700187 auto target_id_result =
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700188 target_am->GetResourceId(*target_resource, "", target_package->GetPackageName());
Ryan Mitchellc75c2e02020-08-17 08:42:48 -0700189 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 Mitchellc75c2e02020-08-17 08:42:48 -0700196 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 Mitchellc75c2e02020-08-17 08:42:48 -0700217 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 Mitchellc75c2e02020-08-17 08:42:48 -0700231 auto target_resource_result = target_am->GetResourceId(full_name);
232 if (!target_resource_result.has_value()) {
233 log_info.Warning(LogMessage() << "failed to find resource \"" << full_name
234 << "\" 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 Mitchellc75c2e02020-08-17 08:42:48 -0700239 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;
288 if (!target_asset_manager.SetApkAssets({&target_apk_assets}, true /* invalidate_caches */,
289 false /* filter_incompatible_configs*/)) {
290 return Error("failed to create target asset manager");
291 }
292
293 AssetManager2 overlay_asset_manager;
294 if (!overlay_asset_manager.SetApkAssets({&overlay_apk_assets}, true /* invalidate_caches */,
295 false /* filter_incompatible_configs */)) {
296 return Error("failed to create overlay asset manager");
297 }
298
299 const LoadedArsc* target_arsc = target_apk_assets.GetLoadedArsc();
300 if (target_arsc == nullptr) {
301 return Error("failed to load target resources.arsc");
302 }
303
304 const LoadedArsc* overlay_arsc = overlay_apk_assets.GetLoadedArsc();
305 if (overlay_arsc == nullptr) {
306 return Error("failed to load overlay resources.arsc");
307 }
308
309 const LoadedPackage* target_pkg = GetPackageAtIndex0(*target_arsc);
310 if (target_pkg == nullptr) {
311 return Error("failed to load target package from resources.arsc");
312 }
313
314 const LoadedPackage* overlay_pkg = GetPackageAtIndex0(*overlay_arsc);
315 if (overlay_pkg == nullptr) {
316 return Error("failed to load overlay package from resources.arsc");
317 }
318
319 size_t string_pool_data_length = 0U;
320 size_t string_pool_offset = 0U;
321 std::unique_ptr<uint8_t[]> string_pool_data;
322 Result<ResourceMapping> resource_mapping = {{}};
323 if (overlay_info.resource_mapping != 0U) {
Ryan Mitchell5035d662020-01-22 13:19:41 -0800324 // Use the dynamic reference table to find the assigned resource id of the map xml.
325 const auto& ref_table = overlay_asset_manager.GetDynamicRefTableForCookie(0);
326 uint32_t resource_mapping_id = overlay_info.resource_mapping;
327 ref_table->lookupResourceId(&resource_mapping_id);
328
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700329 // Load the overlay resource mappings from the file specified using android:resourcesMap.
Ryan Mitchell5035d662020-01-22 13:19:41 -0800330 auto asset = OpenNonAssetFromResource(resource_mapping_id, overlay_asset_manager);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700331 if (!asset) {
332 return Error("failed opening xml for android:resourcesMap: %s",
333 asset.GetErrorMessage().c_str());
334 }
335
336 auto parser =
337 XmlParser::Create((*asset)->getBuffer(true /* wordAligned*/), (*asset)->getLength());
338 if (!parser) {
339 return Error("failed opening ResXMLTree");
340 }
341
342 // Copy the xml string pool data before the parse goes out of scope.
343 auto& string_pool = (*parser)->get_strings();
344 string_pool_data_length = string_pool.bytes();
345 string_pool_data.reset(new uint8_t[string_pool_data_length]);
Ryan Mitchellc75c2e02020-08-17 08:42:48 -0700346
347 // Overlays should not be incrementally installed, so calling unsafe_ptr is fine here.
348 memcpy(string_pool_data.get(), string_pool.data().unsafe_ptr(), string_pool_data_length);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700349
350 // Offset string indices by the size of the overlay resource table string pool.
351 string_pool_offset = overlay_arsc->GetStringPool()->size();
352
353 resource_mapping = CreateResourceMapping(&target_asset_manager, target_pkg, overlay_pkg,
Mårten Kongstadd7e8a532019-10-11 08:32:04 +0200354 string_pool_offset, *(*parser), log_info);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700355 } else {
356 // If no file is specified using android:resourcesMap, it is assumed that the overlay only
357 // defines resources intended to override target resources of the same type and name.
358 resource_mapping = CreateResourceMappingLegacy(&target_asset_manager, &overlay_asset_manager,
Ryan Mitchellc75c2e02020-08-17 08:42:48 -0700359 target_pkg, overlay_pkg, log_info);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700360 }
361
362 if (!resource_mapping) {
363 return resource_mapping.GetError();
364 }
365
366 if (enforce_overlayable) {
367 // Filter out resources the overlay is not allowed to override.
368 (*resource_mapping)
369 .FilterOverlayableResources(&target_asset_manager, target_pkg, overlay_pkg, overlay_info,
Mårten Kongstadd7e8a532019-10-11 08:32:04 +0200370 fulfilled_policies, log_info);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700371 }
372
373 resource_mapping->target_package_id_ = target_pkg->GetPackageId();
374 resource_mapping->overlay_package_id_ = overlay_pkg->GetPackageId();
375 resource_mapping->string_pool_offset_ = string_pool_offset;
376 resource_mapping->string_pool_data_ = std::move(string_pool_data);
377 resource_mapping->string_pool_data_length_ = string_pool_data_length;
378 return std::move(*resource_mapping);
379}
380
381OverlayResourceMap ResourceMapping::GetOverlayToTargetMap() const {
382 // An overlay resource can override multiple target resources at once. Rewrite the overlay
383 // resource as the first target resource it overrides.
384 OverlayResourceMap map;
385 for (const auto& mappings : overlay_map_) {
386 map.insert(std::make_pair(mappings.first, mappings.second));
387 }
388 return map;
389}
390
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700391Result<Unit> ResourceMapping::AddMapping(ResourceId target_resource, ResourceId overlay_resource,
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700392 bool rewrite_overlay_reference) {
393 if (target_map_.find(target_resource) != target_map_.end()) {
394 return Error(R"(target resource id "0x%08x" mapped to multiple values)", target_resource);
395 }
396
397 // TODO(141485591): Ensure that the overlay type is compatible with the target type. If the
398 // runtime types are not compatible, it could cause runtime crashes when the resource is resolved.
399
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700400 target_map_.insert(std::make_pair(target_resource, overlay_resource));
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700401
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700402 if (rewrite_overlay_reference) {
403 overlay_map_.insert(std::make_pair(overlay_resource, target_resource));
404 }
405 return Unit{};
406}
407
408Result<Unit> ResourceMapping::AddMapping(ResourceId target_resource,
409 TargetValue::DataType data_type,
410 TargetValue::DataValue data_value) {
411 if (target_map_.find(target_resource) != target_map_.end()) {
412 return Error(R"(target resource id "0x%08x" mapped to multiple values)", target_resource);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700413 }
414
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700415 // TODO(141485591): Ensure that the overlay type is compatible with the target type. If the
416 // runtime types are not compatible, it could cause runtime crashes when the resource is resolved.
417
418 target_map_.insert(std::make_pair(target_resource, TargetValue{data_type, data_value}));
419 return Unit{};
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700420}
421
422void ResourceMapping::RemoveMapping(ResourceId target_resource) {
423 auto target_iter = target_map_.find(target_resource);
424 if (target_iter == target_map_.end()) {
425 return;
426 }
427
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700428 const auto value = target_iter->second;
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700429 target_map_.erase(target_iter);
430
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700431 const ResourceId* overlay_resource = std::get_if<ResourceId>(&value);
432 if (overlay_resource == nullptr) {
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700433 return;
434 }
435
Ryan Mitchellbf1f45b2020-09-29 17:22:52 -0700436 auto overlay_iter = overlay_map_.equal_range(*overlay_resource);
Ryan Mitchell9e4f52b2019-09-19 12:15:52 -0700437 for (auto i = overlay_iter.first; i != overlay_iter.second; ++i) {
438 if (i->second == target_resource) {
439 overlay_map_.erase(i);
440 return;
441 }
442 }
443}
444
445} // namespace android::idmap2