summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mark Renouf <mrenouf@google.com> 2019-01-23 17:12:34 -0500
committer Mark Renouf <mrenouf@google.com> 2019-01-24 11:33:52 -0500
commit7b71a5d222a6e6e193f46fbd353092287ad7ad9d (patch)
treeb1eab478e2fb5abe9bc7661c1ce25d9f299d00e3
parent5eb1fef318e955df2532b68b4073eec3ebeebcca (diff)
Adds callbacks for task creation and removal
Test: ? Bug: 112574121 Change-Id: Ifb6b82e3656b82f103e529089ae43f79b810aca3
-rw-r--r--core/java/android/app/ActivityView.java63
1 files changed, 55 insertions, 8 deletions
diff --git a/core/java/android/app/ActivityView.java b/core/java/android/app/ActivityView.java
index 4d3711ae7ff5..47398674d74c 100644
--- a/core/java/android/app/ActivityView.java
+++ b/core/java/android/app/ActivityView.java
@@ -23,6 +23,7 @@ import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLI
import android.annotation.NonNull;
import android.annotation.UnsupportedAppUsage;
import android.app.ActivityManager.StackInfo;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.hardware.display.DisplayManager;
@@ -119,6 +120,7 @@ public class ActivityView extends ViewGroup {
/** Callback that notifies when the container is ready or destroyed. */
public abstract static class StateCallback {
+
/**
* Called when the container is ready for launching activities. Calling
* {@link #startActivity(Intent)} prior to this callback will result in an
@@ -127,6 +129,7 @@ public class ActivityView extends ViewGroup {
* @see #startActivity(Intent)
*/
public abstract void onActivityViewReady(ActivityView view);
+
/**
* Called when the container can no longer launch activities. Calling
* {@link #startActivity(Intent)} after this callback will result in an
@@ -135,11 +138,24 @@ public class ActivityView extends ViewGroup {
* @see #startActivity(Intent)
*/
public abstract void onActivityViewDestroyed(ActivityView view);
+
+ /**
+ * Called when a task is created inside the container.
+ * This is a filtered version of {@link TaskStackListener}
+ */
+ public void onTaskCreated(int taskId, ComponentName componentName) { }
+
/**
* Called when a task is moved to the front of the stack inside the container.
* This is a filtered version of {@link TaskStackListener}
*/
public void onTaskMovedToFront(ActivityManager.StackInfo stackInfo) { }
+
+ /**
+ * Called when a task is about to be removed from the stack inside the container.
+ * This is a filtered version of {@link TaskStackListener}
+ */
+ public void onTaskRemovalStarted(int taskId) { }
}
/**
@@ -508,14 +524,45 @@ public class ActivityView extends ViewGroup {
@Override
public void onTaskMovedToFront(int taskId) throws RemoteException {
- if (mActivityViewCallback != null) {
- StackInfo stackInfo = getTopMostStackInfo();
- // if StackInfo was null or unrelated to the "move to front" then there's no use
- // notifying the callback
- if (stackInfo != null
- && taskId == stackInfo.taskIds[stackInfo.taskIds.length - 1]) {
- mActivityViewCallback.onTaskMovedToFront(stackInfo);
- }
+ if (mActivityViewCallback == null) {
+ return;
+ }
+
+ StackInfo stackInfo = getTopMostStackInfo();
+ // if StackInfo was null or unrelated to the "move to front" then there's no use
+ // notifying the callback
+ if (stackInfo != null
+ && taskId == stackInfo.taskIds[stackInfo.taskIds.length - 1]) {
+ mActivityViewCallback.onTaskMovedToFront(stackInfo);
+ }
+ }
+
+ @Override
+ public void onTaskCreated(int taskId, ComponentName componentName) throws RemoteException {
+ if (mActivityViewCallback == null) {
+ return;
+ }
+
+ StackInfo stackInfo = getTopMostStackInfo();
+ // if StackInfo was null or unrelated to the task creation then there's no use
+ // notifying the callback
+ if (stackInfo != null
+ && taskId == stackInfo.taskIds[stackInfo.taskIds.length - 1]) {
+ mActivityViewCallback.onTaskCreated(taskId, componentName);
+ }
+ }
+
+ @Override
+ public void onTaskRemovalStarted(int taskId) throws RemoteException {
+ if (mActivityViewCallback == null) {
+ return;
+ }
+ StackInfo stackInfo = getTopMostStackInfo();
+ // if StackInfo was null or task is on a different display then there's no use
+ // notifying the callback
+ if (stackInfo != null
+ && taskId == stackInfo.taskIds[stackInfo.taskIds.length - 1]) {
+ mActivityViewCallback.onTaskRemovalStarted(taskId);
}
}