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

Commit 852975d5 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #17179314: Make recents limits consistent

The max limit is now 100 (or 50 on svelte devices), and that is
what everyone used.

Re-arranged things so we have a big expensive "fix the world!"
function for recents that we go in to at only select points:
when first initializing the system, when external storage comes
and goes, and if we detect something wrong with the recents
structure.

With that, now getRecentTasks() and addRecentTaskLocked() are
generally much simpler, doing very little work in most cases.
This will help a lot with scaling up to many more recents
entries.

Change-Id: I7b5ae89edc06568f68c8af54a4420aff7635581c
parent 330459d6
Loading
Loading
Loading
Loading
+32 −3
Original line number Diff line number Diff line
@@ -67,6 +67,8 @@ public class ActivityManager {
    private static String TAG = "ActivityManager";
    private static boolean localLOGV = false;

    private static int gMaxRecentTasks = -1;

    private final Context mContext;
    private final Handler mHandler;

@@ -479,6 +481,33 @@ public class ActivityManager {
                !Resources.getSystem().getBoolean(com.android.internal.R.bool.config_avoidGfxAccel);
    }

    /**
     * Return the maximum number of recents entries that we will maintain and show.
     * @hide
     */
    static public int getMaxRecentTasksStatic() {
        if (gMaxRecentTasks < 0) {
            return gMaxRecentTasks = isLowRamDeviceStatic() ? 50 : 100;
        }
        return gMaxRecentTasks;
    }

    /**
     * Return the default limit on the number of recents that an app can make.
     * @hide
     */
    static public int getDefaultAppRecentsLimitStatic() {
        return getMaxRecentTasksStatic() / 6;
    }

    /**
     * Return the maximum limit on the number of recents that an app can make.
     * @hide
     */
    static public int getMaxAppRecentsLimitStatic() {
        return getMaxRecentTasksStatic() / 2;
    }

    /**
     * Information you can set and retrieve about the current activity within the recent task list.
     */
@@ -1191,13 +1220,13 @@ public class ActivityManager {
        public void writeToParcel(Parcel dest, int flags) {
            if (mainThumbnail != null) {
                dest.writeInt(1);
                mainThumbnail.writeToParcel(dest, 0);
                mainThumbnail.writeToParcel(dest, flags);
            } else {
                dest.writeInt(0);
            }
            if (thumbnailFileDescriptor != null) {
                dest.writeInt(1);
                thumbnailFileDescriptor.writeToParcel(dest, 0);
                thumbnailFileDescriptor.writeToParcel(dest, flags);
            } else {
                dest.writeInt(0);
            }
+2 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_NOT_APK;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_NO_CERTIFICATES;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION;

import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentFilter;
@@ -3077,7 +3078,7 @@ public class PackageParser {
                    ActivityInfo.DOCUMENT_LAUNCH_NONE);
            a.info.maxRecents = sa.getInt(
                    com.android.internal.R.styleable.AndroidManifestActivity_maxRecents,
                    15);
                    ActivityManager.getDefaultAppRecentsLimitStatic());
            a.info.screenOrientation = sa.getInt(
                    com.android.internal.R.styleable.AndroidManifestActivity_screenOrientation,
                    ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
+0 −2
Original line number Diff line number Diff line
@@ -145,8 +145,6 @@
    <integer name="recents_animate_task_view_remove_duration">250</integer>
    <!-- The minimum alpha for the dim applied to cards that go deeper into the stack. -->
    <integer name="recents_max_task_stack_view_dim">96</integer>
    <!-- The number of tasks that RecentsTaskLoader should load. -->
    <integer name="recents_max_num_tasks_to_load">50</integer>
    <!-- The delay to enforce between each alt-tab key press. -->
    <integer name="recents_alt_tab_key_delay">200</integer>
    <!-- Transposes the recents layout in landscape. -->
+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.recents;

import android.app.ActivityManager;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
@@ -187,7 +188,7 @@ public class RecentsConfiguration {
                res.getInteger(R.integer.recents_filter_animate_new_views_duration);

        // Loading
        maxNumTasksToLoad = res.getInteger(R.integer.recents_max_num_tasks_to_load);
        maxNumTasksToLoad = ActivityManager.getMaxRecentTasksStatic();

        // Search Bar
        searchBarSpaceHeightPx = res.getDimensionPixelSize(R.dimen.recents_search_bar_space_height);
+383 −88

File changed.

Preview size limit exceeded, changes collapsed.

Loading