summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author kholoud mohamed <kholoudm@google.com> 2021-03-10 13:57:16 +0000
committer kholoud mohamed <kholoudm@google.com> 2021-03-10 18:15:41 +0000
commit3c4b81418972f7c8e2d61e83eeeaec61ea29fc0b (patch)
tree849242c4c95bf603b915601b2a43ffb38ab22a95
parented23887b8ebe0dc9a7b882763164d52c84463621 (diff)
Allow forceUpdateUserSetupComplete on user builds
This fixes some failing cts tests running on user builds. Test: atest android.devicepolicy.cts.DevicePolicyManagerTest Fixes: 181567444 Change-Id: I07c3a98fcbe79d41fb224967569b877eefbc593c
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java2
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java4
-rw-r--r--services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java30
3 files changed, 2 insertions, 34 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index b919bfc92e79..75fda47f4081 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -11769,7 +11769,7 @@ public class DevicePolicyManager {
/**
* @hide
- * Force update user setup completed status. This API has no effect on user build.
+ * Force update user setup completed status.
* @throws {@link SecurityException} if the caller has no
* {@code android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS} or the caller is
* not {@link UserHandle#SYSTEM_USER}
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 28e9acf8d883..fbb8988de2b8 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -14101,10 +14101,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
hasCallingOrSelfPermission(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS));
enforceCallerSystemUserHandle();
- // no effect if it's called from user build
- if (!mInjector.isBuildDebuggable()) {
- return;
- }
final int userId = UserHandle.USER_SYSTEM;
boolean isUserCompleted = mInjector.settingsSecureGetIntForUser(
Settings.Secure.USER_SETUP_COMPLETE, 0, userId) != 0;
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 87100a63e35e..89435e9a8862 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
@@ -3875,7 +3875,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
}
@Test
- public void testForceUpdateUserSetupComplete_userbuild() {
+ public void testForceUpdateUserSetupComplete_forcesUpdate() {
mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
@@ -3888,34 +3888,6 @@ public class DevicePolicyManagerTest extends DpmTestBase {
userData.mUserSetupComplete = true;
dpms.mUserData.put(UserHandle.USER_SYSTEM, userData);
- // GIVEN it's user build
- getServices().buildMock.isDebuggable = false;
-
- assertThat(dpms.hasUserSetupCompleted()).isTrue();
-
- dpm.forceUpdateUserSetupComplete();
-
- // THEN the state in dpms is not changed
- assertThat(dpms.hasUserSetupCompleted()).isTrue();
- }
-
- @Test
- public void testForceUpdateUserSetupComplete_userDebugbuild() {
- mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
- mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
-
- final int userId = UserHandle.USER_SYSTEM;
- // GIVEN userComplete is false in SettingsProvider
- setUserSetupCompleteForUser(false, userId);
-
- // GIVEN userComplete is true in DPM
- DevicePolicyData userData = new DevicePolicyData(userId);
- userData.mUserSetupComplete = true;
- dpms.mUserData.put(UserHandle.USER_SYSTEM, userData);
-
- // GIVEN it's userdebug build
- getServices().buildMock.isDebuggable = true;
-
assertThat(dpms.hasUserSetupCompleted()).isTrue();
dpm.forceUpdateUserSetupComplete();