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

Commit 96b60fbc authored by Jeremy Sim's avatar Jeremy Sim Committed by Android (Google) Code Review
Browse files

Merge "Add a set of top insets when hiding status bar in 10:90 and 90:10" into main

parents cf894ee5 0a8407f4
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -712,6 +712,9 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
        if (!mInitialized) {
            return;
        }

        mStatusBarHider.onInsetsChanged(insetsState, mRootBounds);

        if (mFreezeDividerWindow) {
            // DO NOT change its layout before transition actually run because it might cause
            // flicker.
+26 −4
Original line number Diff line number Diff line
@@ -16,8 +16,13 @@

package com.android.wm.shell.splitscreen

import android.graphics.Insets
import android.graphics.Rect
import android.os.Binder
import android.view.Display.DEFAULT_DISPLAY
import android.view.InsetsSource.FLAG_FORCE_CONSUMING
import android.view.InsetsState
import android.view.WindowInsets.Type.captionBar
import android.view.WindowInsets.Type.navigationBars
import android.view.WindowInsets.Type.statusBars
import android.window.WindowContainerToken
@@ -63,13 +68,17 @@ class SplitStatusBarHider(
     * immersive mode or not
     */
    private var statusBarImmersiveForSplit = false
    /**
     * The height of the status bar, in pixels, in the current configuration.
     */
    private var statusBarHeight = 0

    private lateinit var displayToken: WindowContainerToken
    private val splitStateListener: SplitState.SplitStateChangeListener =
        SplitState.SplitStateChangeListener {
            updateStatusBarBehavior(it, isLeftRightSplit, isSplitVisible)
        }
    private val systemBarVisibilityOverrideCaller = Binder()
    private val systemBarOwner = Binder()

    init {
        if (enableFlexibleTwoAppSplit()) {
@@ -93,6 +102,12 @@ class SplitStatusBarHider(
        updateStatusBarBehavior(currentSplitState, leftRightSplit, isSplitVisible)
    }

    fun onInsetsChanged(insetsState: InsetsState, rootBounds: Rect) {
        // Check the height of the status bar inset and store it.
        statusBarHeight =
            insetsState.calculateInsets(rootBounds, rootBounds, statusBars(), true).top
    }

    fun isStatusBarImmersive(): Boolean = statusBarImmersiveForSplit
    /**
     * Determines if we want to put the status bar in immersive mode or not based on
@@ -148,13 +163,20 @@ class SplitStatusBarHider(
    private fun setStatusBarVisibilityOverride(forceImmersive: Boolean) {
        val wct = WindowContainerTransaction()
        if (forceImmersive) {
            // Add a "replacement" inset for the status bar that is being hidden. This ensures that
            // apps lay out their contents in 90:10 in the same way as they do in 70:30, even though
            // we are hiding the status bar in 90:10.
            val flags = FLAG_FORCE_CONSUMING
            wct.addInsetsSource(displayToken, systemBarOwner, 0, captionBar(),
                Insets.of(0, statusBarHeight, 0, 0), null, flags)
            wct.setSystemBarVisibilityOverride(displayToken,
                systemBarVisibilityOverrideCaller,
                navigationBars() /*forciblyShowingTypes*/,
                systemBarOwner,
                navigationBars() or captionBar() /*forciblyShowingTypes*/,
                statusBars() /*forciblyHidingTypes*/)
        } else {
            wct.removeInsetsSource(displayToken, systemBarOwner, 0, captionBar())
            wct.setSystemBarVisibilityOverride(displayToken,
                systemBarVisibilityOverrideCaller,
                systemBarOwner,
                0 /*forciblyShowingTypes*/,
                0 /*forciblyHidingTypes*/)
        }