fix: fall back at once when a music app refuses the alarm
The start waited for PLAYING and nothing else, so an app that answered the play request with an error (YouTube without Premium) left the alarm vibrating in silence for the full 15 s START_TIMEOUT before the default sound took over. An error stamped at or after the request, or a lost connection, now ends the wait straight away. An error left over from the user's own listening still doesn't count.
This commit is contained in:
1 parent
6637554c9d
commit
d5016183ad
3 files changed
+36
-1
No files matched your search
@@ -29,6 +29,16 @@ class MediaRingPolicyTest {
|
||||
assertThat(MediaRingPolicy.shouldFallBack(long)).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `an error after the play request ends the start, an older one does not`() {
|
||||
val requestedAt = 10_000L
|
||||
|
||||
assertThat(MediaRingPolicy.refusedStart(isError = true, updatedAtMillis = 10_050L, requestedAtMillis = requestedAt)).isTrue()
|
||||
assertThat(MediaRingPolicy.refusedStart(isError = true, updatedAtMillis = requestedAt, requestedAtMillis = requestedAt)).isTrue()
|
||||
assertThat(MediaRingPolicy.refusedStart(isError = true, updatedAtMillis = 9_000L, requestedAtMillis = requestedAt)).isFalse()
|
||||
assertThat(MediaRingPolicy.refusedStart(isError = false, updatedAtMillis = 10_050L, requestedAtMillis = requestedAt)).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `buffering forever is a failure too`() {
|
||||
val brief = run(*repeat(MediaPlayback.TRANSITIONING, MediaRingPolicy.BUFFER_GRACE - tick))
|
||||
|
||||
Reference in new issue
Block a user