summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2016-08-12 09:33:17 +0200
committerMichael Bestas <mikeioannina@gmail.com>2016-09-16 18:15:09 +0300
commit1ae523ee92dd97f2602736da9f4fbb6967e76971 (patch)
treee0a04c4819c7306a020aa4cfc5d93145b90ee020 /src
parent57a450d85700560667a067a5307314778edcebb5 (diff)
downloadandroid_packages_apps_Eleven-1ae523ee92dd97f2602736da9f4fbb6967e76971.tar.gz
android_packages_apps_Eleven-1ae523ee92dd97f2602736da9f4fbb6967e76971.tar.bz2
android_packages_apps_Eleven-1ae523ee92dd97f2602736da9f4fbb6967e76971.zip
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. RM-290 Change-Id: Idd4b8bc00f58eee2ff7fc2e5a685b7918988c37c
Diffstat (limited to 'src')
-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) {