Makes DPM.getLogoutUser() and clearLogoutUser() system APIs.

They're used by CarService, which cannot use hidden APIs anymore.

Test: m update-api
Bug: 214336184
CTS-Coverage-Bug: 214336184

Change-Id: I7d11f0a2b75fa8b87a5a71d43ffc7adb8e84bc9c
This commit is contained in:
Felipe Leme
2022-01-19 15:07:41 -08:00
parent e490dfa3fe
commit cbc67df471
2 changed files with 10 additions and 3 deletions

View File

@@ -63,6 +63,8 @@ package android.app.admin {
public class DevicePolicyManager {
method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public void acknowledgeNewUserDisclaimer();
method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public void clearLogoutUser();
method @Nullable @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public android.os.UserHandle getLogoutUser();
field public static final String ACTION_SHOW_NEW_USER_DISCLAIMER = "android.app.action.SHOW_NEW_USER_DISCLAIMER";
}

View File

@@ -9864,14 +9864,17 @@ public class DevicePolicyManager {
/**
* Gets the user a {@link #logoutUser(ComponentName)} call would switch to,
* or {@link UserHandle#USER_NULL} if the current user is not in a session.
* or {@code null} if the current user is not in a session.
*
* @hide
*/
@RequiresPermission(android.Manifest.permission.MANAGE_USERS)
public @UserIdInt int getLogoutUserId() {
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
public @Nullable UserHandle getLogoutUser() {
// TODO(b/214336184): add CTS test
try {
return mService.getLogoutUserId();
int userId = mService.getLogoutUserId();
return userId == UserHandle.USER_NULL ? null : UserHandle.of(userId);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -9885,7 +9888,9 @@ public class DevicePolicyManager {
* @hide
*/
@RequiresPermission(android.Manifest.permission.MANAGE_USERS)
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
public void clearLogoutUser() {
// TODO(b/214336184): add CTS test
try {
mService.clearLogoutUser();
} catch (RemoteException re) {