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

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

Merge "Enable universal resizeable for new sdk on large screen" into main

parents 753526f1 a8b2c78a
Loading
Loading
Loading
Loading
+23 −6
Original line number Diff line number Diff line
@@ -287,6 +287,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;
@@ -466,6 +469,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
@@ -3182,10 +3190,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();
    }

@@ -8182,7 +8199,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;