summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2021-12-03 00:15:50 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-12-03 00:15:50 +0000
commit45450c2bf209d15b9dd4897e77cd73dffaeaf00a (patch)
tree849301281c7ad4956500585c006e7c0f25f98686 /core/java
parent0f642cfedfe5d4f9873974cf7d838e4c8d9b0f58 (diff)
parent3632fde8513b42fb277496281926e5e517f1d160 (diff)
Merge "Expose StorageVolume.isStub() as @SystemApi API"
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/os/storage/StorageVolume.java23
-rw-r--r--core/java/android/os/storage/VolumeInfo.java5
-rw-r--r--core/java/android/os/storage/VolumeRecord.java4
3 files changed, 26 insertions, 6 deletions
diff --git a/core/java/android/os/storage/StorageVolume.java b/core/java/android/os/storage/StorageVolume.java
index 2adcbc318614..0c2f8b639092 100644
--- a/core/java/android/os/storage/StorageVolume.java
+++ b/core/java/android/os/storage/StorageVolume.java
@@ -99,6 +99,7 @@ public final class StorageVolume implements Parcelable {
@UnsupportedAppUsage
private final boolean mRemovable;
private final boolean mEmulated;
+ private final boolean mStub;
private final boolean mAllowMassStorage;
private final long mMaxFileSize;
private final UserHandle mOwner;
@@ -137,8 +138,9 @@ public final class StorageVolume implements Parcelable {
/** {@hide} */
public StorageVolume(String id, File path, File internalPath, String description,
- boolean primary, boolean removable, boolean emulated, boolean allowMassStorage,
- long maxFileSize, UserHandle owner, UUID uuid, String fsUuid, String state) {
+ boolean primary, boolean removable, boolean emulated, boolean stub,
+ boolean allowMassStorage, long maxFileSize, UserHandle owner, UUID uuid, String fsUuid,
+ String state) {
mId = Preconditions.checkNotNull(id);
mPath = Preconditions.checkNotNull(path);
mInternalPath = Preconditions.checkNotNull(internalPath);
@@ -146,6 +148,7 @@ public final class StorageVolume implements Parcelable {
mPrimary = primary;
mRemovable = removable;
mEmulated = emulated;
+ mStub = stub;
mAllowMassStorage = allowMassStorage;
mMaxFileSize = maxFileSize;
mOwner = Preconditions.checkNotNull(owner);
@@ -162,6 +165,7 @@ public final class StorageVolume implements Parcelable {
mPrimary = in.readInt() != 0;
mRemovable = in.readInt() != 0;
mEmulated = in.readInt() != 0;
+ mStub = in.readInt() != 0;
mAllowMassStorage = in.readInt() != 0;
mMaxFileSize = in.readLong();
mOwner = in.readParcelable(null);
@@ -264,13 +268,23 @@ public final class StorageVolume implements Parcelable {
/**
* Returns true if the volume is emulated.
*
- * @return is removable
+ * @return is emulated
*/
public boolean isEmulated() {
return mEmulated;
}
/**
+ * Returns true if the volume is a stub volume (a volume managed from outside Android).
+ *
+ * @hide
+ */
+ @SystemApi
+ public boolean isStub() {
+ return mStub;
+ }
+
+ /**
* Returns true if this volume can be shared via USB mass storage.
*
* @return whether mass storage is allowed
@@ -506,6 +520,7 @@ public final class StorageVolume implements Parcelable {
pw.printPair("mPrimary", mPrimary);
pw.printPair("mRemovable", mRemovable);
pw.printPair("mEmulated", mEmulated);
+ pw.printPair("mStub", mStub);
pw.printPair("mAllowMassStorage", mAllowMassStorage);
pw.printPair("mMaxFileSize", mMaxFileSize);
pw.printPair("mOwner", mOwner);
@@ -540,6 +555,7 @@ public final class StorageVolume implements Parcelable {
parcel.writeInt(mPrimary ? 1 : 0);
parcel.writeInt(mRemovable ? 1 : 0);
parcel.writeInt(mEmulated ? 1 : 0);
+ parcel.writeInt(mStub ? 1 : 0);
parcel.writeInt(mAllowMassStorage ? 1 : 0);
parcel.writeLong(mMaxFileSize);
parcel.writeParcelable(mOwner, flags);
@@ -621,6 +637,7 @@ public final class StorageVolume implements Parcelable {
mPrimary,
mRemovable,
mEmulated,
+ /* stub= */ false,
/* allowMassStorage= */ false,
/* maxFileSize= */ 0,
mOwner,
diff --git a/core/java/android/os/storage/VolumeInfo.java b/core/java/android/os/storage/VolumeInfo.java
index 39a2e1353237..ebd143c33990 100644
--- a/core/java/android/os/storage/VolumeInfo.java
+++ b/core/java/android/os/storage/VolumeInfo.java
@@ -404,6 +404,7 @@ public class VolumeInfo implements Parcelable {
final boolean removable;
final boolean emulated;
+ final boolean stub = type == TYPE_STUB;
final boolean allowMassStorage = false;
final String envState = reportUnmounted
? Environment.MEDIA_UNMOUNTED : getEnvironmentForState(state);
@@ -459,8 +460,8 @@ public class VolumeInfo implements Parcelable {
}
return new StorageVolume(id, userPath, internalPath, description, isPrimary(), removable,
- emulated, allowMassStorage, maxFileSize, new UserHandle(userId),
- uuid, derivedFsUuid, envState);
+ emulated, stub, allowMassStorage, maxFileSize, new UserHandle(userId), uuid,
+ derivedFsUuid, envState);
}
@UnsupportedAppUsage
diff --git a/core/java/android/os/storage/VolumeRecord.java b/core/java/android/os/storage/VolumeRecord.java
index 1cc982e7dbb5..eac09aab46cd 100644
--- a/core/java/android/os/storage/VolumeRecord.java
+++ b/core/java/android/os/storage/VolumeRecord.java
@@ -105,6 +105,7 @@ public class VolumeRecord implements Parcelable {
final boolean primary = false;
final boolean removable = true;
final boolean emulated = false;
+ final boolean stub = false;
final boolean allowMassStorage = false;
final long maxFileSize = 0;
final UserHandle user = new UserHandle(UserHandle.USER_NULL);
@@ -116,7 +117,8 @@ public class VolumeRecord implements Parcelable {
}
return new StorageVolume(id, userPath, internalPath, description, primary, removable,
- emulated, allowMassStorage, maxFileSize, user, null /* uuid */, fsUuid, envState);
+ emulated, stub, allowMassStorage, maxFileSize, user, null /* uuid */, fsUuid,
+ envState);
}
public void dump(IndentingPrintWriter pw) {