Don't update quota for non-emulated volumes.
Since they don't support quota. Also, don't throw an exception if we
can't find a volume for the passed-in path, but warn instead: the volume
may be unstable and have disappeared by the time we do this.
Bug: 152618535
Test: boot emulated image; verify no crashes when inserting media on
public storage
Change-Id: I0e6b8f5c9f9f35b80b7bd5f6255a70e210a30474
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java
index aee32ed..a1a11ed 100644
--- a/core/java/android/os/storage/StorageManager.java
+++ b/core/java/android/os/storage/StorageManager.java
@@ -2447,7 +2447,12 @@
final String filePath = path.getCanonicalPath();
final StorageVolume volume = getStorageVolume(path);
if (volume == null) {
- throw new IllegalStateException("Failed to update quota type for " + filePath);
+ Log.w(TAG, "Failed to update quota type for " + filePath);
+ return;
+ }
+ if (!volume.isEmulated()) {
+ // We only support quota tracking on emulated filesystems
+ return;
}
final int userId = volume.getOwner().getIdentifier();