android默认打开开发者的adb调试

android默认打开开发者的adb调试

打开开关

--- a/alps/frameworks/base/services/core/java/com/android/server/adb/AdbService.java
+++ b/alps/frameworks/base/services/core/java/com/android/server/adb/AdbService.java
@@ -217,12 +217,15 @@ public class AdbService extends IAdbManager.Stub {
 
         // make sure the ADB_ENABLED setting value matches the current state
         try {
-            Settings.Global.putInt(mContentResolver,
-                    Settings.Global.ADB_ENABLED, mAdbEnabled ? 1 : 0);
+            //Settings.Global.putInt(mContentResolver,
+            //        Settings.Global.ADB_ENABLED, mAdbEnabled ? 1 : 0);
+                       Settings.Global.putInt(mContentResolver,
+                    Settings.Global.ADB_ENABLED, 1);
         } catch (SecurityException e) {
             // If UserManager.DISALLOW_DEBUGGING_FEATURES is on, that this setting can't be changed.
             Slog.d(TAG, "ADB_ENABLED is restricted.");
         }
+               SystemProperties.set(USB_PERSISTENT_CONFIG_PROPERTY, "adb");
     }

默认设备上授权

frameworks/base/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java
在oncreate方法最后加上如下代码


+               
+               try{
+                       IBinder b_adb = ServiceManager.getService(ADB_SERVICE);
+                       IAdbManager adbservice = IAdbManager.Stub.asInterface(b_adb);
+                       adbservice.allowDebugging(true, mKey);
+                       finish();
+               }catch (Exception e) {
+                       Log.e(TAG, "Unable to notify Usb service", e);
+               }
     }


你可能感兴趣的:(android系统,android,adb,java)