默认打开debug调试
在PhoneStatusBar.java里面makeStatusBarView()方法加入:
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.ADB_ENABLED, /*mAdbEnabled ? 1 : 0*/1);
此时会有弹窗。
去弹窗,UsbDebuggingActivity.java修改:
private class UsbDisconnectedReceiver extends BroadcastReceiver {
private final Activity mActivity;
public UsbDisconnectedReceiver(Activity activity) {
mActivity = activity;
}
@Override
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);
boolean connected = false; // add by csc
if (!connected) {
mActivity.finish();
}
// begin add by csc
try {
IBinder b = ServiceManager.getService(USB_SERVICE);
IUsbManager service = IUsbManager.Stub.asInterface(b);
service.allowUsbDebugging(true, mKey);
} catch (Exception e) {
Log.e(TAG, "Unable to notify Usb service", e);
}
// end add by csc
}
}