Loading services/accessibility/java/com/android/server/accessibility/AccessibilitySecurityPolicy.java +10 −0 Original line number Diff line number Diff line Loading @@ -440,6 +440,10 @@ public class AccessibilitySecurityPolicy { /** * Returns the parent userId of the profile according to the specified userId. * * <p>For accessibility purposes, a supervising profile, which is a shell profile used for * setting up parental controls and doesn't have its own accessibility settings, is viewed as a * child of the current user. * * @param userId The userId to check * @return the parent userId of the profile, or self if no parent exist */ Loading @@ -447,6 +451,12 @@ public class AccessibilitySecurityPolicy { if (userId != mAccessibilityUserManager.getCurrentUserIdLocked()) { final long identity = Binder.clearCallingIdentity(); try { if (android.multiuser.Flags.allowSupervisingProfile()) { UserInfo userInfo = mUserManager.getUserInfo(userId); if (userInfo != null && userInfo.isSupervisingProfile()) { return mAccessibilityUserManager.getCurrentUserIdLocked(); } } UserInfo parent = mUserManager.getProfileParent(userId); if (parent != null) { return parent.getUserHandle().getIdentifier(); Loading services/tests/servicestests/src/com/android/server/accessibility/AccessibilitySecurityPolicyTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.accessibility; import static android.content.pm.PackageManager.MATCH_ANY_USER; import static android.os.UserManager.USER_TYPE_PROFILE_SUPERVISING; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; Loading Loading @@ -49,9 +50,11 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManagerInternal; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.pm.UserInfo; import android.os.Process; import android.os.UserHandle; import android.os.UserManager; import android.platform.test.annotations.RequiresFlagsEnabled; import android.testing.DexmakerShareClassLoaderRule; import android.testing.TestableContext; import android.util.ArraySet; Loading Loading @@ -458,6 +461,19 @@ public class AccessibilitySecurityPolicyTest { currentUserId); } @Test @RequiresFlagsEnabled(android.multiuser.Flags.FLAG_ALLOW_SUPERVISING_PROFILE) public void resolveProfileParent_userIdNotCurrentUser_isSupervising_returnCurrentUser() { final int userId = 15; final int currentUserId = 20; when(mMockA11yUserManager.getCurrentUserIdLocked()).thenReturn(currentUserId); when(mMockUserManager.getUserInfo(userId)) .thenReturn( new UserInfo( userId, "Supervising", null, 0, USER_TYPE_PROFILE_SUPERVISING)); assertEquals(mA11ySecurityPolicy.resolveProfileParentLocked(userId), currentUserId); } @Test public void resolveProfileParent_userIdNotCurrentUser_shouldGetProfileParent() { final int userId = 15; Loading Loading
services/accessibility/java/com/android/server/accessibility/AccessibilitySecurityPolicy.java +10 −0 Original line number Diff line number Diff line Loading @@ -440,6 +440,10 @@ public class AccessibilitySecurityPolicy { /** * Returns the parent userId of the profile according to the specified userId. * * <p>For accessibility purposes, a supervising profile, which is a shell profile used for * setting up parental controls and doesn't have its own accessibility settings, is viewed as a * child of the current user. * * @param userId The userId to check * @return the parent userId of the profile, or self if no parent exist */ Loading @@ -447,6 +451,12 @@ public class AccessibilitySecurityPolicy { if (userId != mAccessibilityUserManager.getCurrentUserIdLocked()) { final long identity = Binder.clearCallingIdentity(); try { if (android.multiuser.Flags.allowSupervisingProfile()) { UserInfo userInfo = mUserManager.getUserInfo(userId); if (userInfo != null && userInfo.isSupervisingProfile()) { return mAccessibilityUserManager.getCurrentUserIdLocked(); } } UserInfo parent = mUserManager.getProfileParent(userId); if (parent != null) { return parent.getUserHandle().getIdentifier(); Loading
services/tests/servicestests/src/com/android/server/accessibility/AccessibilitySecurityPolicyTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.accessibility; import static android.content.pm.PackageManager.MATCH_ANY_USER; import static android.os.UserManager.USER_TYPE_PROFILE_SUPERVISING; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; Loading Loading @@ -49,9 +50,11 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManagerInternal; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.pm.UserInfo; import android.os.Process; import android.os.UserHandle; import android.os.UserManager; import android.platform.test.annotations.RequiresFlagsEnabled; import android.testing.DexmakerShareClassLoaderRule; import android.testing.TestableContext; import android.util.ArraySet; Loading Loading @@ -458,6 +461,19 @@ public class AccessibilitySecurityPolicyTest { currentUserId); } @Test @RequiresFlagsEnabled(android.multiuser.Flags.FLAG_ALLOW_SUPERVISING_PROFILE) public void resolveProfileParent_userIdNotCurrentUser_isSupervising_returnCurrentUser() { final int userId = 15; final int currentUserId = 20; when(mMockA11yUserManager.getCurrentUserIdLocked()).thenReturn(currentUserId); when(mMockUserManager.getUserInfo(userId)) .thenReturn( new UserInfo( userId, "Supervising", null, 0, USER_TYPE_PROFILE_SUPERVISING)); assertEquals(mA11ySecurityPolicy.resolveProfileParentLocked(userId), currentUserId); } @Test public void resolveProfileParent_userIdNotCurrentUser_shouldGetProfileParent() { final int userId = 15; Loading