summaryrefslogtreecommitdiff
path: root/cmds/idmap2/idmap2d/Idmap2Service.cpp
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2020-03-26 17:15:01 -0700
committerRyan Mitchell <rtmitchell@google.com>2020-04-07 12:14:51 -0700
commita90930528d4be87b3132bf758afeb6aa7a7524b9 (patch)
tree86321e767843f9448085c7962d2dbe0fa6e64147 /cmds/idmap2/idmap2d/Idmap2Service.cpp
parent2d8d9812e9925ed017c5ce10208b3d807258a2cc (diff)
Invalidate idmap when target updates
When the target package update, check if the idmap file must change. If so, propagate the idmap changes to the targets overlay paths, and invalidate cached overlay ApkAssets in ResourcesManager. Bug: 147794117 Bug: 150877400 Test: OverlayRemountedTest Test: libandroidfw_tests Change-Id: I6115c30bae3672b188a5ff270720a0eea15b43b5
Diffstat (limited to 'cmds/idmap2/idmap2d/Idmap2Service.cpp')
-rw-r--r--cmds/idmap2/idmap2d/Idmap2Service.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/cmds/idmap2/idmap2d/Idmap2Service.cpp b/cmds/idmap2/idmap2d/Idmap2Service.cpp
index e55ea6c00545..75fc7f714ce3 100644
--- a/cmds/idmap2/idmap2d/Idmap2Service.cpp
+++ b/cmds/idmap2/idmap2d/Idmap2Service.cpp
@@ -149,15 +149,21 @@ Status Idmap2Service::createIdmap(const std::string& target_apk_path,
return error(idmap.GetErrorMessage());
}
+ // idmap files are mapped with mmap in libandroidfw. Deleting and recreating the idmap guarantees
+ // that existing memory maps will continue to be valid and unaffected.
+ unlink(idmap_path.c_str());
+
umask(kIdmapFilePermissionMask);
std::ofstream fout(idmap_path);
if (fout.fail()) {
return error("failed to open idmap path " + idmap_path);
}
+
BinaryStreamVisitor visitor(fout);
(*idmap)->accept(&visitor);
fout.close();
if (fout.fail()) {
+ unlink(idmap_path.c_str());
return error("failed to write to idmap path " + idmap_path);
}