Add slot reservation to Gearhead music sample.

Also add SmallIcon metadata.

B=17924045

Change-Id: I145d02efc871af5df4033053fab9375238fb93eb
diff --git a/MusicDemo/src/main/AndroidManifest.xml b/MusicDemo/src/main/AndroidManifest.xml
index 608dbc5..f84ee42 100644
--- a/MusicDemo/src/main/AndroidManifest.xml
+++ b/MusicDemo/src/main/AndroidManifest.xml
@@ -35,6 +35,13 @@
         <meta-data android:name="com.google.android.gms.car.application"
             android:resource="@xml/automotive_app_desc"/>
 
+        <!-- (OPTIONAL) use this meta data to indicate which icon should be used in media
+            notifications (for example, when the music changes and the user is
+            looking at another app) -->
+        <meta-data
+            android:name="com.google.android.gms.car.notification.SmallIcon"
+            android:resource="@drawable/ic_notification" />
+
         <service
             android:name=".MusicService"
             android:exported="true"
@@ -58,4 +65,4 @@
 
     </application>
 
-</manifest>
\ No newline at end of file
+</manifest>
diff --git a/MusicDemo/src/main/java/com/example/android/musicservicedemo/MusicService.java b/MusicDemo/src/main/java/com/example/android/musicservicedemo/MusicService.java
index f7e9dfc..1950cd6 100644
--- a/MusicDemo/src/main/java/com/example/android/musicservicedemo/MusicService.java
+++ b/MusicDemo/src/main/java/com/example/android/musicservicedemo/MusicService.java
@@ -166,6 +166,7 @@
         mWifiLock = ((WifiManager) getSystemService(Context.WIFI_SERVICE))
                 .createWifiLock(WifiManager.WIFI_MODE_FULL, "MusicDemo_lock");
 
+
         // Create the music catalog metadata provider
         mMusicProvider = new MusicProvider();
         mMusicProvider.retrieveMedia(new MusicProvider.Callback() {
@@ -183,6 +184,23 @@
         mSession.setCallback(new MediaSessionCallback());
         mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS |
                 MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
+
+        // Use these extras to reserve space for the corresponding actions, even when they are disabled
+        // in the playbackstate, so the custom actions don't reflow.
+        Bundle extras = new Bundle();
+        extras.putBoolean(
+            "com.google.android.gms.car.media.ALWAYS_RESERVE_SPACE_FOR.ACTION_SKIP_TO_NEXT",
+            true);
+        extras.putBoolean(
+            "com.google.android.gms.car.media.ALWAYS_RESERVE_SPACE_FOR.ACTION_SKIP_TO_PREVIOUS",
+            true);
+        // If you want to reserve the Queue slot when there is no queue
+        // (mSession.setQueue(emptylist)), uncomment the lines below:
+        // extras.putBoolean(
+        //   "com.google.android.gms.car.media.ALWAYS_RESERVE_SPACE_FOR.ACTION_QUEUE",
+        //   true);
+        mSession.setExtras(extras);
+
         updatePlaybackState(null);
 
         mMediaNotification = new MediaNotification(this);
@@ -771,6 +789,7 @@
      *
      */
     private void updatePlaybackState(String error) {
+
         LogHelper.d(TAG, "updatePlaybackState, setting session playback state to " + mState);
         long position = PlaybackState.PLAYBACK_POSITION_UNKNOWN;
         if (mMediaPlayer != null && mMediaPlayer.isPlaying()) {