Android系统去掉 USB插入调试确认框

修改位置:
frameworks\base\packages\SystemUI\src\com\android\systemui\usb\UsbDebuggingActivity.java

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
 
        if (SystemProperties.getInt("service.adb.tcp.port", 0) == 0) {
            mDisconnectedReceiver = new UsbDisconnectedReceiver(this);
        }
 
        Intent intent = getIntent();
        String fingerprints = intent.getStringExtra("fingerprints");
        mKey = intent.getStringExtra("key");
 
        if (fingerprints == null || mKey == null) {
            finish();
            return;
        }
      
       //1:去掉弹窗的初始化
      /*  final AlertController.AlertParams ap = mAlertParams;
        ap.mTitle = getString(R.string.usb_debugging_title);
        ap.mMessage = getString(R.string.usb_debugging_message, fingerprints);
        ap.mPositiveButtonText = getString(android.R.string.ok);
        ap.mNegativeButtonText = getString(android.R.string.cancel);
        ap.mPositiveButtonListener = this;
        ap.mNegativeButtonListener = this;
        // add "always allow" checkbox
        LayoutInflater inflater = LayoutInflater.from(ap.mContext);
        View checkbox = inflater.inflate(com.android.internal.R.layout.always_use_checkbox, null);
        mAlwaysAllow = (CheckBox)checkbox.findViewById(com.android.internal.R.id.alwaysUse);
        mAlwaysAllow.setText(getString(R.string.usb_debugging_always));
        ap.mView = checkbox;
        setupAlert();*/
 
       /:2:将onclik事件的代码移植过来 并设置 allow & alwaysAllow  为true
		boolean allow =  true;// (which == AlertDialog.BUTTON_POSITIVE);
        boolean alwaysAllow = true;//allow && mAlwaysAllow.isChecked();
        try {
            IBinder b = ServiceManager.getService(USB_SERVICE);
            IUsbManager service = IUsbManager.Stub.asInterface(b);
            if (allow) {
                service.allowUsbDebugging(alwaysAllow, mKey);
            } else {
                service.denyUsbDebugging();
            }
        } catch (Exception e) {
            Log.e(TAG, "Unable to notify Usb service", e);
        }
        finish();
    }
发布了70 篇原创文章 · 获赞 24 · 访问量 8261

猜你喜欢

转载自blog.csdn.net/angelsmiling/article/details/103678754