From f920308224766fa3b2b40e8006f20f53fcc9fd5e Mon Sep 17 00:00:00 2001 From: Louis Chang Date: Fri, 10 Mar 2023 04:01:03 +0000 Subject: [PATCH] Ensure child task has activity type set Otherwise, the activity type of the child task is undefined. Also log if the activity type of an Activity is changed once set. Bug: 271528886 Test: drag app into split-screen Change-Id: Ib8e925bc50dc2779bea1230cc22e6c1f68406d2c --- .../core/java/com/android/server/wm/ActivityRecord.java | 6 ++++++ services/core/java/com/android/server/wm/Task.java | 3 +++ 2 files changed, 9 insertions(+) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 9944f127521d5..2b89cb145e4fd 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -8892,6 +8892,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A final boolean wasInPictureInPicture = inPinnedWindowingMode(); final DisplayContent display = mDisplayContent; + final int activityType = getActivityType(); if (wasInPictureInPicture && attachedToProcess() && display != null) { // If the PIP activity is changing to fullscreen with display orientation change, the // fixed rotation will take effect that requires to send fixed rotation adjustments @@ -8916,6 +8917,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } else { super.onConfigurationChanged(newParentConfig); } + if (activityType != ACTIVITY_TYPE_UNDEFINED + && activityType != getActivityType()) { + Slog.w(TAG, "Can't change activity type once set: " + this + + " activityType=" + activityTypeToString(getActivityType())); + } // Configuration's equality doesn't consider seq so if only seq number changes in resolved // override configuration. Therefore ConfigurationContainer doesn't change merged override diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index adaaa259e6807..ddfd5ae2f27d1 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -5884,8 +5884,11 @@ class Task extends TaskFragment { final int taskId = activity != null ? mTaskSupervisor.getNextTaskIdForUser(activity.mUserId) : mTaskSupervisor.getNextTaskIdForUser(); + final int activityType = getActivityType(); task = new Task.Builder(mAtmService) .setTaskId(taskId) + .setActivityType(activityType != ACTIVITY_TYPE_UNDEFINED ? activityType + : ACTIVITY_TYPE_STANDARD) .setActivityInfo(info) .setActivityOptions(options) .setIntent(intent)