Notification muting conditional to exclusive audio focus request

Summary of feature:
Do not mute notifications when speech recognition recording is
  active, but when an app has requested audio focus with
  AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE.

Implementation:
Move definition of AUDIOFOCUS_NONE to AudioManager where other
  audio focus codes are defined.
Add support for querying the current audio focus type.
When audio focus is requested as GAIN_TRANSIENT_EXCLUSIVE, make
  the corresponding loss by LOSS_TRANSIENT.
Before playing a notification, check whether GAIN_TRANSIENT_EXCLUSIVE
  has been requested.

Bug 8251963

Change-Id: I41edc77326b70639d2fdcb4642c53109995b72a8
This commit is contained in:
Jean-Michel Trivi
2013-07-31 14:19:18 -07:00
parent 3a6f25512c
commit 2380566deb
6 changed files with 63 additions and 17 deletions

View File

@@ -424,6 +424,15 @@ public class MediaFocusControl implements OnFinished {
}
}
protected int getCurrentAudioFocus() {
synchronized(mAudioFocusLock) {
if (mFocusStack.empty()) {
return AudioManager.AUDIOFOCUS_NONE;
} else {
return mFocusStack.peek().getGainRequest();
}
}
}
/** @see AudioManager#requestAudioFocus(AudioManager.OnAudioFocusChangeListener, int, int) */
protected int requestAudioFocus(int mainStreamType, int focusChangeHint, IBinder cb,