Synchronously finish boot when user starts in background
Previously call to finishUserBoot method was delayed until ActivityManager
enters idle state. This could lead to unpredictable timeouts, especially
when AM was already idle.
Bug: 26762234
Change-Id: Iae90c3a9b09ff675478b42271469866e1604df0f
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 11dd8a3..2f1c76e 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -1548,14 +1548,6 @@
mService.mUserController.finishUserSwitch(startingUsers.get(i));
}
}
- // Complete starting up of background users
- if (mStartingBackgroundUsers.size() > 0) {
- startingUsers = new ArrayList<UserState>(mStartingBackgroundUsers);
- mStartingBackgroundUsers.clear();
- for (int i = 0; i < startingUsers.size(); i++) {
- mService.mUserController.finishUserBoot(startingUsers.get(i));
- }
- }
}
mService.trimApplications();
@@ -2747,15 +2739,6 @@
return homeInFront;
}
- /**
- * Add background users to send boot completed events to.
- * @param userId The user being started in the background
- * @param uss The state object for the user.
- */
- public void startBackgroundUserLocked(int userId, UserState uss) {
- mStartingBackgroundUsers.add(uss);
- }
-
/** Checks whether the userid is a profile of the current user. */
boolean isCurrentProfileLocked(int userId) {
if (userId == mCurrentUser) return true;
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java
index a21570ce..551f332 100644
--- a/services/core/java/com/android/server/am/UserController.java
+++ b/services/core/java/com/android/server/am/UserController.java
@@ -202,11 +202,11 @@
}
}
- void finishUserBoot(UserState uss) {
+ private void finishUserBoot(UserState uss) {
finishUserBoot(uss, null);
}
- void finishUserBoot(UserState uss, IIntentReceiver resultTo) {
+ private void finishUserBoot(UserState uss, IIntentReceiver resultTo) {
final int userId = uss.mHandle.getIdentifier();
synchronized (mService) {
// Bail if we ended up with a stale user
@@ -711,7 +711,7 @@
moveUserToForegroundLocked(uss, oldUserId, userId);
}
} else {
- mService.mStackSupervisor.startBackgroundUserLocked(userId, uss);
+ mService.mUserController.finishUserBoot(uss);
}
if (needStart) {