Loading core/java/android/os/Environment.java +3 −3 Original line number Diff line number Diff line Loading @@ -80,11 +80,11 @@ public class Environment { public File[] getExternalDirs() { final StorageVolume[] volumes = StorageManager.getVolumeList(mUserId); final File[] dirs = new File[volumes.length]; final File[] files = new File[volumes.length]; for (int i = 0; i < volumes.length; i++) { dirs[i] = volumes[i].getPathFile(); files[i] = volumes[i].getPathFile(); } return dirs; return files; } @Deprecated Loading core/java/android/os/storage/DiskInfo.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.os.storage; parcelable DiskInfo; core/java/android/os/storage/DiskInfo.java 0 → 100644 +118 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.os.storage; import android.content.Context; import android.os.Parcel; import android.os.Parcelable; import android.util.DebugUtils; import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.Preconditions; /** * Information about a physical disk which may contain one or more * {@link VolumeInfo}. * * @hide */ public class DiskInfo implements Parcelable { public static final int FLAG_ADOPTABLE = 1 << 0; public static final int FLAG_DEFAULT_PRIMARY = 1 << 1; public static final int FLAG_SD = 1 << 2; public static final int FLAG_USB = 1 << 3; public final String id; public final int flags; public long size; public String label; public String[] volumes; public DiskInfo(String id, int flags) { this.id = Preconditions.checkNotNull(id); this.flags = flags; } public DiskInfo(Parcel parcel) { id = parcel.readString(); flags = parcel.readInt(); size = parcel.readLong(); label = parcel.readString(); volumes = parcel.readStringArray(); } public String getDescription(Context context) { // TODO: splice vendor label into these strings if ((flags & FLAG_SD) != 0) { return context.getString(com.android.internal.R.string.storage_sd_card); } else if ((flags & FLAG_USB) != 0) { return context.getString(com.android.internal.R.string.storage_usb); } else { return null; } } // 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); // } public void dump(IndentingPrintWriter pw) { pw.println("DiskInfo:"); pw.increaseIndent(); pw.printPair("id", id); pw.printPair("flags", DebugUtils.flagsToString(getClass(), "FLAG_", flags)); pw.printPair("size", size); pw.printPair("label", label); pw.printPair("volumes", volumes); pw.decreaseIndent(); pw.println(); } public static final Creator<DiskInfo> CREATOR = new Creator<DiskInfo>() { @Override public DiskInfo createFromParcel(Parcel in) { return new DiskInfo(in); } @Override public DiskInfo[] newArray(int size) { return new DiskInfo[size]; } }; @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel parcel, int flags) { parcel.writeString(id); parcel.writeInt(flags); parcel.writeLong(size); parcel.writeString(label); parcel.writeStringArray(volumes); } } core/java/android/os/storage/IMountService.java +55 −0 Original line number Diff line number Diff line Loading @@ -904,6 +904,40 @@ public interface IMountService extends IInterface { } return; } @Override public DiskInfo[] getDisks() throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); DiskInfo[] _result; try { _data.writeInterfaceToken(DESCRIPTOR); mRemote.transact(Stub.TRANSACTION_getDisks, _data, _reply, 0); _reply.readException(); _result = _reply.createTypedArray(DiskInfo.CREATOR); } finally { _reply.recycle(); _data.recycle(); } return _result; } @Override public VolumeInfo[] getVolumes() throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); VolumeInfo[] _result; try { _data.writeInterfaceToken(DESCRIPTOR); mRemote.transact(Stub.TRANSACTION_getDisks, _data, _reply, 0); _reply.readException(); _result = _reply.createTypedArray(VolumeInfo.CREATOR); } finally { _reply.recycle(); _data.recycle(); } return _result; } } private static final String DESCRIPTOR = "IMountService"; Loading Loading @@ -996,6 +1030,10 @@ 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; /** * Cast an IBinder object into an IMountService interface, generating a * proxy if needed. Loading Loading @@ -1421,6 +1459,20 @@ public interface IMountService extends IInterface { reply.writeNoException(); return true; } case TRANSACTION_getDisks: { data.enforceInterface(DESCRIPTOR); DiskInfo[] disks = getDisks(); reply.writeNoException(); reply.writeTypedArray(disks, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE); return true; } case TRANSACTION_getVolumes: { data.enforceInterface(DESCRIPTOR); VolumeInfo[] volumes = getVolumes(); reply.writeNoException(); reply.writeTypedArray(volumes, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE); return true; } } return super.onTransact(code, data, reply, flags); } Loading Loading @@ -1707,4 +1759,7 @@ public interface IMountService extends IInterface { public void runMaintenance() throws RemoteException; public void waitForAsecScan() throws RemoteException; public DiskInfo[] getDisks() throws RemoteException; public VolumeInfo[] getVolumes() throws RemoteException; } core/java/android/os/storage/StorageManager.java +24 −11 Original line number Diff line number Diff line Loading @@ -33,14 +33,13 @@ import android.provider.Settings; import android.util.Log; import android.util.SparseArray; import libcore.util.EmptyArray; import com.android.internal.util.Preconditions; import java.io.File; import java.io.IOException; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; Loading @@ -64,6 +63,9 @@ import java.util.concurrent.atomic.AtomicInteger; public class StorageManager { private static final String TAG = "StorageManager"; /** {@hide} */ public static final String PROP_PRIMARY_PHYSICAL = "ro.vold.primary_physical"; private final Context mContext; private final ContentResolver mResolver; Loading Loading @@ -554,6 +556,24 @@ public class StorageManager { return null; } /** {@hide} */ public @NonNull List<DiskInfo> getDisks() { try { return Arrays.asList(mMountService.getDisks()); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } } /** {@hide} */ public @NonNull List<VolumeInfo> getVolumes() { try { return Arrays.asList(mMountService.getVolumes()); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } } /** {@hide} */ public @Nullable StorageVolume getStorageVolume(File file) { return getStorageVolume(getVolumeList(), file); Loading Loading @@ -597,16 +617,9 @@ public class StorageManager { } } /** * Returns list of all mountable volumes. * @hide */ /** {@hide} */ public @NonNull StorageVolume[] getVolumeList() { try { return mMountService.getVolumeList(mContext.getUserId()); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } return getVolumeList(mContext.getUserId()); } /** {@hide} */ Loading Loading
core/java/android/os/Environment.java +3 −3 Original line number Diff line number Diff line Loading @@ -80,11 +80,11 @@ public class Environment { public File[] getExternalDirs() { final StorageVolume[] volumes = StorageManager.getVolumeList(mUserId); final File[] dirs = new File[volumes.length]; final File[] files = new File[volumes.length]; for (int i = 0; i < volumes.length; i++) { dirs[i] = volumes[i].getPathFile(); files[i] = volumes[i].getPathFile(); } return dirs; return files; } @Deprecated Loading
core/java/android/os/storage/DiskInfo.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.os.storage; parcelable DiskInfo;
core/java/android/os/storage/DiskInfo.java 0 → 100644 +118 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.os.storage; import android.content.Context; import android.os.Parcel; import android.os.Parcelable; import android.util.DebugUtils; import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.Preconditions; /** * Information about a physical disk which may contain one or more * {@link VolumeInfo}. * * @hide */ public class DiskInfo implements Parcelable { public static final int FLAG_ADOPTABLE = 1 << 0; public static final int FLAG_DEFAULT_PRIMARY = 1 << 1; public static final int FLAG_SD = 1 << 2; public static final int FLAG_USB = 1 << 3; public final String id; public final int flags; public long size; public String label; public String[] volumes; public DiskInfo(String id, int flags) { this.id = Preconditions.checkNotNull(id); this.flags = flags; } public DiskInfo(Parcel parcel) { id = parcel.readString(); flags = parcel.readInt(); size = parcel.readLong(); label = parcel.readString(); volumes = parcel.readStringArray(); } public String getDescription(Context context) { // TODO: splice vendor label into these strings if ((flags & FLAG_SD) != 0) { return context.getString(com.android.internal.R.string.storage_sd_card); } else if ((flags & FLAG_USB) != 0) { return context.getString(com.android.internal.R.string.storage_usb); } else { return null; } } // 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); // } public void dump(IndentingPrintWriter pw) { pw.println("DiskInfo:"); pw.increaseIndent(); pw.printPair("id", id); pw.printPair("flags", DebugUtils.flagsToString(getClass(), "FLAG_", flags)); pw.printPair("size", size); pw.printPair("label", label); pw.printPair("volumes", volumes); pw.decreaseIndent(); pw.println(); } public static final Creator<DiskInfo> CREATOR = new Creator<DiskInfo>() { @Override public DiskInfo createFromParcel(Parcel in) { return new DiskInfo(in); } @Override public DiskInfo[] newArray(int size) { return new DiskInfo[size]; } }; @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel parcel, int flags) { parcel.writeString(id); parcel.writeInt(flags); parcel.writeLong(size); parcel.writeString(label); parcel.writeStringArray(volumes); } }
core/java/android/os/storage/IMountService.java +55 −0 Original line number Diff line number Diff line Loading @@ -904,6 +904,40 @@ public interface IMountService extends IInterface { } return; } @Override public DiskInfo[] getDisks() throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); DiskInfo[] _result; try { _data.writeInterfaceToken(DESCRIPTOR); mRemote.transact(Stub.TRANSACTION_getDisks, _data, _reply, 0); _reply.readException(); _result = _reply.createTypedArray(DiskInfo.CREATOR); } finally { _reply.recycle(); _data.recycle(); } return _result; } @Override public VolumeInfo[] getVolumes() throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); VolumeInfo[] _result; try { _data.writeInterfaceToken(DESCRIPTOR); mRemote.transact(Stub.TRANSACTION_getDisks, _data, _reply, 0); _reply.readException(); _result = _reply.createTypedArray(VolumeInfo.CREATOR); } finally { _reply.recycle(); _data.recycle(); } return _result; } } private static final String DESCRIPTOR = "IMountService"; Loading Loading @@ -996,6 +1030,10 @@ 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; /** * Cast an IBinder object into an IMountService interface, generating a * proxy if needed. Loading Loading @@ -1421,6 +1459,20 @@ public interface IMountService extends IInterface { reply.writeNoException(); return true; } case TRANSACTION_getDisks: { data.enforceInterface(DESCRIPTOR); DiskInfo[] disks = getDisks(); reply.writeNoException(); reply.writeTypedArray(disks, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE); return true; } case TRANSACTION_getVolumes: { data.enforceInterface(DESCRIPTOR); VolumeInfo[] volumes = getVolumes(); reply.writeNoException(); reply.writeTypedArray(volumes, android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE); return true; } } return super.onTransact(code, data, reply, flags); } Loading Loading @@ -1707,4 +1759,7 @@ public interface IMountService extends IInterface { public void runMaintenance() throws RemoteException; public void waitForAsecScan() throws RemoteException; public DiskInfo[] getDisks() throws RemoteException; public VolumeInfo[] getVolumes() throws RemoteException; }
core/java/android/os/storage/StorageManager.java +24 −11 Original line number Diff line number Diff line Loading @@ -33,14 +33,13 @@ import android.provider.Settings; import android.util.Log; import android.util.SparseArray; import libcore.util.EmptyArray; import com.android.internal.util.Preconditions; import java.io.File; import java.io.IOException; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; Loading @@ -64,6 +63,9 @@ import java.util.concurrent.atomic.AtomicInteger; public class StorageManager { private static final String TAG = "StorageManager"; /** {@hide} */ public static final String PROP_PRIMARY_PHYSICAL = "ro.vold.primary_physical"; private final Context mContext; private final ContentResolver mResolver; Loading Loading @@ -554,6 +556,24 @@ public class StorageManager { return null; } /** {@hide} */ public @NonNull List<DiskInfo> getDisks() { try { return Arrays.asList(mMountService.getDisks()); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } } /** {@hide} */ public @NonNull List<VolumeInfo> getVolumes() { try { return Arrays.asList(mMountService.getVolumes()); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } } /** {@hide} */ public @Nullable StorageVolume getStorageVolume(File file) { return getStorageVolume(getVolumeList(), file); Loading Loading @@ -597,16 +617,9 @@ public class StorageManager { } } /** * Returns list of all mountable volumes. * @hide */ /** {@hide} */ public @NonNull StorageVolume[] getVolumeList() { try { return mMountService.getVolumeList(mContext.getUserId()); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } return getVolumeList(mContext.getUserId()); } /** {@hide} */ Loading