diff options
| author | 2017-01-23 20:37:05 -0700 | |
|---|---|---|
| committer | 2017-01-23 21:02:12 -0700 | |
| commit | 9bed070b0910aad8c5800cec731058911d20c3d3 (patch) | |
| tree | 5d81d0fb19d0a68e797176448e41cb6c29a21615 /services/usage/java | |
| parent | dbb1176b4957857287801bbceef079a6562a3cdf (diff) | |
More APIs for cache status and behavior.
Add APIs for apps to query their cache usage compared to their
currently allocated quota. Since an app's private storage may live
on a different storage volume than the primary shared/external
storage, offer APIs to retrieve those values separately.
Add APIs to control two new cache purging behaviors:
-- setCacheBehaviorAtomic() which causes a marked directory and its
contents to be treated as an atomic unit.
-- setCacheBehaviorTombstone() which causes the OS to truncate
files instead of deleting them.
Test: builds, boots
Bug: 33811826, 33965858, 27948817
Change-Id: I45de165623775c359f78b4ee544c2b5831b8d483
Diffstat (limited to 'services/usage/java')
| -rw-r--r-- | services/usage/java/com/android/server/usage/StorageStatsService.java | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/services/usage/java/com/android/server/usage/StorageStatsService.java b/services/usage/java/com/android/server/usage/StorageStatsService.java index 68765b643c66..68269751efc1 100644 --- a/services/usage/java/com/android/server/usage/StorageStatsService.java +++ b/services/usage/java/com/android/server/usage/StorageStatsService.java @@ -37,6 +37,7 @@ import android.os.storage.VolumeInfo; import android.util.Slog; import com.android.internal.util.ArrayUtils; +import com.android.internal.util.Preconditions; import com.android.server.SystemService; import com.android.server.pm.Installer; import com.android.server.pm.Installer.InstallerException; @@ -46,8 +47,6 @@ public class StorageStatsService extends IStorageStatsManager.Stub { private static final String PROP_VERIFY_STORAGE = "fw.verify_storage"; - // TODO: pivot all methods to manual mode when quota isn't supported - public static class Lifecycle extends SystemService { private StorageStatsService mService; @@ -71,11 +70,11 @@ public class StorageStatsService extends IStorageStatsManager.Stub { private final Installer mInstaller; public StorageStatsService(Context context) { - mContext = context; - mAppOps = context.getSystemService(AppOpsManager.class); - mUser = context.getSystemService(UserManager.class); - mPackage = context.getSystemService(PackageManager.class); - mStorage = context.getSystemService(StorageManager.class); + mContext = Preconditions.checkNotNull(context); + mAppOps = Preconditions.checkNotNull(context.getSystemService(AppOpsManager.class)); + mUser = Preconditions.checkNotNull(context.getSystemService(UserManager.class)); + mPackage = Preconditions.checkNotNull(context.getPackageManager()); + mStorage = Preconditions.checkNotNull(context.getSystemService(StorageManager.class)); mInstaller = new Installer(context); mInstaller.onStart(); @@ -107,7 +106,7 @@ public class StorageStatsService extends IStorageStatsManager.Stub { case AppOpsManager.MODE_ALLOWED: return; case AppOpsManager.MODE_DEFAULT: - mContext.enforceCallingPermission( + mContext.enforceCallingOrSelfPermission( android.Manifest.permission.PACKAGE_USAGE_STATS, TAG); return; default: |