当前位置: 首页>>代码示例>>Java>>正文


Java UsbConstants.USB_CLASS_MASS_STORAGE属性代码示例

本文整理汇总了Java中android.hardware.usb.UsbConstants.USB_CLASS_MASS_STORAGE属性的典型用法代码示例。如果您正苦于以下问题:Java UsbConstants.USB_CLASS_MASS_STORAGE属性的具体用法?Java UsbConstants.USB_CLASS_MASS_STORAGE怎么用?Java UsbConstants.USB_CLASS_MASS_STORAGE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.hardware.usb.UsbConstants的用法示例。


在下文中一共展示了UsbConstants.USB_CLASS_MASS_STORAGE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: nameForClass

private static String nameForClass(UsbDevice usbDevice) {
    int classType = usbDevice.getDeviceClass();
    switch (classType) {
        case UsbConstants.USB_CLASS_AUDIO:
            return "Audio";
        case UsbConstants.USB_CLASS_CDC_DATA:
            return "CDC Control";
        case UsbConstants.USB_CLASS_COMM:
            return "Communications";
        case UsbConstants.USB_CLASS_CONTENT_SEC:
            return "Content Security";
        case UsbConstants.USB_CLASS_CSCID:
            return "Content Smart Card";
        case UsbConstants.USB_CLASS_HID:
            return "Human Interface Device";
        case UsbConstants.USB_CLASS_HUB:
            return "Hub";
        case UsbConstants.USB_CLASS_MASS_STORAGE:
            return "Mass Storage";
        case UsbConstants.USB_CLASS_MISC:
            return "Wireless Miscellaneous";
        case UsbConstants.USB_CLASS_PHYSICA:
            return "Physical";
        case UsbConstants.USB_CLASS_PRINTER:
            return "Printer";
        case UsbConstants.USB_CLASS_STILL_IMAGE:
            return "Still Image";
        case UsbConstants.USB_CLASS_VENDOR_SPEC:
            return String.format("Vendor Specific 0x%02x", classType);
        case UsbConstants.USB_CLASS_VIDEO:
            return "Video";
        case UsbConstants.USB_CLASS_WIRELESS_CONTROLLER:
            return "Wireless Controller";
        default:
            return "";
    }
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:37,代码来源:UsbUtils.java

示例2: nameForClass

public static String nameForClass(int classType) {
    switch (classType) {
        case UsbConstants.USB_CLASS_APP_SPEC:
            return String.format("Application Specific 0x%02x", classType);
        case UsbConstants.USB_CLASS_AUDIO:
            return "Audio";
        case UsbConstants.USB_CLASS_CDC_DATA:
            return "CDC Control";
        case UsbConstants.USB_CLASS_COMM:
            return "Communications";
        case UsbConstants.USB_CLASS_CONTENT_SEC:
            return "Content Security";
        case UsbConstants.USB_CLASS_CSCID:
            return "Content Smart Card";
        case UsbConstants.USB_CLASS_HID:
            return "Human Interface Device";
        case UsbConstants.USB_CLASS_HUB:
            return "Hub";
        case UsbConstants.USB_CLASS_MASS_STORAGE:
            return "Mass Storage";
        case UsbConstants.USB_CLASS_MISC:
            return "Wireless Miscellaneous";
        case UsbConstants.USB_CLASS_PER_INTERFACE:
            return "(Defined Per Interface)";
        case UsbConstants.USB_CLASS_PHYSICA:
            return "Physical";
        case UsbConstants.USB_CLASS_PRINTER:
            return "Printer";
        case UsbConstants.USB_CLASS_STILL_IMAGE:
            return "Still Image";
        case UsbConstants.USB_CLASS_VENDOR_SPEC:
            return String.format("Vendor Specific 0x%02x", classType);
        case UsbConstants.USB_CLASS_VIDEO:
            return "Video";
        case UsbConstants.USB_CLASS_WIRELESS_CONTROLLER:
            return "Wireless Controller";
        default:
            return String.format("0x%02x", classType);
    }
}
 
开发者ID:androidthings,项目名称:sample-usbenum,代码行数:40,代码来源:UsbHelper.java

示例3: getClassName

private String getClassName(int deviceClass) {
    switch (deviceClass) {
        case UsbConstants.USB_CLASS_AUDIO:
            return this.getString(R.string.class_audio);
        case UsbConstants.USB_CLASS_CDC_DATA:
            return this.getString(R.string.class_cdc_data);
        case UsbConstants.USB_CLASS_COMM:
            return this.getString(R.string.class_comm);
        case UsbConstants.USB_CLASS_CONTENT_SEC:
            return this.getString(R.string.class_content_sec);
        case UsbConstants.USB_CLASS_HID:
            return this.getString(R.string.class_hid);
        case UsbConstants.USB_CLASS_HUB:
            return this.getString(R.string.class_hub);
        case UsbConstants.USB_CLASS_MASS_STORAGE:
            return this.getString(R.string.class_mass_storage);
        case UsbConstants.USB_CLASS_MISC:
            return this.getString(R.string.class_misc);
        case UsbConstants.USB_CLASS_PHYSICA:
            return this.getString(R.string.class_physica);
        case UsbConstants.USB_CLASS_PRINTER:
            return this.getString(R.string.class_printer);
        case UsbConstants.USB_CLASS_STILL_IMAGE:
            return this.getString(R.string.class_still_image);
        case UsbConstants.USB_CLASS_VIDEO:
            return this.getString(R.string.class_video);
        case UsbConstants.USB_CLASS_WIRELESS_CONTROLLER:
            return this.getString(R.string.class_wireless_controller);
        default:
            return this.getString(R.string.class_unknown);
    }
}
 
开发者ID:egelke,项目名称:eIDSuite,代码行数:32,代码来源:EidService.java

示例4: getMassStorageDevices

/**
 * This method iterates through all connected USB devices and searches for
 * mass storage devices.
 *
 * @param context Context to get the {@link UsbManager}
 * @return An array of suitable mass storage devices or an empty array if none could be found.
 */
public static UsbMassStorageDevice[] getMassStorageDevices(Context context) {
  UsbManager usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
  ArrayList<UsbMassStorageDevice> result = new ArrayList<UsbMassStorageDevice>();

  for (UsbDevice device : usbManager.getDeviceList().values()) {
    Log.i(TAG, "found usb device: " + device);

    int interfaceCount = device.getInterfaceCount();
    for (int i = 0; i < interfaceCount; i++) {
      UsbInterface usbInterface = device.getInterface(i);
      Log.i(TAG, "found usb interface: " + usbInterface);

      // we currently only support SCSI transparent command set with
      // bulk transfers only!
      if (usbInterface.getInterfaceClass() != UsbConstants.USB_CLASS_MASS_STORAGE
          || usbInterface.getInterfaceSubclass() != INTERFACE_SUBCLASS
          || usbInterface.getInterfaceProtocol() != INTERFACE_PROTOCOL) {
        Log.i(TAG, "device interface not suitable!");
        continue;
      }

      // Every mass storage device has exactly two endpoints
      // One IN and one OUT endpoint
      int endpointCount = usbInterface.getEndpointCount();
      if (endpointCount != 2) {
        Log.w(TAG, "inteface endpoint count != 2");
      }

      UsbEndpoint outEndpoint = null;
      UsbEndpoint inEndpoint = null;
      for (int j = 0; j < endpointCount; j++) {
        UsbEndpoint endpoint = usbInterface.getEndpoint(j);
        Log.i(TAG, "found usb endpoint: " + endpoint);
        if (endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
          if (endpoint.getDirection() == UsbConstants.USB_DIR_OUT) {
            outEndpoint = endpoint;
          } else {
            inEndpoint = endpoint;
          }
        }
      }

      if (outEndpoint == null || inEndpoint == null) {
        Log.e(TAG, "Not all needed endpoints found!");
        continue;
      }

      result.add(new UsbMassStorageDevice(usbManager, device, usbInterface, inEndpoint,
          outEndpoint));

    }
  }

  return result.toArray(new UsbMassStorageDevice[0]);
}
 
开发者ID:mrolcsi,项目名称:FileBrowser-Android,代码行数:62,代码来源:UsbMassStorageDevice.java

示例5: openDevice

public boolean openDevice()
{
    int index = mDevice.getInterfaceCount();
    for(int i=0;i<=index-1;i++)
    {
        if(massStorageInterface == null) // Silly check only meaningful when testing
            massStorageInterface = mDevice.getInterface(i);

        if(massStorageInterface.getInterfaceClass() == UsbConstants.USB_CLASS_MASS_STORAGE && massStorageInterface.getInterfaceSubclass() == 0x06
                && massStorageInterface.getInterfaceProtocol() == 0x50)
        {
            if(mConnection.claimInterface(massStorageInterface, true))
            {
                int endpointCount = massStorageInterface.getEndpointCount();
                for(int j=0;j<=endpointCount-1;j++)
                {
                    UsbEndpoint endpoint = massStorageInterface.getEndpoint(j);
                    if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
                            && endpoint.getDirection() == UsbConstants.USB_DIR_IN)
                    {
                        inEndpoint = endpoint;
                    }else if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
                            && endpoint.getDirection() == UsbConstants.USB_DIR_OUT)
                    {
                        outEndpoint = endpoint;
                    }
                }

                if(inEndpoint != null && outEndpoint != null)
                {
                    dataOutThread = new DataOutThread();
                    dataOutThread.start();
                    dataInThread = new DataInThread();
                    dataInThread.start();

                    while(outHandler == null)
                    {
                        //Busy waiting to avoid outHandler being null :(
                    }

                    return true;
                }else
                {
                    return false;
                }

            }else
            {
                return false;
            }
        }
    }
    return false;
}
 
开发者ID:felHR85,项目名称:Pincho-Usb-Mass-Storage-for-Android,代码行数:54,代码来源:UsbFacade.java


注:本文中的android.hardware.usb.UsbConstants.USB_CLASS_MASS_STORAGE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。