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

Commit b36586a7 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Split some VolumeInfo state into VolumeRecord.

VolumeRecord is a historical record of a volume that we've seen in
the past.  It's now surfaced outside the framework for SystemUI to
drive the notifications that bug users to reinsert missing private
volumes.

Show progress notifications for both storage and package movement
operations.  Notify when an empty disk is inserted (no usable volumes)
which launches into the normal format flow.

Add API to forget volumes.

Bug: 20275424, 20275424
Change-Id: I75602c17fdcd4d1f1f62324e1a08c4a33093eefa
parent 30565ed2
Loading
Loading
Loading
Loading
+13 −14
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ import android.view.Display;
import dalvik.system.VMRuntime;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.os.SomeArgs;
import com.android.internal.util.Preconditions;
import com.android.internal.util.UserIcons;

@@ -2054,8 +2055,7 @@ final class ApplicationPackageManager extends PackageManager {
    /** {@hide} */
    private static class MoveCallbackDelegate extends IPackageMoveObserver.Stub implements
            Handler.Callback {
        private static final int MSG_STARTED = 1;
        private static final int MSG_STATUS_CHANGED = 2;
        private static final int MSG_STATUS_CHANGED = 1;

        final MoveCallback mCallback;
        final Handler mHandler;
@@ -2067,26 +2067,25 @@ final class ApplicationPackageManager extends PackageManager {

        @Override
        public boolean handleMessage(Message msg) {
            final int moveId = msg.arg1;
            switch (msg.what) {
                case MSG_STARTED:
                    mCallback.onStarted(moveId, (String) msg.obj);
                    return true;
                case MSG_STATUS_CHANGED:
                    mCallback.onStatusChanged(moveId, msg.arg2, (long) msg.obj);
                    final SomeArgs args = (SomeArgs) msg.obj;
                    mCallback.onStatusChanged(args.argi1, (String) args.arg2, args.argi3,
                            (long) args.arg4);
                    args.recycle();
                    return true;
            }
            return false;
        }

        @Override
        public void onStarted(int moveId, String title) {
            mHandler.obtainMessage(MSG_STARTED, moveId, 0, title).sendToTarget();
        }

        @Override
        public void onStatusChanged(int moveId, int status, long estMillis) {
            mHandler.obtainMessage(MSG_STATUS_CHANGED, moveId, status, estMillis).sendToTarget();
        public void onStatusChanged(int moveId, String moveTitle, int status, long estMillis) {
            final SomeArgs args = SomeArgs.obtain();
            args.argi1 = moveId;
            args.arg2 = moveTitle;
            args.argi3 = status;
            args.arg4 = estMillis;
            mHandler.obtainMessage(MSG_STATUS_CHANGED, args).sendToTarget();
        }
    }

+1 −2
Original line number Diff line number Diff line
@@ -22,6 +22,5 @@ package android.content.pm;
 * @hide
 */
oneway interface IPackageMoveObserver {
    void onStarted(int moveId, String title);
    void onStatusChanged(int moveId, int status, long estMillis);
    void onStatusChanged(int moveId, String moveTitle, int status, long estMillis);
}
+2 −2
Original line number Diff line number Diff line
@@ -4212,8 +4212,8 @@ public abstract class PackageManager {

    /** {@hide} */
    public static abstract class MoveCallback {
        public abstract void onStarted(int moveId, String title);
        public abstract void onStatusChanged(int moveId, int status, long estMillis);
        public abstract void onStatusChanged(int moveId, String moveTitle, int status,
                long estMillis);
    }

    /** {@hide} */
+68 −16
Original line number Diff line number Diff line
@@ -941,6 +941,24 @@ public interface IMountService extends IInterface {
                return _result;
            }

            @Override
            public VolumeRecord[] getVolumeRecords(int _flags) throws RemoteException {
                Parcel _data = Parcel.obtain();
                Parcel _reply = Parcel.obtain();
                VolumeRecord[] _result;
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    _data.writeInt(_flags);
                    mRemote.transact(Stub.TRANSACTION_getVolumeRecords, _data, _reply, 0);
                    _reply.readException();
                    _result = _reply.createTypedArray(VolumeRecord.CREATOR);
                } finally {
                    _reply.recycle();
                    _data.recycle();
                }
                return _result;
            }

            @Override
            public void mount(String volId) throws RemoteException {
                Parcel _data = Parcel.obtain();
@@ -1033,12 +1051,12 @@ public interface IMountService extends IInterface {
            }

            @Override
            public void setVolumeNickname(String volId, String nickname) throws RemoteException {
            public void setVolumeNickname(String fsUuid, String nickname) throws RemoteException {
                Parcel _data = Parcel.obtain();
                Parcel _reply = Parcel.obtain();
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    _data.writeString(volId);
                    _data.writeString(fsUuid);
                    _data.writeString(nickname);
                    mRemote.transact(Stub.TRANSACTION_setVolumeNickname, _data, _reply, 0);
                    _reply.readException();
@@ -1049,12 +1067,12 @@ public interface IMountService extends IInterface {
            }

            @Override
            public void setVolumeUserFlags(String volId, int flags, int mask) throws RemoteException {
            public void setVolumeUserFlags(String fsUuid, int flags, int mask) throws RemoteException {
                Parcel _data = Parcel.obtain();
                Parcel _reply = Parcel.obtain();
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    _data.writeString(volId);
                    _data.writeString(fsUuid);
                    _data.writeInt(flags);
                    _data.writeInt(mask);
                    mRemote.transact(Stub.TRANSACTION_setVolumeUserFlags, _data, _reply, 0);
@@ -1065,6 +1083,21 @@ public interface IMountService extends IInterface {
                }
            }

            @Override
            public void forgetVolume(String fsUuid) throws RemoteException {
                Parcel _data = Parcel.obtain();
                Parcel _reply = Parcel.obtain();
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    _data.writeString(fsUuid);
                    mRemote.transact(Stub.TRANSACTION_forgetVolume, _data, _reply, 0);
                    _reply.readException();
                } finally {
                    _reply.recycle();
                    _data.recycle();
                }
            }

            @Override
            public String getPrimaryStorageUuid() throws RemoteException {
                Parcel _data = Parcel.obtain();
@@ -1192,20 +1225,22 @@ public interface IMountService extends IInterface {

        static final int TRANSACTION_getDisks = IBinder.FIRST_CALL_TRANSACTION + 44;
        static final int TRANSACTION_getVolumes = IBinder.FIRST_CALL_TRANSACTION + 45;
        static final int TRANSACTION_getVolumeRecords = IBinder.FIRST_CALL_TRANSACTION + 46;

        static final int TRANSACTION_mount = IBinder.FIRST_CALL_TRANSACTION + 46;
        static final int TRANSACTION_unmount = IBinder.FIRST_CALL_TRANSACTION + 47;
        static final int TRANSACTION_format = IBinder.FIRST_CALL_TRANSACTION + 48;
        static final int TRANSACTION_mount = IBinder.FIRST_CALL_TRANSACTION + 47;
        static final int TRANSACTION_unmount = IBinder.FIRST_CALL_TRANSACTION + 48;
        static final int TRANSACTION_format = IBinder.FIRST_CALL_TRANSACTION + 49;

        static final int TRANSACTION_partitionPublic = IBinder.FIRST_CALL_TRANSACTION + 49;
        static final int TRANSACTION_partitionPrivate = IBinder.FIRST_CALL_TRANSACTION + 50;
        static final int TRANSACTION_partitionMixed = IBinder.FIRST_CALL_TRANSACTION + 51;
        static final int TRANSACTION_partitionPublic = IBinder.FIRST_CALL_TRANSACTION + 50;
        static final int TRANSACTION_partitionPrivate = IBinder.FIRST_CALL_TRANSACTION + 51;
        static final int TRANSACTION_partitionMixed = IBinder.FIRST_CALL_TRANSACTION + 52;

        static final int TRANSACTION_setVolumeNickname = IBinder.FIRST_CALL_TRANSACTION + 52;
        static final int TRANSACTION_setVolumeUserFlags = IBinder.FIRST_CALL_TRANSACTION + 53;
        static final int TRANSACTION_setVolumeNickname = IBinder.FIRST_CALL_TRANSACTION + 53;
        static final int TRANSACTION_setVolumeUserFlags = IBinder.FIRST_CALL_TRANSACTION + 54;
        static final int TRANSACTION_forgetVolume = IBinder.FIRST_CALL_TRANSACTION + 55;

        static final int TRANSACTION_getPrimaryStorageUuid = IBinder.FIRST_CALL_TRANSACTION + 54;
        static final int TRANSACTION_setPrimaryStorageUuid = IBinder.FIRST_CALL_TRANSACTION + 55;
        static final int TRANSACTION_getPrimaryStorageUuid = IBinder.FIRST_CALL_TRANSACTION + 56;
        static final int TRANSACTION_setPrimaryStorageUuid = IBinder.FIRST_CALL_TRANSACTION + 57;

        /**
         * Cast an IBinder object into an IMountService interface, generating a
@@ -1647,6 +1682,14 @@ public interface IMountService extends IInterface {
                    reply.writeTypedArray(volumes, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
                    return true;
                }
                case TRANSACTION_getVolumeRecords: {
                    data.enforceInterface(DESCRIPTOR);
                    int _flags = data.readInt();
                    VolumeRecord[] volumes = getVolumeRecords(_flags);
                    reply.writeNoException();
                    reply.writeTypedArray(volumes, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
                    return true;
                }
                case TRANSACTION_mount: {
                    data.enforceInterface(DESCRIPTOR);
                    String volId = data.readString();
@@ -1707,6 +1750,13 @@ public interface IMountService extends IInterface {
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_forgetVolume: {
                    data.enforceInterface(DESCRIPTOR);
                    String fsUuid = data.readString();
                    forgetVolume(fsUuid);
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_getPrimaryStorageUuid: {
                    data.enforceInterface(DESCRIPTOR);
                    String volumeUuid = getPrimaryStorageUuid();
@@ -2012,6 +2062,7 @@ public interface IMountService extends IInterface {

    public DiskInfo[] getDisks() throws RemoteException;
    public VolumeInfo[] getVolumes(int flags) throws RemoteException;
    public VolumeRecord[] getVolumeRecords(int flags) throws RemoteException;

    public void mount(String volId) throws RemoteException;
    public void unmount(String volId) throws RemoteException;
@@ -2021,8 +2072,9 @@ public interface IMountService extends IInterface {
    public void partitionPrivate(String diskId) throws RemoteException;
    public void partitionMixed(String diskId, int ratio) throws RemoteException;

    public void setVolumeNickname(String volId, String nickname) throws RemoteException;
    public void setVolumeUserFlags(String volId, int flags, int mask) throws RemoteException;
    public void setVolumeNickname(String fsUuid, String nickname) throws RemoteException;
    public void setVolumeUserFlags(String fsUuid, int flags, int mask) throws RemoteException;
    public void forgetVolume(String fsUuid) throws RemoteException;

    public String getPrimaryStorageUuid() throws RemoteException;
    public void setPrimaryStorageUuid(String volumeUuid, IPackageMoveObserver callback)
+5 −5
Original line number Diff line number Diff line
@@ -93,8 +93,8 @@ public interface IMountServiceListener extends IInterface {
                }
                case TRANSACTION_onVolumeMetadataChanged: {
                    data.enforceInterface(DESCRIPTOR);
                    final VolumeInfo vol = (VolumeInfo) data.readParcelable(null);
                    onVolumeMetadataChanged(vol);
                    final String fsUuid = data.readString();
                    onVolumeMetadataChanged(fsUuid);
                    reply.writeNoException();
                    return true;
                }
@@ -192,12 +192,12 @@ public interface IMountServiceListener extends IInterface {
            }

            @Override
            public void onVolumeMetadataChanged(VolumeInfo vol) throws RemoteException {
            public void onVolumeMetadataChanged(String fsUuid) throws RemoteException {
                Parcel _data = Parcel.obtain();
                Parcel _reply = Parcel.obtain();
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    _data.writeParcelable(vol, 0);
                    _data.writeString(fsUuid);
                    mRemote.transact(Stub.TRANSACTION_onVolumeMetadataChanged, _data, _reply,
                            android.os.IBinder.FLAG_ONEWAY);
                    _reply.readException();
@@ -253,7 +253,7 @@ public interface IMountServiceListener extends IInterface {
    public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState)
            throws RemoteException;

    public void onVolumeMetadataChanged(VolumeInfo vol) throws RemoteException;
    public void onVolumeMetadataChanged(String fsUuid) throws RemoteException;

    public void onDiskScanned(DiskInfo disk, int volumeCount) throws RemoteException;
}
Loading