本文主要是介绍Android10.0-切换USB用途流程-未完待续,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
插入USB,下拉状态栏切换USB用途流程-未完待续
packages/apps/Settings/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
45 static {
46 FUNCTIONS_MAP.put(UsbManager.FUNCTION_MTP, R.string.usb_use_file_transfers); //文件传输
47 FUNCTIONS_MAP.put(UsbManager.FUNCTION_RNDIS, R.string.usb_use_tethering);//USB 网络共享
48 FUNCTIONS_MAP.put(UsbManager.FUNCTION_MIDI, R.string.usb_use_MIDI);// MIDI
49 FUNCTIONS_MAP.put(UsbManager.FUNCTION_PTP, R.string.usb_use_photo_transfers); //PTP
50 FUNCTIONS_MAP.put(UsbManager.FUNCTION_NONE, R.string.usb_use_charging_only);//不进行数据传输
51 }
onRadioButtonClicked(RadioButtonPreference preference)
要切换非USB 网络共享
mUsbBackend.setCurrentFunctions(function);
packages/apps/Settings/src/com/android/settings/connecteddevice/usb/UsbBackend.java USB后台处理
setCurrentFunctions(function)
mUsbManager.setCurrentFunctions(functions);
frameworks/base/core/java/android/hardware/usb/UsbManager.java USB管理类
setCurrentFunctions(long functions)
mService.setCurrentFunctions(functions); aidl调用
frameworks/base/services/usb/java/com/android/server/usb/UsbService.java USB服务端
setCurrentFunctions(long functions)
mDeviceManager.setCurrentFunctions(functions);
frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java USB设备管理类
setCurrentFunctions(long functions)
mHandler.sendMessage(MSG_SET_CURRENT_FUNCTIONS, functions);
mHandler发消息,消息id: MSG_SET_CURRENT_FUNCTIONS\
收消息:handleMessage(Message msg)
MSG_SET_CURRENT_FUNCTIONS
Usb真正处理类,内部类 UsbHandlerLegacy setEnabledFunctions(functions, false)
1.boolean isUsbDataTransferActive(long functions)
2.updateUsbNotification(boolean force)
3.trySetEnabledFunctions(long usbFunctions, boolean forceRestart)
这篇关于Android10.0-切换USB用途流程-未完待续的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!