去掉SystemUI后打开adb调试,连接adb报error: device unauthorized.
This adbd’s $ADB_VENDOR_KEYS is not set; try ‘adb kill-server’ if that seems wrong.
Otherwise check for a confirmation dialog on your device.原因是打开adb调试应该会出现Debug权限确认的Dialog,其实该dialog是一个activity,启动的是frameworks/base/core/res/res/values/config.xml下的
<!-- Name of the activity or service that prompts the user to reject, accept, or whitelist
an adb host's public key, when an unwhitelisted host connects to the local adbd.
Can be customized for other product types -->
<string name="config_customAdbPublicKeyConfirmationComponent"
>com.android.systemui/com.android.systemui.usb.UsbDebuggingActivity</string>
<!-- Name of the activity that prompts the secondary user to acknowledge she/he needs to
switch to the primary user to enable USB debugging.
Can be customized for other product types -->
<string name="config_customAdbPublicKeyConfirmationSecondaryUserComponent"
>com.android.systemui/com.android.systemui.usb.UsbDebuggingSecondaryUserActivity</string>
去掉SystemUI后无法进入UsbDebuggingActivity或UsbDebuggingSecondaryUserActivity去授权,只需要在启动该activity的代码块中去默认开启debug权限即可,在frameworks/base/services/usb/java/com/android/server/usb/UsbDebuggingManager.java的private void startConfirmation(String key, String fingerprints) 方法内添加如下代码
if(fingerprints == null){
return;
}
try {
IBinder b = ServiceManager.getService(Context.USB_SERVICE);
IUsbManager service = IUsbManager.Stub.asInterface(b);
if (true) {
service.allowUsbDebugging(true, key);
} else {
service.denyUsbDebugging();
}
} catch (Exception e) {
Slog.e(TAG, "Unable to notify Usb service", e);
}