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

Commit b3be7c26 authored by Makoto Onuki's avatar Makoto Onuki Committed by Android Git Automerger
Browse files

am 80b34d7b: Merge "Add StorageEventListener.onDiskDestroyed()" into mnc-dev

* commit '80b34d7b':
  Add StorageEventListener.onDiskDestroyed()
parents c4422b05 80b34d7b
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -113,6 +113,13 @@ public interface IMountServiceListener extends IInterface {
                    reply.writeNoException();
                    return true;
                }
                case TRANSACTION_onDiskDestroyed: {
                    data.enforceInterface(DESCRIPTOR);
                    final DiskInfo disk = (DiskInfo) data.readParcelable(null);
                    onDiskDestroyed(disk);
                    reply.writeNoException();
                    return true;
                }
            }
            return super.onTransact(code, data, reply, flags);
        }
@@ -246,6 +253,22 @@ public interface IMountServiceListener extends IInterface {
                    _data.recycle();
                }
            }

            @Override
            public void onDiskDestroyed(DiskInfo disk) throws RemoteException {
                Parcel _data = Parcel.obtain();
                Parcel _reply = Parcel.obtain();
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    _data.writeParcelable(disk, 0);
                    mRemote.transact(Stub.TRANSACTION_onDiskDestroyed, _data, _reply,
                            android.os.IBinder.FLAG_ONEWAY);
                    _reply.readException();
                } finally {
                    _reply.recycle();
                    _data.recycle();
                }
            }
        }

        static final int TRANSACTION_onUsbMassStorageConnectionChanged = (IBinder.FIRST_CALL_TRANSACTION + 0);
@@ -254,6 +277,7 @@ public interface IMountServiceListener extends IInterface {
        static final int TRANSACTION_onVolumeRecordChanged = (IBinder.FIRST_CALL_TRANSACTION + 3);
        static final int TRANSACTION_onVolumeForgotten = (IBinder.FIRST_CALL_TRANSACTION + 4);
        static final int TRANSACTION_onDiskScanned = (IBinder.FIRST_CALL_TRANSACTION + 5);
        static final int TRANSACTION_onDiskDestroyed = (IBinder.FIRST_CALL_TRANSACTION + 6);
    }

    /**
@@ -280,4 +304,6 @@ public interface IMountServiceListener extends IInterface {
    public void onVolumeForgotten(String fsUuid) throws RemoteException;

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

    public void onDiskDestroyed(DiskInfo disk) throws RemoteException;
}
+3 −0
Original line number Diff line number Diff line
@@ -49,4 +49,7 @@ public class StorageEventListener {

    public void onDiskScanned(DiskInfo disk, int volumeCount) {
    }

    public void onDiskDestroyed(DiskInfo disk) {
    }
}
+12 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ public class StorageManager {
        private static final int MSG_VOLUME_RECORD_CHANGED = 3;
        private static final int MSG_VOLUME_FORGOTTEN = 4;
        private static final int MSG_DISK_SCANNED = 5;
        private static final int MSG_DISK_DESTROYED = 6;

        final StorageEventListener mCallback;
        final Handler mHandler;
@@ -135,6 +136,10 @@ public class StorageManager {
                    mCallback.onDiskScanned((DiskInfo) args.arg1, args.argi2);
                    args.recycle();
                    return true;
                case MSG_DISK_DESTROYED:
                    mCallback.onDiskDestroyed((DiskInfo) args.arg1);
                    args.recycle();
                    return true;
            }
            args.recycle();
            return false;
@@ -184,6 +189,13 @@ public class StorageManager {
            args.argi2 = volumeCount;
            mHandler.obtainMessage(MSG_DISK_SCANNED, args).sendToTarget();
        }

        @Override
        public void onDiskDestroyed(DiskInfo disk) throws RemoteException {
            final SomeArgs args = SomeArgs.obtain();
            args.arg1 = disk;
            mHandler.obtainMessage(MSG_DISK_DESTROYED, args).sendToTarget();
        }
    }

    /**
+15 −1
Original line number Diff line number Diff line
@@ -890,7 +890,10 @@ class MountService extends IMountService.Stub
            }
            case VoldResponseCode.DISK_DESTROYED: {
                if (cooked.length != 2) break;
                mDisks.remove(cooked[1]);
                final DiskInfo disk = mDisks.remove(cooked[1]);
                if (disk != null) {
                    mCallbacks.notifyDiskDestroyed(disk);
                }
                break;
            }

@@ -2971,6 +2974,7 @@ class MountService extends IMountService.Stub
        private static final int MSG_VOLUME_RECORD_CHANGED = 3;
        private static final int MSG_VOLUME_FORGOTTEN = 4;
        private static final int MSG_DISK_SCANNED = 5;
        private static final int MSG_DISK_DESTROYED = 6;

        private final RemoteCallbackList<IMountServiceListener>
                mCallbacks = new RemoteCallbackList<>();
@@ -3026,6 +3030,10 @@ class MountService extends IMountService.Stub
                    callback.onDiskScanned((DiskInfo) args.arg1, args.argi2);
                    break;
                }
                case MSG_DISK_DESTROYED: {
                    callback.onDiskDestroyed((DiskInfo) args.arg1);
                    break;
                }
            }
        }

@@ -3063,6 +3071,12 @@ class MountService extends IMountService.Stub
            args.argi2 = volumeCount;
            obtainMessage(MSG_DISK_SCANNED, args).sendToTarget();
        }

        private void notifyDiskDestroyed(DiskInfo disk) {
            final SomeArgs args = SomeArgs.obtain();
            args.arg1 = disk.clone();
            obtainMessage(MSG_DISK_DESTROYED, args).sendToTarget();
        }
    }

    @Override