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

Commit a04997b0 authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Use new onTaskListUpdated() callback

Migrated to general method for receiving updates
whenever the recents list undergoes any additions or
removals.

Test: Opened apps, and as I closed them I ensured
via debugger and log statements that the callback was
being triggered from the framework module. See
tests in RecentTasksTest

fixes: 111077107
Change-Id: Ia9bddb50861a1b107e6a88c9f9bb89944800d5d8
parent a1db23c0
Loading
Loading
Loading
Loading
+1 −5
Original line number Original line Diff line number Diff line
@@ -119,12 +119,8 @@ public class RecentTasksList extends TaskStackChangeListener {
    }
    }


    @Override
    @Override
    public synchronized void onTaskStackChanged() {
    public void onRecentTaskListUpdated() {
        mChangeId++;
        mChangeId++;
    }

    @Override
    public void onTaskRemoved(int taskId) {
        mTasks = loadTasksInBackground(Integer.MAX_VALUE, false);
        mTasks = loadTasksInBackground(Integer.MAX_VALUE, false);
    }
    }


+13 −12
Original line number Original line Diff line number Diff line
@@ -16,15 +16,12 @@
package com.android.quickstep;
package com.android.quickstep;


import static com.android.quickstep.TaskUtils.checkCurrentOrManagedUserId;
import static com.android.quickstep.TaskUtils.checkCurrentOrManagedUserId;
import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SUPPORTS_WINDOW_CORNERS;
import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_WINDOW_CORNER_RADIUS;


import android.annotation.TargetApi;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.app.ActivityManager;
import android.content.ComponentCallbacks2;
import android.content.ComponentCallbacks2;
import android.content.Context;
import android.content.Context;
import android.os.Build;
import android.os.Build;
import android.os.Bundle;
import android.os.HandlerThread;
import android.os.HandlerThread;
import android.os.Process;
import android.os.Process;
import android.os.RemoteException;
import android.os.RemoteException;
@@ -36,12 +33,11 @@ import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.BackgroundExecutor;
import com.android.systemui.shared.system.KeyguardManagerCompat;
import com.android.systemui.shared.system.KeyguardManagerCompat;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.shared.system.TaskStackChangeListener;


import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Consumer;


@@ -132,7 +128,7 @@ public class RecentsModel extends TaskStackChangeListener {
    }
    }


    @Override
    @Override
    public void onTaskStackChangedBackground() {
    public void onRecentTaskListUpdated() {
        if (!mThumbnailCache.isPreloadingEnabled()) {
        if (!mThumbnailCache.isPreloadingEnabled()) {
            // Skip if we aren't preloading
            // Skip if we aren't preloading
            return;
            return;
@@ -147,7 +143,11 @@ public class RecentsModel extends TaskStackChangeListener {
        // Keep the cache up to date with the latest thumbnails
        // Keep the cache up to date with the latest thumbnails
        int runningTaskId = RecentsModel.getRunningTaskId();
        int runningTaskId = RecentsModel.getRunningTaskId();
        mTaskList.getTaskKeys(mThumbnailCache.getCacheSize(), tasks -> {
        mTaskList.getTaskKeys(mThumbnailCache.getCacheSize(), tasks -> {
            Collection<Task.TaskKey> currentKeys = mThumbnailCache.getTaskKeys();
            List<Task.TaskKey> newKeys = new ArrayList<>(currentKeys.size());

            for (Task task : tasks) {
            for (Task task : tasks) {
                newKeys.add(task.key);
                if (task.key.id == runningTaskId) {
                if (task.key.id == runningTaskId) {
                    // Skip the running task, it's not going to have an up-to-date snapshot by the
                    // Skip the running task, it's not going to have an up-to-date snapshot by the
                    // time the user next enters overview
                    // time the user next enters overview
@@ -155,6 +155,13 @@ public class RecentsModel extends TaskStackChangeListener {
                }
                }
                mThumbnailCache.updateThumbnailInCache(task);
                mThumbnailCache.updateThumbnailInCache(task);
            }
            }

            // Remove all keys we had before but no longer are in recents now
            currentKeys.removeAll(newKeys);
            for (Task.TaskKey tk : currentKeys) {
                mThumbnailCache.remove(tk);
            }

        });
        });
    }
    }


@@ -170,12 +177,6 @@ public class RecentsModel extends TaskStackChangeListener {
        }
        }
    }
    }


    @Override
    public void onTaskRemoved(int taskId) {
        Task.TaskKey dummyKey = new Task.TaskKey(taskId, 0, null, null, 0, 0);
        mThumbnailCache.remove(dummyKey);
    }

    public void setSystemUiProxy(ISystemUiProxy systemUiProxy) {
    public void setSystemUiProxy(ISystemUiProxy systemUiProxy) {
        mSystemUiProxy = systemUiProxy;
        mSystemUiProxy = systemUiProxy;
    }
    }
+5 −0
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@ import com.android.systemui.shared.recents.model.TaskKeyLruCache;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.function.Consumer;
import java.util.function.Consumer;


public class TaskThumbnailCache {
public class TaskThumbnailCache {
@@ -179,6 +180,10 @@ public class TaskThumbnailCache {
        return request;
        return request;
    }
    }


    public Collection<TaskKey> getTaskKeys() {
        return mCache.getValues();
    }

    /**
    /**
     * Clears the cache.
     * Clears the cache.
     */
     */