From 1b862cc3922321e9a5ef8e8c47085f1616ffcdec Mon Sep 17 00:00:00 2001 From: Christopher Eby Date: Sun, 4 Apr 2010 15:34:24 -0500 Subject: [PATCH] Improve the initial state handling Now actually notices when the state is uninitialized and updates the state properly --- src/org/kreed/vanilla/PlaybackService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/org/kreed/vanilla/PlaybackService.java b/src/org/kreed/vanilla/PlaybackService.java index e2c76141..55a4617e 100644 --- a/src/org/kreed/vanilla/PlaybackService.java +++ b/src/org/kreed/vanilla/PlaybackService.java @@ -66,6 +66,7 @@ public class PlaybackService extends Service implements Runnable, MediaPlayer.On public static final int FLAG_NO_MEDIA = 0x2; public static final int FLAG_PLAYING = 0x1; + public static final int ALL_FLAGS = FLAG_NO_MEDIA + FLAG_PLAYING; public static final int NEVER = 0; public static final int WHEN_PLAYING = 1; @@ -335,6 +336,8 @@ public class PlaybackService extends Service implements Runnable, MediaPlayer.On private boolean updateState(int state) { + state &= ALL_FLAGS; + if ((state & FLAG_NO_MEDIA) != 0) state &= ~FLAG_PLAYING; @@ -683,8 +686,6 @@ public class PlaybackService extends Service implements Runnable, MediaPlayer.On mHandler.sendEmptyMessageDelayed(SAVE_STATE, 5000); break; case POST_CREATE: - updateNotification(getSong(0)); - mReceiver = new Receiver(); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_HEADSET_PLUG);