Android源码定制(二) 去除默认USB授权确认框

0. 修改文件

>1. UsbDebuggingActivity.java

文件位置:frameworks/base/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java

修改点1:UsbDisconnectedReceiver-> onReceive大概在129行处,把

boolean connected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false);修改成`boolean connected = true

        public void onReceive(Context content, Intent intent) {
            String action = intent.getAction();
            if (!UsbManager.ACTION_USB_STATE.equals(action)) {
                return;
            }
            //boolean connected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false);
            // Qiled start close authorization dialog
            //直接关闭对话框
            boolean connected = false; 
            
            // Qiled end
            if (!connected) {
                mActivity.finish();
            }
        }

修改点2:大概在157行的onClick方法中.

allowalwaysAllow修改成true, 修改allow可以直接到service.allowDebugging,现在需要传入一个alwaysAllow,我们把它改成true就好了。

    public void onClick(DialogInterface dialog, int which) {
        boolean allow = (which == AlertDialog.BUTTON_POSITIVE);
        boolean alwaysAllow = allow && mAlwaysAllow.isChecked();
        // Qiled Start  always allow
        allow = true;
        alwaysAllow = true;
        try {
            IBinder b = ServiceManager.getService(ADB_SERVICE);
            IAdbManager service = IAdbManager.Stub.asInterface(b);
            if (allow) {
                service.allowDebugging(alwaysAllow, mKey);
            } else {
                service.denyDebugging();
            }
        } catch (Exception e) {
            Log.e(TAG, "Unable to notify Usb service", e);
        }
        finish();
    }

1.编译

切换到源码编译目录

cd /aosp10/
source build/envsetup.sh
lunch 16
make -j100
// make -j100 , 是使用后100线程操作,使劲燥~

当看到#### build completed successfully (05:57 (mm:ss)) ####字符串的时候,我们的源码就编译好了~

然后就可以去刷机了~

adb reboot bootloader
cd ~/aosp10/out/target/product/sailfish
fastboot flashall -w
// -w 是双清