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

Commit ae4bcbb2 authored by Garfield Tan's avatar Garfield Tan
Browse files

Notify moveTaskToBack to TaskStackListeners.

Bug: 170700733
Bug: 177440073
Test: Builds.

Change-Id: Ibd66bbd006a156c443f78b14b24baaa955cebd16
parent fa5c2e7b
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -214,4 +214,11 @@ oneway interface ITaskStackListener {
     * @param displayId id of the display where activity will rotate
     */
     void onActivityRotation(int displayId);

    /**
     * Called when a task is moved to the back behind the home stack.
     *
     * @param taskInfo info about the task which moved
     */
    void onTaskMovedToBack(in ActivityManager.RunningTaskInfo taskInfo);
}
+5 −1
Original line number Diff line number Diff line
@@ -17,13 +17,13 @@
package android.app;

import android.app.ActivityManager.RunningTaskInfo;
import android.window.TaskSnapshot;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
import android.os.RemoteException;
import android.window.TaskSnapshot;

/**
 * Classes interested in observing only a subset of changes using ITaskStackListener can extend
@@ -196,4 +196,8 @@ public abstract class TaskStackListener extends ITaskStackListener.Stub {
    @Override
    public void onActivityRotation(int displayId) {
    }

    @Override
    public void onTaskMovedToBack(RunningTaskInfo taskInfo) {
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -5408,9 +5408,13 @@ class Task extends WindowContainer<WindowContainer> {
                final Task lastFocusedTask = displayArea.getFocusedRootTask();
                displayArea.positionChildAt(POSITION_BOTTOM, this, false /*includingParents*/);
                displayArea.updateLastFocusedRootTask(lastFocusedTask, reason);
                mAtmService.getTaskChangeNotificationController().notifyTaskMovedToBack(
                        getTaskInfo());
            }
            if (task != null && task != this) {
                positionChildAtBottom(task);
                mAtmService.getTaskChangeNotificationController().notifyTaskMovedToBack(
                        task.getTaskInfo());
            }
            return;
        }
+18 −1
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.server.wm;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.window.TaskSnapshot;
import android.app.ITaskStackListener;
import android.app.TaskInfo;
import android.content.ComponentName;
@@ -29,6 +28,7 @@ import android.os.Looper;
import android.os.Message;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.window.TaskSnapshot;

import com.android.internal.os.SomeArgs;

@@ -60,6 +60,7 @@ class TaskChangeNotificationController {
    private static final int NOTIFY_TASK_FOCUS_CHANGED_MSG = 25;
    private static final int NOTIFY_TASK_REQUESTED_ORIENTATION_CHANGED_MSG = 26;
    private static final int NOTIFY_ACTIVITY_ROTATED_MSG = 27;
    private static final int NOTIFY_TASK_MOVED_TO_BACK_LISTENERS_MSG = 28;

    // Delay in notifying task stack change listeners (in millis)
    private static final int NOTIFY_TASK_STACK_CHANGE_LISTENERS_DELAY = 100;
@@ -178,6 +179,10 @@ class TaskChangeNotificationController {
        l.onActivityRotation(m.arg1);
    };

    private final TaskStackConsumer mNotifyTaskMovedToBack = (l, m) -> {
        l.onTaskMovedToBack((RunningTaskInfo) m.obj);
    };

    @FunctionalInterface
    public interface TaskStackConsumer {
        void accept(ITaskStackListener t, Message m) throws RemoteException;
@@ -269,6 +274,9 @@ class TaskChangeNotificationController {
                case NOTIFY_ACTIVITY_ROTATED_MSG:
                    forAllRemoteListeners(mNotifyOnActivityRotation, msg);
                    break;
                case NOTIFY_TASK_MOVED_TO_BACK_LISTENERS_MSG:
                    forAllRemoteListeners(mNotifyTaskMovedToBack, msg);
                    break;
            }
            if (msg.obj instanceof SomeArgs) {
                ((SomeArgs) msg.obj).recycle();
@@ -553,4 +561,13 @@ class TaskChangeNotificationController {
        forAllLocalListeners(mNotifyOnActivityRotation, msg);
        msg.sendToTarget();
    }

    /**
     * Notify that a task is being moved behind home.
     */
    void notifyTaskMovedToBack(TaskInfo ti) {
        final Message msg = mHandler.obtainMessage(NOTIFY_TASK_MOVED_TO_BACK_LISTENERS_MSG, ti);
        forAllLocalListeners(mNotifyTaskMovedToBack, msg);
        msg.sendToTarget();
    }
}