diff options
| author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-11 12:11:56 -0700 |
|---|---|---|
| committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-11 12:11:56 -0700 |
| commit | c39a6e0c51e182338deb8b63d07933b585134929 (patch) | |
| tree | e55fc5bd38b1eb8fb4851a0fe1cc264a7fe2f245 /core/java/android/server | |
| parent | b2a3dd88a53cc8c6d19f6dc8ec4f3d6c4abd9b54 (diff) | |
| download | frameworks_base-c39a6e0c51e182338deb8b63d07933b585134929.zip frameworks_base-c39a6e0c51e182338deb8b63d07933b585134929.tar.gz frameworks_base-c39a6e0c51e182338deb8b63d07933b585134929.tar.bz2 | |
auto import from //branches/cupcake/...@137873
Diffstat (limited to 'core/java/android/server')
| -rw-r--r-- | core/java/android/server/BluetoothA2dpService.java | 9 | ||||
| -rw-r--r-- | core/java/android/server/BluetoothDeviceService.java | 1 | ||||
| -rw-r--r-- | core/java/android/server/BluetoothEventLoop.java | 12 |
3 files changed, 22 insertions, 0 deletions
diff --git a/core/java/android/server/BluetoothA2dpService.java b/core/java/android/server/BluetoothA2dpService.java index f8bc765..3aa4078 100644 --- a/core/java/android/server/BluetoothA2dpService.java +++ b/core/java/android/server/BluetoothA2dpService.java @@ -208,6 +208,15 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { if (mAudioDevices == null) { return BluetoothError.ERROR; } + // ignore if there are any active sinks + if (lookupSinksMatchingStates(new int[] { + BluetoothA2dp.STATE_CONNECTING, + BluetoothA2dp.STATE_CONNECTED, + BluetoothA2dp.STATE_PLAYING, + BluetoothA2dp.STATE_DISCONNECTING}).size() != 0) { + return BluetoothError.ERROR; + } + String path = lookupPath(address); if (path == null) { path = createHeadsetNative(address); diff --git a/core/java/android/server/BluetoothDeviceService.java b/core/java/android/server/BluetoothDeviceService.java index 6f5513a..e271909 100644 --- a/core/java/android/server/BluetoothDeviceService.java +++ b/core/java/android/server/BluetoothDeviceService.java @@ -287,6 +287,7 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub { } else { intent = new Intent(BluetoothIntent.DISABLED_ACTION); } + intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); mContext.sendBroadcast(intent, BLUETOOTH_PERM); mEnableThread = null; diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java index e4ebcca..8e77eed 100644 --- a/core/java/android/server/BluetoothEventLoop.java +++ b/core/java/android/server/BluetoothEventLoop.java @@ -52,6 +52,7 @@ class BluetoothEventLoop { private Context mContext; private static final int EVENT_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY = 1; + private static final int EVENT_RESTART_BLUETOOTH = 2; // The time (in millisecs) to delay the pairing attempt after the first // auto pairing attempt fails. We use an exponential delay with @@ -74,6 +75,10 @@ class BluetoothEventLoop { return; } break; + case EVENT_RESTART_BLUETOOTH: + mBluetoothService.disable(); + mBluetoothService.enable(null); + break; } } }; @@ -372,6 +377,13 @@ class BluetoothEventLoop { } } + private void onRestartRequired() { + if (mBluetoothService.isEnabled()) { + Log.e(TAG, "*** A serious error occured (did hcid crash?) - restarting Bluetooth ***"); + mHandler.sendEmptyMessage(EVENT_RESTART_BLUETOOTH); + } + } + private static void log(String msg) { Log.d(TAG, msg); } |
