Merge "Renamed setStopBackgroundUsersOnSwitch to setStopUserOnSwitch()" into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5908bbe04d
@@ -113,7 +113,7 @@ package android.app {
|
||||
method @RequiresPermission(android.Manifest.permission.RESET_APP_ERRORS) public void resetAppErrors();
|
||||
method public static void resumeAppSwitches() throws android.os.RemoteException;
|
||||
method @RequiresPermission(android.Manifest.permission.CHANGE_CONFIGURATION) public void scheduleApplicationInfoChanged(java.util.List<java.lang.String>, int);
|
||||
method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}) public void setStopBackgroundUsersOnSwitch(int);
|
||||
method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}) public void setStopUserOnSwitch(int);
|
||||
method @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public boolean stopUser(int, boolean);
|
||||
method @RequiresPermission(android.Manifest.permission.CHANGE_CONFIGURATION) public boolean updateMccMncConfiguration(@NonNull String, @NonNull String);
|
||||
method @RequiresPermission(android.Manifest.permission.DUMP) public void waitForBroadcastIdle();
|
||||
@@ -128,9 +128,9 @@ package android.app {
|
||||
field public static final int PROCESS_CAPABILITY_NONE = 0; // 0x0
|
||||
field public static final int PROCESS_STATE_FOREGROUND_SERVICE = 4; // 0x4
|
||||
field public static final int PROCESS_STATE_TOP = 2; // 0x2
|
||||
field public static final int STOP_BG_USERS_ON_SWITCH_DEFAULT = -1; // 0xffffffff
|
||||
field public static final int STOP_BG_USERS_ON_SWITCH_FALSE = 0; // 0x0
|
||||
field public static final int STOP_BG_USERS_ON_SWITCH_TRUE = 1; // 0x1
|
||||
field public static final int STOP_USER_ON_SWITCH_DEFAULT = -1; // 0xffffffff
|
||||
field public static final int STOP_USER_ON_SWITCH_FALSE = 0; // 0x0
|
||||
field public static final int STOP_USER_ON_SWITCH_TRUE = 1; // 0x1
|
||||
}
|
||||
|
||||
public static class ActivityManager.RunningAppProcessInfo implements android.os.Parcelable {
|
||||
|
||||
@@ -4081,45 +4081,46 @@ public class ActivityManager {
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public static final int STOP_BG_USERS_ON_SWITCH_DEFAULT = -1;
|
||||
public static final int STOP_USER_ON_SWITCH_DEFAULT = -1;
|
||||
|
||||
/**
|
||||
* Overrides value defined by the platform and stop background users on switch.
|
||||
* Overrides value defined by the platform and stop user on switch.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public static final int STOP_BG_USERS_ON_SWITCH_TRUE = 1;
|
||||
public static final int STOP_USER_ON_SWITCH_TRUE = 1;
|
||||
|
||||
/**
|
||||
* Overrides value defined by the platform and don't stop background users on switch.
|
||||
* Overrides value defined by the platform and don't stop user on switch.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public static final int STOP_BG_USERS_ON_SWITCH_FALSE = 0;
|
||||
public static final int STOP_USER_ON_SWITCH_FALSE = 0;
|
||||
|
||||
/** @hide */
|
||||
@IntDef(prefix = { "STOP_BG_USERS_ON_SWITCH_" }, value = {
|
||||
STOP_BG_USERS_ON_SWITCH_DEFAULT,
|
||||
STOP_BG_USERS_ON_SWITCH_TRUE,
|
||||
STOP_BG_USERS_ON_SWITCH_FALSE
|
||||
@IntDef(prefix = { "STOP_USER_ON_SWITCH_" }, value = {
|
||||
STOP_USER_ON_SWITCH_DEFAULT,
|
||||
STOP_USER_ON_SWITCH_TRUE,
|
||||
STOP_USER_ON_SWITCH_FALSE
|
||||
})
|
||||
public @interface StopBgUsersOnSwitch {}
|
||||
public @interface StopUserOnSwitch {}
|
||||
|
||||
/**
|
||||
* Sets whether background users should be stopped when the current user is switched.
|
||||
* Sets whether the current foreground user (and its profiles) should be stopped after switched
|
||||
* out.
|
||||
*
|
||||
* <p>Should only be used on tests.
|
||||
* <p>Should only be used on tests. Doesn't apply to {@link UserHandle#SYSTEM system user}.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@RequiresPermission(anyOf = {android.Manifest.permission.MANAGE_USERS,
|
||||
android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})
|
||||
public void setStopBackgroundUsersOnSwitch(@StopBgUsersOnSwitch int value) {
|
||||
public void setStopUserOnSwitch(@StopUserOnSwitch int value) {
|
||||
try {
|
||||
getService().setStopBackgroundUsersOnSwitch(value);
|
||||
getService().setStopUserOnSwitch(value);
|
||||
} catch (RemoteException re) {
|
||||
throw re.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package android.app;
|
||||
|
||||
import static android.app.ActivityManager.StopBgUsersOnSwitch;
|
||||
import static android.app.ActivityManager.StopUserOnSwitch;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
@@ -663,9 +663,10 @@ public abstract class ActivityManagerInternal {
|
||||
@Nullable VoiceInteractionManagerProvider provider);
|
||||
|
||||
/**
|
||||
* Sets whether background users should be stopped when the current user is switched.
|
||||
* Sets whether the current foreground user (and its profiles) should be stopped after switched
|
||||
* out.
|
||||
*/
|
||||
public abstract void setStopBackgroundUsersOnSwitch(@StopBgUsersOnSwitch int value);
|
||||
public abstract void setStopUserOnSwitch(@StopUserOnSwitch int value);
|
||||
|
||||
/**
|
||||
* Provides the interface to communicate between voice interaction manager service and
|
||||
|
||||
@@ -341,7 +341,7 @@ interface IActivityManager {
|
||||
@UnsupportedAppUsage
|
||||
boolean switchUser(int userid);
|
||||
@UnsupportedAppUsage
|
||||
void setStopBackgroundUsersOnSwitch(int value);
|
||||
void setStopUserOnSwitch(int value);
|
||||
boolean removeTask(int taskId);
|
||||
@UnsupportedAppUsage
|
||||
void registerProcessObserver(in IProcessObserver observer);
|
||||
|
||||
@@ -31,7 +31,7 @@ import static android.app.ActivityManager.INTENT_SENDER_ACTIVITY;
|
||||
import static android.app.ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
|
||||
import static android.app.ActivityManager.PROCESS_STATE_NONEXISTENT;
|
||||
import static android.app.ActivityManager.PROCESS_STATE_TOP;
|
||||
import static android.app.ActivityManager.StopBgUsersOnSwitch;
|
||||
import static android.app.ActivityManager.StopUserOnSwitch;
|
||||
import static android.app.ActivityManagerInternal.ALLOW_FULL_ONLY;
|
||||
import static android.app.ActivityManagerInternal.ALLOW_NON_FULL;
|
||||
import static android.app.AppOpsManager.OP_NONE;
|
||||
@@ -15099,8 +15099,8 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStopBackgroundUsersOnSwitch(@StopBgUsersOnSwitch int value) {
|
||||
mUserController.setStopBackgroundUsersOnSwitch(value);
|
||||
public void setStopUserOnSwitch(@StopUserOnSwitch int value) {
|
||||
mUserController.setStopUserOnSwitch(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -16402,8 +16402,8 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStopBackgroundUsersOnSwitch(int value) {
|
||||
ActivityManagerService.this.setStopBackgroundUsersOnSwitch(value);
|
||||
public void setStopUserOnSwitch(int value) {
|
||||
ActivityManagerService.this.setStopUserOnSwitch(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -331,7 +331,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
|
||||
case "get-isolated-pids":
|
||||
return runGetIsolatedProcesses(pw);
|
||||
case "set-stop-user-on-switch":
|
||||
return runSetStopBackgroundUsersOnSwitch(pw);
|
||||
return runSetStopUserOnSwitch(pw);
|
||||
default:
|
||||
return handleDefaultCommands(cmd);
|
||||
}
|
||||
@@ -3166,25 +3166,24 @@ final class ActivityManagerShellCommand extends ShellCommand {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int runSetStopBackgroundUsersOnSwitch(PrintWriter pw) throws RemoteException {
|
||||
private int runSetStopUserOnSwitch(PrintWriter pw) throws RemoteException {
|
||||
mInternal.enforceCallingPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
|
||||
"setStopBackgroundUsersOnSwitch()");
|
||||
"setStopUserOnSwitch()");
|
||||
String arg = getNextArg();
|
||||
if (arg == null) {
|
||||
Slogf.i(TAG, "runSetStopBackgroundUsersOnSwitch(): resetting to default value");
|
||||
mInternal.setStopBackgroundUsersOnSwitch(
|
||||
ActivityManager.STOP_BG_USERS_ON_SWITCH_DEFAULT);
|
||||
Slogf.i(TAG, "setStopUserOnSwitch(): resetting to default value");
|
||||
mInternal.setStopUserOnSwitch(ActivityManager.STOP_USER_ON_SWITCH_DEFAULT);
|
||||
pw.println("Reset to default value");
|
||||
return 0;
|
||||
}
|
||||
|
||||
boolean stop = Boolean.parseBoolean(arg);
|
||||
int value = stop
|
||||
? ActivityManager.STOP_BG_USERS_ON_SWITCH_TRUE
|
||||
: ActivityManager.STOP_BG_USERS_ON_SWITCH_FALSE;
|
||||
? ActivityManager.STOP_USER_ON_SWITCH_TRUE
|
||||
: ActivityManager.STOP_USER_ON_SWITCH_FALSE;
|
||||
|
||||
Slogf.i(TAG, "runSetStopBackgroundUsersOnSwitch(): setting to %d (%b)", value, stop);
|
||||
mInternal.setStopBackgroundUsersOnSwitch(value);
|
||||
Slogf.i(TAG, "runSetStopUserOnSwitch(): setting to %d (%b)", value, stop);
|
||||
mInternal.setStopUserOnSwitch(value);
|
||||
pw.println("Set to " + stop);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -19,9 +19,9 @@ package com.android.server.am;
|
||||
import static android.Manifest.permission.INTERACT_ACROSS_PROFILES;
|
||||
import static android.Manifest.permission.INTERACT_ACROSS_USERS;
|
||||
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
|
||||
import static android.app.ActivityManager.STOP_BG_USERS_ON_SWITCH_DEFAULT;
|
||||
import static android.app.ActivityManager.STOP_BG_USERS_ON_SWITCH_TRUE;
|
||||
import static android.app.ActivityManager.StopBgUsersOnSwitch;
|
||||
import static android.app.ActivityManager.STOP_USER_ON_SWITCH_DEFAULT;
|
||||
import static android.app.ActivityManager.STOP_USER_ON_SWITCH_TRUE;
|
||||
import static android.app.ActivityManager.StopUserOnSwitch;
|
||||
import static android.app.ActivityManager.USER_OP_ERROR_IS_SYSTEM;
|
||||
import static android.app.ActivityManager.USER_OP_ERROR_RELATED_USERS_CANNOT_STOP;
|
||||
import static android.app.ActivityManager.USER_OP_IS_CURRENT;
|
||||
@@ -376,7 +376,7 @@ class UserController implements Handler.Callback {
|
||||
* user is switched.
|
||||
*/
|
||||
@GuardedBy("mLock")
|
||||
private @StopBgUsersOnSwitch int mStopBgUsersOnSwitch = STOP_BG_USERS_ON_SWITCH_DEFAULT;
|
||||
private @StopUserOnSwitch int mStopUserOnSwitch = STOP_USER_ON_SWITCH_DEFAULT;
|
||||
|
||||
UserController(ActivityManagerService service) {
|
||||
this(new Injector(service));
|
||||
@@ -418,29 +418,27 @@ class UserController implements Handler.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
void setStopBackgroundUsersOnSwitch(@StopBgUsersOnSwitch int value) {
|
||||
void setStopUserOnSwitch(@StopUserOnSwitch int value) {
|
||||
if (mInjector.checkCallingPermission(android.Manifest.permission.MANAGE_USERS)
|
||||
== PackageManager.PERMISSION_DENIED && mInjector.checkCallingPermission(
|
||||
android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
|
||||
== PackageManager.PERMISSION_DENIED) {
|
||||
throw new SecurityException(
|
||||
"You either need MANAGE_USERS or INTERACT_ACROSS_USERS_FULL permission to "
|
||||
+ "call setStopBackgroundUsersOnSwitch()");
|
||||
+ "call setStopUserOnSwitch()");
|
||||
}
|
||||
|
||||
synchronized (mLock) {
|
||||
Slogf.i(TAG, "setStopBackgroundUsersOnSwitch(): %d -> %d",
|
||||
mStopBgUsersOnSwitch, value);
|
||||
mStopBgUsersOnSwitch = value;
|
||||
Slogf.i(TAG, "setStopUserOnSwitch(): %d -> %d", mStopUserOnSwitch, value);
|
||||
mStopUserOnSwitch = value;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldStopBackgroundUsersOnSwitch() {
|
||||
private boolean shouldStopUserOnSwitch() {
|
||||
synchronized (mLock) {
|
||||
if (mStopBgUsersOnSwitch != STOP_BG_USERS_ON_SWITCH_DEFAULT) {
|
||||
final boolean value = mStopBgUsersOnSwitch == STOP_BG_USERS_ON_SWITCH_TRUE;
|
||||
Slogf.i(TAG, "isStopBackgroundUsersOnSwitch(): returning overridden value (%b)",
|
||||
value);
|
||||
if (mStopUserOnSwitch != STOP_USER_ON_SWITCH_DEFAULT) {
|
||||
final boolean value = mStopUserOnSwitch == STOP_USER_ON_SWITCH_TRUE;
|
||||
Slogf.i(TAG, "shouldStopUserOnSwitch(): returning overridden value (%b)", value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -1834,7 +1832,7 @@ class UserController implements Handler.Callback {
|
||||
mUserSwitchObservers.finishBroadcast();
|
||||
}
|
||||
|
||||
private void stopBackgroundUsersOnSwitchIfEnforced(@UserIdInt int oldUserId) {
|
||||
private void stopUserOnSwitchIfEnforced(@UserIdInt int oldUserId) {
|
||||
// Never stop system user
|
||||
if (oldUserId == UserHandle.USER_SYSTEM) {
|
||||
return;
|
||||
@@ -1842,18 +1840,17 @@ class UserController implements Handler.Callback {
|
||||
boolean hasRestriction =
|
||||
hasUserRestriction(UserManager.DISALLOW_RUN_IN_BACKGROUND, oldUserId);
|
||||
synchronized (mLock) {
|
||||
// If running in background is disabled or mStopBackgroundUsersOnSwitch mode,
|
||||
// stop the user.
|
||||
boolean disallowRunInBg = hasRestriction || shouldStopBackgroundUsersOnSwitch();
|
||||
// If running in background is disabled or mStopUserOnSwitch mode, stop the user.
|
||||
boolean disallowRunInBg = hasRestriction || shouldStopUserOnSwitch();
|
||||
if (!disallowRunInBg) {
|
||||
if (DEBUG_MU) {
|
||||
Slogf.i(TAG, "stopBackgroundUsersIfEnforced() NOT stopping %d and related "
|
||||
+ "users", oldUserId);
|
||||
Slogf.i(TAG, "stopUserOnSwitchIfEnforced() NOT stopping %d and related users",
|
||||
oldUserId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (DEBUG_MU) {
|
||||
Slogf.i(TAG, "stopBackgroundUsersIfEnforced() stopping %d and related users",
|
||||
Slogf.i(TAG, "stopUserOnSwitchIfEnforced() stopping %d and related users",
|
||||
oldUserId);
|
||||
}
|
||||
stopUsersLU(oldUserId, /* force= */ false, /* allowDelayedLocking= */ true,
|
||||
@@ -1956,7 +1953,7 @@ class UserController implements Handler.Callback {
|
||||
mHandler.removeMessages(REPORT_USER_SWITCH_COMPLETE_MSG);
|
||||
mHandler.sendMessage(mHandler.obtainMessage(REPORT_USER_SWITCH_COMPLETE_MSG, newUserId, 0));
|
||||
stopGuestOrEphemeralUserIfBackground(oldUserId);
|
||||
stopBackgroundUsersOnSwitchIfEnforced(oldUserId);
|
||||
stopUserOnSwitchIfEnforced(oldUserId);
|
||||
}
|
||||
|
||||
private void moveUserToForeground(UserState uss, int oldUserId, int newUserId) {
|
||||
@@ -2646,9 +2643,8 @@ class UserController implements Handler.Callback {
|
||||
pw.println(" mTargetUserId:" + mTargetUserId);
|
||||
pw.println(" mLastActiveUsers:" + mLastActiveUsers);
|
||||
pw.println(" mDelayUserDataLocking:" + mDelayUserDataLocking);
|
||||
pw.println(" shouldStopBackgroundUsersOnSwitch():"
|
||||
+ shouldStopBackgroundUsersOnSwitch());
|
||||
pw.println(" mStopBgUsersOnSwitch:" + mStopBgUsersOnSwitch);
|
||||
pw.println(" shouldStopUserOnSwitch():" + shouldStopUserOnSwitch());
|
||||
pw.println(" mStopUserOnSwitch:" + mStopUserOnSwitch);
|
||||
pw.println(" mMaxRunningUsers:" + mMaxRunningUsers);
|
||||
pw.println(" mUserSwitchUiEnabled:" + mUserSwitchUiEnabled);
|
||||
pw.println(" mInitialized:" + mInitialized);
|
||||
|
||||
Reference in New Issue
Block a user