summaryrefslogtreecommitdiff
path: root/cmds/installd/InstalldNativeService.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cmds/installd/InstalldNativeService.cpp')
-rw-r--r--cmds/installd/InstalldNativeService.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp
index cae212c8a8..7da5642fa3 100644
--- a/cmds/installd/InstalldNativeService.cpp
+++ b/cmds/installd/InstalldNativeService.cpp
@@ -766,9 +766,6 @@ static int32_t copy_directory_recursive(const char* from, const char* to) {
return android_fork_execvp(ARRAY_SIZE(argv), argv, nullptr, false, true);
}
-// TODO(narayan): We should pass through the ceDataInode so that we can call
-// clearAppData(FLAG_CLEAR_CACHE_ONLY | FLAG_CLEAR_CODE_CACHE before we commence
-// the copy.
binder::Status InstalldNativeService::snapshotAppData(
const std::unique_ptr<std::string>& volumeUuid,
const std::string& packageName, int32_t user, int32_t storageFlags) {
@@ -813,6 +810,24 @@ binder::Status InstalldNativeService::snapshotAppData(
return ok();
}
+ // ce_data_inode is not needed when FLAG_CLEAR_CACHE_ONLY is set.
+ binder::Status clear_cache_result = clearAppData(volumeUuid, packageName, user,
+ storageFlags | FLAG_CLEAR_CACHE_ONLY, 0);
+ if (!clear_cache_result.isOk()) {
+ // It should be fine to continue snapshot if we for some reason failed
+ // to clear cache.
+ LOG(WARNING) << "Failed to clear cache of app " << packageName;
+ }
+
+ // ce_data_inode is not needed when FLAG_CLEAR_CODE_CACHE_ONLY is set.
+ binder::Status clear_code_cache_result = clearAppData(volumeUuid, packageName, user,
+ storageFlags | FLAG_CLEAR_CODE_CACHE_ONLY, 0);
+ if (!clear_code_cache_result.isOk()) {
+ // It should be fine to continue snapshot if we for some reason failed
+ // to clear code_cache.
+ LOG(WARNING) << "Failed to clear code_cache of app " << packageName;
+ }
+
if (storageFlags & FLAG_STORAGE_DE) {
auto from = create_data_user_de_package_path(volume_uuid, user, package_name);
auto to = create_data_misc_de_rollback_path(volume_uuid, user);