Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9545dc02 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Include primary flag in StorageVolume.

Bug: 7003520
Change-Id: Iaae2ae22253820c954c51e0199c31087bc825f3f
parent 162fabbc
Loading
Loading
Loading
Loading
+27 −30
Original line number Diff line number Diff line
@@ -26,16 +26,16 @@ import android.os.Parcelable;
 */
public class StorageVolume implements Parcelable {

    //private static final String TAG = "StorageVolume";
    private int mStorageId;

    private final String mPath;
    private final int mDescriptionId;
    private final boolean mPrimary;
    private final boolean mRemovable;
    private final boolean mEmulated;
    private final int mMtpReserveSpace;
    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;

    // 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.
    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) {
        mPath = path;
        mDescriptionId = descriptionId;
        mPrimary = primary;
        mRemovable = removable;
        mEmulated = emulated;
        mMtpReserveSpace = mtpReserveSpace;
@@ -54,18 +55,16 @@ public class StorageVolume implements Parcelable {
        mMaxFileSize = maxFileSize;
    }

    // for parcelling only
    private StorageVolume(String path, int descriptionId, boolean removable,
            boolean emulated, int mtpReserveSpace, int storageId,
            boolean allowMassStorage, long maxFileSize) {
        mPath = path;
        mDescriptionId = descriptionId;
        mRemovable = removable;
        mEmulated = emulated;
        mMtpReserveSpace = mtpReserveSpace;
        mAllowMassStorage = allowMassStorage;
        mStorageId = storageId;
        mMaxFileSize = maxFileSize;
    private StorageVolume(Parcel in) {
        mStorageId = in.readInt();
        mPath = in.readString();
        mDescriptionId = in.readInt();
        mPrimary = in.readByte() != 0;
        mRemovable = in.readByte() != 0;
        mEmulated = in.readByte() != 0;
        mMtpReserveSpace = in.readInt();
        mAllowMassStorage = in.readByte() != 0;
        mMaxFileSize = in.readLong();
    }

    /**
@@ -90,6 +89,10 @@ public class StorageVolume implements Parcelable {
        return mDescriptionId;
    }

    public boolean isPrimary() {
        return mPrimary;
    }

    /**
     * Returns true if the volume is removable.
     *
@@ -183,37 +186,31 @@ public class StorageVolume implements Parcelable {
                + mRemovable + ", mStorageId=" + mStorageId + "]";
    }

    public static final Parcelable.Creator<StorageVolume> CREATOR =
        new Parcelable.Creator<StorageVolume>() {
    public static final Creator<StorageVolume> CREATOR = new Creator<StorageVolume>() {
        @Override
        public StorageVolume createFromParcel(Parcel in) {
            String path = in.readString();
            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);
            return new StorageVolume(in);
        }

        @Override
        public StorageVolume[] newArray(int size) {
            return new StorageVolume[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int flags) {
        parcel.writeInt(mStorageId);
        parcel.writeString(mPath);
        parcel.writeInt(mDescriptionId);
        parcel.writeInt(mPrimary ? 1 : 0);
        parcel.writeInt(mRemovable ? 1 : 0);
        parcel.writeInt(mEmulated ? 1 : 0);
        parcel.writeInt(mStorageId);
        parcel.writeInt(mMtpReserveSpace);
        parcel.writeInt(mAllowMassStorage ? 1 : 0);
        parcel.writeLong(mMaxFileSize);
+2 −3
Original line number Diff line number Diff line
@@ -1114,9 +1114,8 @@ class MountService extends IMountService.Stub
                        Slog.e(TAG, "path or description is null in readStorageList");
                    } else {
                        String pathString = path.toString();
                        StorageVolume volume = new StorageVolume(pathString,
                                descriptionId, removable, emulated,
                                mtpReserve, allowMassStorage, maxFileSize);
                        StorageVolume volume = new StorageVolume(pathString, descriptionId, primary,
                                removable, emulated, mtpReserve, allowMassStorage, maxFileSize);
                        if (primary) {
                            if (mPrimaryVolume == null) {
                                mPrimaryVolume = volume;