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

Commit b11da57e authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Clean up thin letterboxing flag" into main

parents b387a941 c2552799
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
package: "com.android.window.flags"
container: "system"

flag {
  name: "disable_thin_letterboxing_policy"
  namespace: "large_screen_experiences_app_compat"
  description: "Whether reachability is disabled in case of thin letterboxing"
  bug: "341027847"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
  name: "allows_screen_size_decoupled_from_status_bar_and_cutout"
  namespace: "large_screen_experiences_app_compat"
+4 −12
Original line number Diff line number Diff line
@@ -35,8 +35,6 @@ import android.annotation.NonNull;
import android.content.res.Configuration;
import android.graphics.Rect;

import com.android.window.flags.Flags;

/**
 * Encapsulate overrides and configurations about app compat reachability.
 */
@@ -157,33 +155,27 @@ class AppCompatReachabilityOverrides {
    }

    /**
     * @return {@value true} if the vertical reachability should be allowed in case of
     * @return {@code true} if the vertical reachability should be allowed in case of
     * thin letterboxing.
     */
    boolean allowVerticalReachabilityForThinLetterbox() {
        if (!Flags.disableThinLetterboxingPolicy()) {
            return true;
        }
        // When the flag is enabled we allow vertical reachability only if the
        // app is not thin letterboxed vertically.
        return !isVerticalThinLetterboxed();
    }

    /**
     * @return {@value true} if the horizontal reachability should be enabled in case of
     * @return {@code true} if the horizontal reachability should be enabled in case of
     * thin letterboxing.
     */
    boolean allowHorizontalReachabilityForThinLetterbox() {
        if (!Flags.disableThinLetterboxingPolicy()) {
            return true;
        }
        // When the flag is enabled we allow horizontal reachability only if the
        // app is not thin pillarboxed.
        return !isHorizontalThinLetterboxed();
    }

    /**
     * @return {@value true} if the resulting app is letterboxed in a way defined as thin.
     * @return {@code true} if the resulting app is letterboxed in a way defined as thin.
     */
    boolean isVerticalThinLetterboxed() {
        final int thinHeight = mAppCompatConfiguration.getThinLetterboxHeightPx();
@@ -200,7 +192,7 @@ class AppCompatReachabilityOverrides {
    }

    /**
     * @return {@value true} if the resulting app is pillarboxed in a way defined as thin.
     * @return {@code true} if the resulting app is pillarboxed in a way defined as thin.
     */
    boolean isHorizontalThinLetterboxed() {
        final int thinWidth = mAppCompatConfiguration.getThinLetterboxWidthPx();
+1 −24
Original line number Diff line number Diff line
@@ -23,14 +23,10 @@ import static org.mockito.Mockito.spy;

import android.compat.testing.PlatformCompatChangeRule;
import android.graphics.Rect;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.annotations.Presubmit;

import androidx.annotation.NonNull;

import com.android.window.flags.Flags;

import junit.framework.Assert;

import org.junit.Rule;
@@ -125,8 +121,7 @@ public class AppCompatReachabilityOverridesTest extends WindowTestsBase {
    }

    @Test
    @EnableFlags(Flags.FLAG_DISABLE_THIN_LETTERBOXING_POLICY)
    public void testAllowReachabilityForThinLetterboxWithFlagEnabled() {
    public void testAllowReachabilityForThinLetterbox_disableForThinLetterboxing() {
        runTestScenario((robot) -> {
            robot.activity().createActivityWithComponent();

@@ -142,24 +137,6 @@ public class AppCompatReachabilityOverridesTest extends WindowTestsBase {
        });
    }

    @Test
    @DisableFlags(Flags.FLAG_DISABLE_THIN_LETTERBOXING_POLICY)
    public void testAllowReachabilityForThinLetterboxWithFlagDisabled() {
        runTestScenario((robot) -> {
            robot.activity().createActivityWithComponent();

            robot.configureIsVerticalThinLetterboxed(/* isThin */ true);
            robot.checkAllowVerticalReachabilityForThinLetterbox(/* expected */ true);
            robot.configureIsHorizontalThinLetterboxed(/* isThin */ true);
            robot.checkAllowHorizontalReachabilityForThinLetterbox(/* expected */ true);

            robot.configureIsVerticalThinLetterboxed(/* isThin */ false);
            robot.checkAllowVerticalReachabilityForThinLetterbox(/* expected */ true);
            robot.configureIsHorizontalThinLetterboxed(/* isThin */ false);
            robot.checkAllowHorizontalReachabilityForThinLetterbox(/* expected */ true);
        });
    }

    /**
     * Runs a test scenario providing a Robot.
     */