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

Commit b61744f3 authored by Adam Bookatz's avatar Adam Bookatz Committed by Android (Google) Code Review
Browse files

Merge changes Ie427f7f1,I62310c37,Ifbb359af into main

* changes:
  UserControllerTest.assertRunningUsers
  UserController.startInBackgroundTemporarily
  Don't auto-stop bg user if it's playing audio
parents b3c53e1a 3b323355
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -4525,8 +4525,10 @@ public class AlarmManagerService extends SystemService {
                                    mUserWakeupStore.getUserIdsToWakeup(nowELAPSED);
                            for (int i = 0; i < userIds.length; i++) {
                                if (mActivityManagerInternal.isUserRunning(userIds[i], 0)
                                        || !mActivityManagerInternal.startUserInBackground(
                                                userIds[i])) {
                                        || !mActivityManagerInternal
                                                .startUserInBackgroundTemporarily(
                                                        userIds[i],
                                                        UserWakeupStore.USER_RUN_FOR_TIME_SECS)) {
                                    mUserWakeupStore.removeUserWakeup(userIds[i]);
                                }
                            }
+3 −0
Original line number Diff line number Diff line
@@ -80,6 +80,9 @@ public class UserWakeupStore {
     */
    @VisibleForTesting
    static final long BUFFER_TIME_MS = TimeUnit.SECONDS.toMillis(30);

    /** When a user is being woken due to a pending alarm, for how long should it be woken up. */
    public static final int USER_RUN_FOR_TIME_SECS = (int) TimeUnit.MINUTES.toSeconds(10);
    /**
     * Maximum time deviation limit to introduce a 5-second time window for user starts.
     */
+12 −2
Original line number Diff line number Diff line
@@ -162,11 +162,21 @@ public abstract class ActivityManagerInternal {
    public abstract void onUserRemoved(@UserIdInt int userId);

    /**
     * Start user, if it is not already running, but don't bring it to foreground.
     * Start user in the background but only temporarily; if the user hasn't left the background
     * in the provided duration, it may be automatically stopped (at the system's discretion).
     *
     * The automatic stopping is not guaranteed, and there are many cases in which it won't be.
     *
     * Conversely, there is no guarantee that the user will not be stopped prior to the given
     * duration; e.g. if the default inactive stopping time (from
     * config_backgroundUserScheduledStopTimeSecs) is sooner, then we may stop it then
     * instead. There is no guarantee about this implementation.
     *
     * @param userId ID of the user to start
     * @param durSecs in how many seconds we should attempt to stop the user
     * @return true if the user has been successfully started
     */
    public abstract boolean startUserInBackground(int userId);
    public abstract boolean startUserInBackgroundTemporarily(@UserIdInt int userId, int durSecs);

    /**
     * Kill foreground apps from the specified user.
+5 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package android.media;

import android.annotation.SpecialUsers.CannotBeSpecialUser;
import android.annotation.UserIdInt;
import android.util.IntArray;

import com.android.server.LocalServices;
@@ -73,6 +75,9 @@ public abstract class AudioManagerInternal {
     */
    public abstract void setInputMethodServiceUid(int uid);

    /** Returns whether the given user is currently playing audio. */
    public abstract boolean isUserPlayingAudio(@CannotBeSpecialUser @UserIdInt int userId);

    public interface RingerModeDelegate {
        /** Called when external ringer mode is evaluated, returns the new internal ringer mode */
        int onSetRingerModeExternal(int ringerModeOld, int ringerModeNew, String caller,
+2 −2
Original line number Diff line number Diff line
@@ -16796,8 +16796,8 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        @Override
        public boolean startUserInBackground(final int userId) {
            return ActivityManagerService.this.startUserInBackground(userId);
        public boolean startUserInBackgroundTemporarily(@UserIdInt int userId, int durSecs) {
            return mUserController.startUserInBackgroundTemporarily(userId, durSecs);
        }
        @Override
Loading