From 7a7722abe0e76ad15b0b65505f80e3ece6fa83a3 Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Thu, 22 Jul 2021 16:47:11 +0800 Subject: [PATCH] Correcting the package name used on splash screen window. The top activity in TaskActivitiesReport can be filter out if the state of top activity is INITIALIZING, this doesn't make sense for splash screen, because the state of the top activity do can be INITIALIZING. Create a filed targetActivityInfo in StartingWindowInfo to specify the starting activity info. Bug: 193459277 Test: atest SplashscreenTests StartingSurfaceDrawerTests Change-Id: Ifec7aff644013a0426e0622162ab24f6b9fb3d8f --- core/java/android/window/StartingWindowInfo.java | 12 ++++++++++++ .../shell/startingsurface/StartingSurfaceDrawer.java | 10 ++++------ .../startingsurface/StartingSurfaceDrawerTests.java | 1 + services/core/java/com/android/server/wm/Task.java | 4 +++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/core/java/android/window/StartingWindowInfo.java b/core/java/android/window/StartingWindowInfo.java index 566f154fba3b7..8c64474dc887c 100644 --- a/core/java/android/window/StartingWindowInfo.java +++ b/core/java/android/window/StartingWindowInfo.java @@ -22,6 +22,7 @@ import android.annotation.Nullable; import android.annotation.TestApi; import android.app.ActivityManager; import android.app.TaskInfo; +import android.content.pm.ActivityInfo; import android.os.Parcel; import android.os.Parcelable; import android.view.InsetsState; @@ -77,6 +78,14 @@ public final class StartingWindowInfo implements Parcelable { @NonNull public ActivityManager.RunningTaskInfo taskInfo; + /** + * The {@link ActivityInfo} of the target activity which to create the starting window. + * It can be null if the info is the same as the top in task info. + * @hide + */ + @Nullable + public ActivityInfo targetActivityInfo; + /** * InsetsState of TopFullscreenOpaqueWindow * @hide @@ -174,6 +183,7 @@ public final class StartingWindowInfo implements Parcelable { @Override public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeTypedObject(taskInfo, flags); + dest.writeTypedObject(targetActivityInfo, flags); dest.writeInt(startingWindowTypeParameter); dest.writeTypedObject(topOpaqueWindowInsetsState, flags); dest.writeTypedObject(topOpaqueWindowLayoutParams, flags); @@ -185,6 +195,7 @@ public final class StartingWindowInfo implements Parcelable { void readFromParcel(@NonNull Parcel source) { taskInfo = source.readTypedObject(ActivityManager.RunningTaskInfo.CREATOR); + targetActivityInfo = source.readTypedObject(ActivityInfo.CREATOR); startingWindowTypeParameter = source.readInt(); topOpaqueWindowInsetsState = source.readTypedObject(InsetsState.CREATOR); topOpaqueWindowLayoutParams = source.readTypedObject( @@ -198,6 +209,7 @@ public final class StartingWindowInfo implements Parcelable { @Override public String toString() { return "StartingWindowInfo{taskId=" + taskInfo.taskId + + " targetActivityInfo=" + targetActivityInfo + " displayId=" + taskInfo.displayId + " topActivityType=" + taskInfo.topActivityType + " preferredStartingWindowType=" diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java index 243751fe13e8d..fc7c86d669cbf 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java @@ -168,16 +168,14 @@ public class StartingSurfaceDrawer { void addSplashScreenStartingWindow(StartingWindowInfo windowInfo, IBinder appToken, @StartingWindowType int suggestType) { final RunningTaskInfo taskInfo = windowInfo.taskInfo; - final ActivityInfo activityInfo = taskInfo.topActivityInfo; - if (activityInfo == null) { + final ActivityInfo activityInfo = windowInfo.targetActivityInfo != null + ? windowInfo.targetActivityInfo + : taskInfo.topActivityInfo; + if (activityInfo == null || activityInfo.packageName == null) { return; } final int displayId = taskInfo.displayId; - if (activityInfo.packageName == null) { - return; - } - final int taskId = taskInfo.taskId; Context context = mContext; // replace with the default theme if the application didn't set diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java index 284f384a3d263..d536adb9f8ae5 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawerTests.java @@ -214,6 +214,7 @@ public class StartingSurfaceDrawerTests { final ActivityManager.RunningTaskInfo taskInfo = new ActivityManager.RunningTaskInfo(); taskInfo.topActivityInfo = info; taskInfo.taskId = taskId; + windowInfo.targetActivityInfo = info; windowInfo.taskInfo = taskInfo; return windowInfo; } diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 382a2b1b5062f..1a0e091f845cc 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -4167,7 +4167,9 @@ class Task extends WindowContainer { StartingWindowInfo getStartingWindowInfo(ActivityRecord activity) { final StartingWindowInfo info = new StartingWindowInfo(); info.taskInfo = getTaskInfo(); - + info.targetActivityInfo = info.taskInfo.topActivityInfo != null + && activity.info != info.taskInfo.topActivityInfo + ? activity.info : null; info.isKeyguardOccluded = mAtmService.mKeyguardController.isDisplayOccluded(DEFAULT_DISPLAY);