diff options
| author | 2017-05-03 11:38:01 -0600 | |
|---|---|---|
| committer | 2017-05-05 14:58:47 -0600 | |
| commit | fd65813157e4dd7fa9f0b7c5dd4c8f536cc6316a (patch) | |
| tree | 5e475f046b4815f6b8bdb01eb96550d2608113c7 /services/usage/java | |
| parent | e44125cd3a5fc25306285bdfcacc00459e01307b (diff) | |
Offer to wait until broadcasts have drained.
We've seen evidence of lab devices racing with other apps that are
using cache space immediately after tests wipe it clean, which can
cause test failures. To mitigate this, try our best to wait for the
device to go "idle" by watching for broadcast queues to fully drain.
Also improve javadocs along the way.
Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.StorageHostTest
Bug: 37486230, 37566983, 37913442, 37914374
Change-Id: I4d430db443b6fa6d33a625fe07b90279b5d51c12
Diffstat (limited to 'services/usage/java')
| -rw-r--r-- | services/usage/java/com/android/server/usage/StorageStatsService.java | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/services/usage/java/com/android/server/usage/StorageStatsService.java b/services/usage/java/com/android/server/usage/StorageStatsService.java index e13665bed275..935128b1aa36 100644 --- a/services/usage/java/com/android/server/usage/StorageStatsService.java +++ b/services/usage/java/com/android/server/usage/StorageStatsService.java @@ -112,9 +112,12 @@ public class StorageStatsService extends IStorageStatsManager.Stub { mStorage.registerListener(new StorageEventListener() { @Override public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) { - if ((vol.type == VolumeInfo.TYPE_PRIVATE) - && (newState == VolumeInfo.STATE_MOUNTED)) { - invalidateMounts(); + switch (vol.type) { + case VolumeInfo.TYPE_PRIVATE: + case VolumeInfo.TYPE_EMULATED: + if (newState == VolumeInfo.STATE_MOUNTED) { + invalidateMounts(); + } } } }); @@ -178,9 +181,11 @@ public class StorageStatsService extends IStorageStatsManager.Stub { long cacheBytes = 0; final long token = Binder.clearCallingIdentity(); try { - for (UserInfo user : mUser.getUsers()) { - final StorageStats stats = queryStatsForUser(volumeUuid, user.id, null); - cacheBytes += stats.cacheBytes; + if (isQuotaSupported(volumeUuid, callingPackage)) { + for (UserInfo user : mUser.getUsers()) { + final StorageStats stats = queryStatsForUser(volumeUuid, user.id, null); + cacheBytes += stats.cacheBytes; + } } } finally { Binder.restoreCallingIdentity(token); |