summaryrefslogtreecommitdiff
path: root/services/usage/java
diff options
context:
space:
mode:
author Daniel Nishi <dhnishi@google.com> 2017-03-30 15:46:01 -0700
committer Daniel Nishi <dhnishi@google.com> 2017-04-06 14:32:13 -0700
commitb28c9d6b2d3b52d7c4ac1ad8c18591be99e92772 (patch)
treefbd5324f1473544d19e938ef39ab8737377c92f8 /services/usage/java
parenteb93670383aa40ad7ed55861e667c08e8a3682a6 (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.java6
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;
}
}