Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ada9afc4 authored by Massimo Carli's avatar Massimo Carli
Browse files

Prevent NPE on AppCompatDisplayInsets

Flag: EXEMPT Small fix
Fix: 383548418
Test: atest WmTests:ActivityRecordTests
Test: atest WmTests:CameraCompatFreeformPolicyTests
Test: atest WmTests:SizeCompatTests

Change-Id: Iad34c2d4ec35c371435c0f37e1de950eaf07c9af
parent 1a2292b9
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -8995,13 +8995,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                || orientationRespectedWithInsets)) {
            return;
        }
        final AppCompatDisplayInsets mAppCompatDisplayInsets = getAppCompatDisplayInsets();
        final AppCompatDisplayInsets appCompatDisplayInsets = getAppCompatDisplayInsets();
        final AppCompatSizeCompatModePolicy scmPolicy =
                mAppCompatController.getAppCompatSizeCompatModePolicy();

        if (scmPolicy.hasAppCompatDisplayInsetsWithoutInheritance()
                && mAppCompatDisplayInsets != null
                && !mAppCompatDisplayInsets.mIsInFixedOrientationOrAspectRatioLetterbox) {
        if (appCompatDisplayInsets != null
                && !appCompatDisplayInsets.mIsInFixedOrientationOrAspectRatioLetterbox) {
            // App prefers to keep its original size.
            // If the size compat is from previous fixed orientation letterboxing, we may want to
            // have fixed orientation letterbox again, otherwise it will show the size compat
@@ -9053,8 +9052,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                .applyDesiredAspectRatio(newParentConfig, parentBounds, resolvedBounds,
                        containingBoundsWithInsets, containingBounds);

        if (scmPolicy.hasAppCompatDisplayInsetsWithoutInheritance()) {
            mAppCompatDisplayInsets.getBoundsByRotation(mTmpBounds,
        if (appCompatDisplayInsets != null) {
            appCompatDisplayInsets.getBoundsByRotation(mTmpBounds,
                    newParentConfig.windowConfiguration.getRotation());
            if (resolvedBounds.width() != mTmpBounds.width()
                    || resolvedBounds.height() != mTmpBounds.height()) {
@@ -9077,7 +9076,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

        // Calculate app bounds using fixed orientation bounds because they will be needed later
        // for comparison with size compat app bounds in {@link resolveSizeCompatModeConfiguration}.
        mResolveConfigHint.mTmpCompatInsets = mAppCompatDisplayInsets;
        mResolveConfigHint.mTmpCompatInsets = appCompatDisplayInsets;
        computeConfigByResolveHint(getResolvedOverrideConfiguration(), newParentConfig);
        mAppCompatController.getAppCompatAspectRatioPolicy()
                .setLetterboxBoundsForFixedOrientationAndAspectRatio(new Rect(resolvedBounds));