OSDN Git Service

Handle public volumes and otherwise invalid UUIDs.
authorJeff Sharkey <jsharkey@android.com>
Thu, 29 Mar 2018 20:29:27 +0000 (14:29 -0600)
committerJeff Sharkey <jsharkey@android.com>
Thu, 29 Mar 2018 20:29:29 +0000 (14:29 -0600)
Public volumes have short UUIDs (which aren't valid 128-bit UUIDs),
so we can't pass them around.  Even if they were valid UUIDs, we
don't handle clearing cached data on them, and they most likely
don't support fallocate(), so don't match them.

Test: manual
Bug: 74132243
Change-Id: Ib855eb869a86392e96ced94a9926c0b32b87e57e

core/java/android/os/storage/StorageManager.java

index bf20e6a..8905ad1 100644 (file)
@@ -756,10 +756,15 @@ public class StorageManager {
         }
         try {
             for (VolumeInfo vol : mStorageManager.getVolumes(0)) {
-                if (vol.path != null && FileUtils.contains(vol.path, pathString)) {
+                if (vol.path != null && FileUtils.contains(vol.path, pathString)
+                        && vol.type != VolumeInfo.TYPE_PUBLIC) {
                     // TODO: verify that emulated adopted devices have UUID of
                     // underlying volume
-                    return convert(vol.fsUuid);
+                    try {
+                        return convert(vol.fsUuid);
+                    } catch (IllegalArgumentException e) {
+                        continue;
+                    }
                 }
             }
         } catch (RemoteException e) {