Merge "Check ongoing flag for media control dismissal" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f5fb9c6346
@@ -863,7 +863,7 @@ class MediaDataManager(
|
|||||||
notificationKey = key,
|
notificationKey = key,
|
||||||
hasCheckedForResume = hasCheckedForResume,
|
hasCheckedForResume = hasCheckedForResume,
|
||||||
isPlaying = isPlaying,
|
isPlaying = isPlaying,
|
||||||
isClearable = sbn.isClearable(),
|
isClearable = !sbn.isOngoing,
|
||||||
lastActive = lastActive,
|
lastActive = lastActive,
|
||||||
instanceId = instanceId,
|
instanceId = instanceId,
|
||||||
appUid = appUid,
|
appUid = appUid,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.android.systemui.media.controls.pipeline
|
package com.android.systemui.media.controls.pipeline
|
||||||
|
|
||||||
import android.app.Notification
|
import android.app.Notification
|
||||||
|
import android.app.Notification.FLAG_NO_CLEAR
|
||||||
import android.app.Notification.MediaStyle
|
import android.app.Notification.MediaStyle
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.app.smartspace.SmartspaceAction
|
import android.app.smartspace.SmartspaceAction
|
||||||
@@ -1451,6 +1452,39 @@ class MediaDataManagerTest : SysuiTestCase() {
|
|||||||
assertThat(mediaDataCaptor.value.semanticActions).isNull()
|
assertThat(mediaDataCaptor.value.semanticActions).isNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testNoClearNotOngoing_canDismiss() {
|
||||||
|
mediaNotification =
|
||||||
|
SbnBuilder().run {
|
||||||
|
setPkg(PACKAGE_NAME)
|
||||||
|
modifyNotification(context).also {
|
||||||
|
it.setSmallIcon(android.R.drawable.ic_media_pause)
|
||||||
|
it.setStyle(MediaStyle().apply { setMediaSession(session.sessionToken) })
|
||||||
|
it.setOngoing(false)
|
||||||
|
it.setFlag(FLAG_NO_CLEAR, true)
|
||||||
|
}
|
||||||
|
build()
|
||||||
|
}
|
||||||
|
addNotificationAndLoad()
|
||||||
|
assertThat(mediaDataCaptor.value.isClearable).isTrue()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testOngoing_cannotDismiss() {
|
||||||
|
mediaNotification =
|
||||||
|
SbnBuilder().run {
|
||||||
|
setPkg(PACKAGE_NAME)
|
||||||
|
modifyNotification(context).also {
|
||||||
|
it.setSmallIcon(android.R.drawable.ic_media_pause)
|
||||||
|
it.setStyle(MediaStyle().apply { setMediaSession(session.sessionToken) })
|
||||||
|
it.setOngoing(true)
|
||||||
|
}
|
||||||
|
build()
|
||||||
|
}
|
||||||
|
addNotificationAndLoad()
|
||||||
|
assertThat(mediaDataCaptor.value.isClearable).isFalse()
|
||||||
|
}
|
||||||
|
|
||||||
/** Helper function to add a media notification and capture the resulting MediaData */
|
/** Helper function to add a media notification and capture the resulting MediaData */
|
||||||
private fun addNotificationAndLoad() {
|
private fun addNotificationAndLoad() {
|
||||||
mediaDataManager.onNotificationAdded(KEY, mediaNotification)
|
mediaDataManager.onNotificationAdded(KEY, mediaNotification)
|
||||||
|
|||||||
Reference in New Issue
Block a user