summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/api/test-current.txt6
-rw-r--r--core/java/android/app/ActivityManager.java15
-rw-r--r--core/java/android/app/IActivityManager.aidl6
-rw-r--r--core/java/android/os/UserManager.java13
-rw-r--r--core/res/res/values/config.xml4
-rw-r--r--core/res/res/values/symbols.xml2
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java38
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerShellCommand.java14
-rw-r--r--services/core/java/com/android/server/am/UserController.java6
-rw-r--r--services/core/java/com/android/server/pm/UserVisibilityMediator.java61
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/am/ActivityManagerServiceInjectorTest.java40
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/pm/UserVisibilityMediatorTestCase.java8
-rw-r--r--services/tests/servicestests/src/com/android/server/am/ActivityManagerServiceTest.java28
-rw-r--r--services/tests/servicestests/src/com/android/server/am/UserControllerTest.java7
14 files changed, 123 insertions, 125 deletions
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index 5be98bf43d25..42acc2214ff1 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -125,7 +125,7 @@ package android.app {
public class ActivityManager {
method @RequiresPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER) public void addHomeVisibilityListener(@NonNull java.util.concurrent.Executor, @NonNull android.app.HomeVisibilityListener);
method public void alwaysShowUnsupportedCompileSdkWarning(android.content.ComponentName);
- method @Nullable @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}) public int[] getSecondaryDisplayIdsForStartingBackgroundUsers();
+ method @Nullable @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}) public int[] getDisplayIdsForStartingVisibleBackgroundUsers();
method public long getTotalRam();
method @RequiresPermission(allOf={android.Manifest.permission.PACKAGE_USAGE_STATS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}, conditional=true) public int getUidProcessCapabilities(int);
method @RequiresPermission(allOf={android.Manifest.permission.PACKAGE_USAGE_STATS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}, conditional=true) public int getUidProcessState(int);
@@ -136,7 +136,7 @@ package android.app {
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}) public void setStopUserOnSwitch(int);
- method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}) public boolean startUserInBackgroundOnSecondaryDisplay(int, int);
+ method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}) public boolean startUserInBackgroundVisibleOnDisplay(int, 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();
@@ -1942,7 +1942,7 @@ package android.os {
method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public boolean hasBaseUserRestriction(@NonNull String, @NonNull android.os.UserHandle);
method public static boolean isSplitSystemUser();
method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public boolean isUserTypeEnabled(@NonNull String);
- method public boolean isUsersOnSecondaryDisplaysSupported();
+ method public boolean isVisibleBackgroundUsersSupported();
method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public android.content.pm.UserInfo preCreateUser(@NonNull String) throws android.os.UserManager.UserOperationException;
}
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index cf07114197e7..174c98257188 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -4380,7 +4380,7 @@ public class ActivityManager {
*
* <p>This method will allow the user to launch activities on that display, and it's typically
* used only on automotive builds when the vehicle has multiple displays (you can verify if it's
- * supported by calling {@link UserManager#isUsersOnSecondaryDisplaysSupported()}).
+ * supported by calling {@link UserManager#isVisibleBackgroundUsersSupported()}).
*
* <p><b>NOTE:</b> differently from {@link #switchUser(int)}, which stops the current foreground
* user before starting a new one, this method does not stop the previous user running in
@@ -4404,14 +4404,13 @@ public class ActivityManager {
@TestApi
@RequiresPermission(anyOf = {android.Manifest.permission.MANAGE_USERS,
android.Manifest.permission.INTERACT_ACROSS_USERS})
- public boolean startUserInBackgroundOnSecondaryDisplay(@UserIdInt int userId,
- int displayId) {
- if (!UserManager.isUsersOnSecondaryDisplaysEnabled()) {
+ public boolean startUserInBackgroundVisibleOnDisplay(@UserIdInt int userId, int displayId) {
+ if (!UserManager.isVisibleBackgroundUsersEnabled()) {
throw new UnsupportedOperationException(
"device does not support users on secondary displays");
}
try {
- return getService().startUserInBackgroundOnSecondaryDisplay(userId, displayId);
+ return getService().startUserInBackgroundVisibleOnDisplay(userId, displayId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -4427,9 +4426,9 @@ public class ActivityManager {
@Nullable
@RequiresPermission(anyOf = {android.Manifest.permission.MANAGE_USERS,
android.Manifest.permission.INTERACT_ACROSS_USERS})
- public int[] getSecondaryDisplayIdsForStartingBackgroundUsers() {
+ public int[] getDisplayIdsForStartingVisibleBackgroundUsers() {
try {
- return getService().getSecondaryDisplayIdsForStartingBackgroundUsers();
+ return getService().getDisplayIdsForStartingVisibleBackgroundUsers();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -4589,7 +4588,7 @@ public class ActivityManager {
* Stops the given {@code userId}.
*
* <p><b>NOTE:</b> on systems that support
- * {@link UserManager#isUsersOnSecondaryDisplaysSupported() background users on secondary
+ * {@link UserManager#isVisibleBackgroundUsersSupported() background users on secondary
* displays}, this method will also unassign the user from the display it was started on.
*
* @hide
diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl
index 6b6b82007296..0866d945b1bd 100644
--- a/core/java/android/app/IActivityManager.aidl
+++ b/core/java/android/app/IActivityManager.aidl
@@ -799,14 +799,14 @@ interface IActivityManager {
*/
@JavaPassthrough(annotation=
"@android.annotation.RequiresPermission(anyOf = {android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}, conditional = true)")
- boolean startUserInBackgroundOnSecondaryDisplay(int userid, int displayId);
+ boolean startUserInBackgroundVisibleOnDisplay(int userid, int displayId);
/**
- * Gets the ids of displays that can be used on {@link #startUserInBackgroundOnSecondaryDisplay(int userId, int displayId)}.
+ * Gets the ids of displays that can be used on {@link #startUserInBackgroundVisibleOnDisplay(int userId, int displayId)}.
*
* <p>Typically used only by automotive builds when the vehicle has multiple displays.
*/
- @nullable int[] getSecondaryDisplayIdsForStartingBackgroundUsers();
+ @nullable int[] getDisplayIdsForStartingVisibleBackgroundUsers();
/** Returns if the service is a short-service is still "alive" and past the timeout. */
boolean shouldServiceTimeOut(in ComponentName className, in IBinder token);
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 08d15c72c47f..acf3b5cd4ca3 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -2912,14 +2912,15 @@ public class UserManager {
/**
* @hide
*/
- public static boolean isUsersOnSecondaryDisplaysEnabled() {
- return SystemProperties.getBoolean("fw.users_on_secondary_displays",
+ public static boolean isVisibleBackgroundUsersEnabled() {
+ return SystemProperties.getBoolean("fw.visible_bg_users",
Resources.getSystem()
- .getBoolean(R.bool.config_multiuserUsersOnSecondaryDisplays));
+ .getBoolean(R.bool.config_multiuserVisibleBackgroundUsers));
}
/**
- * Returns whether the device allows users to run (and launch activities) on secondary displays.
+ * Returns whether the device allows (full) users to be started in background visible in a given
+ * display (which would allow them to launch activities in that display).
*
* @return {@code false} for most devices, except on automotive builds for vehiches with
* passenger displays.
@@ -2927,8 +2928,8 @@ public class UserManager {
* @hide
*/
@TestApi
- public boolean isUsersOnSecondaryDisplaysSupported() {
- return isUsersOnSecondaryDisplaysEnabled();
+ public boolean isVisibleBackgroundUsersSupported() {
+ return isVisibleBackgroundUsersEnabled();
}
/**
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 28097c29cf58..094f058fd59c 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -2672,9 +2672,9 @@
will be locked. -->
<bool name="config_multiuserDelayUserDataLocking">false</bool>
- <!-- Whether the device allows users to start in background on secondary displays.
+ <!-- Whether the device allows users to start in background visible on displays.
Should be false for most devices, except automotive vehicle with passenger displays. -->
- <bool name="config_multiuserUsersOnSecondaryDisplays">false</bool>
+ <bool name="config_multiuserVisibleBackgroundUsers">false</bool>
<!-- Whether to automatically switch to the designated Dock User (the user chosen for
displaying dreams, etc.) after a timeout when the device is docked. -->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 2df1ef725588..094989fdc9eb 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -468,7 +468,7 @@
<java-symbol type="integer" name="config_multiuserMaximumUsers" />
<java-symbol type="integer" name="config_multiuserMaxRunningUsers" />
<java-symbol type="bool" name="config_multiuserDelayUserDataLocking" />
- <java-symbol type="bool" name="config_multiuserUsersOnSecondaryDisplays" />
+ <java-symbol type="bool" name="config_multiuserVisibleBackgroundUsers" />
<java-symbol type="bool" name="config_enableTimeoutToDockUserWhenDocked" />
<java-symbol type="integer" name="config_userTypePackageWhitelistMode"/>
<java-symbol type="xml" name="config_user_types" />
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index d7c4286b881f..191460c385ad 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -16610,8 +16610,8 @@ public class ActivityManagerService extends IActivityManager.Stub
}
@Override
- public boolean startUserInBackgroundOnSecondaryDisplay(int userId, int displayId) {
- int[] displayIds = getSecondaryDisplayIdsForStartingBackgroundUsers();
+ public boolean startUserInBackgroundVisibleOnDisplay(int userId, int displayId) {
+ int[] displayIds = getDisplayIdsForStartingVisibleBackgroundUsers();
boolean validDisplay = false;
if (displayIds != null) {
for (int i = 0; i < displayIds.length; i++) {
@@ -16631,14 +16631,14 @@ public class ActivityManagerService extends IActivityManager.Stub
displayId, mInjector);
}
// Permission check done inside UserController.
- return mInjector.startUserOnSecondaryDisplay(userId, displayId);
+ return mInjector.startUserInBackgroundVisibleOnDisplay(userId, displayId);
}
@Override
- public int[] getSecondaryDisplayIdsForStartingBackgroundUsers() {
- enforceCallingHasAtLeastOnePermission("getSecondaryDisplayIdsForStartingBackgroundUsers()",
+ public int[] getDisplayIdsForStartingVisibleBackgroundUsers() {
+ enforceCallingHasAtLeastOnePermission("getDisplayIdsForStartingVisibleBackgroundUsers()",
MANAGE_USERS, INTERACT_ACROSS_USERS);
- return mInjector.getSecondaryDisplayIdsForStartingBackgroundUsers();
+ return mInjector.getDisplayIdsForStartingVisibleBackgroundUsers();
}
/** @deprecated see the AIDL documentation {@inheritDoc} */
@@ -18837,7 +18837,7 @@ public class ActivityManagerService extends IActivityManager.Stub
}
/**
- * Called by {@code AMS.getSecondaryDisplayIdsForStartingBackgroundUsers()}.
+ * Called by {@code AMS.getDisplayIdsForStartingVisibleBackgroundUsers()}.
*/
// NOTE: ideally Injector should have no complex logic, but if this logic was moved to AMS,
// it could not be tested with the existing ActivityManagerServiceTest (as DisplayManager,
@@ -18847,9 +18847,9 @@ public class ActivityManagerService extends IActivityManager.Stub
// was added on FrameworksMockingServicesTests and hence uses Extended Mockito to mock
// final and static stuff)
@Nullable
- public int[] getSecondaryDisplayIdsForStartingBackgroundUsers() {
- if (!UserManager.isUsersOnSecondaryDisplaysEnabled()) {
- Slogf.w(TAG, "getSecondaryDisplayIdsForStartingBackgroundUsers(): not supported");
+ public int[] getDisplayIdsForStartingVisibleBackgroundUsers() {
+ if (!UserManager.isVisibleBackgroundUsersEnabled()) {
+ Slogf.w(TAG, "getDisplayIdsForStartingVisibleBackgroundUsers(): not supported");
return null;
}
@@ -18895,7 +18895,7 @@ public class ActivityManagerService extends IActivityManager.Stub
// KitchenSink (or other app) can be used while running CTS tests on devices that
// don't have a real display.
// STOPSHIP: if not removed, it should at least be unit tested
- String testingProp = "fw.secondary_display_for_starting_users_for_testing_purposes";
+ String testingProp = "fw.display_ids_for_starting_users_for_testing_purposes";
int displayId = SystemProperties.getInt(testingProp, Display.DEFAULT_DISPLAY);
if (displayId != Display.DEFAULT_DISPLAY && displayId > 0) {
Slogf.w(TAG, "getSecondaryDisplayIdsForStartingBackgroundUsers(): no valid "
@@ -18903,8 +18903,8 @@ public class ActivityManagerService extends IActivityManager.Stub
testingProp);
return new int[] { displayId };
}
- Slogf.e(TAG, "getSecondaryDisplayIdsForStartingBackgroundUsers(): no valid display"
- + " on %s", Arrays.toString(allDisplays));
+ Slogf.e(TAG, "getDisplayIdsForStartingBackgroundUsers(): no valid display on %s",
+ Arrays.toString(allDisplays));
return null;
}
@@ -18912,7 +18912,7 @@ public class ActivityManagerService extends IActivityManager.Stub
int[] validDisplayIds = new int[numberValidDisplays];
System.arraycopy(displayIds, 0, validDisplayIds, 0, numberValidDisplays);
if (DEBUG_MU) {
- Slogf.d(TAG, "getSecondaryDisplayIdsForStartingBackgroundUsers(): returning "
+ Slogf.d(TAG, "getDisplayIdsForStartingVisibleBackgroundUsers(): returning "
+ "only valid displays (%d instead of %d): %s", numberValidDisplays,
displayIds.length, Arrays.toString(validDisplayIds));
}
@@ -18920,17 +18920,17 @@ public class ActivityManagerService extends IActivityManager.Stub
}
if (DEBUG_MU) {
- Slogf.d(TAG, "getSecondaryDisplayIdsForStartingBackgroundUsers(): returning all "
- + "(but DEFAULT_DISPLAY) displays : %s", Arrays.toString(displayIds));
+ Slogf.d(TAG, "getDisplayIdsForStartingVisibleBackgroundUsers(): returning all (but "
+ + "DEFAULT_DISPLAY) displays : %s", Arrays.toString(displayIds));
}
return displayIds;
}
/**
- * Called by {@code AMS.startUserOnSecondaryDisplay()}.
+ * Called by {@code AMS.startUserInBackgroundVisibleOnDisplay()}.
*/
- public boolean startUserOnSecondaryDisplay(int userId, int displayId) {
- return mUserController.startUserOnSecondaryDisplay(userId, displayId);
+ public boolean startUserInBackgroundVisibleOnDisplay(int userId, int displayId) {
+ return mUserController.startUserVisibleOnDisplay(userId, displayId);
}
/**
diff --git a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
index 7f2e5fb6e5be..80684bf9fed3 100644
--- a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
+++ b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
@@ -373,8 +373,8 @@ final class ActivityManagerShellCommand extends ShellCommand {
return runGetCurrentForegroundProcess(pw, mInternal, mTaskInterface);
case "reset-dropbox-rate-limiter":
return runResetDropboxRateLimiter();
- case "list-secondary-displays-for-starting-users":
- return runListSecondaryDisplaysForStartingUsers(pw);
+ case "list-displays-for-starting-users":
+ return runListDisplaysForStartingUsers(pw);
case "set-foreground-service-delegate":
return runSetForegroundServiceDelegate(pw);
default:
@@ -2157,11 +2157,11 @@ final class ActivityManagerShellCommand extends ShellCommand {
success = mInterface.startUserInBackgroundWithListener(userId, waiter);
displaySuffix = "";
} else {
- if (!UserManager.isUsersOnSecondaryDisplaysEnabled()) {
+ if (!UserManager.isVisibleBackgroundUsersEnabled()) {
pw.println("Not supported");
return -1;
}
- success = mInterface.startUserInBackgroundOnSecondaryDisplay(userId, displayId);
+ success = mInterface.startUserInBackgroundVisibleOnDisplay(userId, displayId);
displaySuffix = " on display " + displayId;
}
if (wait && success) {
@@ -3745,8 +3745,8 @@ final class ActivityManagerShellCommand extends ShellCommand {
return 0;
}
- int runListSecondaryDisplaysForStartingUsers(PrintWriter pw) throws RemoteException {
- int[] displayIds = mInterface.getSecondaryDisplayIdsForStartingBackgroundUsers();
+ int runListDisplaysForStartingUsers(PrintWriter pw) throws RemoteException {
+ int[] displayIds = mInterface.getDisplayIdsForStartingVisibleBackgroundUsers();
pw.println(displayIds == null || displayIds.length == 0
? "none"
: Arrays.toString(displayIds));
@@ -4116,7 +4116,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
pw.println(" Set an app's background restriction level which in turn map to a app standby bucket.");
pw.println(" get-bg-restriction-level [--user <USER_ID>] <PACKAGE>");
pw.println(" Get an app's background restriction level.");
- pw.println(" list-secondary-displays-for-starting-users");
+ pw.println(" list-displays-for-starting-users");
pw.println(" Lists the id of displays that can be used to start users on "
+ "background.");
pw.println(" set-foreground-service-delegate [--user <USER_ID>] <PACKAGE> start|stop");
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java
index e5123eff9095..234eec387590 100644
--- a/services/core/java/com/android/server/am/UserController.java
+++ b/services/core/java/com/android/server/am/UserController.java
@@ -1567,8 +1567,8 @@ class UserController implements Handler.Callback {
*
* @return whether the user was started
*/
- boolean startUserOnSecondaryDisplay(@UserIdInt int userId, int displayId) {
- checkCallingHasOneOfThosePermissions("startUserOnSecondaryDisplay",
+ boolean startUserVisibleOnDisplay(@UserIdInt int userId, int displayId) {
+ checkCallingHasOneOfThosePermissions("startUserOnDisplay",
MANAGE_USERS, INTERACT_ACROSS_USERS);
try {
@@ -3713,7 +3713,7 @@ class UserController implements Handler.Callback {
}
boolean isUsersOnSecondaryDisplaysEnabled() {
- return UserManager.isUsersOnSecondaryDisplaysEnabled();
+ return UserManager.isVisibleBackgroundUsersEnabled();
}
void onUserStarting(@UserIdInt int userId) {
diff --git a/services/core/java/com/android/server/pm/UserVisibilityMediator.java b/services/core/java/com/android/server/pm/UserVisibilityMediator.java
index 40d87bc33ebd..d8e4dac48ebe 100644
--- a/services/core/java/com/android/server/pm/UserVisibilityMediator.java
+++ b/services/core/java/com/android/server/pm/UserVisibilityMediator.java
@@ -100,20 +100,20 @@ public final class UserVisibilityMediator implements Dumpable {
private final Object mLock = new Object();
- private final boolean mUsersOnSecondaryDisplaysEnabled;
+ private final boolean mVisibleBackgroundUsersEnabled;
@UserIdInt
@GuardedBy("mLock")
private int mCurrentUserId = INITIAL_CURRENT_USER_ID;
/**
- * Map of background users started on secondary displays.
+ * Map of background users started visible on displays (key is user id, value is display id).
*
* <p>Only set when {@code mUsersOnSecondaryDisplaysEnabled} is {@code true}.
*/
@Nullable
@GuardedBy("mLock")
- private final SparseIntArray mUsersOnSecondaryDisplays;
+ private final SparseIntArray mUsersOnDisplaysMap;
/**
* Mapping from each started user to its profile group.
@@ -131,13 +131,13 @@ public final class UserVisibilityMediator implements Dumpable {
new CopyOnWriteArrayList<>();
UserVisibilityMediator(Handler handler) {
- this(UserManager.isUsersOnSecondaryDisplaysEnabled(), handler);
+ this(UserManager.isVisibleBackgroundUsersEnabled(), handler);
}
@VisibleForTesting
- UserVisibilityMediator(boolean usersOnSecondaryDisplaysEnabled, Handler handler) {
- mUsersOnSecondaryDisplaysEnabled = usersOnSecondaryDisplaysEnabled;
- mUsersOnSecondaryDisplays = mUsersOnSecondaryDisplaysEnabled ? new SparseIntArray() : null;
+ UserVisibilityMediator(boolean backgroundUsersOnDisplaysEnabled, Handler handler) {
+ mVisibleBackgroundUsersEnabled = backgroundUsersOnDisplaysEnabled;
+ mUsersOnDisplaysMap = mVisibleBackgroundUsersEnabled ? new SparseIntArray() : null;
mHandler = handler;
// TODO(b/242195409): might need to change this if boot logic is refactored for HSUM devices
mStartedProfileGroupIds.put(INITIAL_CURRENT_USER_ID, INITIAL_CURRENT_USER_ID);
@@ -207,7 +207,7 @@ public final class UserVisibilityMediator implements Dumpable {
if (DBG) {
Slogf.d(TAG, "adding user / display mapping (%d -> %d)", userId, displayId);
}
- mUsersOnSecondaryDisplays.put(userId, displayId);
+ mUsersOnDisplaysMap.put(userId, displayId);
break;
case SECONDARY_DISPLAY_MAPPING_NOT_NEEDED:
if (DBG) {
@@ -260,7 +260,7 @@ public final class UserVisibilityMediator implements Dumpable {
foreground, displayId);
return USER_ASSIGNMENT_RESULT_FAILURE;
}
- if (!mUsersOnSecondaryDisplaysEnabled) {
+ if (!mVisibleBackgroundUsersEnabled) {
Slogf.w(TAG, "getUserVisibilityOnStartLocked(%d, %d, %b, %d) failed: called on "
+ "device that doesn't support multiple users on multiple displays",
userId, profileGroupId, foreground, displayId);
@@ -300,7 +300,7 @@ public final class UserVisibilityMediator implements Dumpable {
private int canAssignUserToDisplayLocked(@UserIdInt int userId,
@UserIdInt int profileGroupId, int displayId) {
if (displayId == DEFAULT_DISPLAY
- && (!mUsersOnSecondaryDisplaysEnabled || !isProfile(userId, profileGroupId))) {
+ && (!mVisibleBackgroundUsersEnabled || !isProfile(userId, profileGroupId))) {
// Don't need to do anything because methods (such as isUserVisible()) already
// know that the current user (and its profiles) is assigned to the default display.
// But on MUMD devices, profiles are only supported in the default display, so it
@@ -341,9 +341,9 @@ public final class UserVisibilityMediator implements Dumpable {
}
// Check if display is available
- for (int i = 0; i < mUsersOnSecondaryDisplays.size(); i++) {
- int assignedUserId = mUsersOnSecondaryDisplays.keyAt(i);
- int assignedDisplayId = mUsersOnSecondaryDisplays.valueAt(i);
+ for (int i = 0; i < mUsersOnDisplaysMap.size(); i++) {
+ int assignedUserId = mUsersOnDisplaysMap.keyAt(i);
+ int assignedDisplayId = mUsersOnDisplaysMap.valueAt(i);
if (DBG) {
Slogf.d(TAG, "%d: assignedUserId=%d, assignedDisplayId=%d",
i, assignedUserId, assignedDisplayId);
@@ -388,7 +388,7 @@ public final class UserVisibilityMediator implements Dumpable {
}
mStartedProfileGroupIds.delete(userId);
- if (!mUsersOnSecondaryDisplaysEnabled) {
+ if (!mVisibleBackgroundUsersEnabled) {
// Don't need to do update mUsersOnSecondaryDisplays because methods (such as
// isUserVisible()) already know that the current user (and their profiles) is
// assigned to the default display.
@@ -396,9 +396,9 @@ public final class UserVisibilityMediator implements Dumpable {
}
if (DBG) {
Slogf.d(TAG, "Removing %d from mUsersOnSecondaryDisplays (%s)", userId,
- mUsersOnSecondaryDisplays);
+ mUsersOnDisplaysMap);
}
- mUsersOnSecondaryDisplays.delete(userId);
+ mUsersOnDisplaysMap.delete(userId);
}
/**
@@ -415,7 +415,7 @@ public final class UserVisibilityMediator implements Dumpable {
// Device doesn't support multiple users on multiple displays, so only users checked above
// can be visible
- if (!mUsersOnSecondaryDisplaysEnabled) {
+ if (!mVisibleBackgroundUsersEnabled) {
if (DBG) {
Slogf.d(TAG, "isUserVisible(%d): false for non-current user on MUMD", userId);
}
@@ -424,7 +424,7 @@ public final class UserVisibilityMediator implements Dumpable {
boolean visible;
synchronized (mLock) {
- visible = mUsersOnSecondaryDisplays.indexOfKey(userId) >= 0;
+ visible = mUsersOnDisplaysMap.indexOfKey(userId) >= 0;
}
if (DBG) {
Slogf.d(TAG, "isUserVisible(%d): %b from mapping", userId, visible);
@@ -440,7 +440,7 @@ public final class UserVisibilityMediator implements Dumpable {
return false;
}
- if (!mUsersOnSecondaryDisplaysEnabled || displayId == Display.DEFAULT_DISPLAY) {
+ if (!mVisibleBackgroundUsersEnabled || displayId == Display.DEFAULT_DISPLAY) {
// TODO(b/245939659): will need to move the displayId == Display.DEFAULT_DISPLAY outside
// once it supports background users on DEFAULT_DISPLAY (for example, passengers in a
// no-driver configuration)
@@ -448,7 +448,7 @@ public final class UserVisibilityMediator implements Dumpable {
}
synchronized (mLock) {
- return mUsersOnSecondaryDisplays.get(userId, Display.INVALID_DISPLAY) == displayId;
+ return mUsersOnDisplaysMap.get(userId, Display.INVALID_DISPLAY) == displayId;
}
}
@@ -460,12 +460,12 @@ public final class UserVisibilityMediator implements Dumpable {
return Display.DEFAULT_DISPLAY;
}
- if (!mUsersOnSecondaryDisplaysEnabled) {
+ if (!mVisibleBackgroundUsersEnabled) {
return Display.INVALID_DISPLAY;
}
synchronized (mLock) {
- return mUsersOnSecondaryDisplays.get(userId, Display.INVALID_DISPLAY);
+ return mUsersOnDisplaysMap.get(userId, Display.INVALID_DISPLAY);
}
}
@@ -473,16 +473,16 @@ public final class UserVisibilityMediator implements Dumpable {
* See {@link UserManagerInternal#getUserAssignedToDisplay(int)}.
*/
public int getUserAssignedToDisplay(@UserIdInt int displayId) {
- if (displayId == Display.DEFAULT_DISPLAY || !mUsersOnSecondaryDisplaysEnabled) {
+ if (displayId == Display.DEFAULT_DISPLAY || !mVisibleBackgroundUsersEnabled) {
return getCurrentUserId();
}
synchronized (mLock) {
- for (int i = 0; i < mUsersOnSecondaryDisplays.size(); i++) {
- if (mUsersOnSecondaryDisplays.valueAt(i) != displayId) {
+ for (int i = 0; i < mUsersOnDisplaysMap.size(); i++) {
+ if (mUsersOnDisplaysMap.valueAt(i) != displayId) {
continue;
}
- int userId = mUsersOnSecondaryDisplays.keyAt(i);
+ int userId = mUsersOnDisplaysMap.keyAt(i);
if (!isStartedProfile(userId)) {
return userId;
} else if (DBG) {
@@ -615,12 +615,11 @@ public final class UserVisibilityMediator implements Dumpable {
dumpSparseIntArray(ipw, mStartedProfileGroupIds, "started user / profile group",
"u", "pg");
- ipw.print("Supports background users on secondary displays: ");
- ipw.println(mUsersOnSecondaryDisplaysEnabled);
+ ipw.print("Supports visible background users on displays: ");
+ ipw.println(mVisibleBackgroundUsersEnabled);
- if (mUsersOnSecondaryDisplays != null) {
- dumpSparseIntArray(ipw, mUsersOnSecondaryDisplays,
- "background user / secondary display", "u", "d");
+ if (mUsersOnDisplaysMap != null) {
+ dumpSparseIntArray(ipw, mUsersOnDisplaysMap, "user / display", "u", "d");
}
int numberListeners = mListeners.size();
ipw.print("Number of listeners: ");
diff --git a/services/tests/mockingservicestests/src/com/android/server/am/ActivityManagerServiceInjectorTest.java b/services/tests/mockingservicestests/src/com/android/server/am/ActivityManagerServiceInjectorTest.java
index 09df96f4b917..e01a9a9d473a 100644
--- a/services/tests/mockingservicestests/src/com/android/server/am/ActivityManagerServiceInjectorTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/am/ActivityManagerServiceInjectorTest.java
@@ -69,70 +69,70 @@ public final class ActivityManagerServiceInjectorTest extends ExtendedMockitoTes
}
@Test
- public void testGetSecondaryDisplayIdsForStartingBackgroundUsers_notSupported() {
+ public void testGetDisplayIdsForStartingBackgroundUsers_notSupported() {
mockUmIsUsersOnSecondaryDisplaysEnabled(false);
- int [] displayIds = mInjector.getSecondaryDisplayIdsForStartingBackgroundUsers();
+ int [] displayIds = mInjector.getDisplayIdsForStartingVisibleBackgroundUsers();
- assertWithMessage("mAms.getSecondaryDisplayIdsForStartingBackgroundUsers()")
+ assertWithMessage("mAms.getDisplayIdsForStartingBackgroundUsers()")
.that(displayIds).isNull();
}
@Test
- public void testGetSecondaryDisplayIdsForStartingBackgroundUsers_noDisplaysAtAll() {
+ public void testGetDisplayIdsForStartingBackgroundUsers_noDisplaysAtAll() {
mockUmIsUsersOnSecondaryDisplaysEnabled(true);
mockGetDisplays();
- int[] displayIds = mInjector.getSecondaryDisplayIdsForStartingBackgroundUsers();
+ int[] displayIds = mInjector.getDisplayIdsForStartingVisibleBackgroundUsers();
- assertWithMessage("mAms.getSecondaryDisplayIdsForStartingBackgroundUsers()")
+ assertWithMessage("mAms.getDisplayIdsForStartingBackgroundUsers()")
.that(displayIds).isNull();
}
@Test
- public void testGetSecondaryDisplayIdsForStartingBackgroundUsers_defaultDisplayOnly() {
+ public void testGetDisplayIdsForStartingBackgroundUsers_defaultDisplayOnly() {
mockUmIsUsersOnSecondaryDisplaysEnabled(true);
mockGetDisplays(mDefaultDisplay);
- int[] displayIds = mInjector.getSecondaryDisplayIdsForStartingBackgroundUsers();
+ int[] displayIds = mInjector.getDisplayIdsForStartingVisibleBackgroundUsers();
- assertWithMessage("mAms.getSecondaryDisplayIdsForStartingBackgroundUsers()")
+ assertWithMessage("mAms.getDisplayIdsForStartingBackgroundUsers()")
.that(displayIds).isNull();
}
@Test
- public void testGetSecondaryDisplayIdsForStartingBackgroundUsers_noDefaultDisplay() {
+ public void testGetDisplayIdsForStartingBackgroundUsers_noDefaultDisplay() {
mockUmIsUsersOnSecondaryDisplaysEnabled(true);
mockGetDisplays(validDisplay(42));
- int[] displayIds = mInjector.getSecondaryDisplayIdsForStartingBackgroundUsers();
+ int[] displayIds = mInjector.getDisplayIdsForStartingVisibleBackgroundUsers();
- assertWithMessage("mAms.getSecondaryDisplayIdsForStartingBackgroundUsers()")
+ assertWithMessage("mAms.getDisplayIdsForStartingBackgroundUsers()")
.that(displayIds).isNull();
}
@Test
- public void testGetSecondaryDisplayIdsForStartingBackgroundUsers_mixed() {
+ public void testGetDisplayIdsForStartingBackgroundUsers_mixed() {
mockUmIsUsersOnSecondaryDisplaysEnabled(true);
mockGetDisplays(mDefaultDisplay, validDisplay(42), invalidDisplay(108));
- int[] displayIds = mInjector.getSecondaryDisplayIdsForStartingBackgroundUsers();
+ int[] displayIds = mInjector.getDisplayIdsForStartingVisibleBackgroundUsers();
- assertWithMessage("mAms.getSecondaryDisplayIdsForStartingBackgroundUsers()")
+ assertWithMessage("mAms.getDisplayIdsForStartingBackgroundUsers()")
.that(displayIds).isNotNull();
- assertWithMessage("mAms.getSecondaryDisplayIdsForStartingBackgroundUsers()")
+ assertWithMessage("mAms.getDisplayIdsForStartingBackgroundUsers()")
.that(displayIds).asList().containsExactly(42);
}
// Extra test to make sure the array is properly copied...
@Test
- public void testGetSecondaryDisplayIdsForStartingBackgroundUsers_mixed_invalidFirst() {
+ public void testGetDisplayIdsForStartingBackgroundUsers_mixed_invalidFirst() {
mockUmIsUsersOnSecondaryDisplaysEnabled(true);
mockGetDisplays(invalidDisplay(108), mDefaultDisplay, validDisplay(42));
- int[] displayIds = mInjector.getSecondaryDisplayIdsForStartingBackgroundUsers();
+ int[] displayIds = mInjector.getDisplayIdsForStartingVisibleBackgroundUsers();
- assertWithMessage("mAms.getSecondaryDisplayIdsForStartingBackgroundUsers()")
+ assertWithMessage("mAms.getDisplayIdsForStartingBackgroundUsers()")
.that(displayIds).asList().containsExactly(42);
}
@@ -160,6 +160,6 @@ public final class ActivityManagerServiceInjectorTest extends ExtendedMockitoTes
private void mockUmIsUsersOnSecondaryDisplaysEnabled(boolean enabled) {
Log.d(TAG, "Mocking UserManager.isUsersOnSecondaryDisplaysEnabled() to return " + enabled);
- doReturn(enabled).when(() -> UserManager.isUsersOnSecondaryDisplaysEnabled());
+ doReturn(enabled).when(() -> UserManager.isVisibleBackgroundUsersEnabled());
}
}
diff --git a/services/tests/mockingservicestests/src/com/android/server/pm/UserVisibilityMediatorTestCase.java b/services/tests/mockingservicestests/src/com/android/server/pm/UserVisibilityMediatorTestCase.java
index 74fd9ff3163c..0ac0f5738c6d 100644
--- a/services/tests/mockingservicestests/src/com/android/server/pm/UserVisibilityMediatorTestCase.java
+++ b/services/tests/mockingservicestests/src/com/android/server/pm/UserVisibilityMediatorTestCase.java
@@ -109,12 +109,12 @@ abstract class UserVisibilityMediatorTestCase extends ExtendedMockitoTestCase {
private Handler mHandler;
protected AsyncUserVisibilityListener.Factory mListenerFactory;
- private final boolean mUsersOnSecondaryDisplaysEnabled;
+ private final boolean mBackgroundUsersOnDisplaysEnabled;
protected UserVisibilityMediator mMediator;
- protected UserVisibilityMediatorTestCase(boolean usersOnSecondaryDisplaysEnabled) {
- mUsersOnSecondaryDisplaysEnabled = usersOnSecondaryDisplaysEnabled;
+ protected UserVisibilityMediatorTestCase(boolean backgroundUsersOnDisplaysEnabled) {
+ mBackgroundUsersOnDisplaysEnabled = backgroundUsersOnDisplaysEnabled;
}
@Before
@@ -123,7 +123,7 @@ abstract class UserVisibilityMediatorTestCase extends ExtendedMockitoTestCase {
Thread thread = mHandler.getLooper().getThread();
Log.i(TAG, "setFixtures(): using thread " + thread + " (from handler " + mHandler + ")");
mListenerFactory = new AsyncUserVisibilityListener.Factory(mExpect, thread);
- mMediator = new UserVisibilityMediator(mUsersOnSecondaryDisplaysEnabled, mHandler);
+ mMediator = new UserVisibilityMediator(mBackgroundUsersOnDisplaysEnabled, mHandler);
mDumpableDumperRule.addDumpable(mMediator);
}
diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/am/ActivityManagerServiceTest.java
index 0d6f3267f41d..e9dc0829d905 100644
--- a/services/tests/servicestests/src/com/android/server/am/ActivityManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/am/ActivityManagerServiceTest.java
@@ -834,35 +834,35 @@ public class ActivityManagerServiceTest {
}
@Test
- public void testGetSecondaryDisplayIdsForStartingBackgroundUsers() {
+ public void testGetDisplayIdsForStartingBackgroundUsers() {
mInjector.secondaryDisplayIdsForStartingBackgroundUsers = new int[]{4, 8, 15, 16, 23, 42};
- int [] displayIds = mAms.getSecondaryDisplayIdsForStartingBackgroundUsers();
+ int [] displayIds = mAms.getDisplayIdsForStartingVisibleBackgroundUsers();
- assertWithMessage("mAms.getSecondaryDisplayIdsForStartingBackgroundUsers()")
+ assertWithMessage("mAms.getDisplayIdsForStartingVisibleBackgroundUsers()")
.that(displayIds).asList().containsExactly(4, 8, 15, 16, 23, 42);
}
@Test
- public void testStartUserInBackgroundOnSecondaryDisplay_invalidDisplay() {
+ public void testStartUserInBackgroundVisibleOnDisplay_invalidDisplay() {
mInjector.secondaryDisplayIdsForStartingBackgroundUsers = new int[]{4, 8, 15, 16, 23, 42};
assertThrows(IllegalArgumentException.class,
- () -> mAms.startUserInBackgroundOnSecondaryDisplay(USER_ID, 666));
+ () -> mAms.startUserInBackgroundVisibleOnDisplay(USER_ID, 666));
assertWithMessage("UserController.startUserOnSecondaryDisplay() calls")
.that(mInjector.usersStartedOnSecondaryDisplays).isEmpty();
}
@Test
- public void testStartUserInBackgroundOnSecondaryDisplay_validDisplay_failed() {
+ public void testStartUserInBackgroundVisibleOnDisplay_validDisplay_failed() {
mInjector.secondaryDisplayIdsForStartingBackgroundUsers = new int[]{ 4, 8, 15, 16, 23, 42 };
mInjector.returnValueForstartUserOnSecondaryDisplay = false;
- boolean started = mAms.startUserInBackgroundOnSecondaryDisplay(USER_ID, 42);
+ boolean started = mAms.startUserInBackgroundVisibleOnDisplay(USER_ID, 42);
Log.v(TAG, "Started: " + started);
- assertWithMessage("mAms.startUserInBackgroundOnSecondaryDisplay(%s, 42)", USER_ID)
+ assertWithMessage("mAms.startUserInBackgroundOnDisplay(%s, 42)", USER_ID)
.that(started).isFalse();
assertWithMessage("UserController.startUserOnSecondaryDisplay() calls")
.that(mInjector.usersStartedOnSecondaryDisplays)
@@ -870,16 +870,16 @@ public class ActivityManagerServiceTest {
}
@Test
- public void testStartUserInBackgroundOnSecondaryDisplay_validDisplay_success() {
+ public void testStartUserInBackgroundVisibleOnDisplay_validDisplay_success() {
mInjector.secondaryDisplayIdsForStartingBackgroundUsers = new int[]{ 4, 8, 15, 16, 23, 42 };
mInjector.returnValueForstartUserOnSecondaryDisplay = true;
- boolean started = mAms.startUserInBackgroundOnSecondaryDisplay(USER_ID, 42);
+ boolean started = mAms.startUserInBackgroundVisibleOnDisplay(USER_ID, 42);
Log.v(TAG, "Started: " + started);
- assertWithMessage("mAms.startUserInBackgroundOnSecondaryDisplay(%s, 42)", USER_ID)
+ assertWithMessage("mAms.startUserInBackgroundOnDisplay(%s, 42)", USER_ID)
.that(started).isTrue();
- assertWithMessage("UserController.startUserOnSecondaryDisplay() calls")
+ assertWithMessage("UserController.startUserOnDisplay() calls")
.that(mInjector.usersStartedOnSecondaryDisplays)
.containsExactly(new Pair<>(USER_ID, 42));
}
@@ -1004,12 +1004,12 @@ public class ActivityManagerServiceTest {
}
@Override
- public int[] getSecondaryDisplayIdsForStartingBackgroundUsers() {
+ public int[] getDisplayIdsForStartingVisibleBackgroundUsers() {
return secondaryDisplayIdsForStartingBackgroundUsers;
}
@Override
- public boolean startUserOnSecondaryDisplay(int userId, int displayId) {
+ public boolean startUserInBackgroundVisibleOnDisplay(int userId, int displayId) {
usersStartedOnSecondaryDisplays.add(new Pair<>(userId, displayId));
return returnValueForstartUserOnSecondaryDisplay;
}
diff --git a/services/tests/servicestests/src/com/android/server/am/UserControllerTest.java b/services/tests/servicestests/src/com/android/server/am/UserControllerTest.java
index 0dfe664432c3..b146c2750a05 100644
--- a/services/tests/servicestests/src/com/android/server/am/UserControllerTest.java
+++ b/services/tests/servicestests/src/com/android/server/am/UserControllerTest.java
@@ -243,11 +243,10 @@ public class UserControllerTest {
}
@Test
- public void testStartUserOnSecondaryDisplay() {
- boolean started = mUserController.startUserOnSecondaryDisplay(TEST_USER_ID, 42);
+ public void testStartUserVisibleOnDisplay() {
+ boolean started = mUserController.startUserVisibleOnDisplay(TEST_USER_ID, 42);
- assertWithMessage("startUserOnSecondaryDisplay(%s, %s)", TEST_USER_ID, 42).that(started)
- .isTrue();
+ assertWithMessage("startUserOnDisplay(%s, %s)", TEST_USER_ID, 42).that(started).isTrue();
verifyUserAssignedToDisplay(TEST_USER_ID, 42);
verify(mInjector.getWindowManager(), never()).startFreezingScreen(anyInt(), anyInt());