[MTK]如何默认打开user debug 选项
来源:互联网 发布:杭州淘宝拍照基地 编辑:程序博客网 时间:2024/05/16 12:06
http://blog.csdn.net/duanlove/article/details/9670765
如何默认打开user debug 选项
[Keyword]
user debug root
[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);
mContentResolver.registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.ADB_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);
// 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 修改类似
----------------------------------------------------------------------------------------------------------------------------------------
今天需要编译一个android4.2.2 的user版本来测试;
android编译相关的东西在源码的build目录下,全编前需要执行
. build/envsetup.sh
执行上面的shell脚本会include一些其他目录下的shell脚本,以及声明一些命令函数,比如说接下来执行的choosecombo命令;
1 2 3 4 5 6 7 8 910111213
function choosecombo(){ choosetype $1 echo echo chooseproduct $2 echo echo choosevariant $3 echo set_stuff_for_environment printconfig}
choosecombo release msm8960 eng;
release表示的是Build type;(choose type) type有release和debug两个选项
msm8960表示的是product;(choose product) product有genric和msm8960,当然product根据项目不同是有不同选项的;
eng表示的是版本类型;(choose variant) variant有user,userdebug,eng三个选项
通过adb shell中执行getprop persist.sys.usb.config,可以看到系统usb的相关选项,persist.sys.usb.config显示的就是当前系统关于usb选项的系统配置;
diag,serial_smd,serial_tty,rmnet_bam,mass_storage,adb
全编脚本中make命令会调用build/core/**main.mk**,在里面可以看到一段关于debuggable的编译选项,赋值ADDITIONAL_DEFAULT_PROPERTIES;
123456789
ifeq (true,$(strip $(enable_target_debugging))) # Target is more debuggable and adbd is on by default ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1 # Include the debugging/testing OTA keys in this build. INCLUDE_TEST_OTA_KEYS := trueelse # !enable_target_debugging # Target is less debuggable and adbd is off by default ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0endif # !enable_target_debugging
并且
1
include $(BUILD_SYSTEM)/Makefile
在build/core/Makefile中的
1 2 3 4 5 6 7 8 9101112131415161718
# default.propINSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.propALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)ADDITIONAL_DEFAULT_PROPERTIES := $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))ADDITIONAL_DEFAULT_PROPERTIES += $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))ADDITIONAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, $(ADDITIONAL_DEFAULT_PROPERTIES),=)$(INSTALLED_DEFAULT_PROP_TARGET): @echo Target buildinfo: $@ @mkdir -p $(dir $@) $(hide) echo "#" > $@; echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; echo "#" >> $@; $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), echo "$(line)" >> $@;) build/tools/post_process_props.py $@
执行**post_process_props.py**脚本文件,**post_process_props.py会根据main.mk中的ro.debuggable指定的值来生成default.prop的persist.sys.usb.config;**
**
**
1 2 3 4 5 6 7 8 91011121314
# 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");
如果想要编译user版本的时候打开adb,修改
1
prop.put("persist.sys.usb.config", "none");
为
1
prop.put("persist.sys.usb.config", "adb");
即可;
eng版本的default.prop
1234567
## ADDITIONAL_DEFAULT_PROPERTIES#ro.secure=0ro.allow.mock.location=1ro.debuggable=1persist.sys.usb.config=adb
默认user版本default.prop
**
**
1234567
## ADDITIONAL_DEFAULT_PROPERTIES#ro.secure=1ro.allow.mock.location=1ro.debuggable=0persist.sys.usb.config=none
以上结论经过自己验证可行,如有错误之处,希望能够指出;
另外,针对user版本上无法进行usb debug,可以在settings-About phone-Build number上点击N次,然后就会提示“No need,you are already a developer”,这时,settings中
就会出现Develper options选项,进去就可以打开usb debug了;
声明:eoe文章著作权属于作者,受法律保护,转载时请务必以超链接形式附带如下信息
原文作者: cnhua5
原文地址: http://my.eoe.cn/cnhua5/archive/19725.html
- [MTK]如何默认打开user debug 选项
- [MTK]如何默认打开user debug 选项
- [MTK]如何默认打开user debug 选项
- [FAQ04776]如何默认打开user版本 debug 选项, 默认打开adb 连接
- 如何默认打开user版本 debug 选项, 默认打开adb 连接
- [FAQ04776]如何默认打开user版本 debug 选项, 默认打开adb 连接
- 如何默认打开user版本 debug 选项, 默认打开adb 连接
- MTK 如何默认打开adb debug
- MTK Android user版本如何打开root权限
- MTK Android user版本如何打开root权限
- 如何把"设置--安全--未知来源“默认打开(mtk)
- android user 版本如何默认adb调试为打开
- Android 6.0 如何默认打开user版本的root权限
- Android编译选项中eng、user、user-debug主要区别
- MTK平台打开uart默认输出log
- MTK屏幕闪屏如何Debug
- linux中设置默认打开vim选项
- 【MTK】如何开关默认USB调试功能
- IOS学习之路 第一天
- Quantum(Grizzly) quantum agent(OVS)工作流
- [译] THREE.JS入门教程-2.着色器-上
- j2ee 面试
- TCXGRID控件常用属性介绍
- [MTK]如何默认打开user debug 选项
- 计算机视觉领域的一些牛人博客,超有实力的研究机构等的网站链接
- C++ Primer(第五版) 学习笔记
- Qt资源
- AJAX缓存问题
- java通讯录
- yii中如何显示静态页面
- [译] THREE.JS入门教程-3.着色器-下
- IE对于overflow:hidden;及其它CSS属性不兼容问题