Bug 1289356 - only resume music when we're in the state 'AUDIOFOCUS_LOSS_TRANSIENT'.
The audio should only be resumed when we lose audio-focus transiently. Eg. interrupt by ringtone or telephony.
MozReview-Commit-ID: 78QHSqxEhcp
--- a/mobile/android/base/java/org/mozilla/gecko/media/AudioFocusAgent.java
+++ b/mobile/android/base/java/org/mozilla/gecko/media/AudioFocusAgent.java
@@ -61,16 +61,19 @@ public class AudioFocusAgent {
break;
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_LOSS_TRANSIENT");
notifyObservers("AudioFocusChanged", "lostAudioFocusTransiently");
notifyMediaControlService(MediaControlService.ACTION_PAUSE);
mAudioFocusState = LOST_FOCUS_TRANSIENT;
break;
case AudioManager.AUDIOFOCUS_GAIN:
+ if (!mAudioFocusState.equals(LOST_FOCUS_TRANSIENT)) {
+ return;
+ }
Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_GAIN");
notifyObservers("AudioFocusChanged", "gainAudioFocus");
notifyMediaControlService(MediaControlService.ACTION_PLAY);
mAudioFocusState = OWN_FOCUS;
break;
default:
}
}