SystemServer: initialize ADB before USB
USB depends on ADB to hold the state for ADB debugging enabled, so move it
to initialize before USB attempts to initialize. This removes a race
condition introduced by moving the source of truth for ADB debugging enabled
to the AdbService instead of UsbService.
Bug: 119765805
Test: boot emulator several times
Change-Id: Ib1f5ae0ceab5abe64e2d14b9e2b3a55c9919ad2f
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 9c6f4b3..701b292 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -1399,6 +1399,15 @@
traceEnd();
}
+ // Start ADB Debugging Service
+ traceBeginAndSlog("StartAdbService");
+ try {
+ mSystemServiceManager.startService(ADB_SERVICE_CLASS);
+ } catch (Throwable e) {
+ Slog.e(TAG, "Failure starting AdbService");
+ }
+ traceEnd();
+
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_USB_HOST)
|| mPackageManager.hasSystemFeature(
PackageManager.FEATURE_USB_ACCESSORY)
@@ -1409,15 +1418,6 @@
traceEnd();
}
- // Start ADB Debugging Service
- traceBeginAndSlog("StartAdbService");
- try {
- mSystemServiceManager.startService(ADB_SERVICE_CLASS);
- } catch (Throwable e) {
- Slog.e(TAG, "Failure starting AdbService");
- }
- traceEnd();
-
if (!isWatch) {
traceBeginAndSlog("StartSerialService");
try {