always update notification

Canceled notifications may still stick around a little bit and we want to show the correct state.
This commit is contained in:
Adrian Ulrich 2021-03-03 19:58:00 +01:00
parent 800ecc6edb
commit 0946f4bdd6

View File

@ -1184,10 +1184,14 @@ public final class PlaybackService extends Service
private void updateNotification()
{
if ((mForceNotificationVisible || mNotificationVisibility == VISIBILITY_ALWAYS
|| mNotificationVisibility == VISIBILITY_WHEN_PLAYING && (mState & FLAG_PLAYING) != 0) && mCurrentSong != null) {
if (mCurrentSong != null) {
// We always update the notification, even if we are about to cancel it as it may still stick around
// for a few seconds and we want to ensure that we are showing the correct state.
mNotificationHelper.notify(NOTIFICATION_ID, createNotification(mCurrentSong, mState, mNotificationVisibility));
} else {
}
if (!(mForceNotificationVisible ||
mNotificationVisibility == VISIBILITY_ALWAYS ||
mNotificationVisibility == VISIBILITY_WHEN_PLAYING && (mState & FLAG_PLAYING) != 0)) {
mNotificationHelper.cancel(NOTIFICATION_ID);
}
}