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

Commit f55ee221 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add a config parameter for the max num of tasks" into main

parents dcca529a 449343c7
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -7069,6 +7069,9 @@
    <!-- Whether desktop mode is supported on the current device  -->
    <!-- Whether desktop mode is supported on the current device  -->
    <bool name="config_isDesktopModeSupported">false</bool>
    <bool name="config_isDesktopModeSupported">false</bool>


    <!-- Maximum number of active tasks on a given Desktop Windowing session. Set to 0 for unlimited. -->
    <integer name="config_maxDesktopWindowingActiveTasks">0</integer>

    <!-- Frame rate compatibility value for Wallpaper
    <!-- Frame rate compatibility value for Wallpaper
         FRAME_RATE_COMPATIBILITY_MIN (102) is used by default for lower power consumption -->
         FRAME_RATE_COMPATIBILITY_MIN (102) is used by default for lower power consumption -->
    <integer name="config_wallpaperFrameRateCompatibility">102</integer>
    <integer name="config_wallpaperFrameRateCompatibility">102</integer>
+3 −0
Original line number Original line Diff line number Diff line
@@ -5522,6 +5522,9 @@
  <!-- Whether desktop mode is supported on the current device  -->
  <!-- Whether desktop mode is supported on the current device  -->
  <java-symbol type="bool" name="config_isDesktopModeSupported" />
  <java-symbol type="bool" name="config_isDesktopModeSupported" />


  <!-- Maximum number of active tasks on a given Desktop Windowing session. Set to 0 for unlimited. -->
  <java-symbol type="integer" name="config_maxDesktopWindowingActiveTasks"/>

  <!-- Frame rate compatibility value for Wallpaper -->
  <!-- Frame rate compatibility value for Wallpaper -->
  <java-symbol type="integer" name="config_wallpaperFrameRateCompatibility" />
  <java-symbol type="integer" name="config_wallpaperFrameRateCompatibility" />


