From 047957b89c55719ab6840582e6efca6bebb891cd Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Tue, 22 Jul 2014 13:53:29 +0200 Subject: [PATCH] Bug 1038645: Asynchronous |BluetoothHandsfreeInterface::DeviceStatusNotification| (under bluetooth2/), r=btian --- .../bluedroid/BluetoothInterface.cpp | 14 +++++++---- dom/bluetooth2/bluedroid/BluetoothInterface.h | 7 +++--- .../bluedroid/hfp/BluetoothHfpManager.cpp | 23 ++++++++++++++----- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/dom/bluetooth2/bluedroid/BluetoothInterface.cpp b/dom/bluetooth2/bluedroid/BluetoothInterface.cpp index b3d8eb144730..d2dbedb6fb51 100644 --- a/dom/bluetooth2/bluedroid/BluetoothInterface.cpp +++ b/dom/bluetooth2/bluedroid/BluetoothInterface.cpp @@ -734,13 +734,19 @@ BluetoothHandsfreeInterface::VolumeControl( /* Device status */ -bt_status_t +void BluetoothHandsfreeInterface::DeviceStatusNotification( bthf_network_state_t aNtkState, bthf_service_type_t aSvcType, int aSignal, - int aBattChg) + int aBattChg, BluetoothHandsfreeResultHandler* aRes) { - return mInterface->device_status_notification(aNtkState, aSvcType, aSignal, - aBattChg); + bt_status_t status = mInterface->device_status_notification( + aNtkState, aSvcType, aSignal, aBattChg); + + if (aRes) { + DispatchBluetoothHandsfreeResult( + aRes, &BluetoothHandsfreeResultHandler::DeviceStatusNotification, + status); + } } /* Responses */ diff --git a/dom/bluetooth2/bluedroid/BluetoothInterface.h b/dom/bluetooth2/bluedroid/BluetoothInterface.h index b19706cda808..45e51a0dac92 100644 --- a/dom/bluetooth2/bluedroid/BluetoothInterface.h +++ b/dom/bluetooth2/bluedroid/BluetoothInterface.h @@ -139,9 +139,10 @@ public: /* Device status */ - bt_status_t DeviceStatusNotification(bthf_network_state_t aNtkState, - bthf_service_type_t aSvcType, - int aSignal, int aBattChg); + void DeviceStatusNotification(bthf_network_state_t aNtkState, + bthf_service_type_t aSvcType, + int aSignal, int aBattChg, + BluetoothHandsfreeResultHandler* aRes); /* Responses */ diff --git a/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.cpp b/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.cpp index dda22417e8fa..f76116e20011 100644 --- a/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.cpp +++ b/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.cpp @@ -1183,16 +1183,27 @@ BluetoothHfpManager::UpdatePhoneCIND(uint32_t aCallIndex) numActive, numHeld, callSetupState, number.get(), type)); } +class DeviceStatusNotificationResultHandler MOZ_FINAL +: public BluetoothHandsfreeResultHandler +{ +public: + void OnError(bt_status_t aStatus) MOZ_OVERRIDE + { + BT_WARNING( + "BluetoothHandsfreeInterface::DeviceStatusNotification failed: %d", + (int)aStatus); + } +}; + void BluetoothHfpManager::UpdateDeviceCIND() { if (sBluetoothHfpInterface) { - NS_ENSURE_TRUE_VOID(BT_STATUS_SUCCESS == - sBluetoothHfpInterface->DeviceStatusNotification( - (bthf_network_state_t) mService, - (bthf_service_type_t) mRoam, - mSignal, - mBattChg)); + sBluetoothHfpInterface->DeviceStatusNotification( + (bthf_network_state_t) mService, + (bthf_service_type_t) mRoam, + mSignal, + mBattChg, new DeviceStatusNotificationResultHandler()); } }