Merge \"Don\'t allow showing an activity if user is stopping or shutting down.\" into nyc-dev

am: 2058553b8d

Change-Id: Ie6995527fb31b9b5f0c272726c80754927770c55
This commit is contained in:
Nicolas Prevot
2016-06-22 12:33:41 +00:00
committed by android-build-merger
3 changed files with 13 additions and 3 deletions

View File

@@ -3029,8 +3029,9 @@ public final class ActivityStackSupervisor implements DisplayListener {
/** Checks whether the activity should be shown for current user. */
boolean okToShowLocked(ActivityRecord r) {
return r != null && (isCurrentProfileLocked(r.userId)
|| (r.info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0);
return r != null && ((r.info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0
|| (isCurrentProfileLocked(r.userId)
&& !mService.mUserController.isUserStoppingOrShuttingDownLocked(r.userId)));
}
final ArrayList<ActivityRecord> processStoppingActivitiesLocked(boolean remove) {

View File

@@ -1336,6 +1336,15 @@ final class UserController {
return mStartedUserArray;
}
boolean isUserStoppingOrShuttingDownLocked(int userId) {
UserState state = getStartedUserStateLocked(userId);
if (state == null) {
return false;
}
return state.state == UserState.STATE_STOPPING
|| state.state == UserState.STATE_SHUTDOWN;
}
boolean isUserRunningLocked(int userId, int flags) {
UserState state = getStartedUserStateLocked(userId);
if (state == null) {

View File

@@ -737,9 +737,9 @@ public class UserManagerService extends IUserManager.Stub {
long identity = Binder.clearCallingIdentity();
try {
if (enableQuietMode) {
ActivityManagerNative.getDefault().stopUser(userHandle, /* force */true, null);
LocalServices.getService(ActivityManagerInternal.class)
.killForegroundAppsForUser(userHandle);
ActivityManagerNative.getDefault().stopUser(userHandle, /* force */true, null);
} else {
ActivityManagerNative.getDefault().startUserInBackground(userHandle);
}