OSDN Git Service

Don't start first human user twice on headless-system mode.
authorFelipe Leme <felipeal@google.com>
Fri, 30 Aug 2019 16:26:05 +0000 (09:26 -0700)
committerFelipe Leme <felipeal@google.com>
Fri, 6 Sep 2019 22:01:13 +0000 (15:01 -0700)
It speeds up boot on automotive in about 25ms.

Bug: 128904478
Bug: 132111956

Test: manual verification
Test: atest CtsVoiceInteractionTestCases CtsAssistTestCases # on walleye and automotive

Merged-In: I37cdca09b5280193a07ed9951f2e386ed3cd2299
Change-Id: I37cdca09b5280193a07ed9951f2e386ed3cd2299
(cherry picked from commit 206c09b55331440ded234349dbbe9716b91a095a)

services/core/java/com/android/server/am/ActivityManagerService.java

index bb455cd..6c5bcf5 100644 (file)
@@ -9023,7 +9023,16 @@ public class ActivityManagerService extends IActivityManager.Stub
                 Integer.toString(currentUserId), currentUserId);
         mBatteryStatsService.noteEvent(BatteryStats.HistoryItem.EVENT_USER_FOREGROUND_START,
                 Integer.toString(currentUserId), currentUserId);
-        mSystemServiceManager.startUser(currentUserId);
+
+        // On Automotive, at this point the system user has already been started and unlocked,
+        // and some of the tasks we do here have already been done. So skip those in that case.
+        // TODO(b/132262830): this workdound shouldn't be necessary once we move the
+        // headless-user start logic to UserManager-land
+        final boolean bootingSystemUser = currentUserId == UserHandle.USER_SYSTEM;
+
+        if (bootingSystemUser) {
+            mSystemServiceManager.startUser(currentUserId);
+        }
 
         synchronized (this) {
             // Only start up encryption-aware persistent apps; once user is
@@ -9047,9 +9056,6 @@ public class ActivityManagerService extends IActivityManager.Stub
                     throw e.rethrowAsRuntimeException();
                 }
             }
-            // On Automotive, at this point the system user has already been started and unlocked,
-            // and some of the tasks we do here have already been done. So skip those in that case.
-            final boolean bootingSystemUser = currentUserId == UserHandle.USER_SYSTEM;
 
             if (bootingSystemUser) {
                 mAtmInternal.startHomeOnAllDisplays(currentUserId, "systemReady");