summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2011-08-14 15:16:21 -0700
committerJean-Michel Trivi <jmtrivi@google.com>2011-08-14 15:16:21 -0700
commitbaf674eedd5ecff9da0cf8cabe9868f7699b1695 (patch)
treec3c334581c5d58e97551774f96caac2f045b0eda /media
parent5a586199cea242ea281744e8e35969ac342cbe80 (diff)
downloadframeworks_base-baf674eedd5ecff9da0cf8cabe9868f7699b1695.zip
frameworks_base-baf674eedd5ecff9da0cf8cabe9868f7699b1695.tar.gz
frameworks_base-baf674eedd5ecff9da0cf8cabe9868f7699b1695.tar.bz2
Fail request for audio focus when linkToDeath fails
When requesting audio focus and linkToDeath() threw a RemoteException, AudioService was only logging a warning, and was still changing the focus, with a non-null death handler. The change first check that linkToDeath() didn't fail, and only then proceeds to change the focus (dispatch focus change notification, updates the focus stack, and updates the remote controls). Change-Id: I0b96dd3c6e924d93f419880349d49f8b360b110b
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/AudioService.java25
1 files changed, 13 insertions, 12 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 62a263e..5951229 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -2749,6 +2749,18 @@ public class AudioService extends IAudioService.Stub {
return AudioManager.AUDIOFOCUS_REQUEST_FAILED;
}
+ // handle the potential premature death of the new holder of the focus
+ // (premature death == death before abandoning focus)
+ // Register for client death notification
+ AudioFocusDeathHandler afdh = new AudioFocusDeathHandler(cb);
+ try {
+ cb.linkToDeath(afdh, 0);
+ } catch (RemoteException e) {
+ // client has already died!
+ Log.w(TAG, "AudioFocus requestAudioFocus() could not link to "+cb+" binder death");
+ return AudioManager.AUDIOFOCUS_REQUEST_FAILED;
+ }
+
if (!mFocusStack.empty() && mFocusStack.peek().mClientId.equals(clientId)) {
// if focus is already owned by this client and the reason for acquiring the focus
// hasn't changed, don't do anything
@@ -2773,18 +2785,7 @@ public class AudioService extends IAudioService.Stub {
}
// focus requester might already be somewhere below in the stack, remove it
- removeFocusStackEntry(clientId, false);
-
- // handle the potential premature death of the new holder of the focus
- // (premature death == death before abandoning focus)
- // Register for client death notification
- AudioFocusDeathHandler afdh = new AudioFocusDeathHandler(cb);
- try {
- cb.linkToDeath(afdh, 0);
- } catch (RemoteException e) {
- // client has already died!
- Log.w(TAG, "AudioFocus requestAudioFocus() could not link to "+cb+" binder death");
- }
+ removeFocusStackEntry(clientId, false /* signal */);
// push focus requester at the top of the audio focus stack
mFocusStack.push(new FocusStackEntry(mainStreamType, focusChangeHint, fd, cb,