Allow PO to call setSystemSetting.
As system setting is per user, we should allow PO to call it.
Bug: 77204777
Test: runtest -x services/tests/servicestests/src/
com/android/server/devicepolicy/DevicePolicyManagerTest.java
Change-Id: I84152fa04adb441955b48b676be6e792134b52c2
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 fe47de6..ccf4a82 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
@@ -3454,18 +3454,19 @@
dpm.setSystemSetting(admin1, Settings.System.SCREEN_BRIGHTNESS_FOR_VR, "0"));
}
- public void testSetSystemSettingFailWithPO() throws Exception {
- setupProfileOwner();
- assertExpectException(SecurityException.class, null, () ->
- dpm.setSystemSetting(admin1, Settings.System.SCREEN_BRIGHTNESS, "0"));
- }
-
- public void testSetSystemSetting() throws Exception {
+ public void testSetSystemSettingWithDO() throws Exception {
mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
setupDeviceOwner();
dpm.setSystemSetting(admin1, Settings.System.SCREEN_BRIGHTNESS, "0");
- verify(getServices().settings).settingsSystemPutString(
- Settings.System.SCREEN_BRIGHTNESS, "0");
+ verify(getServices().settings).settingsSystemPutStringForUser(
+ Settings.System.SCREEN_BRIGHTNESS, "0", UserHandle.USER_SYSTEM);
+ }
+
+ public void testSetSystemSettingWithPO() throws Exception {
+ setupProfileOwner();
+ dpm.setSystemSetting(admin1, Settings.System.SCREEN_BRIGHTNESS, "0");
+ verify(getServices().settings).settingsSystemPutStringForUser(
+ Settings.System.SCREEN_BRIGHTNESS, "0", DpmMockContext.CALLER_USER_HANDLE);
}
public void testSetTime() throws Exception {