Backed out changeset 090286c03592 (bug 1357639)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Thu, 04 May 2017 21:24:03 +0200
changeset 573182 e0c1c4a330829d9aec44ed4aa4211d2914600733
parent 573181 32a89a5739234939dc4b8ac8819e492d20033e8b
child 573183 e85f2c69f55e9347ccac411feb5bfe31df0140e1
push id57306
push userbmo:emilio+bugs@crisal.io
push dateFri, 05 May 2017 10:08:55 +0000
bugs1357639
milestone55.0a1
backs out090286c0359222ae390220b6a5e068e6e56839b8
Backed out changeset 090286c03592 (bug 1357639)
mobile/android/base/java/org/mozilla/gecko/media/AudioFocusAgent.java
--- a/mobile/android/base/java/org/mozilla/gecko/media/AudioFocusAgent.java
+++ b/mobile/android/base/java/org/mozilla/gecko/media/AudioFocusAgent.java
@@ -54,42 +54,41 @@ public class AudioFocusAgent {
         mContext = context;
         mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
 
         mAfChangeListener = new OnAudioFocusChangeListener() {
             public void onAudioFocusChange(int focusChange) {
                 switch (focusChange) {
                     case AudioManager.AUDIOFOCUS_LOSS:
                         Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_LOSS");
-                        mAudioFocusState = State.LOST_FOCUS;
                         notifyObservers("audioFocusChanged", "lostAudioFocus");
                         notifyMediaControlService(MediaControlService.ACTION_PAUSE_BY_AUDIO_FOCUS);
+                        mAudioFocusState = State.LOST_FOCUS;
                         break;
                     case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
                         Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_LOSS_TRANSIENT");
-                        mAudioFocusState = State.LOST_FOCUS_TRANSIENT;
                         notifyObservers("audioFocusChanged", "lostAudioFocusTransiently");
                         notifyMediaControlService(MediaControlService.ACTION_PAUSE_BY_AUDIO_FOCUS);
+                        mAudioFocusState = State.LOST_FOCUS_TRANSIENT;
                         break;
                     case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
                         Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK");
+                        notifyMediaControlService(MediaControlService.ACTION_START_AUDIO_DUCK);
                         mAudioFocusState = State.LOST_FOCUS_TRANSIENT_CAN_DUCK;
-                        notifyMediaControlService(MediaControlService.ACTION_START_AUDIO_DUCK);
                         break;
                     case AudioManager.AUDIOFOCUS_GAIN:
-                        State state = mAudioFocusState;
-                        mAudioFocusState = State.OWN_FOCUS;
-                        if (state.equals(State.LOST_FOCUS_TRANSIENT_CAN_DUCK)) {
+                        if (mAudioFocusState.equals(State.LOST_FOCUS_TRANSIENT_CAN_DUCK)) {
                             Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_GAIN (from DUCKING)");
                             notifyMediaControlService(MediaControlService.ACTION_STOP_AUDIO_DUCK);
-                        } else if (state.equals(State.LOST_FOCUS_TRANSIENT)) {
+                        } else if (mAudioFocusState.equals(State.LOST_FOCUS_TRANSIENT)) {
                             Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_GAIN");
                             notifyObservers("audioFocusChanged", "gainAudioFocus");
                             notifyMediaControlService(MediaControlService.ACTION_RESUME_BY_AUDIO_FOCUS);
                         }
+                        mAudioFocusState = State.OWN_FOCUS;
                         break;
                     default:
                 }
             }
         };
         notifyMediaControlService(MediaControlService.ACTION_INIT);
     }