From 34b437b3019663e752f4be884b8827ecc1346935 Mon Sep 17 00:00:00 2001 From: Sudheer Shanka Date: Thu, 17 Jan 2019 17:20:47 -0800 Subject: [PATCH] Use "sys.isolated_storage_snapshot" prop to check for the feature. StorageManager.hasIsolatedStorage() has already been updated to use this, so most callers are already using this sys prop. Now, updating remaining callers to use it as well. Bug: 122559151 Test: manual Change-Id: I6982a84b737a1d329f397b8182b7b7cdc5a8897f --- VolumeManager.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/VolumeManager.cpp b/VolumeManager.cpp index d113cf9..32747d4 100644 --- a/VolumeManager.cpp +++ b/VolumeManager.cpp @@ -79,6 +79,7 @@ static const char* kPathUserMount = "/mnt/user"; static const char* kPathVirtualDisk = "/data/misc/vold/virtual_disk"; static const char* kIsolatedStorage = "persist.sys.isolated_storage"; +static const char* kIsolatedStorageSnapshot = "sys.isolated_storage_snapshot"; static const char* kPropVirtualDisk = "persist.sys.virtual_disk"; static const std::string kEmptyString(""); @@ -108,6 +109,10 @@ VolumeManager::VolumeManager() { VolumeManager::~VolumeManager() {} +static bool hasIsolatedStorage() { + return GetBoolProperty(kIsolatedStorageSnapshot, GetBoolProperty(kIsolatedStorage, false)); +} + int VolumeManager::updateVirtualDisk() { ATRACE_NAME("VolumeManager::updateVirtualDisk"); if (GetBoolProperty(kPropVirtualDisk, false)) { @@ -843,7 +848,7 @@ int VolumeManager::onUserStarted(userid_t userId, const std::vector if (mPrimary) { linkPrimary(userId); } - if (GetBoolProperty(kIsolatedStorage, false)) { + if (hasIsolatedStorage()) { std::vector visibleVolLabels; for (auto& volId : mVisibleVolumeIds) { auto vol = findVolume(volId); @@ -863,7 +868,7 @@ int VolumeManager::onUserStopped(userid_t userId) { LOG(VERBOSE) << "onUserStopped: " << userId; mStartedUsers.erase(userId); - if (GetBoolProperty(kIsolatedStorage, false)) { + if (hasIsolatedStorage()) { mUserPackages.erase(userId); std::string mntTargetDir = StringPrintf("/mnt/user/%d", userId); if (android::vold::UnmountTree(mntTargetDir) != 0) { @@ -897,7 +902,7 @@ int VolumeManager::addSandboxIds(const std::vector& appIds, int VolumeManager::prepareSandboxForApp(const std::string& packageName, appid_t appId, const std::string& sandboxId, userid_t userId) { - if (!GetBoolProperty(kIsolatedStorage, false)) { + if (!hasIsolatedStorage()) { return 0; } else if (mStartedUsers.find(userId) == mStartedUsers.end()) { // User not started, no need to do anything now. Required bind mounts for the package will @@ -923,7 +928,7 @@ int VolumeManager::prepareSandboxForApp(const std::string& packageName, appid_t int VolumeManager::destroySandboxForApp(const std::string& packageName, const std::string& sandboxId, userid_t userId) { - if (!GetBoolProperty(kIsolatedStorage, false)) { + if (!hasIsolatedStorage()) { return 0; } LOG(VERBOSE) << "destroySandboxForApp: " << packageName << ", sandboxId=" << sandboxId @@ -1001,7 +1006,7 @@ int VolumeManager::onSecureKeyguardStateChanged(bool isShowing) { } int VolumeManager::onVolumeMounted(android::vold::VolumeBase* vol) { - if (!GetBoolProperty(kIsolatedStorage, false)) { + if (!hasIsolatedStorage()) { return 0; } @@ -1036,7 +1041,7 @@ int VolumeManager::onVolumeMounted(android::vold::VolumeBase* vol) { } int VolumeManager::onVolumeUnmounted(android::vold::VolumeBase* vol) { - if (!GetBoolProperty(kIsolatedStorage, false)) { + if (!hasIsolatedStorage()) { return 0; } @@ -1084,7 +1089,7 @@ int VolumeManager::destroySandboxesForVol(android::vold::VolumeBase* vol, userid } int VolumeManager::setPrimary(const std::shared_ptr& vol) { - if (GetBoolProperty(kIsolatedStorage, false)) { + if (hasIsolatedStorage()) { return 0; } mPrimary = vol; @@ -1095,7 +1100,7 @@ int VolumeManager::setPrimary(const std::shared_ptr& } int VolumeManager::remountUid(uid_t uid, int32_t mountMode) { - if (!GetBoolProperty(kIsolatedStorage, false)) { + if (!hasIsolatedStorage()) { return remountUidLegacy(uid, mountMode); }