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

Commit a8b2c78a authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Enable universal resizeable for new sdk on large screen

Bug: 357141415
Flag: com.android.window.flags.universal_resizable_by_default
Test: atest SizeCompatTests#testUniversalResizeableByDefault
Change-Id: Ib1ae4f8e04ef65b0d81ca6f614ceecff0cc335fd
parent 8fa39887
Loading
Loading
Loading
Loading
+23 −6
Original line number Diff line number Diff line
@@ -286,6 +286,9 @@ import android.app.servertransaction.StopActivityItem;
import android.app.servertransaction.TopResumedActivityChangeItem;
import android.app.servertransaction.TransferSplashScreenViewStateItem;
import android.app.usage.UsageEvents.Event;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledAfter;
import android.compat.annotation.Overridable;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -465,6 +468,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    // finished destroying itself.
    private static final int DESTROY_TIMEOUT = 10 * 1000;

    @ChangeId
    @Overridable
    @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM)
    static final long UNIVERSAL_RESIZABLE_BY_DEFAULT = 357141415;

    final ActivityTaskManagerService mAtmService;
    final ActivityCallerState mCallerState;
    @NonNull
@@ -3179,10 +3187,19 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     * will be ignored.
     */
    boolean isUniversalResizeable() {
        return mWmService.mConstants.mIgnoreActivityOrientationRequest
                && info.applicationInfo.category != ApplicationInfo.CATEGORY_GAME
        if (info.applicationInfo.category == ApplicationInfo.CATEGORY_GAME) {
            return false;
        }
        final boolean compatEnabled = Flags.universalResizableByDefault()
                && mDisplayContent != null && mDisplayContent.getConfiguration()
                    .smallestScreenWidthDp >= WindowManager.LARGE_SCREEN_SMALLEST_SCREEN_WIDTH_DP
                && mDisplayContent.getIgnoreOrientationRequest()
                && info.isChangeEnabled(UNIVERSAL_RESIZABLE_BY_DEFAULT);
        if (!compatEnabled && !mWmService.mConstants.mIgnoreActivityOrientationRequest) {
            return false;
        }
        // If the user preference respects aspect ratio, then it becomes non-resizable.
                && !mAppCompatController.getAppCompatOverrides().getAppCompatAspectRatioOverrides()
        return !mAppCompatController.getAppCompatOverrides().getAppCompatAspectRatioOverrides()
                .shouldApplyUserMinAspectRatioOverride();
    }

@@ -8179,7 +8196,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    @ActivityInfo.ScreenOrientation
    protected int getOverrideOrientation() {
        int candidateOrientation = super.getOverrideOrientation();
        if (isUniversalResizeable() && ActivityInfo.isFixedOrientation(candidateOrientation)) {
        if (ActivityInfo.isFixedOrientation(candidateOrientation) && isUniversalResizeable()) {
            candidateOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
        }
        return mAppCompatController.getOrientationPolicy()
+19 −0
Original line number Diff line number Diff line
@@ -4881,6 +4881,25 @@ public class SizeCompatTests extends WindowTestsBase {
        assertNotEquals(SCREEN_ORIENTATION_UNSPECIFIED, mActivity.getOverrideOrientation());
    }


    @Test
    @EnableCompatChanges({ActivityRecord.UNIVERSAL_RESIZABLE_BY_DEFAULT})
    public void testUniversalResizeableByDefault() {
        mSetFlagsRule.enableFlags(Flags.FLAG_UNIVERSAL_RESIZABLE_BY_DEFAULT);
        mDisplayContent.setIgnoreOrientationRequest(false);
        setUpApp(mDisplayContent);
        assertFalse(mActivity.isUniversalResizeable());

        mDisplayContent.setIgnoreOrientationRequest(true);
        final int swDp = mDisplayContent.getConfiguration().smallestScreenWidthDp;
        if (swDp < WindowManager.LARGE_SCREEN_SMALLEST_SCREEN_WIDTH_DP) {
            final int height = 100 + (int) (mDisplayContent.getDisplayMetrics().density
                    * WindowManager.LARGE_SCREEN_SMALLEST_SCREEN_WIDTH_DP);
            resizeDisplay(mDisplayContent, 100 + height, height);
        }
        assertTrue(mActivity.isUniversalResizeable());
    }

    @Test
    public void testClearSizeCompat_resetOverrideConfig() {
        final int origDensity = 480;