diff options
| author | 2017-03-30 15:46:01 -0700 | |
|---|---|---|
| committer | 2017-04-06 14:32:13 -0700 | |
| commit | b28c9d6b2d3b52d7c4ac1ad8c18591be99e92772 (patch) | |
| tree | fbd5324f1473544d19e938ef39ab8737377c92f8 /services/usage/java | |
| parent | eb93670383aa40ad7ed55861e667c08e8a3682a6 (diff) | |
Fix crash when measuring storage.
If we are measuring storage and a volume is removed at the same time,
we can enter a state where we previously verified the volume existed,
but it no longer does. This causes an NPE.
By adding in a null check, we can avoid this crash.
Change-Id: Ib8dbf05102a122bdf4bb6063374e993a1de68425
Fixes: 36689190
Test: None
Diffstat (limited to 'services/usage/java')
| -rw-r--r-- | services/usage/java/com/android/server/usage/StorageStatsService.java | 6 |
1 files changed, 6 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 3f39e4f3cf4b..5ad7f8042c01 100644 --- a/services/usage/java/com/android/server/usage/StorageStatsService.java +++ b/services/usage/java/com/android/server/usage/StorageStatsService.java @@ -162,6 +162,9 @@ public class StorageStatsService extends IStorageStatsManager.Stub { return FileUtils.roundStorageSize(mStorage.getPrimaryStorageSize()); } else { final VolumeInfo vol = mStorage.findVolumeByUuid(volumeUuid); + if (vol == null) { + throw new IllegalStateException("Volume was unexpected null"); + } return FileUtils.roundStorageSize(vol.disk.size); } } @@ -185,6 +188,9 @@ public class StorageStatsService extends IStorageStatsManager.Stub { return Environment.getDataDirectory().getUsableSpace() + cacheBytes; } else { final VolumeInfo vol = mStorage.findVolumeByUuid(volumeUuid); + if (vol == null) { + throw new IllegalStateException("Volume was unexpected null"); + } return vol.getPath().getUsableSpace() + cacheBytes; } } |