IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 移动开发 -> 低电时限制USB反向充电 -> 正文阅读

[移动开发]低电时限制USB反向充电

如何识别当前的USB连接是向别的设备充电?

? ? ? ?最好的方式是获取USB的供电电流,如果当前低电量,而且供电电流太大,则对USB总线断电。但是在USB服务上没法似乎无法获得供电电流。按功能是否可行?如果USB没有配置音频、视频、录音、录像、拍照, otg存储等功能,也就是没有常用的defined codes, 则掐断电源。

场景modepowerdataclasssub-c组合备注
pc? 充电ufpsinkdevice//2[source:host, sink:device]
pc? mtpufpsinkdevice//2
pc ptpufpsinkdevice//2
pc cdromufpsinkdevice//2
pc rndis//////不支持rndis
充电头dfpsinkhost//3[source:host, sink:host, sink:device]
充电头ufpsinkdevice//2[source:host, sink:device]
headsetdfpsourcehost612
otg udisksourcehost2
printersourcehost2
y31sdfpsourcehost862
790 充电ufpsinkdevice4[source:host, source:device, sink:host, sink:device]
790 mtpufpsinkdevice4
790 ptpufpsinkdevice4
790cdromufpsinkdevice4
790 充电sinkhost4
790 mtpsinkhost4
790 ptpsinkhost4
790cdromsinkhost4
790 充电ufpsourcedevice4供电方不能弹起连接选择框,受电方可以弹起。
790 mtpsourcedevice4
790 ptpsourcedevice4
790cdromsourcedevice4
790 充电dfpsourcehost2552554
790 mtpsourcehost614
790 ptpsourcehost614
790cdromsourcehost864

Defined Class Codes 类型

Base Class

Descriptor Usage

Description

00h

Device

Use class information in the Interface Descriptors

01h

Interface

Audio

02h

Both

Communications and CDC Control

03h

Interface

HID (Human Interface Device)

05h

Interface

Physical

06h

Interface

Image

07h

Interface

Printer

08h

Interface

Mass Storage

09h

Device

Hub

0Ah

Interface

CDC-Data

0Bh

Interface

Smart Card

0Dh

Interface

Content Security

0Eh

Interface

Video

0Fh

Interface

Personal Healthcare

10h

Interface

Audio/Video Devices

11h

Device

Billboard Device Class

12h

Interface

USB Type-C Bridge Class

3ChInterfaceI3C Device Class

DCh

Both

Diagnostic Device

E0h

Interface

Wireless Controller

EFh

Both

Miscellaneous

FEh

Interface

Application Specific

FFh

Both

Vendor Specific

USB 耳机

