summaryrefslogtreecommitdiffstats
path: root/media/java
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2010-06-30 19:41:56 -0700
committerEric Laurent <elaurent@google.com>2010-06-30 19:41:56 -0700
commite2dd8c4592762414c2c27e4589be7edc91a5ecae (patch)
tree99939552fb10d7f72f007efa3349f6146aaae95e /media/java
parentc6e1d88022db800773401c16803e1ab27fd01a7e (diff)
downloadframeworks_base-e2dd8c4592762414c2c27e4589be7edc91a5ecae.zip
frameworks_base-e2dd8c4592762414c2c27e4589be7edc91a5ecae.tar.gz
frameworks_base-e2dd8c4592762414c2c27e4589be7edc91a5ecae.tar.bz2
Fix issue 2811538: System server crash when disconnecting BT headset after using SCO off call.
Problem: When the bluetooth device is removed, the AudioService clears all active SCO connections and unlinks from the client application's binder interface death. The problem is that the unlinking is done even if no more connections are active for a given client, which throws a runtime exception that is not catched causing the system server to crash. The fix consists in calling unlinkToDeath() in ScoClient.clearCount() only if the number of active SCO connections for this client is not 0. The NoSuchElementException exception is also catched when calling unlinkToDeath() Change-Id: I29a28fcce1a579217cea271956a55778e05d3e37
Diffstat (limited to 'media/java')
-rw-r--r--media/java/android/media/AudioService.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 50f0674..9212708 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -16,6 +16,7 @@
package android.media;
+import java.util.NoSuchElementException;
import android.app.ActivityManagerNative;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -1016,7 +1017,11 @@ public class AudioService extends IAudioService.Stub {
} else {
mStartcount--;
if (mStartcount == 0) {
- mCb.unlinkToDeath(this, 0);
+ try {
+ mCb.unlinkToDeath(this, 0);
+ } catch (NoSuchElementException e) {
+ Log.w(TAG, "decCount() going to 0 but not registered to binder");
+ }
}
requestScoState(BluetoothHeadset.AUDIO_STATE_DISCONNECTED);
}
@@ -1025,8 +1030,14 @@ public class AudioService extends IAudioService.Stub {
public void clearCount(boolean stopSco) {
synchronized(mScoClients) {
+ if (mStartcount != 0) {
+ try {
+ mCb.unlinkToDeath(this, 0);
+ } catch (NoSuchElementException e) {
+ Log.w(TAG, "clearCount() mStartcount: "+mStartcount+" != 0 but not registered to binder");
+ }
+ }
mStartcount = 0;
- mCb.unlinkToDeath(this, 0);
if (stopSco) {
requestScoState(BluetoothHeadset.AUDIO_STATE_DISCONNECTED);
}