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
}
}
在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
}
}
相关文章推荐
- [MTK]如何默认打开user debug 选项
- [FAQ04776]如何默认打开user版本 debug 选项, 默认打开adb 连接
- [MTK]如何默认打开user debug 选项
- 如何默认打开user版本 debug 选项, 默认打开adb 连接
- Android 6.0 如何默认打开user版本的root权限【转】
- 如何默认打开user版本 debug 选项, 默认打开adb 连接
- [FAQ04776]如何默认打开user版本 debug 选项, 默认打开adb 连接
- Android 6.0 如何默认打开user版本的root权限
- android user 版本如何默认adb调试为打开【转】
- [FAQ04776]如何默认打开user版本 debug 选项, 默认打开adb 连接【转】
- [MTK]如何默认打开user debug 选项
- android user 版本如何默认adb调试为打开
- android user版本如何打开root权限
- 修改eclipse android 默认debug 签名
- Android底部弹窗的正确打开方式
- Android默认打开USB adb调试
- 打开android debug设备系统调试
- Android修改Eclipse 中的Default debug keystore路径,以及修改android的AVD默认路径
- msm8909+android5.1.1--打开调试(debug)串口
- Android修改Eclipse 中的Default debug keystore路径,以及修改android的AVD默认路径