From a7c9f7cb4cc7dc4d4d93d543169523bcd9adcfb5 Mon Sep 17 00:00:00 2001 From: Garfield Tan Date: Fri, 13 Mar 2020 15:56:51 -0700 Subject: [PATCH 1/2] 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; } From 59a60fa81a91a19570956359f2d97acdcde03eb8 Mon Sep 17 00:00:00 2001 From: Garfield Tan Date: Tue, 24 Mar 2020 10:32:29 -0700 Subject: [PATCH 2/2] Use isLeafTask() to check whether to save state. We meant to save states for all leaf tasks, including one layer task, which is excluded by the condition checked before. Bug: 152318088 Test: Smoke tests. Change-Id: Iadd8aa60ffe254398d242a12dae39148314891c8 --- services/core/java/com/android/server/wm/Task.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 83fa686bc34b4..ce5f719cd750c 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -610,11 +610,7 @@ class Task extends WindowContainer { return; } - // TODO(xutan): Removed type check after stack and task is merged. - // Before the real merge of stack and task, we need to avoid saving state of stacks. Once - // the merge is finished we can just pass DisplayContent because both windowing mode and - // bounds are set in the merged task. - if (oldParent instanceof ActivityStack) { + if (isLeafTask()) { // This task is going away, so save the last state if necessary. saveLaunchingStateIfNeeded(((WindowContainer) oldParent).getDisplayContent()); }