summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2016-08-12 07:33:17 (GMT)
committerDanny Baumann <dannybaumann@web.de>2016-08-15 10:07:07 (GMT)
commitc7f1f86ff59b739af1193df837b0aadf7a2386ce (patch)
tree1648077b5ed5dabe1591e634013196aa831a7a77
parent4961f4edbc2194359a15430fa99d063ac46c643d (diff)
downloadandroid_packages_apps_Eleven-c7f1f86ff59b739af1193df837b0aadf7a2386ce.zip
android_packages_apps_Eleven-c7f1f86ff59b739af1193df837b0aadf7a2386ce.tar.gz
android_packages_apps_Eleven-c7f1f86ff59b739af1193df837b0aadf7a2386ce.tar.bz2
Convert to new media button receiver logic.
Commit Ide906efdf90a6f42f3fcb6c5386328301165cb7c changed the media button receiving logic to be routed through MediaSession, but missed to also convert the media button intent receiver registration used for receiving button events if our playback is stopped. Also add the possible stop action (we're handling onStop after all) missing in the aforementioned commit. Change-Id: Idd4b8bc00f58eee2ff7fc2e5a685b7918988c37c
-rw-r--r--src/com/cyanogenmod/eleven/MusicPlaybackService.java20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/com/cyanogenmod/eleven/MusicPlaybackService.java b/src/com/cyanogenmod/eleven/MusicPlaybackService.java
index 22e641d..d8163a8 100644
--- a/src/com/cyanogenmod/eleven/MusicPlaybackService.java
+++ b/src/com/cyanogenmod/eleven/MusicPlaybackService.java
@@ -452,8 +452,6 @@ public class MusicPlaybackService extends Service {
*/
private MediaSession mSession;
- private ComponentName mMediaButtonReceiverComponent;
-
// We use this to distinguish between different cards when saving/restoring
// playlists
private int mCardId;
@@ -617,9 +615,6 @@ public class MusicPlaybackService extends Service {
// Initialize the audio manager and register any headset controls for
// playback
mAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
- mMediaButtonReceiverComponent = new ComponentName(getPackageName(),
- MediaButtonIntentReceiver.class.getName());
- mAudioManager.registerMediaButtonEventReceiver(mMediaButtonReceiverComponent);
// Use the remote control APIs to set the playback state
setUpMediaSession();
@@ -703,8 +698,14 @@ public class MusicPlaybackService extends Service {
releaseServiceUiAndStop();
}
});
- mSession.setFlags(MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
- mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS);
+
+ PendingIntent pi = PendingIntent.getBroadcast(this, 0,
+ new Intent(this, MediaButtonIntentReceiver.class),
+ PendingIntent.FLAG_UPDATE_CURRENT);
+ mSession.setMediaButtonReceiver(pi);
+
+ mSession.setFlags(MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS
+ | MediaSession.FLAG_HANDLES_MEDIA_BUTTONS);
}
/**
@@ -1493,7 +1494,8 @@ public class MusicPlaybackService extends Service {
PlaybackState.ACTION_PLAY_FROM_MEDIA_ID |
PlaybackState.ACTION_PAUSE |
PlaybackState.ACTION_SKIP_TO_NEXT |
- PlaybackState.ACTION_SKIP_TO_PREVIOUS;
+ PlaybackState.ACTION_SKIP_TO_PREVIOUS |
+ PlaybackState.ACTION_STOP;
if (what.equals(PLAYSTATE_CHANGED) || what.equals(POSITION_CHANGED)) {
mSession.setPlaybackState(new PlaybackState.Builder()
@@ -2391,8 +2393,6 @@ public class MusicPlaybackService extends Service {
intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
sendBroadcast(intent);
- mAudioManager.registerMediaButtonEventReceiver(new ComponentName(getPackageName(),
- MediaButtonIntentReceiver.class.getName()));
mSession.setActive(true);
if (createNewNextTrack) {