Merge "Fixing issue with play/pause buttons being inverted."
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMediaController.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMediaController.java
index 5a665a9..3a4caa9 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMediaController.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMediaController.java
@@ -83,9 +83,7 @@
     private MediaController.Callback mPlaybackChangedListener = new MediaController.Callback() {
         @Override
         public void onPlaybackStateChanged(PlaybackState state) {
-            if (!mListeners.isEmpty()) {
-                notifyActionsChanged(getMediaActions());
-            }
+            notifyActionsChanged();
         }
     };
 
@@ -146,9 +144,9 @@
         boolean isPlaying = MediaSession.isActiveState(state);
         long actions = mMediaController.getPlaybackState().getActions();
         if (!isPlaying && ((actions & PlaybackState.ACTION_PLAY) != 0)) {
-            mediaActions.add(mPauseAction);
-        } else if (isPlaying && ((actions & PlaybackState.ACTION_PAUSE) != 0)) {
             mediaActions.add(mPlayAction);
+        } else if (isPlaying && ((actions & PlaybackState.ACTION_PAUSE) != 0)) {
+            mediaActions.add(mPauseAction);
         }
         return mediaActions;
     }
@@ -202,9 +200,7 @@
             if (controller != null) {
                 controller.registerCallback(mPlaybackChangedListener);
             }
-            if (!mListeners.isEmpty()) {
-                notifyActionsChanged(getMediaActions());
-            }
+            notifyActionsChanged();
 
             // TODO(winsonc): Consider if we want to close the PIP after a timeout (like on TV)
         }
@@ -213,8 +209,9 @@
     /**
      * Notifies all listeners that the actions have changed.
      */
-    private void notifyActionsChanged(List<RemoteAction> actions) {
+    private void notifyActionsChanged() {
         if (!mListeners.isEmpty()) {
+            List<RemoteAction> actions = getMediaActions();
             mListeners.forEach(l -> l.onMediaActionsChanged(actions));
         }
     }