您的位置:首页 > 移动开发 > Android开发

android user版默认打开debug 不跳弹窗

2018-01-30 17:16 169 查看
默认打开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
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: