Skip to content

Commit

Permalink
Remove workaround for a bug in LyricViewController
Browse files Browse the repository at this point in the history
edit packages/SystemUI/src/com/android/systemui/statusbar/phone/LyricViewController.java
change
boolean isLyric = ((notification.flags & Notification.FLAG_ALWAYS_SHOW_TICKER) != 0)
                && ((notification.flags & Notification.FLAG_ONLY_UPDATE_TICKER) != 0);
to
boolean isLyric = (notification.flags & Notification.FLAG_ALWAYS_SHOW_TICKER) != 0;
  • Loading branch information
nift4 committed Oct 25, 2024
1 parent 38a01d1 commit c99ed47
Showing 1 changed file with 13 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,33 +55,12 @@ class MeiZuLyricsMediaNotificationProvider(private val context: MediaSessionServ
mediaSession, customLayout, actionFactory
) {
onNotificationChangedCallback.onNotificationChanged(it.also {
if (ticker != null) {
it.notification.apply {
extras.putInt("ticker_icon", R.drawable.ic_gramophone_monochrome)
extras.putBoolean("ticker_icon_switch", false)
}
}
if (tickerProvider() != null) {
updateTickerLater(mediaSession)
}
if (ticker != null)
it.applyNotificationFlags(false)
})
}.also {
if (ticker != null) {
it.notification.apply {
extras.putInt("ticker_icon", R.drawable.ic_gramophone_monochrome)
extras.putBoolean("ticker_icon_switch", false)
}
}
if (ticker != null && isManualNotificationUpdate) {
it.notification.apply {
// Keep the status bar lyrics scrolling
flags = flags.or(FLAG_ALWAYS_SHOW_TICKER)
// Only update the ticker (lyrics), and do not update other properties
flags = flags.or(FLAG_ONLY_UPDATE_TICKER)
}
} else if (ticker != null) {
updateTickerLater(mediaSession)
}
if (ticker != null)
it.applyNotificationFlags(isManualNotificationUpdate)
}
}

Expand All @@ -91,18 +70,15 @@ class MeiZuLyricsMediaNotificationProvider(private val context: MediaSessionServ
extras: Bundle
) = inner.handleCustomCommand(session, action, extras)

private fun updateTickerLater(mediaSession: MediaSession) {
// If we set FLAG_ONLY_UPDATE_TICKER on native impl, other notification content
// won't be updated.
// If we don't set FLAG_ONLY_UPDATE_TICKER, Xposed impl won't consider this as
// lyrics. Hence first update for new content and then again to re-apply ticker.
// Yes, these post() calls are needed. (Otherwise we go into a race with media3).
Handler(mediaSession.player.applicationLooper).post {
Handler(Looper.getMainLooper()).post {
Handler(mediaSession.player.applicationLooper).post {
context.doUpdateNotification(mediaSession)
}
}
private fun MediaNotification.applyNotificationFlags(onlyUpdateTicker: Boolean) {
notification.apply {
extras.putInt("ticker_icon", R.drawable.ic_gramophone_monochrome)
extras.putBoolean("ticker_icon_switch", false)
// Keep the status bar lyrics scrolling
flags = flags.or(FLAG_ALWAYS_SHOW_TICKER)
// Only update the ticker (lyrics), and do not update other properties
if (onlyUpdateTicker)
flags = flags.or(FLAG_ONLY_UPDATE_TICKER)
}
}

Expand Down

0 comments on commit c99ed47

Please sign in to comment.