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

Commit be2d5c96 authored by Adam Bookatz's avatar Adam Bookatz
Browse files

Schedule bg user stopping: flag off configuration

The background-user scheduled stopping mechanism is already behind a
flag. We don't want to turn on the feature just yet. But we now plan to
re-use the same infrastructure for other purposes too. So we now split
the flag coverage: the infrastructure will continue to be guarded by the
previous flag (which we plan to advance), but the current feature will
continue to be implicitly disabled until its own dedicated flag gets
advanced too, using the flag introduced in this cl.

Flag: android.multiuser.schedule_stop_of_background_user_by_default
Test: UserControllerTest
Bug: 330351042
Change-Id: I19a2a14b00fcbed3d98582c9d2639ec74b938dac
parent 6ee7692b
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -297,7 +297,14 @@ flag {
flag {
    name: "schedule_stop_of_background_user"
    namespace: "multiuser"
    description: "Schedule background users to be stopped at a future point."
    description: "Schedule background users to be stopped at a future point. Infrastructure only."
    bug: "330351042"
}

flag {
    name: "schedule_stop_of_background_user_by_default"
    namespace: "multiuser"
    description: "Activates the background-stopping schedule of inactive users based on the time specified in the configuration."
    bug: "330351042"
}

+4 −1
Original line number Diff line number Diff line
@@ -477,7 +477,10 @@ class UserController implements Handler.Callback {
            mUserSwitchUiEnabled = userSwitchUiEnabled;
            mMaxRunningUsers = maxRunningUsers;
            mDelayUserDataLocking = delayUserDataLocking;
            if (android.multiuser.Flags.scheduleStopOfBackgroundUserByDefault()) {
                // If flag is off, default value of -1 disables scheduling (but not infrastructure).
                mBackgroundUserScheduledStopTimeSecs = backgroundUserScheduledStopTimeSecs;
            }
            mInitialized = true;
        }
    }
+12 −4
Original line number Diff line number Diff line
@@ -643,7 +643,9 @@ public class UserControllerTest {
    /** Test scheduling stopping of background users after a user-switch. */
    @Test
    public void testScheduleStopOfBackgroundUser_switch() {
        mSetFlagsRule.enableFlags(android.multiuser.Flags.FLAG_SCHEDULE_STOP_OF_BACKGROUND_USER);
        mSetFlagsRule.enableFlags(
                android.multiuser.Flags.FLAG_SCHEDULE_STOP_OF_BACKGROUND_USER,
                android.multiuser.Flags.FLAG_SCHEDULE_STOP_OF_BACKGROUND_USER_BY_DEFAULT);
        assumeFalse(UserManager.isVisibleBackgroundUsersEnabled());

        mUserController.setInitialConfig(/* userSwitchUiEnabled= */ true,
@@ -693,7 +695,9 @@ public class UserControllerTest {
    /** Test scheduling stopping of background users that were started in the background. */
    @Test
    public void testScheduleStopOfBackgroundUser_startInBackground() throws Exception {
        mSetFlagsRule.enableFlags(android.multiuser.Flags.FLAG_SCHEDULE_STOP_OF_BACKGROUND_USER);
        mSetFlagsRule.enableFlags(
                android.multiuser.Flags.FLAG_SCHEDULE_STOP_OF_BACKGROUND_USER,
                android.multiuser.Flags.FLAG_SCHEDULE_STOP_OF_BACKGROUND_USER_BY_DEFAULT);
        assumeFalse(UserManager.isVisibleBackgroundUsersEnabled());

        mUserController.setInitialConfig(/* userSwitchUiEnabled= */ true,
@@ -733,7 +737,9 @@ public class UserControllerTest {
    /** Test scheduling stopping of background users - reschedule if current user is a guest. */
    @Test
    public void testScheduleStopOfBackgroundUser_rescheduleWhenGuest() throws Exception {
        mSetFlagsRule.enableFlags(android.multiuser.Flags.FLAG_SCHEDULE_STOP_OF_BACKGROUND_USER);
        mSetFlagsRule.enableFlags(
                android.multiuser.Flags.FLAG_SCHEDULE_STOP_OF_BACKGROUND_USER,
                android.multiuser.Flags.FLAG_SCHEDULE_STOP_OF_BACKGROUND_USER_BY_DEFAULT);
        assumeFalse(UserManager.isVisibleBackgroundUsersEnabled());

        mUserController.setInitialConfig(/* userSwitchUiEnabled= */ true,
@@ -789,7 +795,9 @@ public class UserControllerTest {
    /** Test scheduling stopping of background users - reschedule if user with a scheduled alarm. */
    @Test
    public void testScheduleStopOfBackgroundUser_rescheduleIfAlarm() throws Exception {
        mSetFlagsRule.enableFlags(android.multiuser.Flags.FLAG_SCHEDULE_STOP_OF_BACKGROUND_USER);
        mSetFlagsRule.enableFlags(
                android.multiuser.Flags.FLAG_SCHEDULE_STOP_OF_BACKGROUND_USER,
                android.multiuser.Flags.FLAG_SCHEDULE_STOP_OF_BACKGROUND_USER_BY_DEFAULT);
        assumeFalse(UserManager.isVisibleBackgroundUsersEnabled());

        mUserController.setInitialConfig(/* userSwitchUiEnabled= */ true,