summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShaleen Jain <shaleen.jain95@gmail.com>2016-07-15 16:41:21 +0530
committerJoey Rizzoli <joey@cyanogenmoditalia.it>2016-08-06 00:58:34 -0700
commit0507a6b863443e9c0e208b3a9a2d092e2516f4eb (patch)
tree7f6da3b8fd47fd0bb0c13b2b4f6726abeb8468a3
parenta6f204a76ba5336d2e651fcb608b79cc1826c64d (diff)
downloadandroid_packages_apps_Eleven-0507a6b863443e9c0e208b3a9a2d092e2516f4eb.tar.gz
android_packages_apps_Eleven-0507a6b863443e9c0e208b3a9a2d092e2516f4eb.tar.bz2
android_packages_apps_Eleven-0507a6b863443e9c0e208b3a9a2d092e2516f4eb.zip
handle media keys
This lets Eleven respond to physical media keys on some devices as well as when the volumn buttons are long pressed when the screen is off and the 'Playback control' preference is true in settings. RM-290 Change-Id: Ide906efdf90a6f42f3fcb6c5386328301165cb7c (cherry picked from commit 815e4d86dc19e623b32366b035d027a3ffa169fa)
-rw-r--r--src/com/cyanogenmod/eleven/MusicPlaybackService.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/com/cyanogenmod/eleven/MusicPlaybackService.java b/src/com/cyanogenmod/eleven/MusicPlaybackService.java
index 1f5660c..22e641d 100644
--- a/src/com/cyanogenmod/eleven/MusicPlaybackService.java
+++ b/src/com/cyanogenmod/eleven/MusicPlaybackService.java
@@ -66,7 +66,6 @@ import com.cyanogenmod.eleven.provider.SongPlayCount;
import com.cyanogenmod.eleven.service.MusicPlaybackTrack;
import com.cyanogenmod.eleven.utils.BitmapWithColors;
import com.cyanogenmod.eleven.utils.Lists;
-import com.cyanogenmod.eleven.utils.PreferenceUtils;
import com.cyanogenmod.eleven.utils.ShakeDetector;
import com.cyanogenmod.eleven.utils.SrtManager;
@@ -705,6 +704,7 @@ public class MusicPlaybackService extends Service {
}
});
mSession.setFlags(MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
+ mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS);
}
/**
@@ -1488,8 +1488,16 @@ public class MusicPlaybackService extends Service {
? PlaybackState.STATE_PLAYING
: PlaybackState.STATE_PAUSED;
+ long playBackStateActions = PlaybackState.ACTION_PLAY |
+ PlaybackState.ACTION_PLAY_PAUSE |
+ PlaybackState.ACTION_PLAY_FROM_MEDIA_ID |
+ PlaybackState.ACTION_PAUSE |
+ PlaybackState.ACTION_SKIP_TO_NEXT |
+ PlaybackState.ACTION_SKIP_TO_PREVIOUS;
+
if (what.equals(PLAYSTATE_CHANGED) || what.equals(POSITION_CHANGED)) {
mSession.setPlaybackState(new PlaybackState.Builder()
+ .setActions(playBackStateActions)
.setState(playState, position(), 1.0f).build());
} else if (what.equals(META_CHANGED) || what.equals(QUEUE_CHANGED)) {
Bitmap albumArt = getAlbumArt(false).getBitmap();
@@ -1517,6 +1525,7 @@ public class MusicPlaybackService extends Service {
.build());
mSession.setPlaybackState(new PlaybackState.Builder()
+ .setActions(playBackStateActions)
.setState(playState, position(), 1.0f).build());
}
}