summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorAdam Bookatz <bookatz@google.com>2020-12-10 17:46:01 -0800
committerLorenzo Colitti <lorenzo@google.com>2021-01-14 17:39:13 +0900
commit81762facaeec7c2daf492b06bda7bd0b9f7cd44e (patch)
treeef2f57439a8ec97a2239757536001388b9246cc6 /core/java/android
parent755cf3be3f2dc0811d005473f25ac4c2a119c8d4 (diff)
UserManager restricted profile SystemApis
Makes two new SystemApis: getRestrictedProfileParent() canHaveRestrictedProfile() Temporarily disables VPN Tests that rely on the old APIs until those tests are updated (b/175883995). Bug: 171529940 Test: atest FrameworksNetTests:com.android.server.connectivity.VpnTest Test: Tests for UserManager SystemApis are TODO awaiting completion of new user test infrastructure (b/163890431) (cherry picked from commit 20ba13f5bc482de37a569c8c791ee5be9e7874b4) Change-Id: I28e39400039631e7d391dc7b0d003e8a38d1f06a
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/os/UserManager.java28
1 files changed, 25 insertions, 3 deletions
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 67d5f5f205cc..59302afd5fb2 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -1992,13 +1992,16 @@ public class UserManager {
}
/**
- * Checks if specified user can have restricted profile.
+ * Checks if the calling context user can have a restricted profile.
+ * @return whether the context user can have a restricted profile.
* @hide
*/
+ @SystemApi
@RequiresPermission(android.Manifest.permission.MANAGE_USERS)
- public boolean canHaveRestrictedProfile(@UserIdInt int userId) {
+ @UserHandleAware
+ public boolean canHaveRestrictedProfile() {
try {
- return mService.canHaveRestrictedProfile(userId);
+ return mService.canHaveRestrictedProfile(mUserId);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
@@ -2020,6 +2023,25 @@ public class UserManager {
}
/**
+ * Get the parent of a restricted profile.
+ *
+ * @return the parent of the user or {@code null} if the user is not restricted profile
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(anyOf = {Manifest.permission.MANAGE_USERS,
+ Manifest.permission.CREATE_USERS})
+ @UserHandleAware
+ public @Nullable UserHandle getRestrictedProfileParent() {
+ final UserInfo info = getUserInfo(mUserId);
+ if (info == null) return null;
+ if (!info.isRestricted()) return null;
+ final int parent = info.restrictedProfileParentId;
+ if (parent == UserHandle.USER_NULL) return null;
+ return UserHandle.of(parent);
+ }
+
+ /**
* Checks if a user is a guest user.
* @return whether user is a guest user.
* @hide