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
This commit is contained in:
committed by
Christian Göllner
parent
e3cbc37188
commit
66d3554229
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user