Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c0006519 authored by arangelov's avatar arangelov Committed by Antoan Angelov
Browse files

Add STATE_USER_PROFILE_FINALIZED as an additional user state

This will be used as an intermediate state after
STATE_USER_PROFILE_COMPLETE once the work profile has been created.

With the current admin-integrated flow refactoring changes,
the work profile will be finalized earlier than before.
Therefore, we add this new state so that SetupWizard
can differentiate between this state and STATE_USER_UNMANAGED.

Instead of the user states for work profile provisioning being
STATE_USER_UNMANAGED -> STATE_USER_PROFILE_COMPLETE ->
STATE_USER_UNMANAGED, they will now be STATE_USER_UNMANAGED ->
STATE_USER_PROFILE_COMPLETE -> STATE_USER_PROFILE_FINALIZED.

Note that CTS testing this API is infeasible, since it's
a system API and it requires the MANAGE_PROFILE_AND_DEVICE_OWNERS
signature permission which can't be granted to a CTS app.

Bug: 161402545
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest#testSetUserProvisioningState_managedProfileFromSetupWizard_primaryUser
Change-Id: I421d8ad431de6aef779a0b58b7f074ffc74dda48
parent 75a720cf
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -912,6 +912,7 @@ package android.app.admin {
    field public static final int PROVISIONING_TRIGGER_QR_CODE = 2; // 0x2
    field public static final int PROVISIONING_TRIGGER_UNSPECIFIED = 0; // 0x0
    field public static final int STATE_USER_PROFILE_COMPLETE = 4; // 0x4
    field public static final int STATE_USER_PROFILE_FINALIZED = 5; // 0x5
    field public static final int STATE_USER_SETUP_COMPLETE = 2; // 0x2
    field public static final int STATE_USER_SETUP_FINALIZED = 3; // 0x3
    field public static final int STATE_USER_SETUP_INCOMPLETE = 1; // 0x1
+11 −1
Original line number Diff line number Diff line
@@ -1829,6 +1829,15 @@ public class DevicePolicyManager {
    @SystemApi
    public static final int STATE_USER_PROFILE_COMPLETE = 4;
    /**
     * Management setup on a managed profile.
     * <p>This is used as an intermediate state after {@link #STATE_USER_PROFILE_COMPLETE} once the
     * work profile has been created.
     * @hide
     */
    @SystemApi
    public static final int STATE_USER_PROFILE_FINALIZED = 5;
    /**
     * @hide
     */
@@ -1837,7 +1846,8 @@ public class DevicePolicyManager {
            STATE_USER_SETUP_INCOMPLETE,
            STATE_USER_SETUP_COMPLETE,
            STATE_USER_SETUP_FINALIZED,
            STATE_USER_PROFILE_COMPLETE
            STATE_USER_PROFILE_COMPLETE,
            STATE_USER_PROFILE_FINALIZED
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface UserProvisioningState {}
+1 −0
Original line number Diff line number Diff line
@@ -860,6 +860,7 @@ package android.app.admin {
    field public static final int PROVISIONING_TRIGGER_QR_CODE = 2; // 0x2
    field public static final int PROVISIONING_TRIGGER_UNSPECIFIED = 0; // 0x0
    field public static final int STATE_USER_PROFILE_COMPLETE = 4; // 0x4
    field public static final int STATE_USER_PROFILE_FINALIZED = 5; // 0x5
    field public static final int STATE_USER_SETUP_COMPLETE = 2; // 0x2
    field public static final int STATE_USER_SETUP_FINALIZED = 3; // 0x3
    field public static final int STATE_USER_SETUP_INCOMPLETE = 1; // 0x1
+1 −1
Original line number Diff line number Diff line
@@ -7793,7 +7793,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                // Current user has a managed-profile, but current user is not managed, so
                // rather than moving to finalized state, go back to unmanaged once
                // profile provisioning is complete.
                if (newState == DevicePolicyManager.STATE_USER_UNMANAGED) {
                if (newState == DevicePolicyManager.STATE_USER_PROFILE_FINALIZED) {
                    return;
                }
                break;
+1 −1
Original line number Diff line number Diff line
@@ -2814,7 +2814,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {

        exerciseUserProvisioningTransitions(CALLER_USER_HANDLE,
                DevicePolicyManager.STATE_USER_PROFILE_COMPLETE,
                DevicePolicyManager.STATE_USER_UNMANAGED);
                DevicePolicyManager.STATE_USER_PROFILE_FINALIZED);
    }

    public void testSetUserProvisioningState_managedProfileFromSetupWizard_managedProfile()