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

Commit 505f7c12 authored by Alex Stetson's avatar Alex Stetson Committed by Android (Google) Code Review
Browse files

Merge "Always report real top focused window to remote inset controller" into main

parents a1af138d 6a11f904
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -2586,12 +2586,14 @@ public class DisplayPolicy {
    }
    }


    void updateSystemBarAttributes() {
    void updateSystemBarAttributes() {
        // The focused window always needs to be sent to System UI regardless of filling
        // display when the remote insets controller is controlling system bars.
        final boolean isRemoteControlling = isRemoteInsetsControllerControllingSystemBars();
        // If there is no window focused, there will be nobody to handle the events
        // If there is no window focused, there will be nobody to handle the events
        // anyway, so just hang on in whatever state we're in until things settle down.
        // anyway, so just hang on in whatever state we're in until things settle down.
        WindowState winCandidate =
        WindowState winCandidate =
                mFocusedWindow != null && fillsDisplayWindowingMode(mFocusedWindow)
                mFocusedWindow != null && (isRemoteControlling || fillsDisplayWindowingMode(
                        ? mFocusedWindow
                        mFocusedWindow)) ? mFocusedWindow : mTopFullscreenOpaqueWindowState;
                        : mTopFullscreenOpaqueWindowState;


        // Immersive mode confirmation should never affect the system bar visibility, otherwise
        // Immersive mode confirmation should never affect the system bar visibility, otherwise
        // it will unhide the navigation bar and hide itself.
        // it will unhide the navigation bar and hide itself.
@@ -2601,7 +2603,7 @@ public class DisplayPolicy {
                // Let notification shade control the system bar visibility.
                // Let notification shade control the system bar visibility.
                winCandidate = mNotificationShade;
                winCandidate = mNotificationShade;
            } else if (mLastFocusedWindow != null && mLastFocusedWindow.canReceiveKeys()
            } else if (mLastFocusedWindow != null && mLastFocusedWindow.canReceiveKeys()
                    && fillsDisplayWindowingMode(mLastFocusedWindow)) {
                    && (isRemoteControlling || fillsDisplayWindowingMode(mLastFocusedWindow))) {
                // Immersive mode confirmation took the focus from mLastFocusedWindow which was
                // Immersive mode confirmation took the focus from mLastFocusedWindow which was
                // controlling the system bar visibility. Let it keep controlling the visibility.
                // controlling the system bar visibility. Let it keep controlling the visibility.
                winCandidate = mLastFocusedWindow;
                winCandidate = mLastFocusedWindow;
@@ -2611,7 +2613,8 @@ public class DisplayPolicy {
        }
        }
        if (winCandidate == null) {
        if (winCandidate == null) {
            final ActivityRecord focusedApp = mDisplayContent.mFocusedApp;
            final ActivityRecord focusedApp = mDisplayContent.mFocusedApp;
            if (focusedApp == null || fillsDisplayWindowingMode(focusedApp)) {
            if (focusedApp == null
                    || (isRemoteControlling || fillsDisplayWindowingMode(focusedApp))) {
                // Don't change the system UI controlling window when the new one is not ready.
                // Don't change the system UI controlling window when the new one is not ready.
                return;
                return;
            }
            }
+29 −0
Original line number Original line Diff line number Diff line
@@ -40,16 +40,22 @@ import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verify;


import android.app.StatusBarManager;
import android.app.StatusBarManager;
import android.content.ComponentName;
import android.graphics.Insets;
import android.graphics.Insets;
import android.graphics.Rect;
import android.graphics.Rect;
import android.os.Binder;
import android.os.Binder;
import android.os.RemoteException;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.annotations.Presubmit;
import android.platform.test.annotations.Presubmit;
import android.view.IDisplayWindowInsetsController;
import android.view.InsetsFrameProvider;
import android.view.InsetsFrameProvider;
import android.view.InsetsSource;
import android.view.InsetsSource;
import android.view.InsetsSourceControl;
import android.view.InsetsSourceControl;
@@ -172,6 +178,29 @@ public class InsetsPolicyTest extends WindowTestsBase {
        assertNull(controls);
        assertNull(controls);
    }
    }


    @Test
    public void testControlsForDispatch_nonFullscreenMultiWindowTaskVisible_remoteInsetControl()
            throws RemoteException {
        addStatusBar();
        addNavigationBar();
        final IDisplayWindowInsetsController insetsController = spy(
                createDisplayWindowInsetsController());
        mDisplayContent.setRemoteInsetsController(insetsController);
        mDisplayContent.getDisplayPolicy().setRemoteInsetsControllerControlsSystemBars(true);

        final WindowState win = newWindowBuilder("app", TYPE_APPLICATION).setActivityType(
                ACTIVITY_TYPE_STANDARD).setWindowingMode(WINDOWING_MODE_MULTI_WINDOW).setDisplay(
                mDisplayContent).build();
        final ComponentName component = win.mActivityRecord.mActivityComponent;
        assertNotNull(component);
        win.getTask().setBounds(new Rect(1, 1, 10, 10));
        final InsetsSourceControl[] controls = addWindowAndGetControlsForDispatch(win);

        // The remote insets controller should control the system bars.
        assertNull(controls);
        verify(insetsController).topFocusedWindowChanged(eq(component), anyInt());
    }

    @Test
    @Test
    public void testControlsForDispatch_forceStatusBarVisible() {
    public void testControlsForDispatch_forceStatusBarVisible() {
        addStatusBar().mAttrs.forciblyShownTypes |= statusBars();
        addStatusBar().mAttrs.forciblyShownTypes |= statusBars();