Loading services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +17 −5 Original line number Original line Diff line number Diff line Loading @@ -1405,8 +1405,8 @@ public class DevicePolicyManagerTest extends DpmTestBase { assertEquals(admin2, dpms.getDeviceOwnerComponent(/* callingUserOnly =*/ false)); assertEquals(admin2, dpms.getDeviceOwnerComponent(/* callingUserOnly =*/ false)); // Then check getDeviceOwnerAdminLocked(). // Then check getDeviceOwnerAdminLocked(). assertEquals(admin2, dpms.getDeviceOwnerAdminLocked().info.getComponent()); assertEquals(admin2, getDeviceOwner().info.getComponent()); assertEquals(DpmMockContext.CALLER_UID, dpms.getDeviceOwnerAdminLocked().getUid()); assertEquals(DpmMockContext.CALLER_UID, getDeviceOwner().getUid()); } } /** /** Loading Loading @@ -1759,7 +1759,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { DpmTestUtils.assertRestrictions( DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions( DpmTestUtils.newRestrictions( UserManager.DISALLOW_ADD_USER, UserManager.DISALLOW_OUTGOING_CALLS), UserManager.DISALLOW_ADD_USER, UserManager.DISALLOW_OUTGOING_CALLS), dpms.getDeviceOwnerAdminLocked().ensureUserRestrictions() getDeviceOwner().ensureUserRestrictions() ); ); DpmTestUtils.assertRestrictions( DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions( DpmTestUtils.newRestrictions( Loading @@ -1776,7 +1776,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { DpmTestUtils.assertRestrictions( DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(UserManager.DISALLOW_OUTGOING_CALLS), DpmTestUtils.newRestrictions(UserManager.DISALLOW_OUTGOING_CALLS), dpms.getDeviceOwnerAdminLocked().ensureUserRestrictions() getDeviceOwner().ensureUserRestrictions() ); ); DpmTestUtils.assertRestrictions( DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(UserManager.DISALLOW_OUTGOING_CALLS), DpmTestUtils.newRestrictions(UserManager.DISALLOW_OUTGOING_CALLS), Loading Loading @@ -1834,6 +1834,18 @@ public class DevicePolicyManagerTest extends DpmTestBase { reset(getServices().userManagerInternal); reset(getServices().userManagerInternal); } } private DevicePolicyManagerService.ActiveAdmin getDeviceOwner() { ComponentName component = dpms.mOwners.getDeviceOwnerComponent(); DevicePolicyManagerService.DevicePolicyData policy = dpms.getUserData(dpms.mOwners.getDeviceOwnerUserId()); for (DevicePolicyManagerService.ActiveAdmin admin : policy.mAdminList) { if (component.equals(admin.info.getComponent())) { return admin; } } return null; } public void testDaDisallowedPolicies_SecurityException() throws Exception { public void testDaDisallowedPolicies_SecurityException() throws Exception { mContext.callerPermissions.add(permission.MANAGE_DEVICE_ADMINS); mContext.callerPermissions.add(permission.MANAGE_DEVICE_ADMINS); mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS_FULL); mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS_FULL); Loading Loading @@ -2067,7 +2079,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { private void assertNoDeviceOwnerRestrictions() { private void assertNoDeviceOwnerRestrictions() { DpmTestUtils.assertRestrictions( DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(), DpmTestUtils.newRestrictions(), dpms.getDeviceOwnerAdminLocked().ensureUserRestrictions() getDeviceOwner().ensureUserRestrictions() ); ); DpmTestUtils.assertRestrictions( DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(), DpmTestUtils.newRestrictions(), Loading Loading
services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +17 −5 Original line number Original line Diff line number Diff line Loading @@ -1405,8 +1405,8 @@ public class DevicePolicyManagerTest extends DpmTestBase { assertEquals(admin2, dpms.getDeviceOwnerComponent(/* callingUserOnly =*/ false)); assertEquals(admin2, dpms.getDeviceOwnerComponent(/* callingUserOnly =*/ false)); // Then check getDeviceOwnerAdminLocked(). // Then check getDeviceOwnerAdminLocked(). assertEquals(admin2, dpms.getDeviceOwnerAdminLocked().info.getComponent()); assertEquals(admin2, getDeviceOwner().info.getComponent()); assertEquals(DpmMockContext.CALLER_UID, dpms.getDeviceOwnerAdminLocked().getUid()); assertEquals(DpmMockContext.CALLER_UID, getDeviceOwner().getUid()); } } /** /** Loading Loading @@ -1759,7 +1759,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { DpmTestUtils.assertRestrictions( DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions( DpmTestUtils.newRestrictions( UserManager.DISALLOW_ADD_USER, UserManager.DISALLOW_OUTGOING_CALLS), UserManager.DISALLOW_ADD_USER, UserManager.DISALLOW_OUTGOING_CALLS), dpms.getDeviceOwnerAdminLocked().ensureUserRestrictions() getDeviceOwner().ensureUserRestrictions() ); ); DpmTestUtils.assertRestrictions( DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions( DpmTestUtils.newRestrictions( Loading @@ -1776,7 +1776,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { DpmTestUtils.assertRestrictions( DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(UserManager.DISALLOW_OUTGOING_CALLS), DpmTestUtils.newRestrictions(UserManager.DISALLOW_OUTGOING_CALLS), dpms.getDeviceOwnerAdminLocked().ensureUserRestrictions() getDeviceOwner().ensureUserRestrictions() ); ); DpmTestUtils.assertRestrictions( DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(UserManager.DISALLOW_OUTGOING_CALLS), DpmTestUtils.newRestrictions(UserManager.DISALLOW_OUTGOING_CALLS), Loading Loading @@ -1834,6 +1834,18 @@ public class DevicePolicyManagerTest extends DpmTestBase { reset(getServices().userManagerInternal); reset(getServices().userManagerInternal); } } private DevicePolicyManagerService.ActiveAdmin getDeviceOwner() { ComponentName component = dpms.mOwners.getDeviceOwnerComponent(); DevicePolicyManagerService.DevicePolicyData policy = dpms.getUserData(dpms.mOwners.getDeviceOwnerUserId()); for (DevicePolicyManagerService.ActiveAdmin admin : policy.mAdminList) { if (component.equals(admin.info.getComponent())) { return admin; } } return null; } public void testDaDisallowedPolicies_SecurityException() throws Exception { public void testDaDisallowedPolicies_SecurityException() throws Exception { mContext.callerPermissions.add(permission.MANAGE_DEVICE_ADMINS); mContext.callerPermissions.add(permission.MANAGE_DEVICE_ADMINS); mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS_FULL); mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS_FULL); Loading Loading @@ -2067,7 +2079,7 @@ public class DevicePolicyManagerTest extends DpmTestBase { private void assertNoDeviceOwnerRestrictions() { private void assertNoDeviceOwnerRestrictions() { DpmTestUtils.assertRestrictions( DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(), DpmTestUtils.newRestrictions(), dpms.getDeviceOwnerAdminLocked().ensureUserRestrictions() getDeviceOwner().ensureUserRestrictions() ); ); DpmTestUtils.assertRestrictions( DpmTestUtils.assertRestrictions( DpmTestUtils.newRestrictions(), DpmTestUtils.newRestrictions(), Loading