diff options
| author | Makoto Onuki <omakoto@google.com> | 2015-06-12 16:10:25 -0700 |
|---|---|---|
| committer | Makoto Onuki <omakoto@google.com> | 2015-06-12 16:11:46 -0700 |
| commit | 9dc575d63c5f0d7511308bd2cd3d5dbd20c15e17 (patch) | |
| tree | 7a14306e1055be571d6dae1d1e354063b68845e5 | |
| parent | 3e634d93587d06d1dddfbe0b409891b39b92daa6 (diff) | |
| download | frameworks_base-9dc575d63c5f0d7511308bd2cd3d5dbd20c15e17.zip frameworks_base-9dc575d63c5f0d7511308bd2cd3d5dbd20c15e17.tar.gz frameworks_base-9dc575d63c5f0d7511308bd2cd3d5dbd20c15e17.tar.bz2 | |
Add StorageEventListener.onDiskDestroyed()
Bug 21336042
Change-Id: I226cf205191dd302ff8d5156f9ae0fe8fc5b2c2b
4 files changed, 56 insertions, 1 deletions
diff --git a/core/java/android/os/storage/IMountServiceListener.java b/core/java/android/os/storage/IMountServiceListener.java index c958fb0..cade9d7 100644 --- a/core/java/android/os/storage/IMountServiceListener.java +++ b/core/java/android/os/storage/IMountServiceListener.java @@ -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; } diff --git a/core/java/android/os/storage/StorageEventListener.java b/core/java/android/os/storage/StorageEventListener.java index 214c60d..4cf83fd 100644 --- a/core/java/android/os/storage/StorageEventListener.java +++ b/core/java/android/os/storage/StorageEventListener.java @@ -49,4 +49,7 @@ public class StorageEventListener { public void onDiskScanned(DiskInfo disk, int volumeCount) { } + + public void onDiskDestroyed(DiskInfo disk) { + } } diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java index 4bbaaa1..9b26f24 100644 --- a/core/java/android/os/storage/StorageManager.java +++ b/core/java/android/os/storage/StorageManager.java @@ -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(); + } } /** diff --git a/services/core/java/com/android/server/MountService.java b/services/core/java/com/android/server/MountService.java index aa7d1f8..f829733 100644 --- a/services/core/java/com/android/server/MountService.java +++ b/services/core/java/com/android/server/MountService.java @@ -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; } @@ -2965,6 +2968,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<>(); @@ -3020,6 +3024,10 @@ class MountService extends IMountService.Stub callback.onDiskScanned((DiskInfo) args.arg1, args.argi2); break; } + case MSG_DISK_DESTROYED: { + callback.onDiskDestroyed((DiskInfo) args.arg1); + break; + } } } @@ -3057,6 +3065,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 |
