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

Commit 1100dafc authored by Mariia Sandrikova's avatar Mariia Sandrikova Committed by Automerger Merge Worker
Browse files

Merge "Don't show letterbox UI for apps that show wallpaper." into sc-dev am: d299c8c0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13855026

Change-Id: Ief9a6e974ccd6850ead7d01383ddea3aa91982b9
parents 567e3ca6 d299c8c0
Loading
Loading
Loading
Loading
+27 −16
Original line number Diff line number Diff line
@@ -438,10 +438,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    final String packageName;
    // the intent component, or target of an alias.
    final ComponentName mActivityComponent;
    // Has a wallpaper window as a background.
    // TODO: Rename to mHasWallpaper and also see if it possible to combine this with the
    // mOccludesParent field.
    final boolean hasWallpaper;
    // Input application handle used by the input dispatcher.
    private InputApplicationHandle mInputApplicationHandle;

@@ -1104,19 +1100,25 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            return;
        }

        boolean isLetterboxed = isLetterboxed(mainWin);
        pw.println(prefix + "isLetterboxed=" + isLetterboxed);
        if (!isLetterboxed) {
        boolean areBoundsLetterboxed = mainWin.isLetterboxedAppWindow();
        pw.println(prefix + "areBoundsLetterboxed=" + areBoundsLetterboxed);
        if (!areBoundsLetterboxed) {
            return;
        }

        pw.println(prefix + "  letterboxReason=" + getLetterboxReasonString(mainWin));
        pw.println(prefix + "  letterboxAspectRatio=" + computeAspectRatio(getBounds()));

        boolean isLetterboxUiShown = isLetterboxed(mainWin);
        pw.println(prefix + "isLetterboxUiShown=" + isLetterboxUiShown);

        if (!isLetterboxUiShown) {
            return;
        }
        pw.println(prefix + "  letterboxBackgroundColor=" + Integer.toHexString(
                getLetterboxBackgroundColor().toArgb()));
        pw.println(prefix + "  letterboxBackgroundType="
                + letterboxBackgroundTypeToString(mWmService.getLetterboxBackgroundType()));
        pw.println(prefix + "  letterboxAspectRatio="
                + computeAspectRatio(getBounds()));
    }

    /**
@@ -1463,9 +1465,17 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                "Unexpected letterbox background type: " + letterboxBackgroundType);
    }

    /** @return {@code true} when main window is letterboxed and activity isn't transparent. */
    private boolean isLetterboxed(WindowState mainWindow) {
        return mainWindow.isLetterboxedAppWindow() && fillsParent();
    /**
     * @return {@code true} when the main window is letterboxed, this activity isn't transparent
     * and doesn't show a wallpaper.
     */
    @VisibleForTesting
    boolean isLetterboxed(WindowState mainWindow) {
        return mainWindow.isLetterboxedAppWindow() && fillsParent()
                // Check for FLAG_SHOW_WALLPAPER explicitly instead of using
                // WindowContainer#showWallpaper because the later will return true when this
                // activity is using blurred wallpaper for letterbox backgroud.
                && (mainWindow.mAttrs.flags & FLAG_SHOW_WALLPAPER) == 0;
    }

    private void updateRoundedCorners(WindowState mainWindow) {
@@ -1655,11 +1665,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                realTheme, com.android.internal.R.styleable.Window, mUserId);

        if (ent != null) {
            mOccludesParent = !ActivityInfo.isTranslucentOrFloating(ent.array);
            hasWallpaper = ent.array.getBoolean(R.styleable.Window_windowShowWallpaper, false);
            mOccludesParent = !ActivityInfo.isTranslucentOrFloating(ent.array)
                    // This style is propagated to the main window attributes with
                    // FLAG_SHOW_WALLPAPER from PhoneWindow#generateLayout.
                    || ent.array.getBoolean(R.styleable.Window_windowShowWallpaper, false);
            noDisplay = ent.array.getBoolean(R.styleable.Window_windowNoDisplay, false);
        } else {
            hasWallpaper = false;
            noDisplay = false;
        }

@@ -2468,7 +2479,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (!includingFinishing && finishing) {
            return false;
        }
        return mOccludesParent;
        return mOccludesParent || showWallpaper();
    }

    boolean setOccludesParent(boolean occludesParent) {
+1 −1
Original line number Diff line number Diff line
@@ -3595,7 +3595,7 @@ class Task extends WindowContainer<WindowContainer> {
            return false;
        }

        if (r.occludesParent() || r.hasWallpaper) {
        if (r.occludesParent()) {
            // Root task isn't translucent if it has at least one fullscreen activity
            // that is visible.
            return true;
+18 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static android.view.Surface.ROTATION_180;
import static android.view.Surface.ROTATION_270;
import static android.view.Surface.ROTATION_90;
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing;
@@ -324,6 +326,22 @@ public class SizeCompatTests extends WindowTestsBase {
        assertActivityMaxBoundsSandboxed();
    }

    @Test
    public void testIsLetterboxed_activityShowsWallpaper_returnsFalse() {
        setUpDisplaySizeWithApp(1000, 2500);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);

        prepareUnresizable(mActivity, SCREEN_ORIENTATION_LANDSCAPE);
        final WindowState window = createWindow(null, TYPE_BASE_APPLICATION, mActivity, "window");

        assertEquals(window, mActivity.findMainWindow());
        assertTrue(mActivity.isLetterboxed(mActivity.findMainWindow()));

        window.mAttrs.flags |= FLAG_SHOW_WALLPAPER;

        assertFalse(mActivity.isLetterboxed(mActivity.findMainWindow()));
    }

    @Test
    public void testAspectRatioMatchParentBoundsAndImeAttachable() {
        setUpApp(new TestDisplayContent.Builder(mAtm, 1000, 2000)