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

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

Fix aspect ratio for letterboxed activity in `LetterboxAppHelper`

Set the non-resizeable portrait activity used by the
`LetterboxAppHelper` to have a min aspect ratio to ensure the activity
is always letterboxed in all orientations.

Flag: NONE(bug fix)
Fixes: 371124043
Test: atest WMShellFlickerTestsAppCompat:QuickSwitchLauncherToLetterboxAppTest
Change-Id: Id84a4b94fc8c66ab48d0e0d274b559298f7fe838
parent 1505c5ce
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.graphics.Rect
import android.platform.test.annotations.Postsubmit
import android.platform.test.annotations.RequiresDevice
import android.tools.NavBar
import android.tools.Rotation
import android.tools.flicker.assertions.FlickerTest
import android.tools.flicker.junit.FlickerParametersRunnerFactory
import android.tools.flicker.legacy.FlickerBuilder
@@ -266,8 +265,7 @@ class QuickSwitchLauncherToLetterboxAppTest(flicker: LegacyFlickerTest) : BaseAp
        @JvmStatic
        fun getParams(): Collection<FlickerTest> {
            return LegacyFlickerTestFactory.nonRotationTests(
                supportedNavigationModes = listOf(NavBar.MODE_GESTURAL),
                supportedRotations = listOf(Rotation.ROTATION_90)
                supportedNavigationModes = listOf(NavBar.MODE_GESTURAL)
            )
        }
    }
+2 −2
Original line number Diff line number Diff line
@@ -33,9 +33,9 @@ class LetterboxAppHelper
@JvmOverloads
constructor(
    instr: Instrumentation,
    launcherName: String = ActivityOptions.NonResizeablePortraitActivity.LABEL,
    launcherName: String = ActivityOptions.NonResizeableFixedAspectRatioPortraitActivity.LABEL,
    component: ComponentNameMatcher =
        ActivityOptions.NonResizeablePortraitActivity.COMPONENT.toFlickerComponent()
        ActivityOptions.NonResizeableFixedAspectRatioPortraitActivity.COMPONENT.toFlickerComponent()
) : StandardAppHelper(instr, launcherName, component) {

    private val gestureHelper: GestureHelper = GestureHelper(instrumentation)
+13 −0
Original line number Diff line number Diff line
@@ -115,6 +115,19 @@
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:name=".NonResizeableFixedAspectRatioPortraitActivity"
            android:theme="@style/CutoutNever"
            android:resizeableActivity="false"
            android:screenOrientation="portrait"
            android:minAspectRatio="1.77"
            android:taskAffinity="com.android.server.wm.flicker.testapp.NonResizeableFixedAspectRatioPortraitActivity"
            android:label="NonResizeableFixedAspectRatioPortraitActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:name=".StartMediaProjectionActivity"
            android:theme="@style/CutoutNever"
            android:resizeableActivity="false"
+6 −0
Original line number Diff line number Diff line
@@ -85,6 +85,12 @@ public class ActivityOptions {
                FLICKER_APP_PACKAGE + ".NonResizeablePortraitActivity");
    }

    public static class NonResizeableFixedAspectRatioPortraitActivity {
        public static final String LABEL = "NonResizeableFixedAspectRatioPortraitActivity";
        public static final ComponentName COMPONENT = new ComponentName(FLICKER_APP_PACKAGE,
                FLICKER_APP_PACKAGE + ".NonResizeableFixedAspectRatioPortraitActivity");
    }

    public static class StartMediaProjectionActivity {
        public static final String LABEL = "StartMediaProjectionActivity";
        public static final ComponentName COMPONENT = new ComponentName(FLICKER_APP_PACKAGE,
+28 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.wm.flicker.testapp;

import android.app.Activity;
import android.os.Bundle;

public class NonResizeableFixedAspectRatioPortraitActivity extends Activity {
    @Override
    protected void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.activity_non_resizeable);
    }
}