android Q 首次开机默认值adb调试设定

这里主要是USB 默认不要打开,如果要打开就设置成1就行了。

首次开机生效,后面重启不影响

 

代码如下,测试10.0是OK 的。

diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/SystemBars.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/SystemBars.java
old mode 100644
new mode 100755
index 4285af0..af72e86
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/SystemBars.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/SystemBars.java
@@ -21,6 +21,12 @@ import com.android.systemui.statusbar.phone.StatusBar;
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
 
+import android.provider.Settings;
+
+import android.content.pm.IPackageManager;
+import android.content.pm.PackageManager;
+import android.os.ServiceManager;
+import android.os.Build;
 /**
  * Ensure a single status bar service implementation is running at all times, using the in-process
  * implementation according to the product config.
@@ -29,6 +35,8 @@ public class SystemBars extends SystemUI {
     private static final String TAG = "SystemBars";
     private static final boolean DEBUG = false;
     private static final int WAIT_FOR_BARS_TO_DIE = 500;
+ // private final PackageManager mPm;
+    private  IPackageManager mIPm;
 
     // in-process fallback implementation, per the product config
     private SystemUI mStatusBar;
@@ -37,6 +45,16 @@ public class SystemBars extends SystemUI {
     public void start() {
         if (DEBUG) Log.d(TAG, "start");
         createStatusBarFromConfig();
+
+               // mPm = context.getPackageManager();
+        mIPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
+               try{
+                       if(mIPm.isFirstBoot() && Build.TYPE.equals("user") ){
+                       Log.d(TAG, "isFirstBoot true");
+                       Settings.Global.putInt(mContext.getContentResolver(),Settings.Global.ADB_ENABLED, 0);
+                       }
+               }catch( Exception e){
+               }
     }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值