diff --git a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp index f8337efb7262..52797895ce55 100644 --- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp +++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp @@ -318,10 +318,7 @@ public: BT_LOGR("BluetoothInterface::Enable failed: %d", aStatus); - nsRefPtr runnable = new BluetoothService::ToggleBtAck(false); - if (NS_FAILED(NS_DispatchToMainThread(runnable))) { - BT_WARNING("Failed to dispatch to main thread!"); - } + BluetoothService::AcknowledgeToggleBt(false); } }; @@ -394,10 +391,7 @@ public: sBtInterface = nullptr; - nsRefPtr runnable = new BluetoothService::ToggleBtAck(false); - if (NS_FAILED(NS_DispatchToMainThread(runnable))) { - BT_WARNING("Failed to dispatch to main thread!"); - } + BluetoothService::AcknowledgeToggleBt(false); } }; @@ -413,10 +407,7 @@ BluetoothServiceBluedroid::StartGonkBluetooth() if (bs->IsEnabled()) { // Keep current enable status - nsRefPtr runnable = new BluetoothService::ToggleBtAck(true); - if (NS_FAILED(NS_DispatchToMainThread(runnable))) { - BT_WARNING("Failed to dispatch to main thread!"); - } + BluetoothService::AcknowledgeToggleBt(true); return NS_OK; } @@ -436,10 +427,7 @@ public: BT_LOGR("BluetoothInterface::Disable failed: %d", aStatus); - nsRefPtr runnable = new BluetoothService::ToggleBtAck(true); - if (NS_FAILED(NS_DispatchToMainThread(runnable))) { - BT_WARNING("Failed to dispatch to main thread!"); - } + BluetoothService::AcknowledgeToggleBt(true); } }; @@ -455,10 +443,7 @@ BluetoothServiceBluedroid::StopGonkBluetooth() if (!bs->IsEnabled()) { // Keep current enable status - nsRefPtr runnable = new BluetoothService::ToggleBtAck(false); - if (NS_FAILED(NS_DispatchToMainThread(runnable))) { - BT_WARNING("Failed to dispatch to main thread!"); - } + BluetoothService::AcknowledgeToggleBt(false); return NS_OK; } @@ -518,11 +503,7 @@ BluetoothServiceBluedroid::StartInternal() nsresult ret = StartGonkBluetooth(); if (NS_FAILED(ret)) { - nsRefPtr runnable = - new BluetoothService::ToggleBtAck(false); - if (NS_FAILED(NS_DispatchToMainThread(runnable))) { - BT_WARNING("Failed to dispatch to main thread!"); - } + BluetoothService::AcknowledgeToggleBt(false); BT_LOGR("Error"); } @@ -536,11 +517,7 @@ BluetoothServiceBluedroid::StopInternal() nsresult ret = StopGonkBluetooth(); if (NS_FAILED(ret)) { - nsRefPtr runnable = - new BluetoothService::ToggleBtAck(true); - if (NS_FAILED(NS_DispatchToMainThread(runnable))) { - BT_WARNING("Failed to dispatch to main thread!"); - } + BluetoothService::AcknowledgeToggleBt(true); BT_LOGR("Error"); }