Eleven: Add shuffle button for Android Auto

Change-Id: Ic363d2241ab9db5f3774537dc95583cd12f9f8fc
diff --git a/src/org/lineageos/eleven/MusicPlaybackService.java b/src/org/lineageos/eleven/MusicPlaybackService.java
index bf23894..ec11186 100644
--- a/src/org/lineageos/eleven/MusicPlaybackService.java
+++ b/src/org/lineageos/eleven/MusicPlaybackService.java
@@ -834,6 +834,13 @@
                 open(mSongs.stream().mapToLong(i -> i).toArray(), position, -1, IdType.NA);
                 onPlay();
             }
+
+            @Override
+            public void onCustomAction(@NonNull String action, @Nullable Bundle extras) {
+                if (action.equals(SHUFFLE_ACTION)) {
+                    cycleShuffle();
+                }
+            }
         });
 
         PendingIntent pi = PendingIntent.getBroadcast(this, 0,
@@ -1631,11 +1638,19 @@
                 PlaybackState.ACTION_SKIP_TO_PREVIOUS |
                 PlaybackState.ACTION_STOP;
 
+        PlaybackState.Builder stateBuilder = new PlaybackState.Builder()
+                .setActions(playBackStateActions)
+                .setActiveQueueItemId(getAudioId())
+                .setState(playState, position(), 1.0f);
+
+        // create custom action
+        stateBuilder.addCustomAction(new PlaybackState.CustomAction.Builder(
+                SHUFFLE_ACTION,
+                getString(R.string.menu_shuffle_item),
+                R.drawable.btn_playback_shuffle_all).build());
+
         if (what.equals(PLAYSTATE_CHANGED) || what.equals(POSITION_CHANGED)) {
-            mSession.setPlaybackState(new PlaybackState.Builder()
-                    .setActions(playBackStateActions)
-                    .setActiveQueueItemId(getAudioId())
-                    .setState(playState, position(), 1.0f).build());
+            mSession.setPlaybackState(stateBuilder.build());
         } else if (what.equals(META_CHANGED) || what.equals(QUEUE_CHANGED)
                 || QUEUE_MOVED.equals(what)) {
             Bitmap albumArt = getAlbumArt(false).getBitmap();
@@ -1665,10 +1680,7 @@
                 updateMediaSessionQueue();
             }
 
-            mSession.setPlaybackState(new PlaybackState.Builder()
-                    .setActions(playBackStateActions)
-                    .setActiveQueueItemId(getAudioId())
-                    .setState(playState, position(), 1.0f).build());
+            mSession.setPlaybackState(stateBuilder.build());
         }
     }