Merge "Prevent NullPointerException in ActivityRecord when in Size Compat Mode" into tm-qpr-dev am: a77ae5c059

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21700183

Change-Id: Ia3564964945a50d0634bd170c57589ba1ec14db9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Massimo Carli
2023-03-07 18:57:53 +00:00
committed by Automerger Merge Worker
2 changed files with 15 additions and 14 deletions

View File

@@ -8107,9 +8107,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
if (isFixedOrientationLetterboxAllowed) { if (isFixedOrientationLetterboxAllowed) {
resolveFixedOrientationConfiguration(newParentConfiguration); resolveFixedOrientationConfiguration(newParentConfiguration);
} }
final CompatDisplayInsets compatDisplayInsets = getCompatDisplayInsets();
if (getCompatDisplayInsets() != null) { if (compatDisplayInsets != null) {
resolveSizeCompatModeConfiguration(newParentConfiguration); resolveSizeCompatModeConfiguration(newParentConfiguration, compatDisplayInsets);
} else if (inMultiWindowMode() && !isFixedOrientationLetterboxAllowed) { } else if (inMultiWindowMode() && !isFixedOrientationLetterboxAllowed) {
// We ignore activities' requested orientation in multi-window modes. They may be // We ignore activities' requested orientation in multi-window modes. They may be
// taken into consideration in resolveFixedOrientationConfiguration call above. // taken into consideration in resolveFixedOrientationConfiguration call above.
@@ -8126,7 +8126,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
resolveAspectRatioRestriction(newParentConfiguration); resolveAspectRatioRestriction(newParentConfiguration);
} }
if (isFixedOrientationLetterboxAllowed || getCompatDisplayInsets() != null if (isFixedOrientationLetterboxAllowed || compatDisplayInsets != null
// In fullscreen, can be letterboxed for aspect ratio. // In fullscreen, can be letterboxed for aspect ratio.
|| !inMultiWindowMode()) { || !inMultiWindowMode()) {
updateResolvedBoundsPosition(newParentConfiguration); updateResolvedBoundsPosition(newParentConfiguration);
@@ -8134,7 +8134,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
boolean isIgnoreOrientationRequest = mDisplayContent != null boolean isIgnoreOrientationRequest = mDisplayContent != null
&& mDisplayContent.getIgnoreOrientationRequest(); && mDisplayContent.getIgnoreOrientationRequest();
if (getCompatDisplayInsets() == null if (compatDisplayInsets == null
// for size compat mode set in updateCompatDisplayInsets // for size compat mode set in updateCompatDisplayInsets
// Fixed orientation letterboxing is possible on both large screen devices // Fixed orientation letterboxing is possible on both large screen devices
// with ignoreOrientationRequest enabled and on phones in split screen even with // with ignoreOrientationRequest enabled and on phones in split screen even with
@@ -8181,7 +8181,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
info.neverSandboxDisplayApis(sConstrainDisplayApisConfig), info.neverSandboxDisplayApis(sConstrainDisplayApisConfig),
info.alwaysSandboxDisplayApis(sConstrainDisplayApisConfig), info.alwaysSandboxDisplayApis(sConstrainDisplayApisConfig),
!matchParentBounds(), !matchParentBounds(),
getCompatDisplayInsets() != null, compatDisplayInsets != null,
shouldCreateCompatDisplayInsets()); shouldCreateCompatDisplayInsets());
} }
resolvedConfig.windowConfiguration.setMaxBounds(mTmpBounds); resolvedConfig.windowConfiguration.setMaxBounds(mTmpBounds);
@@ -8589,7 +8589,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
* Resolves consistent screen configuration for orientation and rotation changes without * Resolves consistent screen configuration for orientation and rotation changes without
* inheriting the parent bounds. * inheriting the parent bounds.
*/ */
private void resolveSizeCompatModeConfiguration(Configuration newParentConfiguration) { private void resolveSizeCompatModeConfiguration(Configuration newParentConfiguration,
@NonNull CompatDisplayInsets compatDisplayInsets) {
final Configuration resolvedConfig = getResolvedOverrideConfiguration(); final Configuration resolvedConfig = getResolvedOverrideConfiguration();
final Rect resolvedBounds = resolvedConfig.windowConfiguration.getBounds(); final Rect resolvedBounds = resolvedConfig.windowConfiguration.getBounds();
@@ -8610,13 +8611,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
? requestedOrientation ? requestedOrientation
// We should use the original orientation of the activity when possible to avoid // We should use the original orientation of the activity when possible to avoid
// forcing the activity in the opposite orientation. // forcing the activity in the opposite orientation.
: getCompatDisplayInsets().mOriginalRequestedOrientation != ORIENTATION_UNDEFINED : compatDisplayInsets.mOriginalRequestedOrientation != ORIENTATION_UNDEFINED
? getCompatDisplayInsets().mOriginalRequestedOrientation ? compatDisplayInsets.mOriginalRequestedOrientation
: newParentConfiguration.orientation; : newParentConfiguration.orientation;
int rotation = newParentConfiguration.windowConfiguration.getRotation(); int rotation = newParentConfiguration.windowConfiguration.getRotation();
final boolean isFixedToUserRotation = mDisplayContent == null final boolean isFixedToUserRotation = mDisplayContent == null
|| mDisplayContent.getDisplayRotation().isFixedToUserRotation(); || mDisplayContent.getDisplayRotation().isFixedToUserRotation();
if (!isFixedToUserRotation && !getCompatDisplayInsets().mIsFloating) { if (!isFixedToUserRotation && !compatDisplayInsets.mIsFloating) {
// Use parent rotation because the original display can be rotated. // Use parent rotation because the original display can be rotated.
resolvedConfig.windowConfiguration.setRotation(rotation); resolvedConfig.windowConfiguration.setRotation(rotation);
} else { } else {
@@ -8632,11 +8633,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
// rely on them to contain the original and unchanging width and height of the app. // rely on them to contain the original and unchanging width and height of the app.
final Rect containingAppBounds = new Rect(); final Rect containingAppBounds = new Rect();
final Rect containingBounds = mTmpBounds; final Rect containingBounds = mTmpBounds;
getCompatDisplayInsets().getContainerBounds(containingAppBounds, containingBounds, rotation, compatDisplayInsets.getContainerBounds(containingAppBounds, containingBounds, rotation,
orientation, orientationRequested, isFixedToUserRotation); orientation, orientationRequested, isFixedToUserRotation);
resolvedBounds.set(containingBounds); resolvedBounds.set(containingBounds);
// The size of floating task is fixed (only swap), so the aspect ratio is already correct. // The size of floating task is fixed (only swap), so the aspect ratio is already correct.
if (!getCompatDisplayInsets().mIsFloating) { if (!compatDisplayInsets.mIsFloating) {
mIsAspectRatioApplied = mIsAspectRatioApplied =
applyAspectRatio(resolvedBounds, containingAppBounds, containingBounds); applyAspectRatio(resolvedBounds, containingAppBounds, containingBounds);
} }
@@ -8645,7 +8646,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
// are calculated in compat container space. The actual position on screen will be applied // are calculated in compat container space. The actual position on screen will be applied
// later, so the calculation is simpler that doesn't need to involve offset from parent. // later, so the calculation is simpler that doesn't need to involve offset from parent.
getTaskFragment().computeConfigResourceOverrides(resolvedConfig, newParentConfiguration, getTaskFragment().computeConfigResourceOverrides(resolvedConfig, newParentConfiguration,
getCompatDisplayInsets()); compatDisplayInsets);
// Use current screen layout as source because the size of app is independent to parent. // Use current screen layout as source because the size of app is independent to parent.
resolvedConfig.screenLayout = TaskFragment.computeScreenLayoutOverride( resolvedConfig.screenLayout = TaskFragment.computeScreenLayoutOverride(
getConfiguration().screenLayout, resolvedConfig.screenWidthDp, getConfiguration().screenLayout, resolvedConfig.screenWidthDp,

View File

@@ -1433,7 +1433,7 @@ final class LetterboxUiController {
* the first opaque activity beneath. * the first opaque activity beneath.
*/ */
boolean hasInheritedLetterboxBehavior() { boolean hasInheritedLetterboxBehavior() {
return mLetterboxConfigListener != null && !mActivityRecord.matchParentBounds(); return mLetterboxConfigListener != null;
} }
/** /**