From 5cc0df214bbe2b169150c9060dc5288bb8aaf338 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Wed, 17 Jun 2015 19:44:05 -0700 Subject: Forget private partition keys. When we forget a private partition, ask vold to also forget the key for that partition GUID. This means we need to track both the filesystem UUID and the partition GUID for a private volume. Bug: 21782268 Change-Id: Icda1cbb65539d61dacc663428daf3d1a2e4c313e --- core/java/android/os/storage/VolumeInfo.java | 7 ++++++- core/java/android/os/storage/VolumeRecord.java | 5 +++++ core/java/android/text/TextUtils.java | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'core/java') diff --git a/core/java/android/os/storage/VolumeInfo.java b/core/java/android/os/storage/VolumeInfo.java index 8d11527..e33baa9 100644 --- a/core/java/android/os/storage/VolumeInfo.java +++ b/core/java/android/os/storage/VolumeInfo.java @@ -137,6 +137,7 @@ public class VolumeInfo implements Parcelable { public final String id; public final int type; public final DiskInfo disk; + public final String partGuid; public int mountFlags = 0; public int mountUserId = -1; public int state = STATE_UNMOUNTED; @@ -149,10 +150,11 @@ public class VolumeInfo implements Parcelable { /** Framework state */ public final int mtpIndex; - public VolumeInfo(String id, int type, DiskInfo disk, int mtpIndex) { + public VolumeInfo(String id, int type, DiskInfo disk, String partGuid, int mtpIndex) { this.id = Preconditions.checkNotNull(id); this.type = type; this.disk = disk; + this.partGuid = partGuid; this.mtpIndex = mtpIndex; } @@ -164,6 +166,7 @@ public class VolumeInfo implements Parcelable { } else { disk = null; } + partGuid = parcel.readString(); mountFlags = parcel.readInt(); mountUserId = parcel.readInt(); state = parcel.readInt(); @@ -385,6 +388,7 @@ public class VolumeInfo implements Parcelable { pw.increaseIndent(); pw.printPair("type", DebugUtils.valueToString(getClass(), "TYPE_", type)); pw.printPair("diskId", getDiskId()); + pw.printPair("partGuid", partGuid); pw.printPair("mountFlags", DebugUtils.flagsToString(getClass(), "MOUNT_FLAG_", mountFlags)); pw.printPair("mountUserId", mountUserId); pw.printPair("state", DebugUtils.valueToString(getClass(), "STATE_", state)); @@ -453,6 +457,7 @@ public class VolumeInfo implements Parcelable { } else { parcel.writeInt(0); } + parcel.writeString(partGuid); parcel.writeInt(mountFlags); parcel.writeInt(mountUserId); parcel.writeInt(state); diff --git a/core/java/android/os/storage/VolumeRecord.java b/core/java/android/os/storage/VolumeRecord.java index 096e2dd..cb16305 100644 --- a/core/java/android/os/storage/VolumeRecord.java +++ b/core/java/android/os/storage/VolumeRecord.java @@ -39,6 +39,7 @@ public class VolumeRecord implements Parcelable { public final int type; public final String fsUuid; + public String partGuid; public String nickname; public int userFlags; @@ -50,6 +51,7 @@ public class VolumeRecord implements Parcelable { public VolumeRecord(Parcel parcel) { type = parcel.readInt(); fsUuid = parcel.readString(); + partGuid = parcel.readString(); nickname = parcel.readString(); userFlags = parcel.readInt(); } @@ -79,6 +81,8 @@ public class VolumeRecord implements Parcelable { pw.increaseIndent(); pw.printPair("type", DebugUtils.valueToString(VolumeInfo.class, "TYPE_", type)); pw.printPair("fsUuid", fsUuid); + pw.printPair("partGuid", partGuid); + pw.println(); pw.printPair("nickname", nickname); pw.printPair("userFlags", DebugUtils.flagsToString(VolumeRecord.class, "USER_FLAG_", userFlags)); @@ -133,6 +137,7 @@ public class VolumeRecord implements Parcelable { public void writeToParcel(Parcel parcel, int flags) { parcel.writeInt(type); parcel.writeString(fsUuid); + parcel.writeString(partGuid); parcel.writeString(nickname); parcel.writeInt(userFlags); } diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java index d51aa79..d8f7158 100644 --- a/core/java/android/text/TextUtils.java +++ b/core/java/android/text/TextUtils.java @@ -465,6 +465,11 @@ public class TextUtils { return false; } + /** {@hide} */ + public static String nullIfEmpty(@Nullable String str) { + return isEmpty(str) ? null : str; + } + /** * Returns the length that the specified CharSequence would have if * spaces and control characters were trimmed from the start and end, -- cgit v1.1