diff options
author | Danny Baumann <dannybaumann@web.de> | 2012-12-25 14:03:03 +0100 |
---|---|---|
committer | Danny Baumann <dannybaumann@web.de> | 2012-12-27 12:08:34 +0100 |
commit | 01ae5f68cd4df65ea54b317aed6500db8face0d0 (patch) | |
tree | 0d9f258ef7f3c78ff30105b9cbb5f23ef1d15cee /media | |
parent | 0644dac1604bd2cf14224b87f25d4149f1919528 (diff) | |
download | frameworks_base-01ae5f68cd4df65ea54b317aed6500db8face0d0.zip frameworks_base-01ae5f68cd4df65ea54b317aed6500db8face0d0.tar.gz frameworks_base-01ae5f68cd4df65ea54b317aed6500db8face0d0.tar.bz2 |
Properly handle changes in phone audio focus.
Change-Id: I921651684f4369a47aa83e93010266c40be71a41
Diffstat (limited to 'media')
-rwxr-xr-x | media/java/android/media/AudioService.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index 140363d..4c0acf6 100755 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -4183,10 +4183,11 @@ public class AudioService extends IAudioService.Stub implements OnFinished { private void notifyTopOfAudioFocusStack() { // notify the top of the stack it gained focus if (!mFocusStack.empty() && (mFocusStack.peek().mFocusDispatcher != null)) { - if (canReassignAudioFocus()) { + String clientId = mFocusStack.peek().mClientId; + if (canReassignAudioFocusTo(clientId)) { try { mFocusStack.peek().mFocusDispatcher.dispatchAudioFocusChange( - AudioManager.AUDIOFOCUS_GAIN, mFocusStack.peek().mClientId); + AudioManager.AUDIOFOCUS_GAIN, clientId); } catch (RemoteException e) { Log.e(TAG, "Failure to signal gain of audio control focus due to "+ e); e.printStackTrace(); @@ -4334,9 +4335,12 @@ public class AudioService extends IAudioService.Stub implements OnFinished { * Helper function: * Returns true if the system is in a state where the focus can be reevaluated, false otherwise. */ - private boolean canReassignAudioFocus() { + private boolean canReassignAudioFocusTo(String clientId) { // focus requests are rejected during a phone call or when the phone is ringing // this is equivalent to IN_VOICE_COMM_FOCUS_ID having the focus + if (IN_VOICE_COMM_FOCUS_ID.equals(clientId)) { + return true; + } if (!mFocusStack.isEmpty() && IN_VOICE_COMM_FOCUS_ID.equals(mFocusStack.peek().mClientId)) { return false; } @@ -4381,7 +4385,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { } synchronized(mAudioFocusLock) { - if (!canReassignAudioFocus()) { + if (!canReassignAudioFocusTo(clientId)) { return AudioManager.AUDIOFOCUS_REQUEST_FAILED; } |