Loading services/core/java/com/android/server/am/ActivityManagerService.java +10 −1 Original line number Diff line number Diff line Loading @@ -8789,7 +8789,6 @@ public class ActivityManagerService extends IActivityManager.Stub mAtmInternal.updateTopComponentForFactoryTest(); retrieveSettings(); final int currentUserId = mUserController.getCurrentUserId(); mUgmInternal.onSystemReady(); final PowerManagerInternal pmi = LocalServices.getService(PowerManagerInternal.class); Loading @@ -8803,6 +8802,16 @@ public class ActivityManagerService extends IActivityManager.Stub } if (goingCallback != null) goingCallback.run(); // Check the current user here as a user can be started inside goingCallback.run() from // other system services. final int currentUserId = mUserController.getCurrentUserId(); Slog.i(TAG, "Current user:" + currentUserId); if (currentUserId != UserHandle.USER_SYSTEM && !mUserController.isSystemUserStarted()) { // User other than system user has started. Make sure that system user is already // started before switching user. throw new RuntimeException("System user not started while current user is:" + currentUserId); } traceLog.traceBegin("ActivityManagerStartApps"); mBatteryStatsService.noteEvent(BatteryStats.HistoryItem.EVENT_USER_RUNNING_START, Integer.toString(currentUserId), currentUserId); Loading services/core/java/com/android/server/am/UserController.java +18 −0 Original line number Diff line number Diff line Loading @@ -1743,6 +1743,24 @@ class UserController implements Handler.Callback { return state.state != UserState.STATE_STOPPING && state.state != UserState.STATE_SHUTDOWN; } /** * Check if system user is already started. Unlike other user, system user is in STATE_BOOTING * even if it is not explicitly started. So isUserRunning cannot give the right state * to check if system user is started or not. * @return true if system user is started. */ boolean isSystemUserStarted() { synchronized (mLock) { UserState uss = mStartedUsers.get(UserHandle.USER_SYSTEM); if (uss == null) { return false; } return uss.state == UserState.STATE_RUNNING_LOCKED || uss.state == UserState.STATE_RUNNING_UNLOCKING || uss.state == UserState.STATE_RUNNING_UNLOCKED; } } UserInfo getCurrentUser() { if ((mInjector.checkCallingPermission(INTERACT_ACROSS_USERS) != PackageManager.PERMISSION_GRANTED) && ( Loading Loading
services/core/java/com/android/server/am/ActivityManagerService.java +10 −1 Original line number Diff line number Diff line Loading @@ -8789,7 +8789,6 @@ public class ActivityManagerService extends IActivityManager.Stub mAtmInternal.updateTopComponentForFactoryTest(); retrieveSettings(); final int currentUserId = mUserController.getCurrentUserId(); mUgmInternal.onSystemReady(); final PowerManagerInternal pmi = LocalServices.getService(PowerManagerInternal.class); Loading @@ -8803,6 +8802,16 @@ public class ActivityManagerService extends IActivityManager.Stub } if (goingCallback != null) goingCallback.run(); // Check the current user here as a user can be started inside goingCallback.run() from // other system services. final int currentUserId = mUserController.getCurrentUserId(); Slog.i(TAG, "Current user:" + currentUserId); if (currentUserId != UserHandle.USER_SYSTEM && !mUserController.isSystemUserStarted()) { // User other than system user has started. Make sure that system user is already // started before switching user. throw new RuntimeException("System user not started while current user is:" + currentUserId); } traceLog.traceBegin("ActivityManagerStartApps"); mBatteryStatsService.noteEvent(BatteryStats.HistoryItem.EVENT_USER_RUNNING_START, Integer.toString(currentUserId), currentUserId); Loading
services/core/java/com/android/server/am/UserController.java +18 −0 Original line number Diff line number Diff line Loading @@ -1743,6 +1743,24 @@ class UserController implements Handler.Callback { return state.state != UserState.STATE_STOPPING && state.state != UserState.STATE_SHUTDOWN; } /** * Check if system user is already started. Unlike other user, system user is in STATE_BOOTING * even if it is not explicitly started. So isUserRunning cannot give the right state * to check if system user is started or not. * @return true if system user is started. */ boolean isSystemUserStarted() { synchronized (mLock) { UserState uss = mStartedUsers.get(UserHandle.USER_SYSTEM); if (uss == null) { return false; } return uss.state == UserState.STATE_RUNNING_LOCKED || uss.state == UserState.STATE_RUNNING_UNLOCKING || uss.state == UserState.STATE_RUNNING_UNLOCKED; } } UserInfo getCurrentUser() { if ((mInjector.checkCallingPermission(INTERACT_ACROSS_USERS) != PackageManager.PERMISSION_GRANTED) && ( Loading