Allow setting managing organization for the device
The Profile Owner of a managed profile can set a string that will be
shown in the UI to identify the organization managing the profile.
This CL extends the functionality to the Device Owner of a managed
device.
Bug: 32692748
Test: DevicePolicyManagerTest unit test + CTS test in separate CL
Change-Id: I47295da2fd6485ebf0e890da13990a044accaf17
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
index 46d93b2..3ad40758 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
@@ -2532,6 +2532,30 @@
assertFalse(dpm.isDeviceManaged());
}
+ public void testDeviceOwnerOrganizationName() throws Exception {
+ mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
+ setupDeviceOwner();
+
+ dpm.setOrganizationName(admin1, "organization");
+
+ // Device owner can retrieve organization managing the device.
+ assertEquals("organization", dpm.getDeviceOwnerOrganizationName());
+
+ // Any uid holding MANAGE_USERS permission can retrieve organization managing the device.
+ mContext.binder.callingUid = 1234567;
+ mContext.callerPermissions.add(permission.MANAGE_USERS);
+ assertEquals("organization", dpm.getDeviceOwnerOrganizationName());
+ mContext.callerPermissions.remove(permission.MANAGE_USERS);
+
+ // System can retrieve organization managing the device.
+ mContext.binder.clearCallingIdentity();
+ assertEquals("organization", dpm.getDeviceOwnerOrganizationName());
+
+ // Removing the device owner clears the organization managing the device.
+ clearDeviceOwner();
+ assertNull(dpm.getDeviceOwnerOrganizationName());
+ }
+
private void setUserSetupCompleteForUser(boolean isUserSetupComplete, int userhandle) {
when(mContext.settings.settingsSecureGetIntForUser(Settings.Secure.USER_SETUP_COMPLETE, 0,
userhandle)).thenReturn(isUserSetupComplete ? 1 : 0);