默认打开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
}
}
本文介绍了一种在Android设备上默认打开debug调试的方法。通过修改PhoneStatusBar.java中的makeStatusBarView()方法和UsbDebuggingActivity.java文件,可以在不触发弹窗的情况下直接启用ADB调试功能。
6880

被折叠的 条评论
为什么被折叠?



