diff options
| author | 2020-03-24 15:22:48 +0800 | |
|---|---|---|
| committer | 2020-03-24 23:14:44 +0800 | |
| commit | 9a8e3ae15c8608f46e29c3aa90a68539c4164cbe (patch) | |
| tree | 859684445fe1673ad9240934706ca583ede7b712 | |
| parent | 4d39f7bbe981115f48efa8aa3f9ae750d4a5378d (diff) | |
Fix temporal display orientation by pip activity
Change to override getOrientation(int) because that is how the parent
gets candidate orientation from children.
Also move the methods to Task because it will be the generic container.
Fix: 152298974
Bug: 151727009
Test: atest TaskRecordTests#testNotSpecifyOrientationByFloatingTask
Change-Id: I9877bb597bf5aa97114673aa079cc72775ff0515
3 files changed, 32 insertions, 15 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityStack.java b/services/core/java/com/android/server/wm/ActivityStack.java index e8bfe8ef63ac..fb22481306dd 100644 --- a/services/core/java/com/android/server/wm/ActivityStack.java +++ b/services/core/java/com/android/server/wm/ActivityStack.java @@ -36,7 +36,6 @@ import static android.app.WindowConfiguration.windowingModeToString; import static android.content.pm.ActivityInfo.CONFIG_SCREEN_LAYOUT; import static android.content.pm.ActivityInfo.FLAG_RESUME_WHILE_PAUSING; import static android.content.pm.ActivityInfo.FLAG_SHOW_FOR_ALL_USERS; -import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD; @@ -3781,20 +3780,6 @@ class ActivityStack extends Task { return super.checkCompleteDeferredRemoval(); } - @Override - int getOrientation() { - return (canSpecifyOrientation()) ? super.getOrientation() : SCREEN_ORIENTATION_UNSET; - } - - private boolean canSpecifyOrientation() { - final int windowingMode = getWindowingMode(); - final int activityType = getActivityType(); - return windowingMode == WINDOWING_MODE_FULLSCREEN - || activityType == ACTIVITY_TYPE_HOME - || activityType == ACTIVITY_TYPE_RECENTS - || activityType == ACTIVITY_TYPE_ASSISTANT; - } - public DisplayInfo getDisplayInfo() { return mDisplayContent.getDisplayInfo(); } diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index f826deb6926a..a201bc053cd9 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -20,6 +20,9 @@ import static android.app.ActivityTaskManager.INVALID_TASK_ID; import static android.app.ActivityTaskManager.RESIZE_MODE_FORCED; import static android.app.ActivityTaskManager.RESIZE_MODE_SYSTEM; import static android.app.ActivityTaskManager.RESIZE_MODE_SYSTEM_SCREEN_ROTATION; +import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT; +import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; +import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; import static android.app.WindowConfiguration.PINNED_WINDOWING_MODE_ELEVATION_IN_DIP; @@ -3211,6 +3214,20 @@ class Task extends WindowContainer<WindowContainer> { } @Override + int getOrientation(int candidate) { + return canSpecifyOrientation() ? super.getOrientation(candidate) : SCREEN_ORIENTATION_UNSET; + } + + private boolean canSpecifyOrientation() { + final int windowingMode = getWindowingMode(); + final int activityType = getActivityType(); + return windowingMode == WINDOWING_MODE_FULLSCREEN + || activityType == ACTIVITY_TYPE_HOME + || activityType == ACTIVITY_TYPE_RECENTS + || activityType == ACTIVITY_TYPE_ASSISTANT; + } + + @Override boolean fillsParent() { return matchParentBounds(); } diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java index a25acae3c036..5848295beefa 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java @@ -27,6 +27,7 @@ import static android.content.Intent.FLAG_ACTIVITY_TASK_ON_HOME; import static android.content.pm.ActivityInfo.FLAG_RELINQUISH_TASK_IDENTITY; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; +import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static android.util.DisplayMetrics.DENSITY_DEFAULT; import static android.view.IWindowManager.FIXED_TO_USER_ROTATION_ENABLED; @@ -939,6 +940,20 @@ public class TaskRecordTests extends ActivityTestsBase { verify(persister, never()).saveTask(same(task), any()); } + @Test + public void testNotSpecifyOrientationByFloatingTask() { + final Task task = getTestTask(); + final ActivityRecord activity = task.getTopMostActivity(); + final WindowContainer<?> taskContainer = task.getParent(); + activity.setRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE); + + assertEquals(SCREEN_ORIENTATION_LANDSCAPE, taskContainer.getOrientation()); + + task.setWindowingMode(WINDOWING_MODE_PINNED); + + assertEquals(SCREEN_ORIENTATION_UNSET, taskContainer.getOrientation()); + } + private Task getTestTask() { final ActivityStack stack = new StackBuilder(mRootWindowContainer).build(); return stack.getBottomMostTask(); |