首页 > 编程知识 正文

android usb转串口,此版本为旧版Android怎么解决

时间:2023-05-04 19:31:41 阅读:40994 作者:4826

1 原理

安卓p q :找到了USB设备管理器。 其中,finishBoot,即启动后将usb模式设置为MTP模式,处理消息时如果为默认模式NONE,则更改为MTP模式。

2 修改方案(Android P Q)

修改文件为frameworks/base/services/USB/Java/com/Android/server/USB/USB device manager.Java,其中修改如下:

//////1消息处理单元publicvoidhandlemessage (消息msg ) switch ) msg.what ) case msg _ update _ state 3360 mconnected=() mconfigured=(msg.arg2==1; 更新用户通告(false; 更新数据库通告(false; 集成电路(mbootcompleted ) (更新用户总线连接评估功能); } if ((mcurrentfunctionsusbmanager.function _ accessory )!=0) {更新数据中心访问sory (; (if ) mbootcompleted ) if (! 已连接! has消息(msg _ accessory _ mode _ enter _ time out )! has messages (msg _ function _ switch _ time out )/restoredefaultswhenusbisdisconnectedif (! mscreenlockedmscreenunlockedfunctions!=USB manager.function _ none (setscreenunlockedfunctions ); } else { //在此将默认的UsbManager.FUNCTION_NONE添加到USB manager.function _ MTP//setenabled functions (USB manager.functione } } updateUsbFunctions (; } else { mpendingbootbroadcast=true; } break; //.}//////2finishboot部分protectedvoidfinishboot({if ) mbootcompletedmcurrentusbfunctionsreceivedmsystemready ) } { if (支持蓝牙连接)更新;更新;获取;应用软件功能(制造商功能); mPendingBootBroadcast=false; (if (! mscreenlockedmscreenunlockedfunctions!=USB manager.function _ none (setscreenunlockedfunctions ); } else { //在此将默认的UsbManager.FUNCTION_NONE添加到USB manager.function _ MTP//setenabled functions (USB manager.functione (if ) mcurrentaccessory!=null (musbdevicemanager.getcurrentsettings ().accessoryattached ) mcurrentaccessory ); }更新用户通告(假); 更新数据库通告(false; updateUsbFunctions (; }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。