Search in sources :

Example 11 with MtpStorageInfo

use of android.mtp.MtpStorageInfo in project android_frameworks_base by DirtyUnicorns.

the class MtpManager method getRoots.

private MtpRoot[] getRoots(int deviceId) throws IOException {
    final MtpDevice device = getDevice(deviceId);
    synchronized (device) {
        final int[] storageIds = ensureNotNull(device.getStorageIds(), "Failed to obtain storage IDs.");
        final ArrayList<MtpRoot> roots = new ArrayList<>();
        for (int i = 0; i < storageIds.length; i++) {
            final MtpStorageInfo info = device.getStorageInfo(storageIds[i]);
            if (info == null) {
                continue;
            }
            roots.add(new MtpRoot(device.getDeviceId(), info));
        }
        return roots.toArray(new MtpRoot[roots.size()]);
    }
}
Also used : MtpDevice(android.mtp.MtpDevice) ArrayList(java.util.ArrayList) MtpStorageInfo(android.mtp.MtpStorageInfo)

Aggregations

MtpDevice (android.mtp.MtpDevice)11 MtpStorageInfo (android.mtp.MtpStorageInfo)11 ArrayList (java.util.ArrayList)11