Loading core/java/android/os/storage/DiskInfo.java +5 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.os.storage; import android.annotation.NonNull; import android.content.res.Resources; import android.os.Parcel; import android.os.Parcelable; Loading Loading @@ -59,6 +60,10 @@ public class DiskInfo implements Parcelable { volumeIds = parcel.readStringArray(); } public @NonNull String getId() { return id; } public String getDescription() { // TODO: splice vendor label into these strings if ((flags & FLAG_SD) != 0) { Loading core/java/android/os/storage/IMountService.java +61 −3 Original line number Diff line number Diff line Loading @@ -923,12 +923,13 @@ public interface IMountService extends IInterface { } @Override public VolumeInfo[] getVolumes() throws RemoteException { public VolumeInfo[] getVolumes(int _flags) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); VolumeInfo[] _result; try { _data.writeInterfaceToken(DESCRIPTOR); _data.writeInt(_flags); mRemote.transact(Stub.TRANSACTION_getVolumes, _data, _reply, 0); _reply.readException(); _result = _reply.createTypedArray(VolumeInfo.CREATOR); Loading Loading @@ -1029,6 +1030,39 @@ public interface IMountService extends IInterface { _data.recycle(); } } @Override public void setVolumeNickname(String volId, String nickname) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); try { _data.writeInterfaceToken(DESCRIPTOR); _data.writeString(volId); _data.writeString(nickname); mRemote.transact(Stub.TRANSACTION_setVolumeNickname, _data, _reply, 0); _reply.readException(); } finally { _reply.recycle(); _data.recycle(); } } @Override public void setVolumeUserFlags(String volId, int flags, int mask) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); try { _data.writeInterfaceToken(DESCRIPTOR); _data.writeString(volId); _data.writeInt(flags); _data.writeInt(mask); mRemote.transact(Stub.TRANSACTION_setVolumeUserFlags, _data, _reply, 0); _reply.readException(); } finally { _reply.recycle(); _data.recycle(); } } } private static final String DESCRIPTOR = "IMountService"; Loading Loading @@ -1132,6 +1166,9 @@ public interface IMountService extends IInterface { static final int TRANSACTION_partitionPrivate = IBinder.FIRST_CALL_TRANSACTION + 50; static final int TRANSACTION_partitionMixed = IBinder.FIRST_CALL_TRANSACTION + 51; static final int TRANSACTION_setVolumeNickname = IBinder.FIRST_CALL_TRANSACTION + 52; static final int TRANSACTION_setVolumeUserFlags = IBinder.FIRST_CALL_TRANSACTION + 53; /** * Cast an IBinder object into an IMountService interface, generating a * proxy if needed. Loading Loading @@ -1566,7 +1603,8 @@ public interface IMountService extends IInterface { } case TRANSACTION_getVolumes: { data.enforceInterface(DESCRIPTOR); VolumeInfo[] volumes = getVolumes(); int _flags = data.readInt(); VolumeInfo[] volumes = getVolumes(_flags); reply.writeNoException(); reply.writeTypedArray(volumes, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE); return true; Loading Loading @@ -1614,6 +1652,23 @@ public interface IMountService extends IInterface { reply.writeNoException(); return true; } case TRANSACTION_setVolumeNickname: { data.enforceInterface(DESCRIPTOR); String volId = data.readString(); String nickname = data.readString(); setVolumeNickname(volId, nickname); reply.writeNoException(); return true; } case TRANSACTION_setVolumeUserFlags: { data.enforceInterface(DESCRIPTOR); String volId = data.readString(); int _flags = data.readInt(); int _mask = data.readInt(); setVolumeUserFlags(volId, _flags, _mask); reply.writeNoException(); return true; } } return super.onTransact(code, data, reply, flags); } Loading Loading @@ -1902,7 +1957,7 @@ public interface IMountService extends IInterface { public void waitForAsecScan() throws RemoteException; public DiskInfo[] getDisks() throws RemoteException; public VolumeInfo[] getVolumes() throws RemoteException; public VolumeInfo[] getVolumes(int flags) throws RemoteException; public void mount(String volId) throws RemoteException; public void unmount(String volId) throws RemoteException; Loading @@ -1911,4 +1966,7 @@ public interface IMountService extends IInterface { public void partitionPublic(String diskId) throws RemoteException; 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; } core/java/android/os/storage/IMountServiceListener.java +26 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,13 @@ public interface IMountServiceListener extends IInterface { reply.writeNoException(); return true; } case TRANSACTION_onVolumeMetadataChanged: { data.enforceInterface(DESCRIPTOR); final VolumeInfo vol = (VolumeInfo) data.readParcelable(null); onVolumeMetadataChanged(vol); reply.writeNoException(); return true; } } return super.onTransact(code, data, reply, flags); } Loading Loading @@ -175,6 +182,22 @@ public interface IMountServiceListener extends IInterface { _data.recycle(); } } @Override public void onVolumeMetadataChanged(VolumeInfo vol) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); try { _data.writeInterfaceToken(DESCRIPTOR); _data.writeParcelable(vol, 0); mRemote.transact(Stub.TRANSACTION_onVolumeMetadataChanged, _data, _reply, android.os.IBinder.FLAG_ONEWAY); _reply.readException(); } finally { _reply.recycle(); _data.recycle(); } } } static final int TRANSACTION_onUsbMassStorageConnectionChanged = (IBinder.FIRST_CALL_TRANSACTION + 0); Loading @@ -182,6 +205,7 @@ public interface IMountServiceListener extends IInterface { static final int TRANSACTION_onStorageStateChanged = (IBinder.FIRST_CALL_TRANSACTION + 1); static final int TRANSACTION_onVolumeStateChanged = (IBinder.FIRST_CALL_TRANSACTION + 2); static final int TRANSACTION_onVolumeMetadataChanged = (IBinder.FIRST_CALL_TRANSACTION + 3); } /** Loading @@ -204,4 +228,6 @@ public interface IMountServiceListener extends IInterface { public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) throws RemoteException; public void onVolumeMetadataChanged(VolumeInfo vol) throws RemoteException; } core/java/android/os/storage/StorageEventListener.java +3 −0 Original line number Diff line number Diff line Loading @@ -40,4 +40,7 @@ public class StorageEventListener { public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) { } public void onVolumeMetadataChanged(VolumeInfo vol) { } } core/java/android/os/storage/StorageManager.java +50 −1 Original line number Diff line number Diff line Loading @@ -70,6 +70,9 @@ public class StorageManager { /** {@hide} */ public static final String PROP_PRIMARY_PHYSICAL = "ro.vold.primary_physical"; /** {@hide} */ public static final int FLAG_ALL_METADATA = 1 << 0; private final Context mContext; private final ContentResolver mResolver; Loading @@ -83,6 +86,7 @@ public class StorageManager { Handler.Callback { private static final int MSG_STORAGE_STATE_CHANGED = 1; private static final int MSG_VOLUME_STATE_CHANGED = 2; private static final int MSG_VOLUME_METADATA_CHANGED = 3; final StorageEventListener mCallback; final Handler mHandler; Loading @@ -105,6 +109,10 @@ public class StorageManager { mCallback.onVolumeStateChanged((VolumeInfo) args.arg1, args.argi2, args.argi3); args.recycle(); return true; case MSG_VOLUME_METADATA_CHANGED: mCallback.onVolumeMetadataChanged((VolumeInfo) args.arg1); args.recycle(); return true; } args.recycle(); return false; Loading Loading @@ -132,6 +140,13 @@ public class StorageManager { args.argi3 = newState; mHandler.obtainMessage(MSG_VOLUME_STATE_CHANGED, args).sendToTarget(); } @Override public void onVolumeMetadataChanged(VolumeInfo vol) { final SomeArgs args = SomeArgs.obtain(); args.arg1 = vol; mHandler.obtainMessage(MSG_VOLUME_METADATA_CHANGED, args).sendToTarget(); } } /** Loading Loading @@ -480,8 +495,13 @@ public class StorageManager { /** {@hide} */ public @NonNull List<VolumeInfo> getVolumes() { return getVolumes(0); } /** {@hide} */ public @NonNull List<VolumeInfo> getVolumes(int flags) { try { return Arrays.asList(mMountService.getVolumes()); return Arrays.asList(mMountService.getVolumes(flags)); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } Loading Loading @@ -555,6 +575,35 @@ public class StorageManager { } } /** {@hide} */ public void setVolumeNickname(String volId, String nickname) { try { mMountService.setVolumeNickname(volId, nickname); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } } /** {@hide} */ public void setVolumeInited(String volId, boolean inited) { try { mMountService.setVolumeUserFlags(volId, inited ? VolumeInfo.USER_FLAG_INITED : 0, VolumeInfo.USER_FLAG_INITED); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } } /** {@hide} */ public void setVolumeSnoozed(String volId, boolean snoozed) { try { mMountService.setVolumeUserFlags(volId, snoozed ? VolumeInfo.USER_FLAG_SNOOZED : 0, VolumeInfo.USER_FLAG_SNOOZED); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } } /** {@hide} */ public @Nullable StorageVolume getStorageVolume(File file) { return getStorageVolume(getVolumeList(), file); Loading Loading
core/java/android/os/storage/DiskInfo.java +5 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.os.storage; import android.annotation.NonNull; import android.content.res.Resources; import android.os.Parcel; import android.os.Parcelable; Loading Loading @@ -59,6 +60,10 @@ public class DiskInfo implements Parcelable { volumeIds = parcel.readStringArray(); } public @NonNull String getId() { return id; } public String getDescription() { // TODO: splice vendor label into these strings if ((flags & FLAG_SD) != 0) { Loading
core/java/android/os/storage/IMountService.java +61 −3 Original line number Diff line number Diff line Loading @@ -923,12 +923,13 @@ public interface IMountService extends IInterface { } @Override public VolumeInfo[] getVolumes() throws RemoteException { public VolumeInfo[] getVolumes(int _flags) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); VolumeInfo[] _result; try { _data.writeInterfaceToken(DESCRIPTOR); _data.writeInt(_flags); mRemote.transact(Stub.TRANSACTION_getVolumes, _data, _reply, 0); _reply.readException(); _result = _reply.createTypedArray(VolumeInfo.CREATOR); Loading Loading @@ -1029,6 +1030,39 @@ public interface IMountService extends IInterface { _data.recycle(); } } @Override public void setVolumeNickname(String volId, String nickname) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); try { _data.writeInterfaceToken(DESCRIPTOR); _data.writeString(volId); _data.writeString(nickname); mRemote.transact(Stub.TRANSACTION_setVolumeNickname, _data, _reply, 0); _reply.readException(); } finally { _reply.recycle(); _data.recycle(); } } @Override public void setVolumeUserFlags(String volId, int flags, int mask) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); try { _data.writeInterfaceToken(DESCRIPTOR); _data.writeString(volId); _data.writeInt(flags); _data.writeInt(mask); mRemote.transact(Stub.TRANSACTION_setVolumeUserFlags, _data, _reply, 0); _reply.readException(); } finally { _reply.recycle(); _data.recycle(); } } } private static final String DESCRIPTOR = "IMountService"; Loading Loading @@ -1132,6 +1166,9 @@ public interface IMountService extends IInterface { static final int TRANSACTION_partitionPrivate = IBinder.FIRST_CALL_TRANSACTION + 50; static final int TRANSACTION_partitionMixed = IBinder.FIRST_CALL_TRANSACTION + 51; static final int TRANSACTION_setVolumeNickname = IBinder.FIRST_CALL_TRANSACTION + 52; static final int TRANSACTION_setVolumeUserFlags = IBinder.FIRST_CALL_TRANSACTION + 53; /** * Cast an IBinder object into an IMountService interface, generating a * proxy if needed. Loading Loading @@ -1566,7 +1603,8 @@ public interface IMountService extends IInterface { } case TRANSACTION_getVolumes: { data.enforceInterface(DESCRIPTOR); VolumeInfo[] volumes = getVolumes(); int _flags = data.readInt(); VolumeInfo[] volumes = getVolumes(_flags); reply.writeNoException(); reply.writeTypedArray(volumes, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE); return true; Loading Loading @@ -1614,6 +1652,23 @@ public interface IMountService extends IInterface { reply.writeNoException(); return true; } case TRANSACTION_setVolumeNickname: { data.enforceInterface(DESCRIPTOR); String volId = data.readString(); String nickname = data.readString(); setVolumeNickname(volId, nickname); reply.writeNoException(); return true; } case TRANSACTION_setVolumeUserFlags: { data.enforceInterface(DESCRIPTOR); String volId = data.readString(); int _flags = data.readInt(); int _mask = data.readInt(); setVolumeUserFlags(volId, _flags, _mask); reply.writeNoException(); return true; } } return super.onTransact(code, data, reply, flags); } Loading Loading @@ -1902,7 +1957,7 @@ public interface IMountService extends IInterface { public void waitForAsecScan() throws RemoteException; public DiskInfo[] getDisks() throws RemoteException; public VolumeInfo[] getVolumes() throws RemoteException; public VolumeInfo[] getVolumes(int flags) throws RemoteException; public void mount(String volId) throws RemoteException; public void unmount(String volId) throws RemoteException; Loading @@ -1911,4 +1966,7 @@ public interface IMountService extends IInterface { public void partitionPublic(String diskId) throws RemoteException; 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; }
core/java/android/os/storage/IMountServiceListener.java +26 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,13 @@ public interface IMountServiceListener extends IInterface { reply.writeNoException(); return true; } case TRANSACTION_onVolumeMetadataChanged: { data.enforceInterface(DESCRIPTOR); final VolumeInfo vol = (VolumeInfo) data.readParcelable(null); onVolumeMetadataChanged(vol); reply.writeNoException(); return true; } } return super.onTransact(code, data, reply, flags); } Loading Loading @@ -175,6 +182,22 @@ public interface IMountServiceListener extends IInterface { _data.recycle(); } } @Override public void onVolumeMetadataChanged(VolumeInfo vol) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); try { _data.writeInterfaceToken(DESCRIPTOR); _data.writeParcelable(vol, 0); mRemote.transact(Stub.TRANSACTION_onVolumeMetadataChanged, _data, _reply, android.os.IBinder.FLAG_ONEWAY); _reply.readException(); } finally { _reply.recycle(); _data.recycle(); } } } static final int TRANSACTION_onUsbMassStorageConnectionChanged = (IBinder.FIRST_CALL_TRANSACTION + 0); Loading @@ -182,6 +205,7 @@ public interface IMountServiceListener extends IInterface { static final int TRANSACTION_onStorageStateChanged = (IBinder.FIRST_CALL_TRANSACTION + 1); static final int TRANSACTION_onVolumeStateChanged = (IBinder.FIRST_CALL_TRANSACTION + 2); static final int TRANSACTION_onVolumeMetadataChanged = (IBinder.FIRST_CALL_TRANSACTION + 3); } /** Loading @@ -204,4 +228,6 @@ public interface IMountServiceListener extends IInterface { public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) throws RemoteException; public void onVolumeMetadataChanged(VolumeInfo vol) throws RemoteException; }
core/java/android/os/storage/StorageEventListener.java +3 −0 Original line number Diff line number Diff line Loading @@ -40,4 +40,7 @@ public class StorageEventListener { public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) { } public void onVolumeMetadataChanged(VolumeInfo vol) { } }
core/java/android/os/storage/StorageManager.java +50 −1 Original line number Diff line number Diff line Loading @@ -70,6 +70,9 @@ public class StorageManager { /** {@hide} */ public static final String PROP_PRIMARY_PHYSICAL = "ro.vold.primary_physical"; /** {@hide} */ public static final int FLAG_ALL_METADATA = 1 << 0; private final Context mContext; private final ContentResolver mResolver; Loading @@ -83,6 +86,7 @@ public class StorageManager { Handler.Callback { private static final int MSG_STORAGE_STATE_CHANGED = 1; private static final int MSG_VOLUME_STATE_CHANGED = 2; private static final int MSG_VOLUME_METADATA_CHANGED = 3; final StorageEventListener mCallback; final Handler mHandler; Loading @@ -105,6 +109,10 @@ public class StorageManager { mCallback.onVolumeStateChanged((VolumeInfo) args.arg1, args.argi2, args.argi3); args.recycle(); return true; case MSG_VOLUME_METADATA_CHANGED: mCallback.onVolumeMetadataChanged((VolumeInfo) args.arg1); args.recycle(); return true; } args.recycle(); return false; Loading Loading @@ -132,6 +140,13 @@ public class StorageManager { args.argi3 = newState; mHandler.obtainMessage(MSG_VOLUME_STATE_CHANGED, args).sendToTarget(); } @Override public void onVolumeMetadataChanged(VolumeInfo vol) { final SomeArgs args = SomeArgs.obtain(); args.arg1 = vol; mHandler.obtainMessage(MSG_VOLUME_METADATA_CHANGED, args).sendToTarget(); } } /** Loading Loading @@ -480,8 +495,13 @@ public class StorageManager { /** {@hide} */ public @NonNull List<VolumeInfo> getVolumes() { return getVolumes(0); } /** {@hide} */ public @NonNull List<VolumeInfo> getVolumes(int flags) { try { return Arrays.asList(mMountService.getVolumes()); return Arrays.asList(mMountService.getVolumes(flags)); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } Loading Loading @@ -555,6 +575,35 @@ public class StorageManager { } } /** {@hide} */ public void setVolumeNickname(String volId, String nickname) { try { mMountService.setVolumeNickname(volId, nickname); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } } /** {@hide} */ public void setVolumeInited(String volId, boolean inited) { try { mMountService.setVolumeUserFlags(volId, inited ? VolumeInfo.USER_FLAG_INITED : 0, VolumeInfo.USER_FLAG_INITED); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } } /** {@hide} */ public void setVolumeSnoozed(String volId, boolean snoozed) { try { mMountService.setVolumeUserFlags(volId, snoozed ? VolumeInfo.USER_FLAG_SNOOZED : 0, VolumeInfo.USER_FLAG_SNOOZED); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } } /** {@hide} */ public @Nullable StorageVolume getStorageVolume(File file) { return getStorageVolume(getVolumeList(), file); Loading