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
This commit is contained in:
Riddle Hsu
2020-03-24 15:22:48 +08:00
parent 4d39f7bbe9
commit 9a8e3ae15c
3 changed files with 32 additions and 15 deletions

View File

@@ -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();
}

View File

@@ -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;
@@ -3210,6 +3213,20 @@ class Task extends WindowContainer<WindowContainer> {
return mTaskDescription;
}
@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();

View File

@@ -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();