Android Q user版本默认关闭USB调试

Android Q user版本默认关闭USB调试

  1. 文件路径
    android/frameworks/base/packages/SystemUI/src/com/android/systemui/SystemBars.java
  2. 代码块
--- a/packages/SystemUI/src/com/android/systemui/SystemBars.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemBars.java
@@ -21,6 +21,13 @@ 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,7 +36,7 @@ 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  IPackageManager mIPm;
     // in-process fallback implementation, per the product config
     private SystemUI mStatusBar;
 
@@ -37,6 +44,16 @@ public class SystemBars extends SystemUI {
     public void start() {
         if (DEBUG) Log.d(TAG, "start");
         createStatusBarFromConfig();
+        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, 1);
+            }
+        }catch( Exception e){
+            Log.d(TAG,"Failed to turn off the USB DEBUG option");
+        }
+
     }

上一篇:贝壳云P1刷机记录(5.10内核Armbian)


下一篇:USB Type-C 接口设计