Notify the system of all remote volume changes

If a volume change occurred because it was sent through the MediaController directly
it wasn't showing the system's volume UI. This fixes things so the volume slider gets
shown for all volume requests with the SHOW_UI flag set.

bug:19036130
Change-Id: I1f7cb2e03386e2f3f7bc448cb4c38a71573775ff
diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java
index 22acfea..77a1fa9 100644
--- a/services/core/java/com/android/server/media/MediaSessionService.java
+++ b/services/core/java/com/android/server/media/MediaSessionService.java
@@ -143,6 +143,20 @@
         mHandler.post(MessageHandler.MSG_SESSIONS_CHANGED, record.getUserId(), 0);
     }
 
+    /**
+     * Tells the system UI that volume has changed on a remote session.
+     */
+    public void notifyRemoteVolumeChanged(int flags, MediaSessionRecord session) {
+        if (mRvc == null) {
+            return;
+        }
+        try {
+            mRvc.remoteVolumeChanged(session.getControllerBinder(), flags);
+        } catch (Exception e) {
+            Log.wtf(TAG, "Error sending volume change to system UI.", e);
+        }
+    }
+
     public void onSessionPlaystateChange(MediaSessionRecord record, int oldState, int newState) {
         boolean updateSessions = false;
         synchronized (mLock) {
@@ -864,14 +878,6 @@
             } else {
                 session.adjustVolume(direction, flags, getContext().getPackageName(),
                         UserHandle.myUserId(), true);
-                if (session.getPlaybackType() == PlaybackInfo.PLAYBACK_TYPE_REMOTE
-                        && mRvc != null && direction != MediaSessionManager.DIRECTION_MUTE) {
-                    try {
-                        mRvc.remoteVolumeChanged(session.getControllerBinder(), flags);
-                    } catch (Exception e) {
-                        Log.wtf(TAG, "Error sending volume change to system UI.", e);
-                    }
-                }
             }
         }