Include primary flag in StorageVolume.
Bug: 7003520 Change-Id: Iaae2ae22253820c954c51e0199c31087bc825f3f
This commit is contained in:
@@ -26,16 +26,16 @@ import android.os.Parcelable;
|
|||||||
*/
|
*/
|
||||||
public class StorageVolume implements Parcelable {
|
public class StorageVolume implements Parcelable {
|
||||||
|
|
||||||
//private static final String TAG = "StorageVolume";
|
private int mStorageId;
|
||||||
|
|
||||||
private final String mPath;
|
private final String mPath;
|
||||||
private final int mDescriptionId;
|
private final int mDescriptionId;
|
||||||
|
private final boolean mPrimary;
|
||||||
private final boolean mRemovable;
|
private final boolean mRemovable;
|
||||||
private final boolean mEmulated;
|
private final boolean mEmulated;
|
||||||
private final int mMtpReserveSpace;
|
private final int mMtpReserveSpace;
|
||||||
private final boolean mAllowMassStorage;
|
private final boolean mAllowMassStorage;
|
||||||
private int mStorageId;
|
/** Maximum file size for the storage, or zero for no limit */
|
||||||
// maximum file size for the storage, or zero for no limit
|
|
||||||
private final long mMaxFileSize;
|
private final long mMaxFileSize;
|
||||||
|
|
||||||
// StorageVolume extra for ACTION_MEDIA_REMOVED, ACTION_MEDIA_UNMOUNTED, ACTION_MEDIA_CHECKING,
|
// StorageVolume extra for ACTION_MEDIA_REMOVED, ACTION_MEDIA_UNMOUNTED, ACTION_MEDIA_CHECKING,
|
||||||
@@ -43,10 +43,11 @@ public class StorageVolume implements Parcelable {
|
|||||||
// ACTION_MEDIA_BAD_REMOVAL, ACTION_MEDIA_UNMOUNTABLE and ACTION_MEDIA_EJECT broadcasts.
|
// ACTION_MEDIA_BAD_REMOVAL, ACTION_MEDIA_UNMOUNTABLE and ACTION_MEDIA_EJECT broadcasts.
|
||||||
public static final String EXTRA_STORAGE_VOLUME = "storage_volume";
|
public static final String EXTRA_STORAGE_VOLUME = "storage_volume";
|
||||||
|
|
||||||
public StorageVolume(String path, int descriptionId, boolean removable,
|
public StorageVolume(String path, int descriptionId, boolean primary, boolean removable,
|
||||||
boolean emulated, int mtpReserveSpace, boolean allowMassStorage, long maxFileSize) {
|
boolean emulated, int mtpReserveSpace, boolean allowMassStorage, long maxFileSize) {
|
||||||
mPath = path;
|
mPath = path;
|
||||||
mDescriptionId = descriptionId;
|
mDescriptionId = descriptionId;
|
||||||
|
mPrimary = primary;
|
||||||
mRemovable = removable;
|
mRemovable = removable;
|
||||||
mEmulated = emulated;
|
mEmulated = emulated;
|
||||||
mMtpReserveSpace = mtpReserveSpace;
|
mMtpReserveSpace = mtpReserveSpace;
|
||||||
@@ -54,18 +55,16 @@ public class StorageVolume implements Parcelable {
|
|||||||
mMaxFileSize = maxFileSize;
|
mMaxFileSize = maxFileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for parcelling only
|
private StorageVolume(Parcel in) {
|
||||||
private StorageVolume(String path, int descriptionId, boolean removable,
|
mStorageId = in.readInt();
|
||||||
boolean emulated, int mtpReserveSpace, int storageId,
|
mPath = in.readString();
|
||||||
boolean allowMassStorage, long maxFileSize) {
|
mDescriptionId = in.readInt();
|
||||||
mPath = path;
|
mPrimary = in.readByte() != 0;
|
||||||
mDescriptionId = descriptionId;
|
mRemovable = in.readByte() != 0;
|
||||||
mRemovable = removable;
|
mEmulated = in.readByte() != 0;
|
||||||
mEmulated = emulated;
|
mMtpReserveSpace = in.readInt();
|
||||||
mMtpReserveSpace = mtpReserveSpace;
|
mAllowMassStorage = in.readByte() != 0;
|
||||||
mAllowMassStorage = allowMassStorage;
|
mMaxFileSize = in.readLong();
|
||||||
mStorageId = storageId;
|
|
||||||
mMaxFileSize = maxFileSize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,6 +89,10 @@ public class StorageVolume implements Parcelable {
|
|||||||
return mDescriptionId;
|
return mDescriptionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPrimary() {
|
||||||
|
return mPrimary;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the volume is removable.
|
* Returns true if the volume is removable.
|
||||||
*
|
*
|
||||||
@@ -183,37 +186,31 @@ public class StorageVolume implements Parcelable {
|
|||||||
+ mRemovable + ", mStorageId=" + mStorageId + "]";
|
+ mRemovable + ", mStorageId=" + mStorageId + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Parcelable.Creator<StorageVolume> CREATOR =
|
public static final Creator<StorageVolume> CREATOR = new Creator<StorageVolume>() {
|
||||||
new Parcelable.Creator<StorageVolume>() {
|
@Override
|
||||||
public StorageVolume createFromParcel(Parcel in) {
|
public StorageVolume createFromParcel(Parcel in) {
|
||||||
String path = in.readString();
|
return new StorageVolume(in);
|
||||||
int descriptionId = in.readInt();
|
|
||||||
int removable = in.readInt();
|
|
||||||
int emulated = in.readInt();
|
|
||||||
int storageId = in.readInt();
|
|
||||||
int mtpReserveSpace = in.readInt();
|
|
||||||
int allowMassStorage = in.readInt();
|
|
||||||
long maxFileSize = in.readLong();
|
|
||||||
return new StorageVolume(path, descriptionId,
|
|
||||||
removable == 1, emulated == 1, mtpReserveSpace,
|
|
||||||
storageId, allowMassStorage == 1, maxFileSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public StorageVolume[] newArray(int size) {
|
public StorageVolume[] newArray(int size) {
|
||||||
return new StorageVolume[size];
|
return new StorageVolume[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void writeToParcel(Parcel parcel, int flags) {
|
public void writeToParcel(Parcel parcel, int flags) {
|
||||||
|
parcel.writeInt(mStorageId);
|
||||||
parcel.writeString(mPath);
|
parcel.writeString(mPath);
|
||||||
parcel.writeInt(mDescriptionId);
|
parcel.writeInt(mDescriptionId);
|
||||||
|
parcel.writeInt(mPrimary ? 1 : 0);
|
||||||
parcel.writeInt(mRemovable ? 1 : 0);
|
parcel.writeInt(mRemovable ? 1 : 0);
|
||||||
parcel.writeInt(mEmulated ? 1 : 0);
|
parcel.writeInt(mEmulated ? 1 : 0);
|
||||||
parcel.writeInt(mStorageId);
|
|
||||||
parcel.writeInt(mMtpReserveSpace);
|
parcel.writeInt(mMtpReserveSpace);
|
||||||
parcel.writeInt(mAllowMassStorage ? 1 : 0);
|
parcel.writeInt(mAllowMassStorage ? 1 : 0);
|
||||||
parcel.writeLong(mMaxFileSize);
|
parcel.writeLong(mMaxFileSize);
|
||||||
|
|||||||
@@ -1114,9 +1114,8 @@ class MountService extends IMountService.Stub
|
|||||||
Slog.e(TAG, "path or description is null in readStorageList");
|
Slog.e(TAG, "path or description is null in readStorageList");
|
||||||
} else {
|
} else {
|
||||||
String pathString = path.toString();
|
String pathString = path.toString();
|
||||||
StorageVolume volume = new StorageVolume(pathString,
|
StorageVolume volume = new StorageVolume(pathString, descriptionId, primary,
|
||||||
descriptionId, removable, emulated,
|
removable, emulated, mtpReserve, allowMassStorage, maxFileSize);
|
||||||
mtpReserve, allowMassStorage, maxFileSize);
|
|
||||||
if (primary) {
|
if (primary) {
|
||||||
if (mPrimaryVolume == null) {
|
if (mPrimaryVolume == null) {
|
||||||
mPrimaryVolume = volume;
|
mPrimaryVolume = volume;
|
||||||
|
|||||||
Reference in New Issue
Block a user