From a7c9f7cb4cc7dc4d4d93d543169523bcd9adcfb5 Mon Sep 17 00:00:00 2001 From: Garfield Tan Date: Fri, 13 Mar 2020 15:56:51 -0700 Subject: [PATCH] Send notification when reusing a stack as a task. We used to always create a task even though we knew there was only one task ever created under a stack. Thus the onTaskCreated() notification is always sent with correct component name. However after we merged stack & task in some cases, stack can be reused as a task and listeners (e.g. SysUI) lost a useful notification as when stack is created componentName is still null. Therefore send out the notification when reuse is decided. Listeners can determine if it's a root task or leaf task from the nullness of component name. Bug: 150252489 Test: Smoke tests & TH. Change-Id: I0896307fd6bbfa53d95843043235e506e1a97a43 --- services/core/java/com/android/server/wm/Task.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index eca7d2e19288a..83fa686bc34b4 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -129,11 +129,11 @@ import android.util.DisplayMetrics; import android.util.Slog; import android.util.proto.ProtoOutputStream; import android.view.DisplayInfo; -import android.window.ITaskOrganizer; import android.view.RemoteAnimationAdapter; import android.view.RemoteAnimationTarget; import android.view.Surface; import android.view.SurfaceControl; +import android.window.ITaskOrganizer; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.app.IVoiceInteractor; @@ -594,6 +594,14 @@ class Task extends WindowContainer { voiceInteractor = _voiceInteractor; setIntent(activity, intent, info); setMinDimensions(info); + // Before we began to reuse a root task (old ActivityStack) as the leaf task, we used to + // create a leaf task in this case. Therefore now we won't send out the task created + // notification when we decide to reuse it here, so we send out the notification below. + // The reason why the created notification sent out when root task is created doesn't work + // is that realActivity isn't set until setIntent() method above is called for the first + // time. Eventually this notification will be removed when we can populate those information + // when root task is created. + mAtmService.getTaskChangeNotificationController().notifyTaskCreated(mTaskId, realActivity); return this; }