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

Commit b4784e8e authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[SB] Don't call SBWindowController#refreshSBHeight from PhoneSBView.

The `#refreshStatusBarHeight` call was added to address b/323299264,
but if I remove the call, I'm still unable to repro b/323299264. My
hunch is that b/323299264 was fixed by a revert in some other part of
the codebase, so the `#refreshStatusBarHeight` call is unnecessary.
But, I'm protecting the removal of that method call behind a flag so
that we can verify this hunch in stages before sending it to everyone.

Bug: 360115167
Flag: com.android.systemui.status_bar_stop_updating_window_height
Test: On unfolded, start in portrait, then rotate clockwise to 90deg,
then rotate clockwise to 270deg -> verify status bar does not get cut
off
Test: atest PhoneStatusBarViewTest

Change-Id: I85b2f4db944232e3fc5aeedbb8268ea41735af79
parent 1f2d77f1
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -386,6 +386,17 @@ flag {
    }
}

flag {
    name: "status_bar_stop_updating_window_height"
    namespace: "systemui"
    description: "Don't have PhoneStatusBarView manually trigger an update of the height in "
        "StatusBarWindowController"
    bug: "360115167"
    metadata {
      purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "compose_bouncer"
    namespace: "systemui"
+3 −0
Original line number Diff line number Diff line
@@ -321,6 +321,9 @@ public class PhoneStatusBarView extends FrameLayout {
    }

    private void updateWindowHeight() {
        if (Flags.statusBarStopUpdatingWindowHeight()) {
            return;
        }
        mStatusBarWindowController.refreshStatusBarHeight();
    }

+35 −3
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.view.View
import android.view.WindowInsets
import android.widget.FrameLayout
import androidx.test.filters.SmallTest
import com.android.systemui.Flags.FLAG_STATUS_BAR_STOP_UPDATING_WINDOW_HEIGHT
import com.android.systemui.Flags.FLAG_STATUS_BAR_SWIPE_OVER_CHIP
import com.android.systemui.Gefingerpoken
import com.android.systemui.SysuiTestCase
@@ -42,6 +43,7 @@ import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Test
import org.mockito.Mockito.never
import org.mockito.Mockito.spy
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
@@ -176,21 +178,40 @@ class PhoneStatusBarViewTest : SysuiTestCase() {
    }

    @Test
    fun onAttachedToWindow_updatesWindowHeight() {
    @DisableFlags(FLAG_STATUS_BAR_STOP_UPDATING_WINDOW_HEIGHT)
    fun onAttachedToWindow_flagOff_updatesWindowHeight() {
        view.onAttachedToWindow()

        verify(windowController).refreshStatusBarHeight()
    }

    @Test
    fun onConfigurationChanged_updatesWindowHeight() {
    @EnableFlags(FLAG_STATUS_BAR_STOP_UPDATING_WINDOW_HEIGHT)
    fun onAttachedToWindow_flagOn_doesNotUpdateWindowHeight() {
        view.onAttachedToWindow()

        verify(windowController, never()).refreshStatusBarHeight()
    }

    @Test
    @DisableFlags(FLAG_STATUS_BAR_STOP_UPDATING_WINDOW_HEIGHT)
    fun onConfigurationChanged_flagOff_updatesWindowHeight() {
        view.onConfigurationChanged(Configuration())

        verify(windowController).refreshStatusBarHeight()
    }

    @Test
    fun onConfigurationChanged_multipleCalls_updatesWindowHeightMultipleTimes() {
    @EnableFlags(FLAG_STATUS_BAR_STOP_UPDATING_WINDOW_HEIGHT)
    fun onConfigurationChanged_flagOn_doesNotUpdateWindowHeight() {
        view.onConfigurationChanged(Configuration())

        verify(windowController, never()).refreshStatusBarHeight()
    }

    @Test
    @DisableFlags(FLAG_STATUS_BAR_STOP_UPDATING_WINDOW_HEIGHT)
    fun onConfigurationChanged_multipleCalls_flagOff_updatesWindowHeightMultipleTimes() {
        view.onConfigurationChanged(Configuration())
        view.onConfigurationChanged(Configuration())
        view.onConfigurationChanged(Configuration())
@@ -199,6 +220,17 @@ class PhoneStatusBarViewTest : SysuiTestCase() {
        verify(windowController, times(4)).refreshStatusBarHeight()
    }

    @Test
    @EnableFlags(FLAG_STATUS_BAR_STOP_UPDATING_WINDOW_HEIGHT)
    fun onConfigurationChanged_multipleCalls_flagOn_neverUpdatesWindowHeight() {
        view.onConfigurationChanged(Configuration())
        view.onConfigurationChanged(Configuration())
        view.onConfigurationChanged(Configuration())
        view.onConfigurationChanged(Configuration())

        verify(windowController, never()).refreshStatusBarHeight()
    }

    @Test
    fun onAttachedToWindow_updatesLeftTopRightPaddingsBasedOnInsets() {
        val insets = Insets.of(/* left= */ 10, /* top= */ 20, /* right= */ 30, /* bottom= */ 40)