From 1b981a3aea4e5011f070108ed0f307f134e22cb9 Mon Sep 17 00:00:00 2001 From: Martijn Coenen Date: Mon, 20 Apr 2020 15:08:36 +0200 Subject: [PATCH] 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 --- core/java/android/os/storage/StorageManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java index aee32ed769acd..a1a11ed54609d 100644 --- a/core/java/android/os/storage/StorageManager.java +++ b/core/java/android/os/storage/StorageManager.java @@ -2447,7 +2447,12 @@ public class StorageManager { 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();