From d92f01d01f91d66eae79356dc8f19e9d6e446039 Mon Sep 17 00:00:00 2001 From: Adrian Ulrich Date: Sat, 3 Oct 2015 08:52:28 +0200 Subject: [PATCH] Hide remote-control artwork if notification is not forced This fixes stuck artwork on some motorola (only?) devices --- .../blinkenlights/android/vanilla/PlaybackService.java | 2 +- src/ch/blinkenlights/android/vanilla/RemoteControl.java | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ch/blinkenlights/android/vanilla/PlaybackService.java b/src/ch/blinkenlights/android/vanilla/PlaybackService.java index 1467f4f6..788ab03c 100644 --- a/src/ch/blinkenlights/android/vanilla/PlaybackService.java +++ b/src/ch/blinkenlights/android/vanilla/PlaybackService.java @@ -1045,7 +1045,7 @@ public final class PlaybackService extends Service if (mReadaheadEnabled) triggerReadAhead(); - RemoteControl.updateRemote(this, mCurrentSong, mState); + RemoteControl.updateRemote(this, mCurrentSong, mState, mForceNotificationVisible); if (mStockBroadcast) stockMusicBroadcast(); diff --git a/src/ch/blinkenlights/android/vanilla/RemoteControl.java b/src/ch/blinkenlights/android/vanilla/RemoteControl.java index 0ff5d479..30af00d9 100644 --- a/src/ch/blinkenlights/android/vanilla/RemoteControl.java +++ b/src/ch/blinkenlights/android/vanilla/RemoteControl.java @@ -75,14 +75,17 @@ public class RemoteControl { * @param context A context to use. * @param song The song containing the new metadata. * @param state PlaybackService state, used to determine playback state. + * @param keepPaused whether or not to keep the remote updated in paused mode */ - public static void updateRemote(Context context, Song song, int state) + public static void updateRemote(Context context, Song song, int state, boolean keepPaused) { RemoteControlClient remote = sRemote; if (remote == null) return; - remote.setPlaybackState((state & PlaybackService.FLAG_PLAYING) != 0 ? RemoteControlClient.PLAYSTATE_PLAYING : RemoteControlClient.PLAYSTATE_PAUSED); + boolean isPlaying = ((state & PlaybackService.FLAG_PLAYING) != 0); + + remote.setPlaybackState(isPlaying ? RemoteControlClient.PLAYSTATE_PLAYING : RemoteControlClient.PLAYSTATE_PAUSED); RemoteControlClient.MetadataEditor editor = remote.editMetadata(true); if (song != null && song.id != -1) { String artist_album = song.artist + " - " + song.album; @@ -92,7 +95,7 @@ public class RemoteControl { editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, artist_album); editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, song.title); Bitmap bitmap = song.getCover(context); - if (bitmap != null) { + if (bitmap != null && (isPlaying || keepPaused)) { // Create a copy of the cover art, since RemoteControlClient likes // to recycle what we give it. bitmap = bitmap.copy(Bitmap.Config.RGB_565, false);