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

Commit 5c5f3a06 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Clear size compat config when resizing to large screen" into main

parents 3062c27f 8f81dad6
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -7583,6 +7583,9 @@ final class ActivityRecord extends WindowToken {

    @Override
    void resolveOverrideConfiguration(Configuration newParentConfiguration) {
        final AppCompatSizeCompatModePolicy scmPolicy =
                mAppCompatController.getSizeCompatModePolicy();
        scmPolicy.clearSizeCompatModeIfNeededOnResolveOverrideConfiguration();
        final Configuration requestedOverrideConfig = getRequestedOverrideConfiguration();
        if (requestedOverrideConfig.assetsSeq != ASSETS_SEQ_UNDEFINED
                && newParentConfiguration.assetsSeq > requestedOverrideConfig.assetsSeq) {
@@ -7640,8 +7643,6 @@ final class ActivityRecord extends WindowToken {
        // Don't apply aspect ratio if app is overridden to fullscreen by device user/manufacturer.
        aspectRatioPolicy.resolveAspectRatioRestrictionIfNeeded(newParentConfiguration);
        final AppCompatDisplayInsets appCompatDisplayInsets = getAppCompatDisplayInsets();
        final AppCompatSizeCompatModePolicy scmPolicy =
                mAppCompatController.getSizeCompatModePolicy();
        if (appCompatDisplayInsets != null) {
            scmPolicy.resolveSizeCompatModeConfiguration(newParentConfiguration,
                    appCompatDisplayInsets, mTmpBounds);
+15 −2
Original line number Diff line number Diff line
@@ -171,8 +171,7 @@ class AppCompatSizeCompatModePolicy {
                .clearInheritedAppCompatDisplayInsets();
    }

    void clearSizeCompatMode() {
        clearSizeCompatModeAttributes();
    private Configuration clearOverrideConfiguration() {
        // Clear config override in #updateAppCompatDisplayInsets().
        final int activityType = mActivityRecord.getActivityType();
        final Configuration overrideConfig = mActivityRecord.getRequestedOverrideConfiguration();
@@ -180,9 +179,23 @@ class AppCompatSizeCompatModePolicy {
        // Keep the activity type which was set when attaching to a task to prevent leaving it
        // undefined.
        overrideConfig.windowConfiguration.setActivityType(activityType);
        return overrideConfig;
    }

    void clearSizeCompatMode() {
        clearSizeCompatModeAttributes();
        final Configuration overrideConfig = clearOverrideConfiguration();
        mActivityRecord.onRequestedOverrideConfigurationChanged(overrideConfig);
    }

    void clearSizeCompatModeIfNeededOnResolveOverrideConfiguration() {
        if (mAppCompatDisplayInsets == null || !mActivityRecord.isUniversalResizeable()) {
            return;
        }
        clearSizeCompatModeAttributes();
        clearOverrideConfiguration();
    }

    void dump(@NonNull PrintWriter pw, @NonNull String prefix) {
        if (mSizeCompatScale != 1f || hasSizeCompatBounds()) {
            pw.println(prefix + "mSizeCompatScale=" + mSizeCompatScale + " mSizeCompatBounds="
+7 −1
Original line number Diff line number Diff line
@@ -5431,12 +5431,18 @@ public class SizeCompatTests extends WindowTestsBase {
    public void testUniversalResizeableByDefault() {
        mSetFlagsRule.enableFlags(Flags.FLAG_UNIVERSAL_RESIZABLE_BY_DEFAULT);
        mDisplayContent.setIgnoreOrientationRequest(false);
        setUpApp(mDisplayContent);
        setUpApp(mDisplayContent, new ActivityBuilder(mAtm)
                .setResizeMode(RESIZE_MODE_UNRESIZEABLE)
                .setScreenOrientation(SCREEN_ORIENTATION_LANDSCAPE)
                .setMinAspectRatio(OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE));
        assertFalse(mActivity.isUniversalResizeable());
        mActivity.mAppCompatController.getSizeCompatModePolicy().updateAppCompatDisplayInsets();
        assertNotNull(mActivity.getAppCompatDisplayInsets());

        mDisplayContent.setIgnoreOrientationRequest(true);
        makeDisplayLargeScreen(mDisplayContent);
        assertTrue(mActivity.isUniversalResizeable());
        assertFitted();
    }

    @Test