diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-10-12 14:05:44 -0400 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-10-12 14:05:44 -0400 |
commit | d301c90446644f63cda9b9263f83332676065bb4 (patch) | |
tree | b8b5c7184b5d86b4add63cb59f6545c0b4802c9b | |
parent | f836acf241f10d943d72d439fa425fda73a6d56b (diff) | |
parent | bc1fc05c1b3e8c407fa07b25777bf577d5285f49 (diff) | |
download | frameworks_base-d301c90446644f63cda9b9263f83332676065bb4.zip frameworks_base-d301c90446644f63cda9b9263f83332676065bb4.tar.gz frameworks_base-d301c90446644f63cda9b9263f83332676065bb4.tar.bz2 |
Merge change I305c181c into eclair
* changes:
Delay 500ms between each registering each SDP record using sdptool.
-rw-r--r-- | core/java/android/server/BluetoothService.java | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java index 5c8c7cc..67b30a9 100644 --- a/core/java/android/server/BluetoothService.java +++ b/core/java/android/server/BluetoothService.java @@ -208,6 +208,7 @@ public class BluetoothService extends IBluetooth.Stub { return false; } setBluetoothState(BluetoothAdapter.STATE_TURNING_OFF); + mHandler.removeMessages(MESSAGE_REGISTER_SDP_RECORDS); // Allow 3 seconds for profiles to gracefully disconnect // TODO: Introduce a callback mechanism so that each profile can notify @@ -327,12 +328,39 @@ public class BluetoothService extends IBluetooth.Stub { public void handleMessage(Message msg) { switch (msg.what) { case MESSAGE_REGISTER_SDP_RECORDS: - //TODO: Don't assume HSP/HFP is running, don't use sdptool, - if (isEnabled()) { + if (!isEnabled()) { + return; + } + // SystemService.start() forks sdptool to register service + // records. It can fail to register some records if it is + // forked multiple times in a row, probably because there is + // some race in sdptool or bluez when operated in parallel. + // As a workaround, delay 500ms between each fork of sdptool. + // TODO: Don't fork sdptool in order to regsiter service + // records, use a DBUS call instead. + switch (msg.arg1) { + case 1: + Log.d(TAG, "Registering hsag record"); SystemService.start("hsag"); + mHandler.sendMessageDelayed( + mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 2, -1), 500); + break; + case 2: + Log.d(TAG, "Registering hfag record"); SystemService.start("hfag"); + mHandler.sendMessageDelayed( + mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 3, -1), 500); + break; + case 3: + Log.d(TAG, "Registering opush record"); SystemService.start("opush"); + mHandler.sendMessageDelayed( + mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 4, -1), 500); + break; + case 4: + Log.d(TAG, "Registering pbap record"); SystemService.start("pbap"); + break; } break; case MESSAGE_FINISH_DISABLE: @@ -402,8 +430,8 @@ public class BluetoothService extends IBluetooth.Stub { } mIsDiscovering = false; mBondState.loadBondState(); - mHandler.sendMessageDelayed(mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS), - 3000); + mHandler.sendMessageDelayed( + mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 1, -1), 3000); // Log bluetooth on to battery stats. long ident = Binder.clearCallingIdentity(); |