summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2020-10-16 21:01:08 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-10-16 21:01:08 +0000
commitbc2dd97ee892a35eb5924b4523f3e735185cb31c (patch)
tree6107fdd18d04c23eb5756300efc60583b64d27cd
parent145f83bc1444679e82e3860f9855df22851802bd (diff)
parentc1b65c7387b693c865cb5b81aa3e7632b6c34789 (diff)
Merge "Notifications starting paused shall still be subject to timeout."
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/MediaTimeoutListener.kt10
1 files changed, 4 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaTimeoutListener.kt b/packages/SystemUI/src/com/android/systemui/media/MediaTimeoutListener.kt
index 51dbfa733541..ce72991d01c0 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaTimeoutListener.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaTimeoutListener.kt
@@ -46,7 +46,7 @@ class MediaTimeoutListener @Inject constructor(
/**
* Callback representing that a media object is now expired:
* @param token Media session unique identifier
- * @param pauseTimeuot True when expired for {@code PAUSED_MEDIA_TIMEOUT}
+ * @param pauseTimeout True when expired for {@code PAUSED_MEDIA_TIMEOUT}
*/
lateinit var timeoutCallback: (String, Boolean) -> Unit
@@ -57,11 +57,10 @@ class MediaTimeoutListener @Inject constructor(
// Having an old key means that we're migrating from/to resumption. We should update
// the old listener to make sure that events will be dispatched to the new location.
val migrating = oldKey != null && key != oldKey
- var wasPlaying = false
if (migrating) {
val reusedListener = mediaListeners.remove(oldKey)
if (reusedListener != null) {
- wasPlaying = reusedListener.playing ?: false
+ val wasPlaying = reusedListener.playing ?: false
if (DEBUG) Log.d(TAG, "migrating key $oldKey to $key, for resumption")
reusedListener.mediaData = data
reusedListener.key = key
@@ -159,9 +158,8 @@ class MediaTimeoutListener @Inject constructor(
Log.v(TAG, "Execute timeout for $key")
}
timedOut = true
- if (dispatchEvents) {
- timeoutCallback(key, timedOut)
- }
+ // this event is async, so it's safe even when `dispatchEvents` is false
+ timeoutCallback(key, timedOut)
}, PAUSED_MEDIA_TIMEOUT)
} else {
expireMediaTimeout(key, "playback started - $state, $key")