Merge "Per-app override for disabling ignoreOrientationRequest" into tm-qpr-dev am: 61a6250921 am: 0b3dcae402
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21150119 Change-Id: I075fb4c30cb806849af7d2dd87be99ce3c38982e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1102,6 +1102,17 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
|
||||
@TestApi
|
||||
public static final long ALWAYS_SANDBOX_DISPLAY_APIS = 185004937L; // buganizer id
|
||||
|
||||
/**
|
||||
* This change id excludes the packages it is applied to from ignoreOrientationRequest behaviour
|
||||
* that can be enabled by the device manufacturers for the com.android.server.wm.DisplayArea
|
||||
* or for the whole display.
|
||||
* @hide
|
||||
*/
|
||||
@ChangeId
|
||||
@Overridable
|
||||
@Disabled
|
||||
public static final long OVERRIDE_RESPECT_REQUESTED_ORIENTATION = 236283604L; // buganizer id
|
||||
|
||||
/**
|
||||
* This change id excludes the packages it is applied to from the camera compat force rotation
|
||||
* treatment. See com.android.server.wm.DisplayRotationCompatPolicy for context.
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.server.wm;
|
||||
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND;
|
||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
|
||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
||||
@@ -246,7 +247,22 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
|
||||
|| orientation == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) {
|
||||
return false;
|
||||
}
|
||||
return getIgnoreOrientationRequest();
|
||||
return getIgnoreOrientationRequest()
|
||||
&& !shouldRespectOrientationRequestDueToPerAppOverride();
|
||||
}
|
||||
|
||||
private boolean shouldRespectOrientationRequestDueToPerAppOverride() {
|
||||
if (mDisplayContent == null) {
|
||||
return false;
|
||||
}
|
||||
ActivityRecord activity = mDisplayContent.topRunningActivity(
|
||||
/* considerKeyguardState= */ true);
|
||||
return activity != null && activity.getTaskFragment() != null
|
||||
// Checking TaskFragment rather than ActivityRecord to ensure that transition
|
||||
// between fullscreen and PiP would work well. Checking TaskFragment rather than
|
||||
// Task to ensure that Activity Embedding is excluded.
|
||||
&& activity.getTaskFragment().getWindowingMode() == WINDOWING_MODE_FULLSCREEN
|
||||
&& activity.mLetterboxUiController.isOverrideRespectRequestedOrientationEnabled();
|
||||
}
|
||||
|
||||
boolean getIgnoreOrientationRequest() {
|
||||
|
||||
@@ -25,6 +25,7 @@ import static android.content.pm.ActivityInfo.OVERRIDE_ENABLE_COMPAT_FAKE_FOCUS;
|
||||
import static android.content.pm.ActivityInfo.OVERRIDE_ENABLE_COMPAT_IGNORE_REQUESTED_ORIENTATION;
|
||||
import static android.content.pm.ActivityInfo.OVERRIDE_LANDSCAPE_ORIENTATION_TO_REVERSE_LANDSCAPE;
|
||||
import static android.content.pm.ActivityInfo.OVERRIDE_ORIENTATION_ONLY_FOR_CAMERA;
|
||||
import static android.content.pm.ActivityInfo.OVERRIDE_RESPECT_REQUESTED_ORIENTATION;
|
||||
import static android.content.pm.ActivityInfo.OVERRIDE_UNDEFINED_ORIENTATION_TO_NOSENSOR;
|
||||
import static android.content.pm.ActivityInfo.OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT;
|
||||
import static android.content.pm.ActivityInfo.OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION;
|
||||
@@ -143,6 +144,8 @@ final class LetterboxUiController {
|
||||
private final boolean mIsOverrideOrientationOnlyForCameraEnabled;
|
||||
// Corresponds to OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION
|
||||
private final boolean mIsOverrideUseDisplayLandscapeNaturalOrientationEnabled;
|
||||
// Corresponds to OVERRIDE_RESPECT_REQUESTED_ORIENTATION
|
||||
private final boolean mIsOverrideRespectRequestedOrientationEnabled;
|
||||
|
||||
// Corresponds to OVERRIDE_CAMERA_COMPAT_DISABLE_FORCE_ROTATION
|
||||
private final boolean mIsOverrideCameraCompatDisableForceRotationEnabled;
|
||||
@@ -272,6 +275,8 @@ final class LetterboxUiController {
|
||||
isCompatChangeEnabled(OVERRIDE_ORIENTATION_ONLY_FOR_CAMERA);
|
||||
mIsOverrideUseDisplayLandscapeNaturalOrientationEnabled =
|
||||
isCompatChangeEnabled(OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION);
|
||||
mIsOverrideRespectRequestedOrientationEnabled =
|
||||
isCompatChangeEnabled(OVERRIDE_RESPECT_REQUESTED_ORIENTATION);
|
||||
|
||||
mIsOverrideCameraCompatDisableForceRotationEnabled =
|
||||
isCompatChangeEnabled(OVERRIDE_CAMERA_COMPAT_DISABLE_FORCE_ROTATION);
|
||||
@@ -418,6 +423,10 @@ final class LetterboxUiController {
|
||||
mIsRefreshAfterRotationRequested = isRequested;
|
||||
}
|
||||
|
||||
boolean isOverrideRespectRequestedOrientationEnabled() {
|
||||
return mIsOverrideRespectRequestedOrientationEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether should fix display orientation to landscape natural orientation when a task is
|
||||
* fullscreen and the display is ignoring orientation requests.
|
||||
|
||||
@@ -1894,6 +1894,43 @@ public class SizeCompatTests extends WindowTestsBase {
|
||||
activity.getBounds().width(), 0.5);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableCompatChanges({ActivityInfo.OVERRIDE_RESPECT_REQUESTED_ORIENTATION})
|
||||
public void testOverrideRespectRequestedOrientationIsEnabled_orientationIsRespected() {
|
||||
// Set up a display in landscape
|
||||
setUpDisplaySizeWithApp(2800, 1400);
|
||||
|
||||
final ActivityRecord activity = buildActivityRecord(/* supportsSizeChanges= */ false,
|
||||
RESIZE_MODE_UNRESIZEABLE, SCREEN_ORIENTATION_PORTRAIT);
|
||||
activity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
|
||||
|
||||
// Display should be rotated.
|
||||
assertEquals(SCREEN_ORIENTATION_PORTRAIT, activity.mDisplayContent.getOrientation());
|
||||
|
||||
// No size compat mode
|
||||
assertFalse(activity.inSizeCompatMode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableCompatChanges({ActivityInfo.OVERRIDE_RESPECT_REQUESTED_ORIENTATION})
|
||||
public void testOverrideRespectRequestedOrientationIsEnabled_multiWindow_orientationIgnored() {
|
||||
// Set up a display in landscape
|
||||
setUpDisplaySizeWithApp(2800, 1400);
|
||||
|
||||
final ActivityRecord activity = buildActivityRecord(/* supportsSizeChanges= */ false,
|
||||
RESIZE_MODE_UNRESIZEABLE, SCREEN_ORIENTATION_PORTRAIT);
|
||||
TaskFragment taskFragment = activity.getTaskFragment();
|
||||
spyOn(taskFragment);
|
||||
activity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
|
||||
doReturn(WINDOWING_MODE_MULTI_WINDOW).when(taskFragment).getWindowingMode();
|
||||
|
||||
// Display should not be rotated.
|
||||
assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, activity.mDisplayContent.getOrientation());
|
||||
|
||||
// No size compat mode
|
||||
assertFalse(activity.inSizeCompatMode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSplitAspectRatioForUnresizableLandscapeApps() {
|
||||
// Set up a display in portrait and ignoring orientation request.
|
||||
|
||||
Reference in New Issue
Block a user