Search in sources :

Example 1 with MtpDeviceInfo

use of android.mtp.MtpDeviceInfo in project platform_frameworks_base by android.

the class MtpManager method createDeviceRecord.

private MtpDeviceRecord createDeviceRecord(UsbDevice device) {
    final MtpDevice mtpDevice = mDevices.get(device.getDeviceId());
    final boolean opened = mtpDevice != null;
    final String name = device.getProductName();
    MtpRoot[] roots;
    int[] operationsSupported = null;
    int[] eventsSupported = null;
    if (opened) {
        try {
            roots = getRoots(device.getDeviceId());
        } catch (IOException exp) {
            Log.e(MtpDocumentsProvider.TAG, "Failed to open device", exp);
            // If we failed to fetch roots for the device, we still returns device model
            // with an empty set of roots so that the device is shown DocumentsUI as long as
            // the device is physically connected.
            roots = new MtpRoot[0];
        }
        final MtpDeviceInfo info = mtpDevice.getDeviceInfo();
        if (info != null) {
            operationsSupported = mtpDevice.getDeviceInfo().getOperationsSupported();
            eventsSupported = mtpDevice.getDeviceInfo().getEventsSupported();
        }
    } else {
        roots = new MtpRoot[0];
    }
    return new MtpDeviceRecord(device.getDeviceId(), name, device.getSerialNumber(), opened, roots, operationsSupported, eventsSupported);
}
Also used : MtpDevice(android.mtp.MtpDevice) IOException(java.io.IOException) MtpDeviceInfo(android.mtp.MtpDeviceInfo)

Example 2 with MtpDeviceInfo

use of android.mtp.MtpDeviceInfo in project android_frameworks_base by crdroidandroid.

the class MtpManager method createDeviceRecord.

private MtpDeviceRecord createDeviceRecord(UsbDevice device) {
    final MtpDevice mtpDevice = mDevices.get(device.getDeviceId());
    final boolean opened = mtpDevice != null;
    final String name = device.getProductName();
    MtpRoot[] roots;
    int[] operationsSupported = null;
    int[] eventsSupported = null;
    if (opened) {
        try {
            roots = getRoots(device.getDeviceId());
        } catch (IOException exp) {
            Log.e(MtpDocumentsProvider.TAG, "Failed to open device", exp);
            // If we failed to fetch roots for the device, we still returns device model
            // with an empty set of roots so that the device is shown DocumentsUI as long as
            // the device is physically connected.
            roots = new MtpRoot[0];
        }
        final MtpDeviceInfo info = mtpDevice.getDeviceInfo();
        if (info != null) {
            operationsSupported = info.getOperationsSupported();
            eventsSupported = info.getEventsSupported();
        }
    } else {
        roots = new MtpRoot[0];
    }
    return new MtpDeviceRecord(device.getDeviceId(), name, device.getSerialNumber(), opened, roots, operationsSupported, eventsSupported);
}
Also used : MtpDevice(android.mtp.MtpDevice) IOException(java.io.IOException) MtpDeviceInfo(android.mtp.MtpDeviceInfo)

Example 3 with MtpDeviceInfo

use of android.mtp.MtpDeviceInfo in project android_frameworks_base by AOSPA.

the class MtpManager method createDeviceRecord.

private MtpDeviceRecord createDeviceRecord(UsbDevice device) {
    final MtpDevice mtpDevice = mDevices.get(device.getDeviceId());
    final boolean opened = mtpDevice != null;
    final String name = device.getProductName();
    MtpRoot[] roots;
    int[] operationsSupported = null;
    int[] eventsSupported = null;
    if (opened) {
        try {
            roots = getRoots(device.getDeviceId());
        } catch (IOException exp) {
            Log.e(MtpDocumentsProvider.TAG, "Failed to open device", exp);
            // If we failed to fetch roots for the device, we still returns device model
            // with an empty set of roots so that the device is shown DocumentsUI as long as
            // the device is physically connected.
            roots = new MtpRoot[0];
        }
        final MtpDeviceInfo info = mtpDevice.getDeviceInfo();
        if (info != null) {
            operationsSupported = info.getOperationsSupported();
            eventsSupported = info.getEventsSupported();
        }
    } else {
        roots = new MtpRoot[0];
    }
    return new MtpDeviceRecord(device.getDeviceId(), name, device.getSerialNumber(), opened, roots, operationsSupported, eventsSupported);
}
Also used : MtpDevice(android.mtp.MtpDevice) IOException(java.io.IOException) MtpDeviceInfo(android.mtp.MtpDeviceInfo)

Example 4 with MtpDeviceInfo

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

the class MtpManager method createDeviceRecord.

private MtpDeviceRecord createDeviceRecord(UsbDevice device) {
    final MtpDevice mtpDevice = mDevices.get(device.getDeviceId());
    final boolean opened = mtpDevice != null;
    final String name = device.getProductName();
    MtpRoot[] roots;
    int[] operationsSupported = null;
    int[] eventsSupported = null;
    if (opened) {
        try {
            roots = getRoots(device.getDeviceId());
        } catch (IOException exp) {
            Log.e(MtpDocumentsProvider.TAG, "Failed to open device", exp);
            // If we failed to fetch roots for the device, we still returns device model
            // with an empty set of roots so that the device is shown DocumentsUI as long as
            // the device is physically connected.
            roots = new MtpRoot[0];
        }
        final MtpDeviceInfo info = mtpDevice.getDeviceInfo();
        if (info != null) {
            operationsSupported = info.getOperationsSupported();
            eventsSupported = info.getEventsSupported();
        }
    } else {
        roots = new MtpRoot[0];
    }
    return new MtpDeviceRecord(device.getDeviceId(), name, device.getSerialNumber(), opened, roots, operationsSupported, eventsSupported);
}
Also used : MtpDevice(android.mtp.MtpDevice) IOException(java.io.IOException) MtpDeviceInfo(android.mtp.MtpDeviceInfo)

Example 5 with MtpDeviceInfo

use of android.mtp.MtpDeviceInfo in project android_frameworks_base by ResurrectionRemix.

the class MtpManager method createDeviceRecord.

private MtpDeviceRecord createDeviceRecord(UsbDevice device) {
    final MtpDevice mtpDevice = mDevices.get(device.getDeviceId());
    final boolean opened = mtpDevice != null;
    final String name = device.getProductName();
    MtpRoot[] roots;
    int[] operationsSupported = null;
    int[] eventsSupported = null;
    if (opened) {
        try {
            roots = getRoots(device.getDeviceId());
        } catch (IOException exp) {
            Log.e(MtpDocumentsProvider.TAG, "Failed to open device", exp);
            // If we failed to fetch roots for the device, we still returns device model
            // with an empty set of roots so that the device is shown DocumentsUI as long as
            // the device is physically connected.
            roots = new MtpRoot[0];
        }
        final MtpDeviceInfo info = mtpDevice.getDeviceInfo();
        if (info != null) {
            operationsSupported = info.getOperationsSupported();
            eventsSupported = info.getEventsSupported();
        }
    } else {
        roots = new MtpRoot[0];
    }
    return new MtpDeviceRecord(device.getDeviceId(), name, device.getSerialNumber(), opened, roots, operationsSupported, eventsSupported);
}
Also used : MtpDevice(android.mtp.MtpDevice) IOException(java.io.IOException) MtpDeviceInfo(android.mtp.MtpDeviceInfo)

Aggregations

MtpDevice (android.mtp.MtpDevice)5 MtpDeviceInfo (android.mtp.MtpDeviceInfo)5 IOException (java.io.IOException)5