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

Commit 80705810 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Storage methods using IDs, update listeners."

parents 8fbc7bc7 7151a9a8
Loading
Loading
Loading
Loading
+20 −11
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import android.util.DebugUtils;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.Preconditions;

import java.io.CharArrayWriter;

/**
 * Information about a physical disk which may contain one or more
 * {@link VolumeInfo}.
@@ -66,17 +68,12 @@ public class DiskInfo implements Parcelable {
        }
    }

//    public void partitionPublic() throws NativeDaemonConnectorException {
//        mConnector.execute("volume", "partition", id, "public");
//    }
//
//    public void partitionPrivate() throws NativeDaemonConnectorException {
//        mConnector.execute("volume", "partition", id, "private");
//    }
//
//    public void partitionMixed(int frac) throws NativeDaemonConnectorException {
//        mConnector.execute("volume", "partition", id, "mixed", frac);
//    }
    @Override
    public String toString() {
        final CharArrayWriter writer = new CharArrayWriter();
        dump(new IndentingPrintWriter(writer, "    ", 80));
        return writer.toString();
    }

    public void dump(IndentingPrintWriter pw) {
        pw.println("DiskInfo:");
@@ -90,6 +87,18 @@ public class DiskInfo implements Parcelable {
        pw.println();
    }

    @Override
    public DiskInfo clone() {
        final Parcel temp = Parcel.obtain();
        try {
            writeToParcel(temp, 0);
            temp.setDataPosition(0);
            return CREATOR.createFromParcel(temp);
        } finally {
            temp.recycle();
        }
    }

    public static final Creator<DiskInfo> CREATOR = new Creator<DiskInfo>() {
        @Override
        public DiskInfo createFromParcel(Parcel in) {
+151 −2
Original line number Diff line number Diff line
@@ -929,7 +929,7 @@ public interface IMountService extends IInterface {
                VolumeInfo[] _result;
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    mRemote.transact(Stub.TRANSACTION_getDisks, _data, _reply, 0);
                    mRemote.transact(Stub.TRANSACTION_getVolumes, _data, _reply, 0);
                    _reply.readException();
                    _result = _reply.createTypedArray(VolumeInfo.CREATOR);
                } finally {
@@ -938,6 +938,97 @@ public interface IMountService extends IInterface {
                }
                return _result;
            }

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

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

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

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

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

            @Override
            public void partitionMixed(String diskId, int ratio) throws RemoteException {
                Parcel _data = Parcel.obtain();
                Parcel _reply = Parcel.obtain();
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    _data.writeString(diskId);
                    _data.writeInt(ratio);
                    mRemote.transact(Stub.TRANSACTION_partitionMixed, _data, _reply, 0);
                    _reply.readException();
                } finally {
                    _reply.recycle();
                    _data.recycle();
                }
            }
        }

        private static final String DESCRIPTOR = "IMountService";
@@ -1031,9 +1122,16 @@ public interface IMountService extends IInterface {
        static final int TRANSACTION_waitForAsecScan = IBinder.FIRST_CALL_TRANSACTION + 43;

        static final int TRANSACTION_getDisks = IBinder.FIRST_CALL_TRANSACTION + 44;

        static final int TRANSACTION_getVolumes = IBinder.FIRST_CALL_TRANSACTION + 45;

        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_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;

        /**
         * Cast an IBinder object into an IMountService interface, generating a
         * proxy if needed.
@@ -1473,6 +1571,49 @@ public interface IMountService extends IInterface {
                    reply.writeTypedArray(volumes, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
                    return true;
                }
                case TRANSACTION_mount: {
                    data.enforceInterface(DESCRIPTOR);
                    String volId = data.readString();
                    mount(volId);
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_unmount: {
                    data.enforceInterface(DESCRIPTOR);
                    String volId = data.readString();
                    unmount(volId);
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_format: {
                    data.enforceInterface(DESCRIPTOR);
                    String volId = data.readString();
                    format(volId);
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_partitionPublic: {
                    data.enforceInterface(DESCRIPTOR);
                    String diskId = data.readString();
                    partitionPublic(diskId);
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_partitionPrivate: {
                    data.enforceInterface(DESCRIPTOR);
                    String diskId = data.readString();
                    partitionPrivate(diskId);
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_partitionMixed: {
                    data.enforceInterface(DESCRIPTOR);
                    String diskId = data.readString();
                    int ratio = data.readInt();
                    partitionMixed(diskId, ratio);
                    reply.writeNoException();
                    return true;
                }
            }
            return super.onTransact(code, data, reply, flags);
        }
@@ -1762,4 +1903,12 @@ public interface IMountService extends IInterface {

    public DiskInfo[] getDisks() throws RemoteException;
    public VolumeInfo[] getVolumes() throws RemoteException;

    public void mount(String volId) throws RemoteException;
    public void unmount(String volId) throws RemoteException;
    public void format(String volId) throws RemoteException;

    public void partitionPublic(String diskId) throws RemoteException;
    public void partitionPrivate(String diskId) throws RemoteException;
    public void partitionMixed(String diskId, int ratio) throws RemoteException;
}
+39 −8
Original line number Diff line number Diff line
@@ -75,16 +75,22 @@ public interface IMountServiceListener extends IInterface {
                }
                case TRANSACTION_onStorageStateChanged: {
                    data.enforceInterface(DESCRIPTOR);
                    String path;
                    path = data.readString();
                    String oldState;
                    oldState = data.readString();
                    String newState;
                    newState = data.readString();
                    final String path = data.readString();
                    final String oldState = data.readString();
                    final String newState = data.readString();
                    this.onStorageStateChanged(path, oldState, newState);
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_onVolumeStateChanged: {
                    data.enforceInterface(DESCRIPTOR);
                    final VolumeInfo vol = (VolumeInfo) data.readParcelable(null);
                    final int oldState = data.readInt();
                    final int newState = data.readInt();
                    onVolumeStateChanged(vol, oldState, newState);
                    reply.writeNoException();
                    return true;
                }
            }
            return super.onTransact(code, data, reply, flags);
        }
@@ -116,7 +122,7 @@ public interface IMountServiceListener extends IInterface {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    _data.writeInt(((connected) ? (1) : (0)));
                    mRemote.transact(Stub.TRANSACTION_onUsbMassStorageConnectionChanged, _data,
                            _reply, 0);
                            _reply, android.os.IBinder.FLAG_ONEWAY);
                    _reply.readException();
                } finally {
                    _reply.recycle();
@@ -142,7 +148,27 @@ public interface IMountServiceListener extends IInterface {
                    _data.writeString(path);
                    _data.writeString(oldState);
                    _data.writeString(newState);
                    mRemote.transact(Stub.TRANSACTION_onStorageStateChanged, _data, _reply, 0);
                    mRemote.transact(Stub.TRANSACTION_onStorageStateChanged, _data, _reply,
                            android.os.IBinder.FLAG_ONEWAY);
                    _reply.readException();
                } finally {
                    _reply.recycle();
                    _data.recycle();
                }
            }

            @Override
            public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState)
                    throws RemoteException {
                Parcel _data = Parcel.obtain();
                Parcel _reply = Parcel.obtain();
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    _data.writeParcelable(vol, 0);
                    _data.writeInt(oldState);
                    _data.writeInt(newState);
                    mRemote.transact(Stub.TRANSACTION_onVolumeStateChanged, _data, _reply,
                            android.os.IBinder.FLAG_ONEWAY);
                    _reply.readException();
                } finally {
                    _reply.recycle();
@@ -154,6 +180,8 @@ public interface IMountServiceListener extends IInterface {
        static final int TRANSACTION_onUsbMassStorageConnectionChanged = (IBinder.FIRST_CALL_TRANSACTION + 0);

        static final int TRANSACTION_onStorageStateChanged = (IBinder.FIRST_CALL_TRANSACTION + 1);

        static final int TRANSACTION_onVolumeStateChanged = (IBinder.FIRST_CALL_TRANSACTION + 2);
    }

    /**
@@ -173,4 +201,7 @@ public interface IMountServiceListener extends IInterface {
     */
    public void onStorageStateChanged(String path, String oldState, String newState)
            throws RemoteException;

    public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState)
            throws RemoteException;
}
+4 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ package android.os.storage;
 * 
 * @hide
 */
public abstract class StorageEventListener {
public class StorageEventListener {
    /**
     * Called when the detection state of a USB Mass Storage host has changed.
     * @param connected true if the USB mass storage is connected.
@@ -37,4 +37,7 @@ public abstract class StorageEventListener {
     */
    public void onStorageStateChanged(String path, String oldState, String newState) {
    }

    public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
    }
}
+132 −202

File changed.

Preview size limit exceeded, changes collapsed.

Loading