diff --git a/dom/bluetooth/bluedroid/BluetoothInterface.cpp b/dom/bluetooth/bluedroid/BluetoothInterface.cpp index d7cfe29903e0..1c9ebeb562e1 100644 --- a/dom/bluetooth/bluedroid/BluetoothInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothInterface.cpp @@ -2302,7 +2302,7 @@ struct BluetoothHandsfreeCallback } static void - KeyPressedCallback() + KeyPressed() { KeyPressedNotification::Dispatch( &BluetoothHandsfreeNotificationHandler::KeyPressedNotification); @@ -2323,10 +2323,33 @@ BluetoothHandsfreeInterface::~BluetoothHandsfreeInterface() { } void -BluetoothHandsfreeInterface::Init(bthf_callbacks_t* aCallbacks, - BluetoothHandsfreeResultHandler* aRes) +BluetoothHandsfreeInterface::Init( + BluetoothHandsfreeNotificationHandler* aNotificationHandler, + BluetoothHandsfreeResultHandler* aRes) { - bt_status_t status = mInterface->init(aCallbacks); + static bthf_callbacks_t sCallbacks = { + .size = sizeof(sCallbacks), + .connection_state_cb = BluetoothHandsfreeCallback::ConnectionState, + .audio_state_cb = BluetoothHandsfreeCallback::AudioState, + .vr_cmd_cb = BluetoothHandsfreeCallback::VoiceRecognition, + .answer_call_cmd_cb = BluetoothHandsfreeCallback::AnswerCall, + .hangup_call_cmd_cb = BluetoothHandsfreeCallback::HangupCall, + .volume_cmd_cb = BluetoothHandsfreeCallback::Volume, + .dial_call_cmd_cb = BluetoothHandsfreeCallback::DialCall, + .dtmf_cmd_cb = BluetoothHandsfreeCallback::Dtmf, + .nrec_cmd_cb = BluetoothHandsfreeCallback::NoiseReductionEchoCancellation, + .chld_cmd_cb = BluetoothHandsfreeCallback::CallHold, + .cnum_cmd_cb = BluetoothHandsfreeCallback::Cnum, + .cind_cmd_cb = BluetoothHandsfreeCallback::Cind, + .cops_cmd_cb = BluetoothHandsfreeCallback::Cops, + .clcc_cmd_cb = BluetoothHandsfreeCallback::Clcc, + .unknown_at_cmd_cb = BluetoothHandsfreeCallback::UnknownAt, + .key_pressed_cmd_cb = BluetoothHandsfreeCallback::KeyPressed + }; + + sHandsfreeNotificationHandler = aNotificationHandler; + + bt_status_t status = mInterface->init(&sCallbacks); if (aRes) { DispatchBluetoothHandsfreeResult(aRes, diff --git a/dom/bluetooth/bluedroid/BluetoothInterface.h b/dom/bluetooth/bluedroid/BluetoothInterface.h index 3a9fe874f93c..2b04fb144713 100644 --- a/dom/bluetooth/bluedroid/BluetoothInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothInterface.h @@ -193,7 +193,7 @@ class BluetoothHandsfreeInterface public: friend class BluetoothInterface; - void Init(bthf_callbacks_t* aCallbacks, + void Init(BluetoothHandsfreeNotificationHandler* aNotificationHandler, BluetoothHandsfreeResultHandler* aRes); void Cleanup(BluetoothHandsfreeResultHandler* aRes); diff --git a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp index 6b596c170d84..d871ce40d321 100644 --- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp +++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp @@ -475,7 +475,9 @@ public: void RunInit() { - mInterface->Init(&sBluetoothHfpCallbacks, this); + BluetoothHfpManager* hfpManager = BluetoothHfpManager::Get(); + + mInterface->Init(hfpManager, this); } private: