Merge "Fix media showing AOD in split shade and double-line clock disabled" into tm-qpr-dev am: 383f8f1fa0
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22433071 Change-Id: I94755cddb8874df41532563b7d4c4f618f692aa0 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -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