Bug 1053804: Use Bluetooth Handsfree notifications, r=shuang

This patch replaces Handsfree callbacks by notifications. One
important change is that the first call to |BluetoothHandsfreeManager::Get|
now happens during initialization. Hence the Handsfree manager is now setup
immediately, instead of later at use.
This commit is contained in:
Thomas Zimmermann 2014-08-21 10:10:38 +02:00
Родитель 7b23e8dfad
Коммит 6246668276
3 изменённых файлов: 31 добавлений и 6 удалений

Просмотреть файл

@ -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,

Просмотреть файл

@ -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);

Просмотреть файл

@ -475,7 +475,9 @@ public:
void RunInit()
{
mInterface->Init(&sBluetoothHfpCallbacks, this);
BluetoothHfpManager* hfpManager = BluetoothHfpManager::Get();
mInterface->Init(hfpManager, this);
}
private: