diff options
author | Nick Pelly <npelly@google.com> | 2009-10-12 11:11:38 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-10-12 11:11:38 -0700 |
commit | 77df9d6e0ca56a34c66a1e30e9696085ddbd9038 (patch) | |
tree | ba59173dbb132df09cac6cbcfa28378a38fa57f6 /core/java/android/server/BluetoothService.java | |
parent | 7fa610638b09f2a4a29d7df1b16d2fe686b5e5e6 (diff) | |
parent | d301c90446644f63cda9b9263f83332676065bb4 (diff) | |
download | frameworks_base-77df9d6e0ca56a34c66a1e30e9696085ddbd9038.zip frameworks_base-77df9d6e0ca56a34c66a1e30e9696085ddbd9038.tar.gz frameworks_base-77df9d6e0ca56a34c66a1e30e9696085ddbd9038.tar.bz2 |
am d301c904: Merge change I305c181c into eclair
Merge commit 'd301c90446644f63cda9b9263f83332676065bb4' into eclair-mr2
* commit 'd301c90446644f63cda9b9263f83332676065bb4':
Delay 500ms between each registering each SDP record using sdptool.
Diffstat (limited to 'core/java/android/server/BluetoothService.java')
-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 f0bd249..0db29a4 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(); |