Adds TaskInfo to some TaskChangeListener methods
This change dispatches TaskInfo directly for some methods
which currently only pass taskId. This eliminates the need
for second binder call to search for the TaskInfo.
See also: ag/6306456
Bug: 124058588
Bug: 123631242
Test: atest WmTests:TaskStackChangedListenerTest
Change-Id: I2e4c458f2a1ae684ef8d9f6a4ab2fbcfe13570b5
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListener.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListener.java
index f9aa8da..3d2f61e 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListener.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListener.java
@@ -16,7 +16,7 @@
package com.android.systemui.shared.system;
-import android.app.ActivityManager.TaskSnapshot;
+import android.app.ActivityManager.RunningTaskInfo;
import android.content.ComponentName;
import android.os.UserHandle;
import android.util.Log;
@@ -43,10 +43,20 @@
public void onActivityForcedResizable(String packageName, int taskId, int reason) { }
public void onActivityDismissingDockedStack() { }
public void onActivityLaunchOnSecondaryDisplayFailed() { }
+
+ public void onActivityLaunchOnSecondaryDisplayFailed(RunningTaskInfo taskInfo) {
+ onActivityLaunchOnSecondaryDisplayFailed();
+ }
+
public void onTaskProfileLocked(int taskId, int userId) { }
public void onTaskCreated(int taskId, ComponentName componentName) { }
public void onTaskRemoved(int taskId) { }
public void onTaskMovedToFront(int taskId) { }
+
+ public void onTaskMovedToFront(RunningTaskInfo taskInfo) {
+ onTaskMovedToFront(taskInfo.taskId);
+ }
+
public void onActivityRequestedOrientationChanged(int taskId, int requestedOrientation) { }
/**
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListeners.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListeners.java
index 628b3c6..a9ac42f 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListeners.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListeners.java
@@ -16,8 +16,9 @@
package com.android.systemui.shared.system;
-import android.app.ActivityTaskManager;
+import android.app.ActivityManager.RunningTaskInfo;
import android.app.ActivityManager.TaskSnapshot;
+import android.app.ActivityTaskManager;
import android.app.IActivityManager;
import android.app.TaskStackListener;
import android.content.ComponentName;
@@ -132,8 +133,11 @@
}
@Override
- public void onActivityLaunchOnSecondaryDisplayFailed() throws RemoteException {
- mHandler.sendEmptyMessage(H.ON_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_FAILED);
+ public void onActivityLaunchOnSecondaryDisplayFailed(RunningTaskInfo taskInfo,
+ int requestedDisplayId) throws RemoteException {
+ mHandler.obtainMessage(H.ON_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_FAILED, requestedDisplayId,
+ 0 /* unused */,
+ taskInfo).sendToTarget();
}
@Override
@@ -157,8 +161,9 @@
}
@Override
- public void onTaskMovedToFront(int taskId) throws RemoteException {
- mHandler.obtainMessage(H.ON_TASK_MOVED_TO_FRONT, taskId, 0).sendToTarget();
+ public void onTaskMovedToFront(RunningTaskInfo taskInfo)
+ throws RemoteException {
+ mHandler.obtainMessage(H.ON_TASK_MOVED_TO_FRONT, taskInfo).sendToTarget();
}
@Override
@@ -258,8 +263,10 @@
break;
}
case ON_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_FAILED: {
+ final RunningTaskInfo info = (RunningTaskInfo) msg.obj;
for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
- mTaskStackListeners.get(i).onActivityLaunchOnSecondaryDisplayFailed();
+ mTaskStackListeners.get(i)
+ .onActivityLaunchOnSecondaryDisplayFailed(info);
}
break;
}
@@ -283,15 +290,16 @@
break;
}
case ON_TASK_MOVED_TO_FRONT: {
+ final RunningTaskInfo info = (RunningTaskInfo) msg.obj;
for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
- mTaskStackListeners.get(i).onTaskMovedToFront(msg.arg1);
+ mTaskStackListeners.get(i).onTaskMovedToFront(info);
}
break;
}
case ON_ACTIVITY_REQUESTED_ORIENTATION_CHANGE: {
for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
- mTaskStackListeners.get(i).onActivityRequestedOrientationChanged(
- msg.arg1, msg.arg2);
+ mTaskStackListeners.get(i)
+ .onActivityRequestedOrientationChanged(msg.arg1, msg.arg2);
}
break;
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index a67e1b7..9b826e1 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -25,6 +25,7 @@
import android.annotation.Nullable;
import android.app.ActivityManager;
+import android.app.ActivityManager.RunningTaskInfo;
import android.app.ActivityTaskManager;
import android.app.IActivityTaskManager;
import android.app.INotificationManager;
@@ -481,15 +482,8 @@
}
@Override
- public void onTaskMovedToFront(int taskId) {
- ActivityManager.StackInfo stackInfo = null;
- try {
- stackInfo = findStackInfo(taskId);
- } catch (RemoteException e) {
- e.rethrowAsRuntimeException();
- }
- if (stackInfo != null && stackInfo.displayId == Display.DEFAULT_DISPLAY
- && mStackView != null) {
+ public void onTaskMovedToFront(RunningTaskInfo taskInfo) {
+ if (mStackView != null && taskInfo.displayId == Display.DEFAULT_DISPLAY) {
mStackView.collapseStack();
}
}
@@ -500,9 +494,9 @@
* ultimately ended up, displays an error message toast, and calls this method instead of
* onTaskMovedToFront.
*/
- // TODO(b/124058588): add requestedDisplayId to this callback, ignore unless matches
@Override
- public void onActivityLaunchOnSecondaryDisplayFailed() {
+ public void onActivityLaunchOnSecondaryDisplayFailed(RunningTaskInfo taskInfo) {
+ // TODO(b/124058588): move to ActivityView.StateCallback, filter on virtualDisplay ID
if (mStackView != null) {
mStackView.collapseStack();
}