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

Commit aa76a53b authored by Eghosa Ewansiha-Vlachavas's avatar Eghosa Ewansiha-Vlachavas
Browse files

Make user aspect ratio fullscreen override public and introduce proto for CTS

Bug: 294227289
Test: atest CtsWindowManagerDeviceDisplay:CompatChangeTests
Change-Id: I9ef1ee8f907eae0aaa4a6f2df926f3b1dd072b22
parent f2eddf2f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -53959,6 +53959,7 @@ package android.view {
    field public static final String PROPERTY_COMPAT_ALLOW_ORIENTATION_OVERRIDE = "android.window.PROPERTY_COMPAT_ALLOW_ORIENTATION_OVERRIDE";
    field @FlaggedApi("com.android.window.flags.app_compat_properties_api") public static final String PROPERTY_COMPAT_ALLOW_RESIZEABLE_ACTIVITY_OVERRIDES = "android.window.PROPERTY_COMPAT_ALLOW_RESIZEABLE_ACTIVITY_OVERRIDES";
    field public static final String PROPERTY_COMPAT_ALLOW_SANDBOXING_VIEW_BOUNDS_APIS = "android.window.PROPERTY_COMPAT_ALLOW_SANDBOXING_VIEW_BOUNDS_APIS";
    field @FlaggedApi("com.android.window.flags.app_compat_properties_api") public static final String PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE = "android.window.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE";
    field @FlaggedApi("com.android.window.flags.app_compat_properties_api") public static final String PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE = "android.window.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE";
    field public static final String PROPERTY_COMPAT_ENABLE_FAKE_FOCUS = "android.window.PROPERTY_COMPAT_ENABLE_FAKE_FOCUS";
    field public static final String PROPERTY_COMPAT_IGNORE_REQUESTED_ORIENTATION = "android.window.PROPERTY_COMPAT_IGNORE_REQUESTED_ORIENTATION";
+4 −3
Original line number Diff line number Diff line
@@ -1331,7 +1331,9 @@ public interface WindowManager extends ViewManager {
     * <p>When users apply the aspect ratio override, the minimum aspect ratio
     * specified in the app manifest is overridden. If users choose a
     * full-screen aspect ratio, the orientation of the activity is forced to
     * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_USER}.
     * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_USER};
     * see {@link #PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE} to
     * disable the full-screen option only.
     *
     * <p>The user override is intended to improve the app experience on devices
     * that have the ignore orientation request display setting enabled by OEMs
@@ -1399,9 +1401,8 @@ public interface WindowManager extends ViewManager {
     *     android:value="false"/&gt;
     * &lt;/application&gt;
     * </pre>
     * @hide
     */
    // TODO(b/294227289): Make this public API
    @FlaggedApi(Flags.FLAG_APP_COMPAT_PROPERTIES_API)
    String PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE =
            "android.window.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE";

+1 −0
Original line number Diff line number Diff line
@@ -398,6 +398,7 @@ message ActivityRecordProto {
    optional bool should_ignore_orientation_request_loop = 43;
    optional bool should_override_force_resize_app = 44;
    optional bool should_enable_user_aspect_ratio_settings = 45;
    optional bool is_user_fullscreen_override_enabled = 46;
}

/* represents WindowToken */
+3 −0
Original line number Diff line number Diff line
@@ -168,6 +168,7 @@ import static com.android.server.wm.ActivityRecordProto.FILLS_PARENT;
import static com.android.server.wm.ActivityRecordProto.FRONT_OF_TASK;
import static com.android.server.wm.ActivityRecordProto.IN_SIZE_COMPAT_MODE;
import static com.android.server.wm.ActivityRecordProto.IS_ANIMATING;
import static com.android.server.wm.ActivityRecordProto.IS_USER_FULLSCREEN_OVERRIDE_ENABLED;
import static com.android.server.wm.ActivityRecordProto.IS_WAITING_FOR_TRANSITION_START;
import static com.android.server.wm.ActivityRecordProto.LAST_ALL_DRAWN;
import static com.android.server.wm.ActivityRecordProto.LAST_DROP_INPUT_MODE;
@@ -10366,6 +10367,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                mLetterboxUiController.shouldOverrideForceResizeApp());
        proto.write(SHOULD_ENABLE_USER_ASPECT_RATIO_SETTINGS,
                mLetterboxUiController.shouldEnableUserAspectRatioSettings());
        proto.write(IS_USER_FULLSCREEN_OVERRIDE_ENABLED,
                mLetterboxUiController.isUserFullscreenOverrideEnabled());
    }

    @Override
+10 −3
Original line number Diff line number Diff line
@@ -1189,18 +1189,25 @@ final class LetterboxUiController {
                && mUserAspectRatio != USER_MIN_ASPECT_RATIO_FULLSCREEN;
    }

    boolean shouldApplyUserFullscreenOverride() {
    boolean isUserFullscreenOverrideEnabled() {
        if (FALSE.equals(mBooleanPropertyAllowUserAspectRatioOverride)
                || FALSE.equals(mBooleanPropertyAllowUserAspectRatioFullscreenOverride)
                || !mLetterboxConfiguration.isUserAppAspectRatioFullscreenEnabled()) {
            return false;
        }
        return true;
    }

    boolean shouldApplyUserFullscreenOverride() {
        if (isUserFullscreenOverrideEnabled()) {
            mUserAspectRatio = getUserMinAspectRatioOverrideCode();

            return mUserAspectRatio == USER_MIN_ASPECT_RATIO_FULLSCREEN;
        }

        return false;
    }

    float getUserMinAspectRatio() {
        switch (mUserAspectRatio) {
            case USER_MIN_ASPECT_RATIO_DISPLAY_SIZE: