From 84289d3985759260e19bcf2e95651bf814845cde Mon Sep 17 00:00:00 2001 From: Shawn Lin Date: Fri, 13 May 2022 09:35:17 +0000 Subject: [PATCH] Add getAdjacentTaskFragment check for the split screen case Previously, the root task created by kids mode would be treated the same as split screen to return SCREEN_ORIENTATION_UNSPECIFIED. Now, also check getAdjacentTaskFragment != null for the split screen case, so that apps in the kids mode root task will work as expect. Bug: 231575466 Test: - Enter kids mode -> rotate device - apps should follow their request orientations - Enter split screen(not in kids mode) -> rotate device - tasks should be rotated Change-Id: I930e162ef74d114ba2375eae03e13f7ccdd34baa --- .../java/com/android/server/wm/TaskDisplayArea.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java index ce406e4ecb20b..dd1b50fc5e0bc 100644 --- a/services/core/java/com/android/server/wm/TaskDisplayArea.java +++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java @@ -654,12 +654,14 @@ final class TaskDisplayArea extends DisplayArea { } // Apps and their containers are not allowed to specify an orientation of non floating - // visible tasks created by organizer. The organizer handles the orientation instead. + // visible tasks created by organizer and that has an adjacent task. final Task nonFloatingTopTask = - getRootTask(t -> !t.getWindowConfiguration().tasksAreFloating()); - if (nonFloatingTopTask != null && nonFloatingTopTask.mCreatedByOrganizer - && nonFloatingTopTask.isVisible()) { - return SCREEN_ORIENTATION_UNSPECIFIED; + getTask(t -> !t.getWindowConfiguration().tasksAreFloating()); + if (nonFloatingTopTask != null) { + final Task task = nonFloatingTopTask.getCreatedByOrganizerTask(); + if (task != null && task.getAdjacentTaskFragment() != null && task.isVisible()) { + return SCREEN_ORIENTATION_UNSPECIFIED; + } } final int orientation = super.getOrientation(candidate);