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

Commit 14218125 authored by Kazuki Takise's avatar Kazuki Takise
Browse files

Make presentation immersive

The main intention of this change is to ensure that all system bars
are hidden while the display is presenting. To achive this, this
change has two changes:

(i) Call WindowInsetsController#hide() in Presentation#show()
  We decided to apply this unanimously to all presentations.

(ii) Give presentation per-display focus when shown
  At least per-display focus is needed so that presentation windows
  can control system bar visibility. The easiest way to achive this
  would be to move the display to top and give global focus when
  a presentation gets shown, but unfortunately a presentation
  shouldn't steal global focus from its activity when it gets
  shown on another display, so with this change, only update
  per-display focus by triggering findFocusedWindow() when a
  presentation gets shown on a display.

Flag: com.android.window.flags.enable_presentation_for_connected_displays
Bug: 390481142
Test: atest PresentationTest

Change-Id: I90860f72363ef285f49674262d1c9a868c45f8e7
parent badfb594
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,8 @@ import static android.view.WindowManager.LayoutParams.INVALID_WINDOW_TYPE;
import static android.view.WindowManager.LayoutParams.TYPE_PRESENTATION;
import static android.view.WindowManager.LayoutParams.TYPE_PRESENTATION;
import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION;
import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION;


import static com.android.window.flags.Flags.enablePresentationForConnectedDisplays;

import android.annotation.NonNull;
import android.annotation.NonNull;
import android.compat.annotation.UnsupportedAppUsage;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.Context;
@@ -34,6 +36,8 @@ import android.view.ContextThemeWrapper;
import android.view.Display;
import android.view.Display;
import android.view.Gravity;
import android.view.Gravity;
import android.view.Window;
import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowInsetsController;
import android.view.WindowManager;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams.WindowType;
import android.view.WindowManager.LayoutParams.WindowType;


@@ -277,6 +281,11 @@ public class Presentation extends Dialog {
    @Override
    @Override
    public void show() {
    public void show() {
        super.show();
        super.show();

        WindowInsetsController controller = getWindow().getInsetsController();
        if (controller != null && enablePresentationForConnectedDisplays()) {
            controller.hide(WindowInsets.Type.systemBars());
        }
    }
    }


    /**
    /**
+8 −2
Original line number Original line Diff line number Diff line
@@ -157,6 +157,7 @@ import static com.android.server.wm.utils.DisplayInfoOverrides.copyDisplayInfoFi
import static com.android.server.wm.utils.RegionUtils.forEachRectReverse;
import static com.android.server.wm.utils.RegionUtils.forEachRectReverse;
import static com.android.server.wm.utils.RegionUtils.rectListToRegion;
import static com.android.server.wm.utils.RegionUtils.rectListToRegion;
import static com.android.window.flags.Flags.enablePersistingDensityScaleForConnectedDisplays;
import static com.android.window.flags.Flags.enablePersistingDensityScaleForConnectedDisplays;
import static com.android.window.flags.Flags.enablePresentationForConnectedDisplays;


import android.annotation.IntDef;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.NonNull;
@@ -3835,13 +3836,18 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp


    /**
    /**
     * Looking for the focused window on this display if the top focused display hasn't been
     * Looking for the focused window on this display if the top focused display hasn't been
     * found yet (topFocusedDisplayId is INVALID_DISPLAY) or per-display focused was allowed.
     * found yet (topFocusedDisplayId is INVALID_DISPLAY), per-display focused was allowed, or
     * the display is presenting. The last one is needed to update system bar visibility in response
     * to presentation visibility because per-display focus is needed to change system bar
     * visibility, but the display shouldn't get global focus when a presentation gets shown.
     *
     *
     * @param topFocusedDisplayId Id of the top focused display.
     * @param topFocusedDisplayId Id of the top focused display.
     * @return The focused window or null if there isn't any or no need to seek.
     * @return The focused window or null if there isn't any or no need to seek.
     */
     */
    WindowState findFocusedWindowIfNeeded(int topFocusedDisplayId) {
    WindowState findFocusedWindowIfNeeded(int topFocusedDisplayId) {
        return (hasOwnFocus() || topFocusedDisplayId == INVALID_DISPLAY)
        return (hasOwnFocus() || topFocusedDisplayId == INVALID_DISPLAY
                || (enablePresentationForConnectedDisplays()
                && mWmService.mPresentationController.isPresentationVisible(mDisplayId)))
                    ? findFocusedWindow() : null;
                    ? findFocusedWindow() : null;
    }
    }


+1 −1
Original line number Original line Diff line number Diff line
@@ -80,7 +80,7 @@ class PresentationController implements DisplayManager.DisplayListener {
        return mPresentations.contains(displayId);
        return mPresentations.contains(displayId);
    }
    }


    private boolean isPresentationVisible(int displayId) {
    boolean isPresentationVisible(int displayId) {
        final Presentation presentation = mPresentations.get(displayId);
        final Presentation presentation = mPresentations.get(displayId);
        return presentation != null && presentation.mWin.mToken.isVisibleRequested();
        return presentation != null && presentation.mWin.mToken.isVisibleRequested();
    }
    }