diff options
| author | 2023-04-04 16:20:01 +0200 | |
|---|---|---|
| committer | 2023-04-05 13:23:25 +0000 | |
| commit | 66d35542299ddfdbb4ab30b54f318c023652e94a (patch) | |
| tree | d38a2e0e692c837726575ce91176d263f58ce4de | |
| parent | e3cbc371888c0710067e10fe7ea280ad3adf9d9d (diff) | |
Fix media showing AOD in split shade and double-line clock disabled
For split shade, media is not automatically hidden when going to AOD.
When using the double line clock, this is not an issue, as the clock
container takes the whole size of the keyguard status container, hiding
also media.
For single line clock, the clock container uses less space, making media
visible.
In single shade, media is part of the NSSL container, which already gets
hidden during AOD, also hiding media.
Test: KeyguardMediaControllerTest.kt
Test: Manually - Single shade, and split shade, with
the double line clock setting enabled and disabled,
while media is showing. Then going from/to AOD.
Fixes: 276682118
Change-Id: Ie2f4ac3aab4bcdb69f33c57292ff0c9a073bbcae
2 files changed, 57 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/KeyguardMediaController.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/KeyguardMediaController.kt index 8f1c9048026f..30ee147e302a 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/KeyguardMediaController.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/KeyguardMediaController.kt @@ -63,6 +63,10 @@ constructor( override fun onStateChanged(newState: Int) { refreshMediaPosition() } + + override fun onDozingChanged(isDozing: Boolean) { + refreshMediaPosition() + } } ) configurationController.addCallback( @@ -198,7 +202,8 @@ constructor( mediaHost.visible && !bypassController.bypassEnabled && keyguardOrUserSwitcher && - allowMediaPlayerOnLockScreen + allowMediaPlayerOnLockScreen && + shouldBeVisibleForSplitShade() if (visible) { showMediaPlayer() } else { @@ -206,6 +211,19 @@ constructor( } } + private fun shouldBeVisibleForSplitShade(): Boolean { + if (!useSplitShade) { + return true + } + // We have to explicitly hide media for split shade when on AOD, as it is a child view of + // keyguard status view, and nothing hides keyguard status view on AOD. + // When using the double-line clock, it is not an issue, as media gets implicitly hidden + // by the clock. This is not the case for single-line clock though. + // For single shade, we don't need to do it, because media is a child of NSSL, which already + // gets hidden on AOD. + return !statusBarStateController.isDozing + } + private fun showMediaPlayer() { if (useSplitShade) { setVisibility(splitShadeContainer, View.VISIBLE) diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/KeyguardMediaControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/KeyguardMediaControllerTest.kt index 20260069c943..b40ebc9bb156 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/KeyguardMediaControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/KeyguardMediaControllerTest.kt @@ -24,12 +24,14 @@ import android.view.View.GONE import android.view.View.VISIBLE import android.widget.FrameLayout import com.android.systemui.SysuiTestCase +import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.statusbar.StatusBarState import com.android.systemui.statusbar.SysuiStatusBarStateController import com.android.systemui.statusbar.notification.stack.MediaContainerView import com.android.systemui.statusbar.phone.KeyguardBypassController import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.util.animation.UniqueObjectHostView +import com.android.systemui.util.mockito.whenever import com.android.systemui.util.settings.FakeSettings import com.android.systemui.utils.os.FakeHandler import com.google.common.truth.Truth.assertThat @@ -39,8 +41,9 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock +import org.mockito.Mockito.any +import org.mockito.Mockito.doAnswer import org.mockito.Mockito.verify -import org.mockito.Mockito.`when` as whenever import org.mockito.junit.MockitoJUnit @SmallTest @@ -61,9 +64,16 @@ class KeyguardMediaControllerTest : SysuiTestCase() { private lateinit var keyguardMediaController: KeyguardMediaController private lateinit var testableLooper: TestableLooper private lateinit var fakeHandler: FakeHandler + private lateinit var statusBarStateListener: StatusBarStateController.StateListener @Before fun setup() { + doAnswer { + statusBarStateListener = it.arguments[0] as StatusBarStateController.StateListener + return@doAnswer Unit + } + .whenever(statusBarStateController) + .addCallback(any(StatusBarStateController.StateListener::class.java)) // default state is positive, media should show up whenever(mediaHost.visible).thenReturn(true) whenever(statusBarStateController.state).thenReturn(StatusBarState.KEYGUARD) @@ -170,4 +180,31 @@ class KeyguardMediaControllerTest : SysuiTestCase() { fun testMediaHost_expandedPlayer() { verify(mediaHost).expansion = MediaHostState.EXPANDED } + + @Test + fun dozing_inSplitShade_mediaIsHidden() { + val splitShadeContainer = FrameLayout(context) + keyguardMediaController.attachSplitShadeContainer(splitShadeContainer) + keyguardMediaController.useSplitShade = true + + setDozing() + + assertThat(splitShadeContainer.visibility).isEqualTo(GONE) + } + + @Test + fun dozing_inSingleShade_mediaIsVisible() { + val splitShadeContainer = FrameLayout(context) + keyguardMediaController.attachSplitShadeContainer(splitShadeContainer) + keyguardMediaController.useSplitShade = false + + setDozing() + + assertThat(mediaContainerView.visibility).isEqualTo(VISIBLE) + } + + private fun setDozing() { + whenever(statusBarStateController.isDozing).thenReturn(true) + statusBarStateListener.onDozingChanged(true) + } } |