Merge "Per-app override for disabling ignoreOrientationRequest" into tm-qpr-dev am: 61a6250921
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21150119 Change-Id: I8128ddd11e1d35ad67bf5fb956bc907ccf04222e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1057,6 +1057,17 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
|
|||||||
@TestApi
|
@TestApi
|
||||||
public static final long ALWAYS_SANDBOX_DISPLAY_APIS = 185004937L; // buganizer id
|
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
|
* 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.
|
* treatment. See com.android.server.wm.DisplayRotationCompatPolicy for context.
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.server.wm;
|
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_BEHIND;
|
||||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
|
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
|
||||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
|
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) {
|
|| orientation == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) {
|
||||||
return false;
|
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() {
|
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_ENABLE_COMPAT_IGNORE_REQUESTED_ORIENTATION;
|
||||||
import static android.content.pm.ActivityInfo.OVERRIDE_LANDSCAPE_ORIENTATION_TO_REVERSE_LANDSCAPE;
|
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_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_NOSENSOR;
|
||||||
import static android.content.pm.ActivityInfo.OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT;
|
import static android.content.pm.ActivityInfo.OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT;
|
||||||
import static android.content.pm.ActivityInfo.OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION;
|
import static android.content.pm.ActivityInfo.OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION;
|
||||||
@@ -143,6 +144,8 @@ final class LetterboxUiController {
|
|||||||
private final boolean mIsOverrideOrientationOnlyForCameraEnabled;
|
private final boolean mIsOverrideOrientationOnlyForCameraEnabled;
|
||||||
// Corresponds to OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION
|
// Corresponds to OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION
|
||||||
private final boolean mIsOverrideUseDisplayLandscapeNaturalOrientationEnabled;
|
private final boolean mIsOverrideUseDisplayLandscapeNaturalOrientationEnabled;
|
||||||
|
// Corresponds to OVERRIDE_RESPECT_REQUESTED_ORIENTATION
|
||||||
|
private final boolean mIsOverrideRespectRequestedOrientationEnabled;
|
||||||
|
|
||||||
// Corresponds to OVERRIDE_CAMERA_COMPAT_DISABLE_FORCE_ROTATION
|
// Corresponds to OVERRIDE_CAMERA_COMPAT_DISABLE_FORCE_ROTATION
|
||||||
private final boolean mIsOverrideCameraCompatDisableForceRotationEnabled;
|
private final boolean mIsOverrideCameraCompatDisableForceRotationEnabled;
|
||||||
@@ -272,6 +275,8 @@ final class LetterboxUiController {
|
|||||||
isCompatChangeEnabled(OVERRIDE_ORIENTATION_ONLY_FOR_CAMERA);
|
isCompatChangeEnabled(OVERRIDE_ORIENTATION_ONLY_FOR_CAMERA);
|
||||||
mIsOverrideUseDisplayLandscapeNaturalOrientationEnabled =
|
mIsOverrideUseDisplayLandscapeNaturalOrientationEnabled =
|
||||||
isCompatChangeEnabled(OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION);
|
isCompatChangeEnabled(OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION);
|
||||||
|
mIsOverrideRespectRequestedOrientationEnabled =
|
||||||
|
isCompatChangeEnabled(OVERRIDE_RESPECT_REQUESTED_ORIENTATION);
|
||||||
|
|
||||||
mIsOverrideCameraCompatDisableForceRotationEnabled =
|
mIsOverrideCameraCompatDisableForceRotationEnabled =
|
||||||
isCompatChangeEnabled(OVERRIDE_CAMERA_COMPAT_DISABLE_FORCE_ROTATION);
|
isCompatChangeEnabled(OVERRIDE_CAMERA_COMPAT_DISABLE_FORCE_ROTATION);
|
||||||
@@ -418,6 +423,10 @@ final class LetterboxUiController {
|
|||||||
mIsRefreshAfterRotationRequested = isRequested;
|
mIsRefreshAfterRotationRequested = isRequested;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isOverrideRespectRequestedOrientationEnabled() {
|
||||||
|
return mIsOverrideRespectRequestedOrientationEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether should fix display orientation to landscape natural orientation when a task is
|
* Whether should fix display orientation to landscape natural orientation when a task is
|
||||||
* fullscreen and the display is ignoring orientation requests.
|
* fullscreen and the display is ignoring orientation requests.
|
||||||
|
|||||||
@@ -1875,6 +1875,43 @@ public class SizeCompatTests extends WindowTestsBase {
|
|||||||
activity.getBounds().width(), 0.5);
|
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
|
@Test
|
||||||
public void testSplitAspectRatioForUnresizableLandscapeApps() {
|
public void testSplitAspectRatioForUnresizableLandscapeApps() {
|
||||||
// Set up a display in portrait and ignoring orientation request.
|
// Set up a display in portrait and ignoring orientation request.
|
||||||
|
|||||||
Reference in New Issue
Block a user