public class USBCore extends Object
SystemCapability.Usb#USB_MANAGER| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static String |
ACTION_USB_DEVICE_ATTACHED |
Indicates a common event for attaching a USB device.
|
static String |
ACTION_USB_DEVICE_DETACHED |
Indicates a common event for detaching a USB device.
|
static String |
EXTRA_DEVICE |
Indicates additional device data.
|
static String |
EXTRA_PERMISSION_GRANTED |
Indicates that the access permission is granted.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
USBDevicePipe |
connectDevice(USBDevice device) |
Opens a USB device based on device information returned by
getDevices(). |
HashMap<String,USBDevice> |
getDevices() |
Returns the hash map of USB devices.
|
boolean |
hasRight(USBDevice device) |
Returns true if the caller has right to access the device.
|
void |
requestRight(USBDevice device,
String intentName) |
Requests temporary permission for the given package to access the device.
|
static long |
usbFunctionsFromString(String functions) |
Parses a string of usb functions that are comma separated.
|
static String |
usbFunctionsToString(long functions) |
Converts the given function mask to string.
|
public static final String ACTION_USB_DEVICE_ATTACHED
After subscribing to this event, an application receives a notification and get the corresponding device information when a USB device is attached.
public static final String ACTION_USB_DEVICE_DETACHED
After subscribing to this event, an application receives a notification and performs the corresponding action when a USB device is detached.
public static final String EXTRA_DEVICE
It is additional data contained in the ACTION_USB_DEVICE_ATTACHED
and ACTION_USB_DEVICE_DETACHED common events.
public USBCore(Context context)
USBCore.context - Indicates the context of the calling ability.public HashMap<String,USBDevice> getDevices()
The hash map contains devices and their names. Applications can traverse USB devices in the hash map to
perform operations on the devices. For details on the operations, see USBDevice.
public USBDevicePipe connectDevice(USBDevice device)
getDevices().
A USBDevicePipe instance is returned. Data transfer is performed based on the
instance.
device - Indicates a USBDevicePipe instance.USBDevicePipe instance.public boolean hasRight(USBDevice device)
device - to check right fortrue if caller has right to access this devicepublic void requestRight(USBDevice device, String intentName)
device - Device to request permissions forintentName - Intent for returning resultpublic static String usbFunctionsToString(long functions)
functions - the usb functions long valuepublic static long usbFunctionsFromString(String functions)
functions - the usb functions