Merge "Notify moveTaskToBack to TaskStackListeners."
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5443,9 +5443,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,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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user