+9 −13
Original line number Original line Diff line number Diff line
@@ -89,20 +89,15 @@ public class DesktopModeStatus {
    private static final int DESKTOP_DENSITY_MAX = 1000;
    private static final int DESKTOP_DENSITY_MAX = 1000;


    /**
    /**
     * Default value for {@code MAX_TASK_LIMIT}.
     * Sysprop declaring the maximum number of Tasks to show in Desktop Mode at any one time.
     */
     *
    @VisibleForTesting
     * <p>If it is not defined, then {@code R.integer.config_maxDesktopWindowingActiveTasks} is
    public static final int DEFAULT_MAX_TASK_LIMIT = 4;
     * used.

    // TODO(b/335131008): add a config-overlay field for the max number of tasks in Desktop Mode
    /**
     * Flag declaring the maximum number of Tasks to show in Desktop Mode at any one time.
     *
     *
     * <p>The limit does NOT affect Picture-in-Picture, Bubbles, or System Modals (like a screen
     * <p>The limit does NOT affect Picture-in-Picture, Bubbles, or System Modals (like a screen
     * recording window, or Bluetooth pairing window).
     * recording window, or Bluetooth pairing window).
     */
     */
    private static final int MAX_TASK_LIMIT = SystemProperties.getInt(
    private static final String MAX_TASK_LIMIT_SYS_PROP = "persist.wm.debug.desktop_max_task_limit";
            "persist.wm.debug.desktop_max_task_limit", DEFAULT_MAX_TASK_LIMIT);


    /**
    /**
     * Return {@code true} if veiled resizing is active. If false, fluid resizing is used.
     * Return {@code true} if veiled resizing is active. If false, fluid resizing is used.
@@ -139,8 +134,9 @@ public class DesktopModeStatus {
    /**
    /**
     * Return the maximum limit on the number of Tasks to show in Desktop Mode at any one time.
     * Return the maximum limit on the number of Tasks to show in Desktop Mode at any one time.
     */
     */
    public static int getMaxTaskLimit() {
    public static int getMaxTaskLimit(@NonNull Context context) {
        return MAX_TASK_LIMIT;
        return SystemProperties.getInt(MAX_TASK_LIMIT_SYS_PROP,
                context.getResources().getInteger(R.integer.config_maxDesktopWindowingActiveTasks));
    }
    }


    /**
    /**
+4 −2
Original line number Original line Diff line number Diff line
@@ -567,13 +567,15 @@ public abstract class WMShellModule {
            Transitions transitions,
            Transitions transitions,
            @DynamicOverride DesktopModeTaskRepository desktopModeTaskRepository,
            @DynamicOverride DesktopModeTaskRepository desktopModeTaskRepository,
            ShellTaskOrganizer shellTaskOrganizer) {
            ShellTaskOrganizer shellTaskOrganizer) {
        int maxTaskLimit = DesktopModeStatus.getMaxTaskLimit(context);
        if (!DesktopModeStatus.canEnterDesktopMode(context)
        if (!DesktopModeStatus.canEnterDesktopMode(context)
                || DESKTOP_WINDOWING_MODE.isEnabled(context)) {
                || DESKTOP_WINDOWING_MODE.isEnabled(context)
                || maxTaskLimit <= 0) {
            return Optional.empty();
            return Optional.empty();
        }
        }
        return Optional.of(
        return Optional.of(
                new DesktopTasksLimiter(
                new DesktopTasksLimiter(
                        transitions, desktopModeTaskRepository, shellTaskOrganizer));
                        transitions, desktopModeTaskRepository, shellTaskOrganizer, maxTaskLimit));
    }
    }




+6 −8
Original line number Original line Diff line number Diff line
@@ -26,7 +26,6 @@ import androidx.annotation.VisibleForTesting
import com.android.internal.protolog.ProtoLog
import com.android.internal.protolog.ProtoLog
import com.android.wm.shell.ShellTaskOrganizer
import com.android.wm.shell.ShellTaskOrganizer
import com.android.wm.shell.protolog.ShellProtoLogGroup
import com.android.wm.shell.protolog.ShellProtoLogGroup
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus
import com.android.wm.shell.transition.Transitions
import com.android.wm.shell.transition.Transitions
import com.android.wm.shell.transition.Transitions.TransitionObserver
import com.android.wm.shell.transition.Transitions.TransitionObserver


@@ -40,12 +39,17 @@ class DesktopTasksLimiter (
        transitions: Transitions,
        transitions: Transitions,
        private val taskRepository: DesktopModeTaskRepository,
        private val taskRepository: DesktopModeTaskRepository,
        private val shellTaskOrganizer: ShellTaskOrganizer,
        private val shellTaskOrganizer: ShellTaskOrganizer,
        private val maxTasksLimit: Int,
) {
) {
    private val minimizeTransitionObserver = MinimizeTransitionObserver()
    private val minimizeTransitionObserver = MinimizeTransitionObserver()
    @VisibleForTesting
    @VisibleForTesting
    val leftoverMinimizedTasksRemover = LeftoverMinimizedTasksRemover()
    val leftoverMinimizedTasksRemover = LeftoverMinimizedTasksRemover()


    init {
    init {
        require(maxTasksLimit > 0) {
            "DesktopTasksLimiter should not be created with a maxTasksLimit at 0 or less. " +
                    "Current value: $maxTasksLimit."
        }
        transitions.registerObserver(minimizeTransitionObserver)
        transitions.registerObserver(minimizeTransitionObserver)
        taskRepository.addActiveTaskListener(leftoverMinimizedTasksRemover)
        taskRepository.addActiveTaskListener(leftoverMinimizedTasksRemover)
    }
    }
@@ -193,12 +197,6 @@ class DesktopTasksLimiter (
                transition, TaskDetails(displayId, taskId))
                transition, TaskDetails(displayId, taskId))
    }
    }


    /**
     * Returns the maximum number of tasks that should ever be displayed at the same time in Desktop
     * Mode.
     */
    fun getMaxTaskLimit(): Int = DesktopModeStatus.getMaxTaskLimit()

    /**
    /**
     * Returns the Task to minimize given 1. a list of visible tasks ordered from front to back and
     * Returns the Task to minimize given 1. a list of visible tasks ordered from front to back and
     * 2. a new task placed in front of all the others.
     * 2. a new task placed in front of all the others.
@@ -216,7 +214,7 @@ class DesktopTasksLimiter (
    fun getTaskToMinimizeIfNeeded(
    fun getTaskToMinimizeIfNeeded(
            visibleFreeformTaskIdsOrderedFrontToBack: List<Int>
            visibleFreeformTaskIdsOrderedFrontToBack: List<Int>
    ): RunningTaskInfo? {
    ): RunningTaskInfo? {
        if (visibleFreeformTaskIdsOrderedFrontToBack.size <= getMaxTaskLimit()) {
        if (visibleFreeformTaskIdsOrderedFrontToBack.size <= maxTasksLimit) {
            ProtoLog.v(
            ProtoLog.v(
                    ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE,
                    ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE,
                    "DesktopTasksLimiter: no need to minimize; tasks below limit")
                    "DesktopTasksLimiter: no need to minimize; tasks below limit")
Loading