diff options
author | Felka Chang <felkachang@google.com> | 2020-02-12 13:29:58 +0800 |
---|---|---|
committer | Felka Chang <felkachang@google.com> | 2020-02-12 17:15:26 +0800 |
commit | 1980c9a8939ed7f3332048fcd6bade03719f829f (patch) | |
tree | dc38448968337b5aefa04c25f0684c6aeb119fcb /services/usage | |
parent | 8869427bbbd672eb0b131962ca48576e3f959549 (diff) |
Disable storage crates functionalities
The Storage Crates functionalities is disabled by default. In order to
make the android system more secure, the crate function should throw
exception to tell the caller that the crate function is disabled until
it addes more tests such as benchmark and memory regression tests.
Bug: 148179319
Fixes: 149366046
Test: atest \
CtsOsTestCases:android.os.storage.cts.StorageCrateTest \
CtsOsTestCases:android.os.storage.cts.StorageStatsManagerTest \
CtsOsTestCases:android.os.storage.cts.CrateInfoTest
Test: adb root ;\
adb shell setprop fw.storage_crates 1 ;\
atest \
CtsOsTestCases:android.os.storage.cts.StorageCrateTest \
CtsOsTestCases:android.os.storage.cts.StorageStatsManagerTest \
CtsOsTestCases:android.os.storage.cts.CrateInfoTest
Change-Id: I7bfbdcbde5a90ecad7ef690a9d9a62e5ed0ad5eb
Diffstat (limited to 'services/usage')
-rw-r--r-- | services/usage/java/com/android/server/usage/StorageStatsService.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/services/usage/java/com/android/server/usage/StorageStatsService.java b/services/usage/java/com/android/server/usage/StorageStatsService.java index 18b640ff6bf5..c3d3d83f02fa 100644 --- a/services/usage/java/com/android/server/usage/StorageStatsService.java +++ b/services/usage/java/com/android/server/usage/StorageStatsService.java @@ -86,6 +86,7 @@ import java.util.function.Consumer; public class StorageStatsService extends IStorageStatsManager.Stub { private static final String TAG = "StorageStatsService"; + private static final String PROP_STORAGE_CRATES = "fw.storage_crates"; private static final String PROP_DISABLE_QUOTA = "fw.disable_quota"; private static final String PROP_VERIFY_STORAGE = "fw.verify_storage"; @@ -595,6 +596,13 @@ public class StorageStatsService extends IStorageStatsManager.Stub { Uri.parse("content://com.android.externalstorage.documents/"), null, false); } + private static void checkCratesEnable() { + final boolean enable = SystemProperties.getBoolean(PROP_STORAGE_CRATES, false); + if (!enable) { + throw new IllegalStateException("Storage Crate feature is disabled."); + } + } + /** * To enforce the calling or self to have the {@link android.Manifest.permission#MANAGE_CRATES} * permission. @@ -650,6 +658,7 @@ public class StorageStatsService extends IStorageStatsManager.Stub { @Override public ParceledListSlice<CrateInfo> queryCratesForPackage(String volumeUuid, @NonNull String packageName, @UserIdInt int userId, @NonNull String callingPackage) { + checkCratesEnable(); if (userId != UserHandle.getCallingUserId()) { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.INTERACT_ACROSS_USERS, TAG); @@ -677,6 +686,7 @@ public class StorageStatsService extends IStorageStatsManager.Stub { @Override public ParceledListSlice<CrateInfo> queryCratesForUid(String volumeUuid, int uid, @NonNull String callingPackage) { + checkCratesEnable(); final int userId = UserHandle.getUserId(uid); if (userId != UserHandle.getCallingUserId()) { mContext.enforceCallingOrSelfPermission( @@ -718,6 +728,7 @@ public class StorageStatsService extends IStorageStatsManager.Stub { @Override public ParceledListSlice<CrateInfo> queryCratesForUser(String volumeUuid, int userId, @NonNull String callingPackage) { + checkCratesEnable(); if (userId != UserHandle.getCallingUserId()) { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.INTERACT_ACROSS_USERS, TAG); |