Android 4.4系统,User模式adb默认开启,取消授权,开启root调试记录

开启User模式adb,取消授权,修改如下:

1、 /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
# 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

#把0改为1

ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
endif # !enable_target_debugging

2,

frameworks/base/services/java/com/android/server/usb/UsbDeviceManager.java

修改以下内容:

public class UsbDeviceManager {
mUseUsbNotification = !massStorageSupported;

// make sure the ADB_ENABLED setting value matches the current state
 Settings.Global.putInt(mContentResolver, Settings.Global.ADB_ENABLED, mAdbEnabled ? 1 : 0);


/* SPRD: reset the usb functions flag for usb function and SprdUsbSettings display @{ */
if (Settings.Global.getInt(mContentResolver,

 将 mAdbEnabled ? 1 : 0 修改为 1,即

Settings.Global.putInt(mContentResolver, Settings.Global.ADB_ENABLED, 1);

开启User模式 Adb root权限,修改如下:

1,system/core/adb/Android.mk 

修改以下内容:

LOCAL_SRC_FILES :=
LOCAL_CFLAGS := -O2 -g -DADB_HOST=0 -Wall -Wno-unused-parameter
LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE

ifneq (,$(filter user userdebug eng,$(TARGET_BUILD_VARIANT)))
LOCAL_CFLAGS += -DALLOW_ADBD_ROOT=1
endif

LOCAL_MODULE := adbd

将红色部分注释掉

2,/system/core/adb/adb.c

修改以下内容:

static void drop_capabilities_bounding_set_if_needed() {

static int should_drop_privileges() {
#ifndef ALLOW_ADBD_ROOT
return 1;
#else /* ALLOW_ADBD_ROOT */
int secure = 0;
char value[PROPERTY_VALUE_MAX];
@@ -1243,7 +1243,7 @@ static int should_drop_privileges() {
}
}
}
 return secure;
#endif /* ALLOW_ADBD_ROOT */
}
#endif /* !ADB_HOST */

 将 标红的部分修改为 return 0

原文地址:https://www.cnblogs.com/acesui/p/12509489.html