diff options
| author | 2019-12-04 09:27:49 -0800 | |
|---|---|---|
| committer | 2019-12-04 09:27:49 -0800 | |
| commit | f32fa062eeddcc2f005dc2f991bdc1e586c8bae2 (patch) | |
| tree | 879256d80a3881eac35b0d6ce7d45dacc2f87fc4 | |
| parent | 5f1f490d39d4fcf99afe0739e2dab190c60c465b (diff) | |
| parent | 2484b04b7b9b2a4099ff9675a10f80d8fe01d17a (diff) | |
Merge "Delete external app dir on app uninstall with FUSE" am: c3323c7d1b
am: 2484b04b7b
Change-Id: I5d022cbbd75663ff13564ef56055cdc48c86f5f0
| -rw-r--r-- | cmds/installd/InstalldNativeService.cpp | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp index 4026f29208..b23d69c52f 100644 --- a/cmds/installd/InstalldNativeService.cpp +++ b/cmds/installd/InstalldNativeService.cpp @@ -101,6 +101,7 @@ static constexpr const char* IDMAP_SUFFIX = "@idmap"; static constexpr int kVerityPageSize = 4096; static constexpr size_t kSha256Size = 32; static constexpr const char* kPropApkVerityMode = "ro.apk_verity.mode"; +static constexpr const char* kFuseProp = "persist.sys.fuse"; namespace { @@ -592,12 +593,21 @@ binder::Status InstalldNativeService::clearAppData(const std::unique_ptr<std::st std::lock_guard<std::recursive_mutex> lock(mMountsLock); for (const auto& n : mStorageMounts) { auto extPath = n.second; - if (n.first.compare(0, 14, "/mnt/media_rw/") != 0) { - extPath += StringPrintf("/%d", userId); - } else if (userId != 0) { - // TODO: support devices mounted under secondary users - continue; + + if (android::base::GetBoolProperty(kFuseProp, false)) { + std::regex re("^\\/mnt\\/pass_through\\/[0-9]+\\/emulated"); + if (std::regex_match(extPath, re)) { + extPath += "/" + std::to_string(userId); + } + } else { + if (n.first.compare(0, 14, "/mnt/media_rw/") != 0) { + extPath += StringPrintf("/%d", userId); + } else if (userId != 0) { + // TODO: support devices mounted under secondary users + continue; + } } + if (flags & FLAG_CLEAR_CACHE_ONLY) { // Clear only cached data from shared storage auto path = StringPrintf("%s/Android/data/%s/cache", extPath.c_str(), pkgname); @@ -688,16 +698,26 @@ binder::Status InstalldNativeService::destroyAppData(const std::unique_ptr<std:: std::lock_guard<std::recursive_mutex> lock(mMountsLock); for (const auto& n : mStorageMounts) { auto extPath = n.second; - if (n.first.compare(0, 14, "/mnt/media_rw/") != 0) { - extPath += StringPrintf("/%d", userId); - } else if (userId != 0) { - // TODO: support devices mounted under secondary users - continue; + + if (android::base::GetBoolProperty(kFuseProp, false)) { + std::regex re("^\\/mnt\\/pass_through\\/[0-9]+\\/emulated"); + if (std::regex_match(extPath, re)) { + extPath += "/" + std::to_string(userId); + } + } else { + if (n.first.compare(0, 14, "/mnt/media_rw/") != 0) { + extPath += StringPrintf("/%d", userId); + } else if (userId != 0) { + // TODO: support devices mounted under secondary users + continue; + } } + auto path = StringPrintf("%s/Android/data/%s", extPath.c_str(), pkgname); if (delete_dir_contents_and_dir(path, true) != 0) { res = error("Failed to delete contents of " + path); } + path = StringPrintf("%s/Android/media/%s", extPath.c_str(), pkgname); if (delete_dir_contents_and_dir(path, true) != 0) { res = error("Failed to delete contents of " + path); @@ -2778,12 +2798,19 @@ binder::Status InstalldNativeService::invalidateMounts() { std::getline(in, target, ' '); std::getline(in, ignored); + if (android::base::GetBoolProperty(kFuseProp, false)) { + if (target.compare(0, 17, "/mnt/pass_through") == 0) { + LOG(DEBUG) << "Found storage mount " << source << " at " << target; + mStorageMounts[source] = target; + } + } else { #if !BYPASS_SDCARDFS - if (target.compare(0, 21, "/mnt/runtime/default/") == 0) { - LOG(DEBUG) << "Found storage mount " << source << " at " << target; - mStorageMounts[source] = target; - } + if (target.compare(0, 21, "/mnt/runtime/default/") == 0) { + LOG(DEBUG) << "Found storage mount " << source << " at " << target; + mStorageMounts[source] = target; + } #endif + } } return ok(); } |