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

Commit 8e54796a authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Add callback to notify frozen RecentTasks

TaskStackListener can now know when
RecentTasks recents list has been
frozen and unfrozen.
Launcher needs this to know when to listen
for multiple swipe regions in quickstep
for apps with different orientations.

Fixes: 140116135
Test: Had Launcher be a consumer of new
listener and verified via logs and
debugger that it was sending the correct
callback when quickswitching apps.

Change-Id: I65fb92d2490c91837523b99563d4fef422dabb76
parent 3019d9c8
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -197,4 +197,11 @@ oneway interface ITaskStackListener {
     * Called when any additions or deletions to the recent tasks list have been made.
     */
    void onRecentTaskListUpdated();

    /**
     * Called when Recent Tasks list is frozen or unfrozen.
     *
     * @param frozen if true, Recents Tasks list is currently frozen, false otherwise
     */
    void onRecentTaskListFrozenChanged(boolean frozen);
}
+4 −0
Original line number Diff line number Diff line
@@ -190,4 +190,8 @@ public abstract class TaskStackListener extends ITaskStackListener.Stub {
    @Override
    public void onRecentTaskListUpdated() throws RemoteException {
    }

    @Override
    public void onRecentTaskListFrozenChanged(boolean frozen) {
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.shared.system;

import android.app.ActivityManager.RunningTaskInfo;
import android.app.ITaskStackListener;
import android.content.ComponentName;
import android.os.IBinder;
import android.os.UserHandle;
@@ -106,6 +107,9 @@ public abstract class TaskStackChangeListener {
     */
    public void onRecentTaskListUpdated() { }

    /** @see ITaskStackListener#onRecentTaskListFrozenChanged(boolean) */
    public void onRecentTaskListFrozenChanged(boolean frozen) { }

    /**
     * Checks that the current user matches the process. Since
     * {@link android.app.ITaskStackListener} is not multi-user aware, handlers of
+13 −0
Original line number Diff line number Diff line
@@ -224,6 +224,12 @@ public class TaskStackChangeListeners extends TaskStackListener {
        mHandler.obtainMessage(H.ON_TASK_LIST_UPDATED).sendToTarget();
    }

    @Override
    public void onRecentTaskListFrozenChanged(boolean frozen) {
        mHandler.obtainMessage(H.ON_TASK_LIST_FROZEN_UNFROZEN, frozen ? 1 : 0, 0 /* unused */)
                .sendToTarget();
    }

    private final class H extends Handler {
        private static final int ON_TASK_STACK_CHANGED = 1;
        private static final int ON_TASK_SNAPSHOT_CHANGED = 2;
@@ -247,6 +253,7 @@ public class TaskStackChangeListeners extends TaskStackListener {
        private static final int ON_TASK_DISPLAY_CHANGED = 20;
        private static final int ON_TASK_LIST_UPDATED = 21;
        private static final int ON_SINGLE_TASK_DISPLAY_EMPTY = 22;
        private static final int ON_TASK_LIST_FROZEN_UNFROZEN = 23;


        public H(Looper looper) {
@@ -408,6 +415,12 @@ public class TaskStackChangeListeners extends TaskStackListener {
                        }
                        break;
                    }
                    case ON_TASK_LIST_FROZEN_UNFROZEN: {
                        for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
                            mTaskStackListeners.get(i).onRecentTaskListFrozenChanged(msg.arg1 != 0);
                        }
                        break;
                    }
                }
            }
        }
+7 −1
Original line number Diff line number Diff line
@@ -272,9 +272,14 @@ class RecentTasks {
     * app, or a timeout occurs.
     */
    void setFreezeTaskListReordering() {
        // Only fire the callback once per quickswitch session, not on every individual switch
        if (!mFreezeTaskListReordering) {
            mTaskNotificationController.notifyTaskListFrozen(true);
            mFreezeTaskListReordering = true;
        }

        // Always update the reordering time when this is called to ensure that the timeout
        // is reset
        mFreezeTaskListReordering = true;
        mService.mH.removeCallbacks(mResetFreezeTaskListOnTimeoutRunnable);
        mService.mH.postDelayed(mResetFreezeTaskListOnTimeoutRunnable, mFreezeTaskListTimeoutMs);
    }
@@ -302,6 +307,7 @@ class RecentTasks {
        trimInactiveRecentTasks();

        mTaskNotificationController.notifyTaskStackChanged();
        mTaskNotificationController.notifyTaskListFrozen(false);
    }

    /**
Loading