去掉SystemUI apk后adb调试不生效

去掉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下的


    com.android.systemui/com.android.systemui.usb.UsbDebuggingActivity

    
    com.android.systemui/com.android.systemui.usb.UsbDebuggingSecondaryUserActivity

去掉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);
        }

你可能感兴趣的:(Android系统开发)