当前位置: 首页 > 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/444743/

相关文章:

  • 做淘宝美工需要知道的网站app软件推广平台
  • 做自己个人网站搜索竞价
  • 兰州网站优化哪家好手机系统流畅神器
  • 广东深圳住房和城乡建设部网站文章优化软件
  • java制作动态网站开发怎么可以让百度快速收录视频
  • 做网站管理好吗阳泉seo
  • 网站排名优化建设seo人人网
  • html5可以做动态网站惠州seo计费
  • 商城网站带宽控制河南网站建设哪家公司好
  • 贵阳网络公司网站建设网络推广公司深圳
  • 企业网站建设公司电话西安seo分析报告怎么写
  • 岳阳市政府网网站seo优化报告
  • 门头沟网站建设外贸谷歌推广
  • 铜陵市住房和城乡建设委员会网站中国最新疫情最新消息
  • 动态网站建设 教程接广告推广的平台
  • 人力资源和社会保障部是干什么的seo最新快速排名
  • 网站标题关键优化网络营销代运营外包公司
  • 罗山网站建设seo网络推广优化
  • 如何在eclipse上做网站网站链接查询
  • 企业网站如何设计网页直通车推广计划方案
  • 简单的购物网站设计seo网络推广知识
  • 做众筹的网站关键词网站推广
  • 做网站 页面自适应渠道推广
  • 广东企业网站建设策划高端网站设计公司
  • wordpress文章批量编辑网站优化方案模板
  • 北京互联网公司开发的网站今日关注
  • 网站限制上传图片大小免费网络推广100种方法
  • 提供网站建设服务的网站价格快速推广
  • 政府网站建设原则 统筹规划进入百度官网
  • 网站如何做等级保护谷歌搜索引擎363