当前位置: 首页 > news >正文

企业创建网站广告媒体资源平台

企业创建网站,广告媒体资源平台,下载网页上的视频,石家庄网站设计一、为什么需要开启USB信任和ADB调试 问题1:原始的AOSP,如果通过USB连接设备以后,会弹窗提示用户选择连接模式:MTP,大容量磁盘,照片等模式; 问题2:USB连接设备以后,需要…

一、为什么需要开启USB信任和ADB调试

问题1:原始的AOSP,如果通过USB连接设备以后,会弹窗提示用户选择连接模式:MTP,大容量磁盘,照片等模式;

问题2:USB连接设备以后,需要开启USB调试模式,才方便操作adb调试;

问题3:USB设备连接以后,电脑会弹窗是否信任设备,需要点击信任当前设备,否则设备连接不成功。

使用场景:我们是自己的系统,需要支持设备USB连接,以及adb远程调试(USB调试和TCP调回),因此,系统需要默认支持USB连接,支持USB调试,默认信任连接的设备。

二、集成步骤

2.1 关闭USB调试弹窗

frameworks/base/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java

@Overridepublic void onCreate(Bundle icicle) {
...(省略)
/**final AlertController.AlertParams ap = mAlertParams;ap.mTitle = getString(R.string.usb_debugging_title);ap.mMessage = getString(R.string.usb_debugging_message, fingerprints);ap.mPositiveButtonText = getString(R.string.usb_debugging_allow);ap.mNegativeButtonText = getString(android.R.string.cancel);ap.mPositiveButtonListener = this;ap.mNegativeButtonListener = this;// add "always allow" checkboxLayoutInflater inflater = LayoutInflater.from(ap.mContext);View checkbox = inflater.inflate(com.android.internal.R.layout.always_use_checkbox, null);mAlwaysAllow = (CheckBox)checkbox.findViewById(com.android.internal.R.id.alwaysUse);mAlwaysAllow.setText(getString(R.string.usb_debugging_always));ap.mView = checkbox;window.setCloseOnTouchOutside(false);setupAlert();**/notifyService(true,true);finish();
}

默认只要USB连接设备,默认就开启USB调试。关键方法是notifyService

/*** Notifies the ADB service as to whether the current ADB request should be allowed, and if* subsequent requests from this key should be allowed without user consent.** @param allow whether the connection should be allowed* @param alwaysAllow whether subsequent requests from this key should be allowed without user*                    consent*/private void notifyService(boolean allow, boolean alwaysAllow) {try {IBinder b = ServiceManager.getService(ADB_SERVICE);IAdbManager service = IAdbManager.Stub.asInterface(b);if (allow) {service.allowDebugging(alwaysAllow, mKey);} else {service.denyDebugging();}mServiceNotified = true;} catch (Exception e) {Log.e(TAG, "Unable to notify Usb service", e);}}

这个方法很简单,通过ADB服务,设置允许调试。

mKey是什么呢?就是设备指纹,即我们常说的设备SN。

2.2 授权ADB调试5555端口

device/qcom/lahaina/init.target.rc

    #Allow access to memory hotplug device attributeschown system system /sys/kernel/mem-offline/anon_migrate# ==== modify start===== zhouronghua open adb debug port 5555setprop service.adb.tcp.port 5555# ==== modify end=====

2.3 接收到USB连接默认开启USB调试

frameworks/base/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java

在其中有监听USB连接和断开的广播接收器UsbDisconnectedReceiver,

private class UsbDisconnectedReceiver extends BroadcastReceiver {
...(省略)@Overridepublic void onReceive(Context content, Intent intent) {String action = intent.getAction();if (!UsbManager.ACTION_USB_STATE.equals(action)) {return;}// ====== modify begin ==========// fix: zhouronghua usb debug default auth// boolean connected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false);boolean connected = false;if (!connected) {Log.d(TAG, "USB disconnected, notifying service");// notifyService(false);mActivity.finish();}try {IBinder b = ServiceManager.getService(USB_SERVICE);IUsbManager service = IUsbManager.Stub.asInterface(b);service.allowUsbDebugging(true, mKey);} catch (Exception e) { Log.e(TAG, "Unable to notify Usb service", e);}// =========== modify end ==========}}

http://www.hkea.cn/news/514052/

相关文章:

  • wordpress 相册 主题seo整站优化技术培训
  • 做窗帘网站图片百度自动点击器下载
  • 飘雪影视大全免费观看视频快推达seo
  • 做网站的装饰标语seo宣传网站
  • 国外 平面设计 网站百度收录
  • 做网站话术简述搜索引擎的工作原理
  • 现在建设网站赚钱吗seo外链论坛
  • 青海网站建设企业海南百度竞价推广
  • 南京做网站yuanmus电脑突然多了windows优化大师
  • 美国做deals的网站软文营销经典案例优秀软文
  • 招标网站怎么做吴江seo网站优化软件
  • 苏州建设工程协会网站seo去哪里学
  • 上海正规网站制作价格可口可乐软文营销案例
  • 番禺网站 建设信科网络站长之家ping
  • 建筑工程施工承包合同关键词优化报价推荐
  • 网站可以免费看企业网站系统
  • 中华人民共和国建设部网站seo怎么快速提高排名
  • 南宁做网站的有几家东莞网络营销网站建设
  • 苏州知名网站建设开发新区seo整站优化公司
  • 政府建设网站计划书品牌营销策略包括哪些内容
  • 深圳市做网站百度seo排名点击器app
  • 五莲网站建设维护推广网络营销推广及优化方案
  • 重庆网红整站多关键词优化
  • 动易网站cms一级消防工程师考试
  • wordpress更新报错想找搜索引擎优化
  • 提供网站建设费用资源网
  • wordpress怎么使用主题seo优化评论
  • 柳州做网站如何建网站详细步骤
  • 黄岛做网站哪家好四川seo关键词工具
  • dede门户网站模版写软文推广