标签:
由于项目需要,需要发布版本默认开启调试模式,修改方式如下:
1.开启开发者模式
context.getSharedPreferences(DevelopmentSettings.PREF_FILE,Context.MODE_PRIVATE).edit().putBoolean(
DevelopmentSettings.PREF_SHOW, true).apply();
2.勾选USB调试
Settings.Global.putInt(context.getContentResolver(), Settings.Global.ADB_ENABLED, 1);
3.去掉USB插入时的授权提示
修改frameworks\base\packages\SystemUI\src\com\android\systemui\usb\UsbDebuggingActivity.java的如下内容:
@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); if (!connected) { mActivity.finish(); }*/ boolean connected = false; //给connect赋值,关掉UI if (!connected) { mActivity.finish(); } 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); } }
标签:
原文地址:http://www.cnblogs.com/suxiaoqi/p/4882297.html