zoukankan      html  css  js  c++  java
  • android user版本默认开启调试模式

    由于项目需要,需要发布版本默认开启调试模式,修改方式如下:

    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插入时的授权提示

     修改frameworksasepackagesSystemUIsrccomandroidsystemuiusbUsbDebuggingActivity.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);
                }
            }                
    
  • 相关阅读:
    257. Binary Tree Paths
    324. Wiggle Sort II
    315. Count of Smaller Numbers After Self
    350. Intersection of Two Arrays II
    295. Find Median from Data Stream
    289. Game of Life
    287. Find the Duplicate Number
    279. Perfect Squares
    384. Shuffle an Array
    E
  • 原文地址:https://www.cnblogs.com/suxiaoqi/p/4882297.html
Copyright © 2011-2022 走看看