USBMonitor.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:DeviceConnect-Android 作者:
/**
 * get interface
 * @param interface_id
 * @param altsetting
 * @return
 * @throws IllegalStateException
 */
public synchronized UsbInterface getInterface(final int interface_id, final int altsetting) throws IllegalStateException {
    checkConnection();
    SparseArray<UsbInterface> intfs = mInterfaces.get(interface_id);
    if (intfs == null) {
        intfs = new SparseArray<UsbInterface>();
        mInterfaces.put(interface_id, intfs);
    }
    UsbInterface intf = intfs.get(altsetting);
    if (intf == null) {
        final UsbDevice device = mWeakDevice.get();
        final int n = device.getInterfaceCount();
        for (int i = 0; i < n; i++) {
            final UsbInterface temp = device.getInterface(i);
            if ((temp.getId() == interface_id) && (temp.getAlternateSetting() == altsetting)) {
                intf = temp;
                break;
            }
        }
        if (intf != null) {
            intfs.append(altsetting, intf);
        }
    }
    return intf;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号