USB_STATE 广播的额外内容
Extras for USB_STATE broadcast
我偶尔会看到有人提到 android.hardware.usb.action.USB_STATE
广播,据说它携带了一些 USB 状态信息。
它似乎不是官方的一部分 Android API。是否有关于它的任何文档,特别是支持的附加列表?
来自 platform_frameworks_base/core/java/android/hardware/usb/UsbManager.java:
该常量带有 @UnsupportedAppUsage
标记,表明它不应该被应用公开 to/used。这可能意味着它不能保证跨版本稳定。
此外,意图似乎是向主机指示 USB link 的状态,而不是 USB OTG 状态。
UsbManager
的 javadoc 说:
This class allows you to access the state of USB and communicate with USB devices. Currently only host mode is supported in the public API.
对于ACTION_USB_STATE
:
Broadcast Action: A sticky broadcast for USB state change events when in device mode.
This is a sticky broadcast for clients that includes USB connected/disconnected state,
"connected"
boolean indicating whether USB is connected or disconnected.
"host_connected"
boolean indicating whether USB is connected or disconnected as host.
"configured"
boolean indicating whether USB is configured. currently zero if not configured, one for configured.
"adb"
boolean extra indicating whether the adb function is enabled
"rndis"
boolean extra indicating whether the RNDIS ethernet function is enabled
"mtp"
boolean extra indicating whether the MTP function is enabled
USB_FUNCTION_PTP
boolean extra indicating whether the PTP function is enabled
"ptp"
boolean extra indicating whether the accessory function is enabled
"audio_source"
boolean extra indicating whether the audio source function is enabled
"midi"
boolean extra indicating whether the MIDI function is enabled
If the sticky intent has not been found, that indicates USB is disconnected, USB is not configued, MTP function is enabled, and all the other functions are disabled.
我偶尔会看到有人提到 android.hardware.usb.action.USB_STATE
广播,据说它携带了一些 USB 状态信息。
它似乎不是官方的一部分 Android API。是否有关于它的任何文档,特别是支持的附加列表?
来自 platform_frameworks_base/core/java/android/hardware/usb/UsbManager.java:
该常量带有 @UnsupportedAppUsage
标记,表明它不应该被应用公开 to/used。这可能意味着它不能保证跨版本稳定。
此外,意图似乎是向主机指示 USB link 的状态,而不是 USB OTG 状态。
UsbManager
的 javadoc 说:
This class allows you to access the state of USB and communicate with USB devices. Currently only host mode is supported in the public API.
对于ACTION_USB_STATE
:
Broadcast Action: A sticky broadcast for USB state change events when in device mode.
This is a sticky broadcast for clients that includes USB connected/disconnected state,
"connected"
boolean indicating whether USB is connected or disconnected."host_connected"
boolean indicating whether USB is connected or disconnected as host."configured"
boolean indicating whether USB is configured. currently zero if not configured, one for configured."adb"
boolean extra indicating whether the adb function is enabled"rndis"
boolean extra indicating whether the RNDIS ethernet function is enabled"mtp"
boolean extra indicating whether the MTP function is enabledUSB_FUNCTION_PTP
boolean extra indicating whether the PTP function is enabled"ptp"
boolean extra indicating whether the accessory function is enabled"audio_source"
boolean extra indicating whether the audio source function is enabled"midi"
boolean extra indicating whether the MIDI function is enabledIf the sticky intent has not been found, that indicates USB is disconnected, USB is not configued, MTP function is enabled, and all the other functions are disabled.