Android User版本默认开启usb调试
近来接到项目反馈,客户要求设备默认开启usb调试以方便设备调试,具体修改参照如下:
/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
// make sure the ADB_ENABLED setting value matches the current state
try {
Settings.Global.putInt(mContentResolver,
- Settings.Global.ADB_ENABLED, mAdbEnabled ? 1 : 0);
+ Settings.Global.ADB_ENABLED, 1);
} catch (SecurityException e) {
// If UserManager.DISALLOW_DEBUGGING_FEATURES is on, that this setting can't be changed.
/frameworks/base/services/usb/java/com/android/server/usb/UsbDebuggingManager.java
case MESSAGE_ADB_CONFIRM: {
if ("trigger_restart_min_framework".equals(
SystemProperties.get("vold.decrypt"))) {
Slog.d(TAG, "Deferring adb confirmation until after vold decrypt");
if (mThread != null) {
mThread.sendResponse("NO");
}
break;
}
String key = (String)msg.obj;
String fingerprints = getFingerprints(key);
if ("".equals(fingerprints)) {
if (mThread != null) {
mThread.sendResponse("NO");
}
break;
}
mFingerprints = fingerprints;
- startConfirmation(key, mFingerprints);
+ allowUsbDebugging(true,key);
break;
}
重新编译验证,修改生效,User版本usb调试已默认开启