Storage API polishing.
Based on API council feedback, switch to using real UUID objects
instead of Strings. Since UUID is a general-purpose utility class
that will be passed around quite a bit, add it to Parcel and Bundle.
Define well-known namespaced UUID values for "default" and "primary
physical" storage devices, which will let us annotate a bunch of
things with @NonNull.
Define new extras for MANAGE_STORAGE intent that apps can use to
signal where and how much space they'd like the user to free up.
Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.StorageHostTest
Bug: 37325923, 35812899, 35806020
Change-Id: I8421b126d680f69141a361c1e77223fe2bf4a325
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index 5f53e27..8b2809a 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -29,6 +29,7 @@
import android.os.Parcel;
import android.os.Parcelable;
import android.os.UserHandle;
+import android.os.storage.StorageManager;
import android.text.TextUtils;
import android.util.Printer;
import android.util.SparseArray;
@@ -41,6 +42,7 @@
import java.util.Arrays;
import java.util.Comparator;
import java.util.Objects;
+import java.util.UUID;
/**
* Information you can retrieve about a particular application. This
@@ -621,12 +623,17 @@
*/
public float maxAspectRatio;
+ /** @removed */
+ @Deprecated
+ public String volumeUuid;
+
/**
* UUID of the storage volume on which this application is being hosted. For
* apps hosted on the default internal storage at
- * {@link Environment#getDataDirectory()}, the UUID value is {@code null}.
+ * {@link Environment#getDataDirectory()}, the UUID value is
+ * {@link StorageManager#UUID_DEFAULT}.
*/
- public String volumeUuid;
+ public UUID storageUuid;
/** {@hide} */
public String scanSourceDir;
@@ -1134,6 +1141,7 @@
compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
largestWidthLimitDp = orig.largestWidthLimitDp;
volumeUuid = orig.volumeUuid;
+ storageUuid = orig.storageUuid;
scanSourceDir = orig.scanSourceDir;
scanPublicSourceDir = orig.scanPublicSourceDir;
sourceDir = orig.sourceDir;
@@ -1195,7 +1203,7 @@
dest.writeInt(requiresSmallestWidthDp);
dest.writeInt(compatibleWidthLimitDp);
dest.writeInt(largestWidthLimitDp);
- dest.writeString(volumeUuid);
+ dest.writeUuid(storageUuid);
dest.writeString(scanSourceDir);
dest.writeString(scanPublicSourceDir);
dest.writeString(sourceDir);
@@ -1257,7 +1265,8 @@
requiresSmallestWidthDp = source.readInt();
compatibleWidthLimitDp = source.readInt();
largestWidthLimitDp = source.readInt();
- volumeUuid = source.readString();
+ storageUuid = source.readUuid();
+ volumeUuid = StorageManager.convert(storageUuid);
scanSourceDir = source.readString();
scanPublicSourceDir = source.readString();
sourceDir = source.readString();