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

Commit d6aa3db6 authored by Winson Chung's avatar Winson Chung
Browse files

2/Trimming tasks based on active and visibility

- Add logic to trim tasks beyond the max-recents policy, including
  migrating the trimming of quiet profile tasks and visibile tasks
  to the system (to ensure callers always get a consistent list)
- Remove trimmed recent tasks from the active task list
- Add logic to actually handle config_hasRecents to determine whether to
  apply visibility filtering (otherwise only filters by max-recents as
  before)

Bug: 34270611
Test: runtest --path frameworks/base/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java

Change-Id: If17586cd9e8ac1ae8f112239381adc96a0528123
parent 1dbc8112
Loading
Loading
Loading
Loading
+29 −1
Original line number Diff line number Diff line
@@ -2352,9 +2352,37 @@
    <!-- Package name for default network scorer app; overridden by product overlays. -->
    <string name="config_defaultNetworkScorerPackageName"></string>

    <!-- default device has recents property -->
    <!-- Determines whether recent tasks are provided to the user. Default device has recents
         property. If this is false, then the following recents config flags are ignored. -->
    <bool name="config_hasRecents">true</bool>

    <!-- The minimum number of visible recent tasks to be presented to the user through the
         SystemUI. Can be -1 if there is no minimum limit. -->
    <integer name="config_minNumVisibleRecentTasks_grid">-1</integer>

    <!-- The maximum number of visible recent tasks to be presented to the user through the
         SystemUI. Can be -1 if there is no maximum limit. -->
    <integer name="config_maxNumVisibleRecentTasks_grid">9</integer>

    <!-- The minimum number of visible recent tasks to be presented to the user through the
         SystemUI. Can be -1 if there is no minimum limit. -->
    <integer name="config_minNumVisibleRecentTasks_lowRam">-1</integer>

    <!-- The maximum number of visible recent tasks to be presented to the user through the
         SystemUI. Can be -1 if there is no maximum limit. -->
    <integer name="config_maxNumVisibleRecentTasks_lowRam">9</integer>

    <!-- The minimum number of visible recent tasks to be presented to the user through the
         SystemUI. Can be -1 if there is no minimum limit. -->
    <integer name="config_minNumVisibleRecentTasks">5</integer>

    <!-- The maximum number of visible recent tasks to be presented to the user through the
         SystemUI. Can be -1 if there is no maximum limit. -->
    <integer name="config_maxNumVisibleRecentTasks">-1</integer>

    <!-- The duration in which a recent task is considered in session and should be visible. -->
    <integer name="config_activeTaskDurationHours">6</integer>

    <!-- default window ShowCircularMask property -->
    <bool name="config_windowShowCircularMask">false</bool>

+7 −0
Original line number Diff line number Diff line
@@ -311,6 +311,13 @@
  <java-symbol type="bool" name="config_enableMultiUserUI"/>
  <java-symbol type="bool" name="config_disableUsbPermissionDialogs"/>
  <java-symbol type="bool" name="config_hasRecents" />
  <java-symbol type="integer" name="config_minNumVisibleRecentTasks_lowRam" />
  <java-symbol type="integer" name="config_maxNumVisibleRecentTasks_lowRam" />
  <java-symbol type="integer" name="config_minNumVisibleRecentTasks_grid" />
  <java-symbol type="integer" name="config_maxNumVisibleRecentTasks_grid" />
  <java-symbol type="integer" name="config_minNumVisibleRecentTasks" />
  <java-symbol type="integer" name="config_maxNumVisibleRecentTasks" />
  <java-symbol type="integer" name="config_activeTaskDurationHours" />
  <java-symbol type="bool" name="config_windowShowCircularMask" />
  <java-symbol type="bool" name="config_windowEnableCircularEmulatorDisplayOverlay" />
  <java-symbol type="bool" name="config_wifi_framework_enable_associated_network_selection" />
+1 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ class ActivityManagerDebugConfig {
    static final boolean DEBUG_PROVIDER = DEBUG_ALL || false;
    static final boolean DEBUG_PSS = DEBUG_ALL || false;
    static final boolean DEBUG_RECENTS = DEBUG_ALL || false;
    static final boolean DEBUG_RECENTS_TRIM_TASKS = DEBUG_RECENTS || false;
    static final boolean DEBUG_RELEASE = DEBUG_ALL_ACTIVITIES || false;
    static final boolean DEBUG_RESULTS = DEBUG_ALL || false;
    static final boolean DEBUG_SAVED_STATE = DEBUG_ALL_ACTIVITIES || false;
+1 −4
Original line number Diff line number Diff line
@@ -1730,9 +1730,6 @@ public class ActivityManagerService extends IActivityManager.Stub
     */
    private boolean mUserIsMonkey;
    /** Flag whether the device has a Recents UI */
    boolean mHasRecents;
    /** The dimensions of the thumbnails in the Recents UI. */
    int mThumbnailWidth;
    int mThumbnailHeight;
@@ -2777,6 +2774,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                new TaskChangeNotificationController(this, mStackSupervisor, mHandler);
        mActivityStarter = new ActivityStarter(this, mStackSupervisor);
        mRecentTasks = new RecentTasks(this, mStackSupervisor);
        mStackSupervisor.setRecentTasks(mRecentTasks);
        mLockTaskController = new LockTaskController(mContext, mStackSupervisor, mHandler);
        mProcessCpuThread = new Thread("CpuTracker") {
@@ -13911,7 +13909,6 @@ public class ActivityManagerService extends IActivityManager.Stub
            // Load resources only after the current configuration has been set.
            final Resources res = mContext.getResources();
            mHasRecents = res.getBoolean(com.android.internal.R.bool.config_hasRecents);
            mThumbnailWidth = res.getDimensionPixelSize(
                    com.android.internal.R.dimen.thumbnail_width);
            mThumbnailHeight = res.getDimensionPixelSize(
+7 −1
Original line number Diff line number Diff line
@@ -3016,7 +3016,13 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
    }

    @Override
    public void onRecentTaskRemoved(TaskRecord task) {
    public void onRecentTaskRemoved(TaskRecord task, boolean wasTrimmed) {
        if (wasTrimmed) {
            // Task was trimmed from the recent tasks list -- remove the active task record as well
            // since the user won't really be able to go back to it
            removeTaskByIdLocked(task.taskId, false /* killProcess */,
                    false /* removeFromRecents */);
        }
        task.removedFromRecents();
    }

Loading