android allow usb debugging,Android USB debugging 功能失效

艾修然
2023-12-01

1. 修改按Builder number 的次數成為開發者:

packages/app/setings/DeviceInfoSettings.java

static final int TAPS_TO_BE_A_DEVELOPER = 7;

DevelopmentSettings.PREF_SHOW = true;

2. packages/apps/Settings/src/com/android/settings/DevelopmentSettings.java

mEnableAdb = "USB debugging" check box

"Allow development settings?"

mAdbDialog = "Allow USB debugging?" dialog box

mAdbKeysDialog = "Revoke access to USB debugging from all computers you\'ve previously authorized?"

updateVerifyAppsOverUsbOptions()

private void updateVerifyAppsOverUsbOptions() {

updateCheckBox(mVerifyAppsOverUsb, Settings.Global.getInt(getActivity().getContentResolver(),

Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, 1) != 0);

mVerifyAppsOverUsb.setEnabled(enableVerifierSetting());

}

mVerifyAppsOverUsb

mVerifyAppsOverUsb = findAndInitCheckboxPref(VERIFY_APPS_OVER_USB_KEY);

"clear_adb_keys" 不見了

mClearAdbKeys = findPreference(CLEAR_ADB_KEYS);

if (!SystemProperties.getBoolean("ro.adb.secure", false)) {

if (debugDebuggingCategory != null) {

debugDebuggingCategory.removePreference(mClearAdbKeys);

}

}

The ADB host authentication functionality is enabled by default when the ro.adb.secure system property is set to 1, and there is no way to disable it via the system settings interface.

/default.prop doesn't set ro.adb.secure

current default.prop:

ro.secure=1

ro.allow.mock.location=0

ro.debuggable=1

persist.sys.usb.config=adb

but it should be something like this:

ro.secure=1

ro.allow.mock.location=0

ro.debuggable=0

persist.sys.usb.config=mtp

ro.adb.secure=1

How to set ro.adb.secure=1 ?

PRODUCT_DEFAULT_PROPERTY_OVERRIDES := \

$(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEFAULT_PROPERTY_OVERRIDES))

------------------------

Solution:

1. 修改 ./build/core/main.mk

ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1

+  ADDITIONAL_DEFAULT_PROPERTIES += ro.adb.secure=1

2. 修改  ./device/asus/flo/device.mk

+ PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \

+    persist.sys.usb.config=mtp

重build BSP, 觀察 root/default.prop 內容:

root$ cat default.prop

#

# ADDITIONAL_DEFAULT_PROPERTIES

#

ro.secure=1

ro.adb.secure=1

ro.allow.mock.location=0

ro.debuggable=1

persist.sys.usb.config=mtp,adb

燒到Nexus 平版, Debug 可以認到了

 类似资料: