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

Commit 176ad444 authored by Mariia Sandrikova's avatar Mariia Sandrikova
Browse files

Don't show letterbox UI for apps that show wallpaper.

Also, integrate hasWallpaper in mOccludesParent and occludesParent() in ActivityRecord.

Fix: 181976470
Test: manual + atest SizeCompatTests + adb shell dumpsys activity top-resumed
Change-Id: Ibc8423910223e8c4abd3641a36793477405d04a5
parent 592bdb62
Loading
Loading
Loading
Loading
+27 −16
Original line number Diff line number Diff line
@@ -436,10 +436,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;

@@ -1099,19 +1095,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()));
    }

    /**
@@ -1502,9 +1504,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) {
@@ -1694,11 +1704,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;
        }

@@ -2493,7 +2504,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;
@@ -323,6 +325,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)