Method of adb shell root

Source: Internet
Author: User

After Android 4.2, because the ADB control, unified use of persist.sys.usb.config to control, so the corresponding set point also changed to frameworks/base/service/...../usb/ Usbdevicemanager.java, you can also see similar code such as:
Public Usbhandler (Looper Looper) {
Persist.sys.usb.config should never be unset. But if it's, set it to "ADB"
So we had a chance of debugging what happened.
Mdefaultfunctions = Systemproperties.get ("Persist.sys.usb.config", "adb");
Sanity Check the Sys.usb.config system property
This is 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);p ublic void SystemReady () {
Make sure the Adb_enabled setting value matches the current state
Settings.Secure.putInt (Mcontentresolver, Settings.Secure.ADB_ENABLED, madbenabled 1:0);

The ADB configuration in this persist.sys.usb.config is set in alps/build/tools/post_process_props.py according to ro.debuggable = 1 or, 1 is open adb, 0 is off ADB Debug. And this ro.debuggable is set in Alps/build/core/main.mk, and the 2.3 changes are similar

However, after you open this, for the user version of the ADB shell open or shell permissions, rather than root permissions, if you need root permission, you need to change the SYSTEM/CORE/ADB/ADB.C inside the Should_drop_ Privileges () This function, return 0 at #ifndef Allow_adbd_root; instead of return 1; Can.

static int should_drop_privileges () {
#ifndef Allow_adbd_root
return 1;
return 0;
#else/* Allow_adbd_root */

After the compilation, you can do the ADB operation, install the application or ADB push file, easy to develop. The same is true of the android4.3 method.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.