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

Commit 3e73749c authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Create general callback for changes to RecentTaskList

New callback called whenever a user visible task
is added or removed to the recents list. This results
in less work by updating only when recent task list
changes instead of listening for active task list
changes.

Test: atest RecentTasksTest

fixes: 111077107

Change-Id: I9acf13762d0c79bfde90b64fa5e0edaf882068cc
parent 2c79b41c
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -185,4 +185,9 @@ oneway interface ITaskStackListener {
     * @param newDisplayId id of the new display.
     * @param newDisplayId id of the new display.
     */
     */
    void onTaskDisplayChanged(int taskId, int newDisplayId);
    void onTaskDisplayChanged(int taskId, int newDisplayId);

    /**
     * Called when any additions or deletions to the recent tasks list have been made.
     */
    void onRecentTaskListUpdated();
}
}
+4 −0
Original line number Original line Diff line number Diff line
@@ -182,4 +182,8 @@ public abstract class TaskStackListener extends ITaskStackListener.Stub {
    @Override
    @Override
    public void onTaskDisplayChanged(int taskId, int newDisplayId) throws RemoteException {
    public void onTaskDisplayChanged(int taskId, int newDisplayId) throws RemoteException {
    }
    }

    @Override
    public void onRecentTaskListUpdated() throws RemoteException {
    }
}
}
+2 −1
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package android.util;
package android.util;


import android.annotation.UnsupportedAppUsage;
import android.annotation.UnsupportedAppUsage;

import java.util.LinkedHashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map;


@@ -260,7 +261,7 @@ public class LruCache<K, V> {
     * @param evicted true if the entry is being removed to make space, false
     * @param evicted true if the entry is being removed to make space, false
     *     if the removal was caused by a {@link #put} or {@link #remove}.
     *     if the removal was caused by a {@link #put} or {@link #remove}.
     * @param newValue the new value for {@code key}, if it exists. If non-null,
     * @param newValue the new value for {@code key}, if it exists. If non-null,
     *     this removal was caused by a {@link #put}. Otherwise it was caused by
     *     this removal was caused by a {@link #put} or a {@link #get}. Otherwise it was caused by
     *     an eviction or a {@link #remove}.
     *     an eviction or a {@link #remove}.
     */
     */
    protected void entryRemoved(boolean evicted, K key, V oldValue, V newValue) {}
    protected void entryRemoved(boolean evicted, K key, V oldValue, V newValue) {}
+12 −0
Original line number Original line Diff line number Diff line
@@ -21,6 +21,9 @@ import android.util.SparseArray;


import com.android.systemui.shared.recents.model.Task.TaskKey;
import com.android.systemui.shared.recents.model.Task.TaskKey;


import java.util.ArrayList;
import java.util.Collection;

/**
/**
 * Base class for both strong and LRU task key cache.
 * Base class for both strong and LRU task key cache.
 */
 */
@@ -76,6 +79,15 @@ public abstract class TaskKeyCache<V> {
        mKeys.remove(key.id);
        mKeys.remove(key.id);
    }
    }


    /** @return {@link Collection} of {@link TaskKey} */
    public Collection<TaskKey> getValues() {
        Collection<TaskKey> result = new ArrayList<>(mKeys.size());
        for (int i = 0; i < mKeys.size(); i++) {
            result.add(mKeys.valueAt(i));
        }
        return result;
    }

    /** Removes all the entries in the cache. */
    /** Removes all the entries in the cache. */
    public final synchronized void evictAll() {
    public final synchronized void evictAll() {
        evictAllCache();
        evictAllCache();
+5 −0
Original line number Original line Diff line number Diff line
@@ -94,6 +94,11 @@ public abstract class TaskStackChangeListener {
     */
     */
    public void onTaskDisplayChanged(int taskId, int newDisplayId) { }
    public void onTaskDisplayChanged(int taskId, int newDisplayId) { }


    /**
     * Called when any additions or deletions to the recent tasks list have been made.
     */
    public void onRecentTaskListUpdated() { }

    /**
    /**
     * Checks that the current user matches the process. Since
     * Checks that the current user matches the process. Since
     * {@link android.app.ITaskStackListener} is not multi-user aware, handlers of
     * {@link android.app.ITaskStackListener} is not multi-user aware, handlers of
Loading