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.