[FAQ04776]如何默认打开user版本 debug 选项, 默认打开adb 连接【转】
本文转载自:http://blog.csdn.net/thinkinwm/article/details/24865933
Description]
如何默认打开user 版本的USB debug 选项, 默认打开adb 连接
[Keyword]
量产版本 user usb debug root adb 连接
[Solution]
1. 在android 4.0 之前,这个设置是在frameworks/base/service/..../SystemServer.java 里面
设置会根据system property 的persist.service.adb.enable 来设置。您可以看到类似如代码:
- // make sure the ADB_ENABLED setting value matches the secure property value
- Settings.Secure.putInt(mContentResolver, Settings.Secure.ADB_ENABLED,
- "1".equals(SystemProperties.get("persist.service.adb.enable")) ? 1 : 0);
- // register observer to listen for settings changes
- mContentResolver.registerContentObserver(Settings.Secure.getUriFor(Settings.Secu
- ENABLED),false, new AdbSettingsObserver());
而这个persist.service.adb.enable 默认是放在在default.prop 中,在编译的时候在
build/core/main.mk 中确认,
- ifeq (true,$(strip $(enable_target_debugging)))
- # Target is more debuggable and adbd is on by default
- ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1 persist.service.adb.enable=1
- # Include the debugging/testing OTA keys in this build.
- INCLUDE_TEST_OTA_KEYS := true
- else # !enable_target_debugging
- # Target is less debuggable and adbd is off by default
- ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0 persist.service.adb.enable=0
- endif # !enable_target_debugging
您需要将: ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
persist.service.adb.enable=0 改成
ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1 persist.service.adb.enable=1
2. 在android 4.0 之后,因为adb 的控制,统一使用了persist.sys.usb.config 来控制,于是对
应的设置点也改到了frameworks/base/service/...../usb/UsbDeviceManager.java 中,您也可以
看到类似的代码如:
- public UsbHandler(Looper looper) {
- // persist.sys.usb.config should never be unset. But if it is, set it to "adb"
- // so we have a chance of debugging what happened.
- mDefaultFunctions = SystemProperties.get("persist.sys.usb.config", "adb");
- // sanity check the sys.usb.config system property
- // this may be necessary if we crashed while switching USB configurations
- String config = SystemProperties.get("sys.usb.config", "none");
- if (!config.equals(mDefaultFunctions)) {
- Slog.w(TAG, "resetting config to persistent property: " + mDefaultFunctions);
- SystemProperties.set("sys.usb.config", mDefaultFunctions);
- }
- mCurrentFunctions = mDefaultFunctions;
- String state = FileUtils.readTextFile(new File(STATE_PATH), 0, null).trim();
- updateState(state);
- mAdbEnabled = containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_ADB);
- public void systemReady() {
- // make sure the ADB_ENABLED setting value matches the current state
- Settings.Secure.putInt(mContentResolver, Settings.Secure.ADB_ENABLED, mAdbEnabled ?
- 1 : 0);
而这个persist.sys.usb.config 中adb 的配置是在alps/build/tools/post_process_props.py 中
根据ro.debuggable = 1 or 0 来设置,1 就是开启adb, 0 即关闭adb debug. 而这个
ro.debuggable 也是在alps/build/core/main.mk 中设置,和2.3 修改类似
不过您这样打开之后,对于user 版本adb shell 开启的还是shell 权限,而不是root 权限,如果
您需要root 权限,需要再改一下system/core/adb/adb.c 里面的should_drop_privileges() 这个
函数,在#ifndef ALLOW_ADBD_ROOT 时return 0; 而不是return 1; 即可。
---------------------------------------------------------------------------------------
1. 根据编译命令确定ro.debuggable
build/core/main.mk
- ## user/userdebug ##
- user_variant := $(filter user userdebug,$(TARGET_BUILD_VARIANT))
- enable_target_debugging := true
- tags_to_install :=
- ifneq (,$(user_variant))
- # Target is secure in user builds.
- ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
- ifeq ($(user_variant),userdebug)
- # Pick up some extra useful tools
- tags_to_install += debug
- # Enable Dalvik lock contention logging for userdebug builds.
- ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.lockprof.threshold=500
- else
- # Disable debugging in plain user builds.
- enable_target_debugging :=
- endif
- # enable dex pre-optimization for all TARGET projects in default to
- # speed up device first boot-up
- #add by yanqi.liu for costomization @{
- ifneq ($(JRD_IS_GOAL_PERSO),true)
- WITH_DEXPREOPT := true
- endif
- #}
- # Turn on Dalvik preoptimization for user builds, but only if not
- # explicitly disabled and the build is running on Linux (since host
- # Dalvik isn't built for non-Linux hosts).
- ifneq (true,$(DISABLE_DEXPREOPT))
- ifeq ($(user_variant),user)
- ifeq ($(HOST_OS),linux)
- ifneq ($(JRD_IS_GOAL_PERSO),true)
- WITH_DEXPREOPT := true
- endif
- endif
- endif
- endif
- # Disallow mock locations by default for user builds
- ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=0
- else # !user_variant
- # Turn on checkjni for non-user builds.
- # Kirby: turn off it temporarily to gain performance {
- # ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1
- # ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=0
- # } Kirby
- # Set device insecure for non-user builds.
- ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0
- # Allow mock locations by default for non user builds
- ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1
- endif # !user_variant
- # always enable aed
- ADDITIONAL_DEFAULT_PROPERTIES += persist.mtk.aee.aed=on
- # Turn on Jazz AOT by default if not explicitly disabled and the build
- # is running on Linux (since host Dalvik isn't built for non-Linux hosts).
- ifneq (true,$(DISABLE_JAZZ))
- ifeq ($(strip $(MTK_JAZZ)),yes)
- ifeq ($(HOST_OS),linux)
- # Build host dalvikvm which Jazz AOT relies on.
- WITH_HOST_DALVIK := true
- WITH_JAZZ := true
- endif
- endif
- endif
- ifeq (true,$(strip $(enable_target_debugging)))
- # Target is more debuggable and adbd is on by default
- ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1
- ADDITIONAL_DEFAULT_PROPERTIES += ro.adb.secure=0
- # Include the debugging/testing OTA keys in this build.
- INCLUDE_TEST_OTA_KEYS := true
- else # !enable_target_debugging
- # Target is less debuggable and adbd is off by default
- ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
- ADDITIONAL_DEFAULT_PROPERTIES += ro.adb.secure=1
- endif # !enable_target_debugging
2. 确定默认的usb功能
build/tools/post_process_props.py
- # Put the modifications that you need to make into the /system/build.prop into this
- # function. The prop object has get(name) and put(name,value) methods.
- def mangle_build_prop(prop):
- #pass
- #If ro.mmitest is true, then disable MTP, add mass_storage for default
- if prop.get("ro.mmitest") == "true":
- prop.put("persist.sys.usb.config", "mass_storage")
- # If ro.debuggable is 1, then enable adb on USB by default
- # (this is for userdebug builds)
- if prop.get("ro.build.type") == "eng":
- val = prop.get("persist.sys.usb.config").strip('\r\n')
- if val == "":
- val = "adb"
- else:
- val = val + ",adb"
- prop.put("persist.sys.usb.config", val)
- # UsbDeviceManager expects a value here. If it doesn't get it, it will
- # default to "adb". That might not the right policy there, but it's better
- # to be explicit.
- if not prop.get("persist.sys.usb.config"):
- prop.put("persist.sys.usb.config", "none");
- # Put the modifications that you need to make into the /system/build.prop into this
- # function. The prop object has get(name) and put(name,value) methods.
- def mangle_default_prop(prop):
- # If ro.debuggable is 1, then enable adb on USB by default
- # (this is for userdebug builds)
- if prop.get("ro.debuggable") == "1":
- val = prop.get("persist.sys.usb.config")
- if val == "":
- val = "adb"
- else:
- val = val + ",adb"
- prop.put("persist.sys.usb.config", val)
- # UsbDeviceManager expects a value here. If it doesn't get it, it will
- # default to "adb". That might not the right policy there, but it's better
- # to be explicit.
- if not prop.get("persist.sys.usb.config"):
- prop.put("persist.sys.usb.config", "none");
[FAQ04776]如何默认打开user版本 debug 选项, 默认打开adb 连接【转】的更多相关文章
- ionic新入坑-环境搭建+新建项目+打开低版本项目处理
是的.我又双叒叕入新坑了.想我大学的时候web-app刚火起来.还帮忙做了我们学校医务室系统的web-app页面部分呢.时间太紧最后也没出个完整的版本.那时候只是用H5简单做了web部分.是想着用ph ...
- maven 修改默认的JDK版本
maven jdk 版本配置 maven 默认使用的 jdk 版本 新建一个 maven 项目,如下 : 项目左下方出现一个感叹号,JRE 显示的是 1.5 版本.解决方式有两种,一种是配置 pom. ...
- Android 5.0 版本 USB 调试模式打开方法
Android 4.2 版本 USB 调试模式打开方法 1. 进入“设置”页面,点击“关于平板电脑”.见下图红色方框. 2. 疯狂点击“版本号”,见下图红色方框,直到出现“您现在处于开发者模式!” ...
- 修改linux下默认的python版本
首先在终端输入:python --verison 查看本机默认采用的python 版本 接着进入/usr/local/lib 目录查看当前系统中安装了多少个python版本 如果只有一个,就安装你需要 ...
- 转:使用vs2013打开VS2015的工程文件的解决方案(适用于大多数vs低版本打开高版本)
http://www.cnblogs.com/WayneLiu/p/5060277.html 前言:重装系统前我使用的是vs2015(有点装*),由于使用2015实在在班上太另类了, 导致我想在其他同 ...
- winform窗口打开后文本框的默认焦点设置
原文:http://blog.csdn.net/kongwei521/article/details/6871411 winform窗口打开后文本框的默认焦点设置,进入窗口后默认聚焦到某个文本框,两种 ...
- (转)Windows Server 2008 默认"照片库查看器" 无法打开图片, 只能用画图程序打开
1.解决[启用Win2008照片查看器] Win2008 中放了一些图片,本来以为可以象Win7那样直接用“照片查看器”打开,可是Win2008默认竟然是用“画图”打开的,非常不方便. 再仔细一看,“ ...
- 低版本的 opencv库的 vs2010 打开 高版本opencv
打开track.vcxproj文件, 注释掉跟版本有关的行就可. 本例子中,当用双击.sln用vs2010打开高版本的opencv项目时,会出现错误, 并且会有错误信息提示,双击该错误信息,就会打开该 ...
- VS2010打开旧版本MFC工程无对话框
解决方案: 左侧有个"资源视图",打开,里面就能找得到对话框,如果没有资源视图,就在菜单的视图选项里打开资源视图!
随机推荐
- properties类的基本使用方法
properties类的基本使用方法1.假设有“pp.properties”,内容有 age=22 2.java中用下面方法: Properties props = ...
- gitweb 搭建教程
1. 前言 git 是一个版本控制工具,类似svn. 本文内容主要涉及git仓库通过浏览器访问(用web的方式去查看git提交历史记录,tag,branch等信息),即gitweb. 效果图: 在这里 ...
- linux的cpu性能评估
linux的cpu性能评估 参考自:自学it网,http://www.zixue.it/. (1)利用vmstat命令监控系统CPU[test@localhost ~]$ vmstat 2 3 #每2 ...
- laravel的视图
//输出视图 //建立控制器方法public function hello_test(){ return view('member/hello_test',['name'=>'张三','age' ...
- Day 3 网络基础
网络基础 一.什么是互联网协议及为何要有互联网协议 ? 互联网协议:指的就是一系列统一的标准,这些标准称之为互联网协议.互联网的本质就是一系列的协议,总称为‘互联网协议’(Internet Proto ...
- ViewPager 无限循环遇到的坑 viewpager.setOffscreenPageLimit(2);
viewpager.setOffscreenPageLimit(limit);这个方法,是表示viewpage除了当前显示的页面外,左右个预加载的页面个数,也就是 为limit=2时表示当前一共加载了 ...
- centos 7 -- Disk Requirements: At least 134MB more space needed on the / filesystem.
用了幾年的centos7,今天執行yum update時,彈出一行有錯誤的提示:Disk Requirements: At least 134MB more space needed on the ...
- BeagleBone Black Industrial系统更新设置一贴通
前言 原创文章,转载引用务必注明链接.水平有限,欢迎指正. 本文使用markdown写成,为获得更好的阅读体验,推荐访问我的博客原文: http://www.omoikane.cn/2016/09/1 ...
- 关于 redux-saga 中 take 使用方法详解
本文介绍了关于redux-saga中take使用方法详解,分享给大家,具体如下: 带来一个自己研究好久的API使用方法. redux-saga中effect中take这个API使用方式,用的多的是ca ...
- Android——坐标系及转化
一.坐标系 Android应用层坐标系原点在左上角,坐标范围(0,0)——(width,height). Android底层坐标系原点在屏幕中央,坐标范围(-1000,,1000)——(1000,10 ...