07-14 15:34:06.836 ?1091 ?2461 I android.hardware.usb@1.2-service-qti: auto suspend usb interfaces /sys/devices/platform/soc/a600000.ssusb/a600000.dwc3/xhci-hcd.2.auto/usb2/2-1
07-14 15:33:51.712 21715 21715 I [21715:kworker/0:3]input: bestechnic HUAWEI USB-C HEADSET as /devices/platform/soc/a600000.ssusb/a600000.dwc3/xhci-hcd.2.auto/usb2/2-1/2-1:1.3/0003:12D1:3A07.0001/input/input6
07-14 15:33:51.784 21715 21715 I [21715:kworker/0:3]hid-generic 0003: 12D1:3A07.0001: input,hidraw0: USB HID v1.11 Device [bestechnic HUAWEI USB-C HEADSET] on usb-xhci-hcd.2.auto-1/input3
07-14 15:34:06.941 12615 12821 D EventHub: No input device configuration file found for device 'bestechnic HUAWEI USB-C HEADSET'.
07-14 15:34:06.947 ?1091 ?2461 I android.hardware.usb@1.2-service-qti: auto suspend usb interfaces /sys/devices/platform/soc/a600000.ssusb/a600000.dwc3/xhci-hcd.2.auto/usb2/2-1
07-14 15:34:06.950 12615 12939 D UsbHostManager: USB device attached: vidpid 12d1:3a07 mfg/product/ver/serial bestechnic/HUAWEI USB-C HEADSET/0.24/0296A100000000000000000000000 hasAudio/HID/Storage: true/true/false
07-14 15:34:06.955 12615 12939 D UsbDeviceDescriptor: ? 1 configs
07-14 15:34:06.958 12615 12939 D UsbHostManager: Added device UsbDevice[mName=/dev/bus/usb/002/002,mVendorId=4817,mProductId=14855,mClass=0,mSubclass=0,mProtocol=0,mManufacturerName=bestechnic,mProductName=HUAWEI USB-C HEADSET,mVersion=0.24,mSerialNumberReader=com.android.server.usb.UsbSerialReader@fb536d0, mHasAudioPlayback=true, mHasAudioCapture=true, mHasMidi=false, mHasVideoCapture=false, mHasVideoPlayback=false, mConfigurations=[
07-14 15:34:06.958 12615 12939 D UsbHostManager: UsbConfiguration[mId=1,mName=null,mAttributes=160,mMaxPower=50,mInterfaces=[
07-14 15:34:06.958 12615 12939 D UsbHostManager: UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=1,mSubclass=1,mProtocol=0,mEndpoints=[]
07-14 15:34:06.958 12615 12939 D UsbHostManager: UsbInterface[mId=1,mAlternateSetting=0,mName=null,mClass=1,mSubclass=2,mProtocol=0,mEndpoints=[]
07-14 15:34:06.958 12615 12939 D UsbHostManager: UsbInterface[mId=1,mAlternateSetting=1,mName=null,mClass=1,mSubclass=2,mProtocol=0,mEndpoints=[
07-14 15:34:06.958 12615 12939 D UsbHostManager: UsbEndpoint[mAddress=131,mAttributes=13,mMaxPacketSize=192,mInterval=1]]
07-14 15:34:06.958 12615 12939 D UsbHostManager: UsbInterface[mId=2,mAlternateSetting=0,mName=null,mClass=1,mSubclass=2,mProtocol=0,mEndpoints=[]
07-14 15:34:06.958 12615 12939 D UsbHostManager: UsbInterface[mId=2,mAlternateSetting=1,mName=null,mClass=1,mSubclass=2,mProtocol=0,mEndpoints=[
07-14 15:34:06.958 12615 12939 D UsbHostManager: UsbEndpoint[mAddress=3,mAttributes=13,mMaxPacketSize=384,mInterval=1]]
07-14 15:34:06.958 12615 12939 D UsbHostManager: UsbInterface[mId=2,mAlternateSetting=2,mName=null,mClass=1,mSubclass=2,mProtocol=0,mEndpoints=[
07-14 15:34:06.958 12615 12939 D UsbHostManager: UsbEndpoint[mAddress=3,mAttributes=13,mMaxPacketSize=576,mInterval=1]]
07-14 15:34:06.958 12615 12939 D UsbHostManager: UsbInterface[mId=3,mAlternateSetting=0,mName=null,mClass=3,mSubclass=0,mProtocol=0,mEndpoints=[
07-14 15:34:06.958 12615 12939 D UsbHostManager:

UsbEndpoint[mAddress=132,mAttributes=3,mMaxPacketSize=3,mInterval=1]]]]

对端是 DRP端口的手机,仅充电config

07-14 17:59:40.935 11994 11994 I [11994:kworker/u16:2]hub 3-0: 1.0: 1 port detected
07-14 17:59:41.488 ?1091 ?2461 I android.hardware.usb@1.2-service-qti: uevent received change@/devices/platform/soc/soc:qcom,pmic_glink/soc:qcom,pmic_glink:qcom,ucsi/typec/port0
07-14 17:59:41.496 ?1091 ?2461 I android.hardware.usb@1.2-service-qti: port0
07-14 17:59:41.499 ?1091 ?2461 I android.hardware.usb@1.2-service-qti: connected:1 canChangeMode:1 canChagedata:1 canChangePower:1
07-14 17:59:41.501 12615 12911 I UsbPortManager: ClientCallback V1_2: port0
07-14 17:59:41.502 12615 12648 I UsbPortManager: USB port changed: port=UsbPort{id=port0, supportedModes=dual, audio_accsupportedContaminantProtectionModes=5supportsEnableContaminantPresenceProtection=falsesupportsEnableContaminantPresenceDetection=false, status=UsbPortStatus{connected=true, currentMode=dfp, currentPowerRole=source, currentDataRole=host, supportedRoleCombinations=[source:host, source:device, sink:host, sink:device], contaminantDetectionStatus=2, contaminantProtectionStatus=1}, canChangeMode=true, canChangePowerRole=true, canChangeDataRole=true, connectedAtMillis=14369516, lastConnectDurationMillis=0
07-14 17:59:41.504 12615 12615 I UsbDeviceManager: updateHostState UsbPort{id=port0, supportedModes=dual, audio_accsupportedContaminantProtectionModes=5supportsEnableContaminantPresenceProtection=falsesupportsEnableContaminantPresenceDetection=false status=UsbPortStatus{connected=true, currentMode=dfp, currentPowerRole=source, currentDataRole=host, supportedRoleCombinations=[source:host, source:device, sink:host, sink:device], contaminantDetectionStatus=2, contaminantProtectionStatus=1}
07-14 17:59:41.341 31352 31352 I [31352:kworker/0:2]usb 2-1: new high-speed USB device number 2 using xhci-hcd
07-14 17:59:41.500 31352 31352 I [31352:kworker/0:2]usb 2-1: New USB device found, VID=109b, PID=90be
07-14 17:59:42.011 12615 12939 D UsbHostManager: USB device attached: vidpid 109b:90be mfg/product/ver/serial Android/Android/5.04/ABCDEFGH hasAudio/HID/Storage: false/false/false
07-14 17:59:42.020 12615 12939 D UsbDeviceDescriptor: ? 1 configs
07-14 17:59:42.038 12615 12939 D UsbHostManager: Added device UsbDevice[mName=/dev/bus/usb/002/002,mVendorId=4251,mProductId=37054,mClass=0,mSubclass=0,mProtocol=0,mManufacturerName=Android,mProductName=Android,mVersion=5.04,mSerialNumberReader=com.android.server.usb.UsbSerialReader@c9820d6, mHasAudioPlayback=false, mHasAudioCapture=false, mHasMidi=false, mHasVideoCapture=false, mHasVideoPlayback=false, mConfigurations=[
07-14 17:59:42.038 12615 12939 D UsbHostManager: UsbConfiguration[mId=1,mName=diag_adb,mAttributes=192,mMaxPower=0,mInterfaces=[
07-14 17:59:42.038 12615 12939 D UsbHostManager: UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=255,mSubclass=255,mProtocol=48,mEndpoints=[
07-14 17:59:42.038 12615 12939 D UsbHostManager: UsbEndpoint[mAddress=1,mAttributes=2,mMaxPacketSize=512,mInterval=0]
07-14 17:59:42.038 12615 12939 D UsbHostManager: UsbEndpoint[mAddress=129,mAttributes=2,mMaxPacketSize=512,mInterval=0]]
07-14 17:59:42.038 12615 12939 D UsbHostManager: UsbInterface[mId=1,mAlternateSetting=0,mName=ADB Interface,mClass=255,mSubclass=66,mProtocol=1,mEndpoints=[
07-14 17:59:42.038 12615 12939 D UsbHostManager: UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=512,mInterval=0]
07-14 17:59:42.038 12615 12939 D UsbHostManager: UsbEndpoint[mAddress=130,mAttributes=2,mMaxPacketSize=512,mInterval=0]]]]
07-14 17:59:42.047 12615 12615 D AS.AudioService: onReceive() ?action= android.hardware.usb.action.USB_DEVICE_ATTACHED

对端是手机且设置为mtp

07-14 18:10:49.967 12615 12939 D UsbHostManager: USB device attached: vidpid 109b:9135 mfg/product/ver/serial Android/Android/5.04/ABCDEFGH hasAudio/HID/Storage: false/false/false
07-14 18:10:49.972 12615 12939 D UsbDeviceDescriptor: ? 1 configs
07-14 18:10:49.991 12615 12939 D UsbHostManager: Added device UsbDevice[mName=/dev/bus/usb/002/003,mVendorId=4251,mProductId=37173,mClass=0,mSubclass=0,mProtocol=0,mManufacturerName=Android,mProductName=Android,mVersion=5.04,mSerialNumberReader=com.android.server.usb.UsbSerialReader@6872391, mHasAudioPlayback=false, mHasAudioCapture=false, mHasMidi=false, mHasVideoCapture=false, mHasVideoPlayback=false, mConfigurations=[
07-14 18:10:49.991 12615 12939 D UsbHostManager: UsbConfiguration[mId=1,mName=mtp_adb,mAttributes=192,mMaxPower=0,mInterfaces=[
07-14 18:10:49.991 12615 12939 D UsbHostManager: UsbInterface[mId=0,mAlternateSetting=0,mName=MTP,mClass=6,mSubclass=1,mProtocol=1,mEndpoints=[
07-14 18:10:49.991 12615 12939 D UsbHostManager: UsbEndpoint[mAddress=129,mAttributes=2,mMaxPacketSize=512,mInterval=0]
07-14 18:10:49.991 12615 12939 D UsbHostManager: UsbEndpoint[mAddress=1,mAttributes=2,mMaxPacketSize=512,mInterval=0]
07-14 18:10:49.991 12615 12939 D UsbHostManager: UsbEndpoint[mAddress=130,mAttributes=3,mMaxPacketSize=28,mInterval=6]]
07-14 18:10:49.991 12615 12939 D UsbHostManager: UsbInterface[mId=1,mAlternateSetting=0,mName=ADB Interface,mClass=255,mSubclass=66,mProtocol=1,mEndpoints=[
07-14 18:10:49.991 12615 12939 D UsbHostManager: UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=512,mInterval=0]
07-14 18:10:49.991 12615 12939 D UsbHostManager: UsbEndpoint[mAddress=131,mAttributes=2,mMaxPacketSize=512,mInterval=0]]]]

  移动开发 最新文章
Vue3装载axios和element-ui
android adb cmd
【xcode】Xcode常用快捷键与技巧
Android开发中的线程池使用
Java 和 Android 的 Base64
Android 测试文字编码格式
微信小程序支付
安卓权限记录
知乎之自动养号
【Android Jetpack】DataStore
上一篇文章      下一篇文章      查看所有文章
加:2022-07-20 19:00:48  更:2022-07-20 19:02:59 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/25 4:05:01-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码