adb shell root的方法
来源:互联网 发布:gotv源码 网盘 贴吧 编辑:程序博客网 时间:2024/05/21 06:52
android 4.2之后,因为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 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 修改类似
// 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; 即可。
static int should_drop_privileges() {
#ifndef ALLOW_ADBD_ROOT
// return 1;
return 0;
#else /* ALLOW_ADBD_ROOT */
完成编译后,即可随心所欲的进行adb操作,安装应用或者adb push文件,方便开发。android4.3的方法也是一样。
0 0
- adb shell root的方法
- adb shell root权限
- adb Shell root 权限
- Adb shell获取root权限
- adb shell获取root权限
- adb shell获取root权限
- adb shell获取root权限
- 解决adb shell root权限
- adb shell获取root权限
- root后,adb shell 失败
- 转adb Shell root 权限
- android adb root方法
- android adb root方法
- Android adb shell启动应用程序的方法
- Android adb shell启动应用程序的方法
- Android adb shell启动应用程序的方法
- Android adb shell启动应用程序的方法
- Android adb shell启动应用程序的方法
- Java解惑二:字符字谜
- 让一个div层浮在最上层的方法
- Access android app data
- jQuery-Mobile-Bootstrap-Theme
- 三星数码相机误删的文件怎么恢复,相机照片删除了怎么恢复
- adb shell root的方法
- XSLT初步
- Java解惑三:循环之谜
- fdisk
- codeforce 18B
- 黑马程序员——面试题——2.银行业务调度系统
- swift开发语言中文文档
- 通用文件操作类的设计
- simhash算法原理和代码实现