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

Commit 5210e50e authored by Kiril Mikos's avatar Kiril Mikos
Browse files

SystemUI: Fix missing top task in recent panel.

If preloadRecentTasksList was not called or was called too
late and RecentsActivty already started and last top activity has
excludeFromRecents flag setted it might be missing
from recent application list.

Change-Id: Idf7153824805ceea9fcaf04ac645b73a5e93a4d9
parent d7ba85c0
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -518,6 +518,11 @@ public class ActivityManager {
     */
    public static final int RECENT_IGNORE_UNAVAILABLE = 0x0002;

    /**
     * @hide
     */
    public static final int RECENT_DO_NOT_COUNT_EXCLUDED = 0x0004;

    /**
     * Return a list of the tasks that the user has recently launched, with
     * the most recent being first and older ones after in order.
+12 −1
Original line number Diff line number Diff line
@@ -442,12 +442,15 @@ public class RecentTasksLoader implements View.OnTouchListener {
                mContext.getSystemService(Context.ACTIVITY_SERVICE);

                final List<ActivityManager.RecentTaskInfo> recentTasks =
                        am.getRecentTasks(MAX_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE);
                        am.getRecentTasks(MAX_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE
                                | ActivityManager.RECENT_WITH_EXCLUDED
                                | ActivityManager.RECENT_DO_NOT_COUNT_EXCLUDED);
                int numTasks = recentTasks.size();
                ActivityInfo homeInfo = new Intent(Intent.ACTION_MAIN)
                        .addCategory(Intent.CATEGORY_HOME).resolveActivityInfo(pm, 0);

                boolean firstScreenful = true;
                boolean loadOneExcluded = true;
                ArrayList<TaskDescription> tasks = new ArrayList<TaskDescription>();

                // skip the first task - assume it's either the home screen or the current activity.
@@ -465,6 +468,7 @@ public class RecentTasksLoader implements View.OnTouchListener {

                    // Don't load the current home activity.
                    if (isCurrentHomeActivity(intent.getComponent(), homeInfo)) {
                        loadOneExcluded = false;
                        continue;
                    }

@@ -473,6 +477,13 @@ public class RecentTasksLoader implements View.OnTouchListener {
                        continue;
                    }

                    if (!loadOneExcluded && (recentInfo.baseIntent.getFlags()
                            & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0) {
                        continue;
                    }

                    loadOneExcluded = false;

                    TaskDescription item = createTaskDescription(recentInfo.id,
                            recentInfo.persistentId, recentInfo.baseIntent,
                            recentInfo.origActivity, recentInfo.description);
+5 −1
Original line number Diff line number Diff line
@@ -6028,9 +6028,13 @@ public final class ActivityManagerService extends ActivityManagerNative
                    }
                    
                    res.add(rti);
                    if ((tr.intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0
                            || (flags & ActivityManager.RECENT_DO_NOT_COUNT_EXCLUDED) == 0
                            || i == 0) {
                        maxNum--;
                    }
                }
            }
            return res;
        }
    }