installd: add command 'removeIdmap'
Add an installd command to remove an idmap file. This is the inverse of
the 'idmap' command and is intended for clean-up once an idmap file is
no longer needed because an APK was removed, etc.
This commit depends on a corresponding commit in frameworks/base (with
the same Change-Id).
Bug: 31052947
Test: run tests from 'OMS: tests for OverlayManagerService'
Change-Id: Iae19a519803f0c172b02a32faa283ef36f43863c
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp
index ede31fc..4589241 100644
--- a/cmds/installd/InstalldNativeService.cpp
+++ b/cmds/installd/InstalldNativeService.cpp
@@ -1890,6 +1890,22 @@
return error();
}
+binder::Status InstalldNativeService::removeIdmap(const std::string& overlayApkPath) {
+ const char* overlay_apk = overlayApkPath.c_str();
+ char idmap_path[PATH_MAX];
+
+ if (flatten_path(IDMAP_PREFIX, IDMAP_SUFFIX, overlay_apk,
+ idmap_path, sizeof(idmap_path)) == -1) {
+ ALOGE("idmap cannot generate idmap path for overlay %s\n", overlay_apk);
+ return error();
+ }
+ if (unlink(idmap_path) < 0) {
+ ALOGE("couldn't unlink idmap file %s\n", idmap_path);
+ return error();
+ }
+ return ok();
+}
+
binder::Status InstalldNativeService::restoreconAppData(const std::unique_ptr<std::string>& uuid,
const std::string& packageName, int32_t userId, int32_t flags, int32_t appId,
const std::string& seInfo) {