diff --git a/b2g/config/dolphin/sources.xml b/b2g/config/dolphin/sources.xml index 6d6d3ffdfd40..535d8c4ea793 100644 --- a/b2g/config/dolphin/sources.xml +++ b/b2g/config/dolphin/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index c08ff689c301..9977b4c82fde 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 94ab7da848ee..5fb63e75f54d 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + @@ -135,7 +135,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index dbf889f18652..fcb729c7f0bf 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator-l/sources.xml b/b2g/config/emulator-l/sources.xml index 89e976a401cd..e84b0c9066e4 100644 --- a/b2g/config/emulator-l/sources.xml +++ b/b2g/config/emulator-l/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index c08ff689c301..9977b4c82fde 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame-kk/sources.xml b/b2g/config/flame-kk/sources.xml index 1ed4c62fad48..fb1883eccc8b 100644 --- a/b2g/config/flame-kk/sources.xml +++ b/b2g/config/flame-kk/sources.xml @@ -15,7 +15,7 @@ - + @@ -146,7 +146,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index e6f8ede740bc..3801b7f5db7f 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + @@ -145,7 +145,7 @@ - + diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index c27dce3a0564..c0cfbd5a412d 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,9 +1,9 @@ { "git": { - "git_revision": "22230c9a340a0a2c3af73320cf47e1cb544517ad", + "git_revision": "7512026a377271a0cade12d70846557f0bc7781c", "remote": "https://git.mozilla.org/releases/gaia.git", "branch": "" }, - "revision": "298fece36f2564e042e347a48fcc104aca78e3b5", + "revision": "53713e514b92cccfd55404cebd2b627cb9804bc2", "repo_path": "integration/gaia-central" } diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index 546c83502748..0b5032842a65 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + @@ -130,7 +130,7 @@ - + diff --git a/b2g/config/nexus-5-l/sources.xml b/b2g/config/nexus-5-l/sources.xml index 532e88087776..a5e0b3d1bd19 100644 --- a/b2g/config/nexus-5-l/sources.xml +++ b/b2g/config/nexus-5-l/sources.xml @@ -15,7 +15,7 @@ - + @@ -141,7 +141,7 @@ - + @@ -157,5 +157,5 @@ - + diff --git a/dom/bluetooth/BluetoothInterfaceHelpers.cpp b/dom/bluetooth/BluetoothInterfaceHelpers.cpp new file mode 100644 index 000000000000..6ee75d0d9abe --- /dev/null +++ b/dom/bluetooth/BluetoothInterfaceHelpers.cpp @@ -0,0 +1,28 @@ +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "BluetoothInterfaceHelpers.h" + +BEGIN_BLUETOOTH_NAMESPACE + +// +// Conversion +// + +nsresult +Convert(nsresult aIn, BluetoothStatus& aOut) +{ + if (NS_SUCCEEDED(aIn)) { + aOut = STATUS_SUCCESS; + } else if (aIn == NS_ERROR_OUT_OF_MEMORY) { + aOut = STATUS_NOMEM; + } else { + aOut = STATUS_FAIL; + } + return NS_OK; +} + +END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/BluetoothInterfaceHelpers.h b/dom/bluetooth/BluetoothInterfaceHelpers.h index 6f33c703aca3..96c5a844eb79 100644 --- a/dom/bluetooth/BluetoothInterfaceHelpers.h +++ b/dom/bluetooth/BluetoothInterfaceHelpers.h @@ -12,6 +12,13 @@ BEGIN_BLUETOOTH_NAMESPACE +// +// Conversion +// + +nsresult +Convert(nsresult aIn, BluetoothStatus& aOut); + // // Result handling // @@ -49,6 +56,9 @@ public: static void Dispatch(Obj* aObj, Res (Obj::*aMethod)(), const InitOp& aInitOp) { + if (!aObj) { + return; // silently return if no result runnable has been given + } nsRefPtr runnable = Create(aObj, aMethod, aInitOp); if (!runnable) { BT_LOGR("BluetoothResultRunnable0::Create failed"); @@ -108,6 +118,9 @@ public: static void Dispatch(Obj* aObj, Res (Obj::*aMethod)(Arg1), const InitOp& aInitOp) { + if (!aObj) { + return; // silently return if no result runnable has been given + } nsRefPtr runnable = Create(aObj, aMethod, aInitOp); if (!runnable) { BT_LOGR("BluetoothResultRunnable1::Create failed"); @@ -174,6 +187,9 @@ public: Dispatch(Obj* aObj, Res (Obj::*aMethod)(Arg1, Arg2, Arg3), const InitOp& aInitOp) { + if (!aObj) { + return; // silently return if no result runnable has been given + } nsRefPtr runnable = Create(aObj, aMethod, aInitOp); if (!runnable) { BT_LOGR("BluetoothResultRunnable3::Create failed"); diff --git a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp index d7dcaf1b37b0..da76d630b360 100644 --- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp +++ b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp @@ -335,6 +335,9 @@ public: { BT_WARNING("BluetoothAvrcpInterface::Cleanup failed: %d", (int)aStatus); + + sBtAvrcpInterface = nullptr; + if (mRes) { if (aStatus == STATUS_UNSUPPORTED) { /* Not all versions of Bluedroid support AVRCP. So if the @@ -371,6 +374,9 @@ public: { BT_WARNING("BluetoothA2dpInterface::Cleanup failed: %d", (int)aStatus); + + sBtA2dpInterface = nullptr; + if (mRes) { mRes->OnError(NS_ERROR_FAILURE); } diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp index 93dfed534c20..162924623b8a 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp @@ -395,7 +395,7 @@ BluetoothDaemonA2dpInterface::Init( nsresult rv = mModule->RegisterModule(BluetoothDaemonA2dpModule::SERVICE_ID, 0x00, BluetoothDaemonA2dpModule::MAX_NUM_CLIENTS, res); if (NS_FAILED(rv) && aRes) { - DispatchError(aRes, STATUS_FAIL); + DispatchError(aRes, rv); } } @@ -443,8 +443,12 @@ void BluetoothDaemonA2dpInterface::Cleanup( BluetoothA2dpResultHandler* aRes) { - mModule->UnregisterModule(BluetoothDaemonA2dpModule::SERVICE_ID, - new CleanupResultHandler(mModule, aRes)); + nsresult rv = mModule->UnregisterModule( + BluetoothDaemonA2dpModule::SERVICE_ID, + new CleanupResultHandler(mModule, aRes)); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } /* Connect / Disconnect */ @@ -455,7 +459,10 @@ BluetoothDaemonA2dpInterface::Connect( { MOZ_ASSERT(mModule); - mModule->ConnectCmd(aBdAddr, aRes); + nsresult rv = mModule->ConnectCmd(aBdAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -464,7 +471,10 @@ BluetoothDaemonA2dpInterface::Disconnect( { MOZ_ASSERT(mModule); - mModule->DisconnectCmd(aBdAddr, aRes); + nsresult rv = mModule->DisconnectCmd(aBdAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -477,4 +487,16 @@ BluetoothDaemonA2dpInterface::DispatchError( ConstantInitOp1(aStatus)); } +void +BluetoothDaemonA2dpInterface::DispatchError( + BluetoothA2dpResultHandler* aRes, nsresult aRv) +{ + BluetoothStatus status; + + if (NS_WARN_IF(NS_FAILED(Convert(aRv, status)))) { + status = STATUS_FAIL; + } + DispatchError(aRes, status); +} + END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.h b/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.h index 6e63ac3a412a..0639b0bc7931 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.h @@ -155,6 +155,7 @@ public: private: void DispatchError(BluetoothA2dpResultHandler* aRes, BluetoothStatus aStatus); + void DispatchError(BluetoothA2dpResultHandler* aRes, nsresult aRv); BluetoothDaemonA2dpModule* mModule; }; diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp index bc154eea64f1..b8ee8f5afe70 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp @@ -893,7 +893,7 @@ BluetoothDaemonAvrcpInterface::Init( BluetoothDaemonAvrcpModule::MAX_NUM_CLIENTS, 0x00, res); if (NS_FAILED(rv) && aRes) { - DispatchError(aRes, STATUS_FAIL); + DispatchError(aRes, rv); } } @@ -943,8 +943,12 @@ BluetoothDaemonAvrcpInterface::Cleanup( { MOZ_ASSERT(mModule); - mModule->UnregisterModule(BluetoothDaemonAvrcpModule::SERVICE_ID, - new CleanupResultHandler(mModule, aRes)); + nsresult rv = mModule->UnregisterModule( + BluetoothDaemonAvrcpModule::SERVICE_ID, + new CleanupResultHandler(mModule, aRes)); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -954,7 +958,11 @@ BluetoothDaemonAvrcpInterface::GetPlayStatusRsp( { MOZ_ASSERT(mModule); - mModule->GetPlayStatusRspCmd(aPlayStatus, aSongLen, aSongPos, aRes); + nsresult rv = mModule->GetPlayStatusRspCmd(aPlayStatus, aSongLen, + aSongPos, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -964,7 +972,10 @@ BluetoothDaemonAvrcpInterface::ListPlayerAppAttrRsp( { MOZ_ASSERT(mModule); - mModule->ListPlayerAppAttrRspCmd(aNumAttr, aPAttrs, aRes); + nsresult rv = mModule->ListPlayerAppAttrRspCmd(aNumAttr, aPAttrs, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -973,7 +984,10 @@ BluetoothDaemonAvrcpInterface::ListPlayerAppValueRsp( { MOZ_ASSERT(mModule); - mModule->ListPlayerAppValueRspCmd(aNumVal, aPVals, aRes); + nsresult rv = mModule->ListPlayerAppValueRspCmd(aNumVal, aPVals, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -983,7 +997,11 @@ BluetoothDaemonAvrcpInterface::GetPlayerAppValueRsp( { MOZ_ASSERT(mModule); - mModule->GetPlayerAppValueRspCmd(aNumAttrs, aIds, aValues, aRes); + nsresult rv = mModule->GetPlayerAppValueRspCmd(aNumAttrs, aIds, + aValues, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -993,7 +1011,11 @@ BluetoothDaemonAvrcpInterface::GetPlayerAppAttrTextRsp( { MOZ_ASSERT(mModule); - mModule->GetPlayerAppAttrTextRspCmd(aNumAttr, aIds, aTexts, aRes); + nsresult rv = mModule->GetPlayerAppAttrTextRspCmd(aNumAttr, aIds, + aTexts, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -1003,7 +1025,11 @@ BluetoothDaemonAvrcpInterface::GetPlayerAppValueTextRsp( { MOZ_ASSERT(mModule); - mModule->GetPlayerAppValueTextRspCmd(aNumVal, aIds, aTexts, aRes); + nsresult rv = mModule->GetPlayerAppValueTextRspCmd(aNumVal, aIds, + aTexts, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -1013,7 +1039,10 @@ BluetoothDaemonAvrcpInterface::GetElementAttrRsp( { MOZ_ASSERT(mModule); - mModule->GetElementAttrRspCmd(aNumAttr, aAttr, aRes); + nsresult rv = mModule->GetElementAttrRspCmd(aNumAttr, aAttr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -1022,7 +1051,10 @@ BluetoothDaemonAvrcpInterface::SetPlayerAppValueRsp( { MOZ_ASSERT(mModule); - mModule->SetPlayerAppValueRspCmd(aRspStatus, aRes); + nsresult rv = mModule->SetPlayerAppValueRspCmd(aRspStatus, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -1034,7 +1066,11 @@ BluetoothDaemonAvrcpInterface::RegisterNotificationRsp( { MOZ_ASSERT(mModule); - mModule->RegisterNotificationRspCmd(aEvent, aType, aParam, aRes); + nsresult rv = mModule->RegisterNotificationRspCmd(aEvent, aType, + aParam, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -1043,7 +1079,10 @@ BluetoothDaemonAvrcpInterface::SetVolume( { MOZ_ASSERT(mModule); - mModule->SetVolumeCmd(aVolume, aRes); + nsresult rv = mModule->SetVolumeCmd(aVolume, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -1056,4 +1095,16 @@ BluetoothDaemonAvrcpInterface::DispatchError( ConstantInitOp1(aStatus)); } +void +BluetoothDaemonAvrcpInterface::DispatchError( + BluetoothAvrcpResultHandler* aRes, nsresult aRv) +{ + BluetoothStatus status; + + if (NS_WARN_IF(NS_FAILED(Convert(aRv, status)))) { + status = STATUS_FAIL; + } + DispatchError(aRes, status); +} + END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.h b/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.h index 3fa61cf0a175..f52f76312f4e 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.h @@ -346,6 +346,7 @@ public: private: void DispatchError(BluetoothAvrcpResultHandler* aRes, BluetoothStatus aStatus); + void DispatchError(BluetoothAvrcpResultHandler* aRes, nsresult aRv); BluetoothDaemonAvrcpModule* mModule; }; diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.cpp index 161bfa3817ba..9b42173268b4 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.cpp @@ -1512,7 +1512,7 @@ BluetoothDaemonHandsfreeInterface::Init( aMaxNumClients, res); if (NS_FAILED(rv) && aRes) { - DispatchError(aRes, STATUS_FAIL); + DispatchError(aRes, rv); } } @@ -1532,6 +1532,7 @@ public: { MOZ_ASSERT(NS_IsMainThread()); + BT_LOGR("%s:%d", __func__, __LINE__); if (mRes) { mRes->OnError(aStatus); } @@ -1541,6 +1542,7 @@ public: { MOZ_ASSERT(NS_IsMainThread()); + BT_LOGR("%s:%d", __func__, __LINE__); // Clear notification handler _after_ module has been // unregistered. While unregistering the module, we might // still receive notifications. @@ -1560,8 +1562,14 @@ void BluetoothDaemonHandsfreeInterface::Cleanup( BluetoothHandsfreeResultHandler* aRes) { - mModule->UnregisterModule(BluetoothDaemonHandsfreeModule::SERVICE_ID, - new CleanupResultHandler(mModule, aRes)); + BT_LOGR("%s:%d", __func__, __LINE__); + nsresult rv = mModule->UnregisterModule( + BluetoothDaemonHandsfreeModule::SERVICE_ID, + new CleanupResultHandler(mModule, aRes)); + BT_LOGR("%s:%d", __func__, __LINE__); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } /* Connect / Disconnect */ @@ -1572,7 +1580,10 @@ BluetoothDaemonHandsfreeInterface::Connect( { MOZ_ASSERT(mModule); - mModule->ConnectCmd(aBdAddr, aRes); + nsresult rv = mModule->ConnectCmd(aBdAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -1581,7 +1592,10 @@ BluetoothDaemonHandsfreeInterface::Disconnect( { MOZ_ASSERT(mModule); - mModule->DisconnectCmd(aBdAddr, aRes); + nsresult rv = mModule->DisconnectCmd(aBdAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -1590,7 +1604,10 @@ BluetoothDaemonHandsfreeInterface::ConnectAudio( { MOZ_ASSERT(mModule); - mModule->ConnectAudioCmd(aBdAddr, aRes); + nsresult rv = mModule->ConnectAudioCmd(aBdAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -1599,7 +1616,10 @@ BluetoothDaemonHandsfreeInterface::DisconnectAudio( { MOZ_ASSERT(mModule); - mModule->DisconnectAudioCmd(aBdAddr, aRes); + nsresult rv = mModule->DisconnectAudioCmd(aBdAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } /* Voice Recognition */ @@ -1610,7 +1630,10 @@ BluetoothDaemonHandsfreeInterface::StartVoiceRecognition( { MOZ_ASSERT(mModule); - mModule->StartVoiceRecognitionCmd(aBdAddr, aRes); + nsresult rv = mModule->StartVoiceRecognitionCmd(aBdAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -1619,7 +1642,10 @@ BluetoothDaemonHandsfreeInterface::StopVoiceRecognition( { MOZ_ASSERT(mModule); - mModule->StopVoiceRecognitionCmd(aBdAddr, aRes); + nsresult rv = mModule->StopVoiceRecognitionCmd(aBdAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } /* Volume */ @@ -1631,7 +1657,10 @@ BluetoothDaemonHandsfreeInterface::VolumeControl( { MOZ_ASSERT(mModule); - mModule->VolumeControlCmd(aType, aVolume, aBdAddr, aRes); + nsresult rv = mModule->VolumeControlCmd(aType, aVolume, aBdAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } /* Device status */ @@ -1644,8 +1673,12 @@ BluetoothDaemonHandsfreeInterface::DeviceStatusNotification( { MOZ_ASSERT(mModule); - mModule->DeviceStatusNotificationCmd(aNtkState, aSvcType, aSignal, - aBattChg, aRes); + nsresult rv = mModule->DeviceStatusNotificationCmd(aNtkState, aSvcType, + aSignal, aBattChg, + aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } /* Responses */ @@ -1657,7 +1690,10 @@ BluetoothDaemonHandsfreeInterface::CopsResponse( { MOZ_ASSERT(mModule); - mModule->CopsResponseCmd(aCops, aBdAddr, aRes); + nsresult rv = mModule->CopsResponseCmd(aCops, aBdAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -1669,8 +1705,12 @@ BluetoothDaemonHandsfreeInterface::CindResponse( { MOZ_ASSERT(mModule); - mModule->CindResponseCmd(aSvc, aNumActive, aNumHeld, aCallSetupState, - aSignal, aRoam, aBattChg, aBdAddr, aRes); + nsresult rv = mModule->CindResponseCmd(aSvc, aNumActive, aNumHeld, + aCallSetupState, aSignal, + aRoam, aBattChg, aBdAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -1680,7 +1720,10 @@ BluetoothDaemonHandsfreeInterface::FormattedAtResponse( { MOZ_ASSERT(mModule); - mModule->FormattedAtResponseCmd(aRsp, aBdAddr, aRes); + nsresult rv = mModule->FormattedAtResponseCmd(aRsp, aBdAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -1690,7 +1733,11 @@ BluetoothDaemonHandsfreeInterface::AtResponse( { MOZ_ASSERT(mModule); - mModule->AtResponseCmd(aResponseCode, aErrorCode, aBdAddr, aRes); + nsresult rv = mModule->AtResponseCmd(aResponseCode, aErrorCode, + aBdAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -1706,8 +1753,11 @@ BluetoothDaemonHandsfreeInterface::ClccResponse( { MOZ_ASSERT(mModule); - mModule->ClccResponseCmd(aIndex, aDir, aState, aMode, aMpty, aNumber, - aType, aBdAddr, aRes); + nsresult rv = mModule->ClccResponseCmd(aIndex, aDir, aState, aMode, aMpty, + aNumber, aType, aBdAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } /* Phone State */ @@ -1722,8 +1772,12 @@ BluetoothDaemonHandsfreeInterface::PhoneStateChange( { MOZ_ASSERT(mModule); - mModule->PhoneStateChangeCmd(aNumActive, aNumHeld, aCallSetupState, aNumber, - aType, aRes); + nsresult rv = mModule->PhoneStateChangeCmd(aNumActive, aNumHeld, + aCallSetupState, aNumber, + aType, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } /* Wide Band Speech */ @@ -1735,7 +1789,10 @@ BluetoothDaemonHandsfreeInterface::ConfigureWbs( { MOZ_ASSERT(mModule); - mModule->ConfigureWbsCmd(aBdAddr, aConfig, aRes); + nsresult rv = mModule->ConfigureWbsCmd(aBdAddr, aConfig, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -1748,4 +1805,16 @@ BluetoothDaemonHandsfreeInterface::DispatchError( ConstantInitOp1(aStatus)); } +void +BluetoothDaemonHandsfreeInterface::DispatchError( + BluetoothHandsfreeResultHandler* aRes, nsresult aRv) +{ + BluetoothStatus status; + + if (NS_WARN_IF(NS_FAILED(Convert(aRv, status)))) { + status = STATUS_FAIL; + } + DispatchError(aRes, status); +} + END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.h b/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.h index 5b6c897301d5..e52e342ff65d 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothDaemonHandsfreeInterface.h @@ -472,6 +472,7 @@ public: private: void DispatchError(BluetoothHandsfreeResultHandler* aRes, BluetoothStatus aStatus); + void DispatchError(BluetoothHandsfreeResultHandler* aRes, nsresult aRv); BluetoothDaemonHandsfreeModule* mModule; }; diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp index 7c41a8ef6444..05740fd40909 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp @@ -1893,7 +1893,15 @@ void BluetoothDaemonInterface::OnDisconnect(enum Channel aChannel) { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(!mResultHandlerQ.IsEmpty()); + + if (mResultHandlerQ.IsEmpty()) { + if (sNotificationHandler) { + // Bluetooth daemon crashed; clear state + sNotificationHandler->AdapterStateChangedNotification(false); + sNotificationHandler = nullptr; + } + return; + } switch (aChannel) { case CMD_CHANNEL: @@ -2194,19 +2202,31 @@ BluetoothDaemonInterface::Cleanup(BluetoothResultHandler* aRes) mResultHandlerQ.AppendElement(aRes); // Cleanup, step 1: Unregister Socket module - mProtocol->UnregisterModuleCmd(0x02, new CleanupResultHandler(this)); + nsresult rv = mProtocol->UnregisterModuleCmd( + 0x02, new CleanupResultHandler(this)); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void BluetoothDaemonInterface::Enable(BluetoothResultHandler* aRes) { - static_cast(mProtocol)->EnableCmd(aRes); + nsresult rv = + static_cast(mProtocol)->EnableCmd(aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void BluetoothDaemonInterface::Disable(BluetoothResultHandler* aRes) { - static_cast(mProtocol)->DisableCmd(aRes); + nsresult rv = + static_cast(mProtocol)->DisableCmd(aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } /* Adapter Properties */ @@ -2214,24 +2234,33 @@ BluetoothDaemonInterface::Disable(BluetoothResultHandler* aRes) void BluetoothDaemonInterface::GetAdapterProperties(BluetoothResultHandler* aRes) { - static_cast + nsresult rv = static_cast (mProtocol)->GetAdapterPropertiesCmd(aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void BluetoothDaemonInterface::GetAdapterProperty(const nsAString& aName, BluetoothResultHandler* aRes) { - static_cast + nsresult rv = static_cast (mProtocol)->GetAdapterPropertyCmd(aName, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void BluetoothDaemonInterface::SetAdapterProperty( const BluetoothNamedValue& aProperty, BluetoothResultHandler* aRes) { - static_cast + nsresult rv = static_cast (mProtocol)->SetAdapterPropertyCmd(aProperty, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } /* Remote Device Properties */ @@ -2240,8 +2269,11 @@ void BluetoothDaemonInterface::GetRemoteDeviceProperties( const nsAString& aRemoteAddr, BluetoothResultHandler* aRes) { - static_cast + nsresult rv = static_cast (mProtocol)->GetRemoteDevicePropertiesCmd(aRemoteAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -2249,8 +2281,11 @@ BluetoothDaemonInterface::GetRemoteDeviceProperty( const nsAString& aRemoteAddr, const nsAString& aName, BluetoothResultHandler* aRes) { - static_cast + nsresult rv = static_cast (mProtocol)->GetRemoteDevicePropertyCmd(aRemoteAddr, aName, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -2258,8 +2293,11 @@ BluetoothDaemonInterface::SetRemoteDeviceProperty( const nsAString& aRemoteAddr, const BluetoothNamedValue& aProperty, BluetoothResultHandler* aRes) { - static_cast + nsresult rv = static_cast (mProtocol)->SetRemoteDevicePropertyCmd(aRemoteAddr, aProperty, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } /* Remote Services */ @@ -2269,16 +2307,22 @@ BluetoothDaemonInterface::GetRemoteServiceRecord(const nsAString& aRemoteAddr, const uint8_t aUuid[16], BluetoothResultHandler* aRes) { - static_cast( - mProtocol)->GetRemoteServiceRecordCmd(aRemoteAddr, aUuid, aRes); + nsresult rv = static_cast + (mProtocol)->GetRemoteServiceRecordCmd(aRemoteAddr, aUuid, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void BluetoothDaemonInterface::GetRemoteServices(const nsAString& aRemoteAddr, BluetoothResultHandler* aRes) { - static_cast( - mProtocol)->GetRemoteServicesCmd(aRemoteAddr, aRes); + nsresult rv = static_cast + (mProtocol)->GetRemoteServicesCmd(aRemoteAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } /* Discovery */ @@ -2286,14 +2330,21 @@ BluetoothDaemonInterface::GetRemoteServices(const nsAString& aRemoteAddr, void BluetoothDaemonInterface::StartDiscovery(BluetoothResultHandler* aRes) { - static_cast(mProtocol)->StartDiscoveryCmd(aRes); + nsresult rv = static_cast + (mProtocol)->StartDiscoveryCmd(aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void BluetoothDaemonInterface::CancelDiscovery(BluetoothResultHandler* aRes) { - static_cast + nsresult rv = static_cast (mProtocol)->CancelDiscoveryCmd(aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } /* Bonds */ @@ -2303,24 +2354,33 @@ BluetoothDaemonInterface::CreateBond(const nsAString& aBdAddr, BluetoothTransport aTransport, BluetoothResultHandler* aRes) { - static_cast + nsresult rv = static_cast (mProtocol)->CreateBondCmd(aBdAddr, aTransport, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void BluetoothDaemonInterface::RemoveBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes) { - static_cast + nsresult rv = static_cast (mProtocol)->RemoveBondCmd(aBdAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void BluetoothDaemonInterface::CancelBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes) { - static_cast + nsresult rv = static_cast (mProtocol)->CancelBondCmd(aBdAddr, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } /* Connection */ @@ -2339,8 +2399,11 @@ BluetoothDaemonInterface::PinReply(const nsAString& aBdAddr, bool aAccept, const nsAString& aPinCode, BluetoothResultHandler* aRes) { - static_cast + nsresult rv = static_cast (mProtocol)->PinReplyCmd(aBdAddr, aAccept, aPinCode, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -2349,8 +2412,11 @@ BluetoothDaemonInterface::SspReply(const nsAString& aBdAddr, bool aAccept, uint32_t aPasskey, BluetoothResultHandler* aRes) { - static_cast + nsresult rv = static_cast (mProtocol)->SspReplyCmd(aBdAddr, aVariant, aAccept, aPasskey, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } /* DUT Mode */ @@ -2359,8 +2425,11 @@ void BluetoothDaemonInterface::DutModeConfigure(bool aEnable, BluetoothResultHandler* aRes) { - static_cast + nsresult rv = static_cast (mProtocol)->DutModeConfigureCmd(aEnable, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -2368,8 +2437,11 @@ BluetoothDaemonInterface::DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen, BluetoothResultHandler* aRes) { - static_cast + nsresult rv = static_cast (mProtocol)->DutModeSendCmd(aOpcode, aBuf, aLen, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } /* LE Mode */ @@ -2379,8 +2451,11 @@ BluetoothDaemonInterface::LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen, BluetoothResultHandler* aRes) { - static_cast + nsresult rv = static_cast (mProtocol)->LeTestModeCmd(aOpcode, aBuf, aLen, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } /* Energy Information */ @@ -2401,6 +2476,18 @@ BluetoothDaemonInterface::DispatchError(BluetoothResultHandler* aRes, ConstantInitOp1(aStatus)); } +void +BluetoothDaemonInterface::DispatchError(BluetoothResultHandler* aRes, + nsresult aRv) +{ + BluetoothStatus status; + + if (NS_WARN_IF(NS_FAILED(Convert(aRv, status)))) { + status = STATUS_FAIL; + } + DispatchError(aRes, status); +} + // Profile Interfaces // diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.h b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.h index 8201e5e49917..b68e3f175073 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.h @@ -135,6 +135,7 @@ protected: private: void DispatchError(BluetoothResultHandler* aRes, BluetoothStatus aStatus); + void DispatchError(BluetoothResultHandler* aRes, nsresult aRv); nsCString mListenSocketName; nsRefPtr mListenSocket; diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp index b293e9dd5d75..4142f37ffd19 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp @@ -315,8 +315,11 @@ BluetoothDaemonSocketInterface::Listen(BluetoothSocketType aType, { MOZ_ASSERT(mModule); - mModule->ListenCmd(aType, aServiceName, aServiceUuid, aChannel, - aEncrypt, aAuth, aRes); + nsresult rv = mModule->ListenCmd(aType, aServiceName, aServiceUuid, + aChannel, aEncrypt, aAuth, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -329,7 +332,11 @@ BluetoothDaemonSocketInterface::Connect(const nsAString& aBdAddr, { MOZ_ASSERT(mModule); - mModule->ConnectCmd(aBdAddr, aType, aUuid, aChannel, aEncrypt, aAuth, aRes); + nsresult rv = mModule->ConnectCmd(aBdAddr, aType, aUuid, aChannel, + aEncrypt, aAuth, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -338,7 +345,10 @@ BluetoothDaemonSocketInterface::Accept(int aFd, { MOZ_ASSERT(mModule); - mModule->AcceptCmd(aFd, aRes); + nsresult rv = mModule->AcceptCmd(aFd, aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } } void @@ -346,7 +356,32 @@ BluetoothDaemonSocketInterface::Close(BluetoothSocketResultHandler* aRes) { MOZ_ASSERT(mModule); - mModule->CloseCmd(aRes); + nsresult rv = mModule->CloseCmd(aRes); + if (NS_FAILED(rv)) { + DispatchError(aRes, rv); + } +} + +void +BluetoothDaemonSocketInterface::DispatchError( + BluetoothSocketResultHandler* aRes, BluetoothStatus aStatus) +{ + BluetoothResultRunnable1::Dispatch( + aRes, &BluetoothSocketResultHandler::OnError, + ConstantInitOp1(aStatus)); +} + +void +BluetoothDaemonSocketInterface::DispatchError( + BluetoothSocketResultHandler* aRes, nsresult aRv) +{ + BluetoothStatus status; + + if (NS_WARN_IF(NS_FAILED(Convert(aRv, status)))) { + status = STATUS_FAIL; + } + DispatchError(aRes, status); } END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.h b/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.h index cda13c52774e..d92a88acac3d 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.h @@ -113,6 +113,10 @@ public: void Close(BluetoothSocketResultHandler* aRes); private: + void DispatchError(BluetoothSocketResultHandler* aRes, + BluetoothStatus aStatus); + void DispatchError(BluetoothSocketResultHandler* aRes, nsresult aRv); + BluetoothDaemonSocketModule* mModule; }; diff --git a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp index b6fd6af1e357..ad99b53d0c07 100644 --- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp +++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp @@ -310,7 +310,8 @@ public: BT_LOGR("BluetoothInterface::Disable failed: %d", aStatus); - BluetoothService::AcknowledgeToggleBt(true); + // Always make progress; even on failures + BluetoothService::AcknowledgeToggleBt(false); } }; diff --git a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp index e36add11e458..db9cfc08a517 100644 --- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp +++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp @@ -432,6 +432,9 @@ public: void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothHandsfreeInterface::Cleanup failed: %d", (int)aStatus); + + sBluetoothHfpInterface = nullptr; + if (mRes) { mRes->OnError(NS_ERROR_FAILURE); } diff --git a/dom/bluetooth/moz.build b/dom/bluetooth/moz.build index 63a60168541b..15e9c8eb0017 100644 --- a/dom/bluetooth/moz.build +++ b/dom/bluetooth/moz.build @@ -10,6 +10,7 @@ if CONFIG['MOZ_B2G_BT']: 'BluetoothDevice.cpp', 'BluetoothHidManager.cpp', 'BluetoothInterface.cpp', + 'BluetoothInterfaceHelpers.cpp', 'BluetoothManager.cpp', 'BluetoothProfileController.cpp', 'BluetoothPropertyContainer.cpp', diff --git a/testing/taskcluster/tasks/branches/b2g-inbound/job_flags.yml b/testing/taskcluster/tasks/branches/b2g-inbound/job_flags.yml new file mode 100644 index 000000000000..6fa387a9e9b2 --- /dev/null +++ b/testing/taskcluster/tasks/branches/b2g-inbound/job_flags.yml @@ -0,0 +1,35 @@ +--- +# For complete sample of all build and test jobs, +# see /testing/taskcluster/tasks/job_flags.yml + +$inherits: + from: tasks/branches/base_job_flags.yml + +builds: + flame-kk: + platforms: + - b2g + types: + opt: + task: tasks/builds/b2g_flame_kk_opt.yml + flame-kk-eng: + platforms: + - b2g + types: + opt: + task: tasks/builds/b2g_flame_kk_eng.yml + +tests: + gaia-build: + allowed_build_tasks: + tasks/builds/b2g_flame_kk_opt.yml: + task: tasks/tests/b2g_build_test.yml + tasks/builds/b2g_flame_kk_eng.yml: + task: tasks/tests/b2g_build_test.yml + gaia-linter: + allowed_build_tasks: + tasks/builds/b2g_flame_kk_opt.yml: + task: tasks/tests/b2g_linter.yml + tasks/builds/b2g_flame_kk_eng.yml: + task: tasks/tests/b2g_linter.yml + diff --git a/testing/taskcluster/tasks/branches/cypress/job_flags.yml b/testing/taskcluster/tasks/branches/cypress/job_flags.yml new file mode 100644 index 000000000000..6fa387a9e9b2 --- /dev/null +++ b/testing/taskcluster/tasks/branches/cypress/job_flags.yml @@ -0,0 +1,35 @@ +--- +# For complete sample of all build and test jobs, +# see /testing/taskcluster/tasks/job_flags.yml + +$inherits: + from: tasks/branches/base_job_flags.yml + +builds: + flame-kk: + platforms: + - b2g + types: + opt: + task: tasks/builds/b2g_flame_kk_opt.yml + flame-kk-eng: + platforms: + - b2g + types: + opt: + task: tasks/builds/b2g_flame_kk_eng.yml + +tests: + gaia-build: + allowed_build_tasks: + tasks/builds/b2g_flame_kk_opt.yml: + task: tasks/tests/b2g_build_test.yml + tasks/builds/b2g_flame_kk_eng.yml: + task: tasks/tests/b2g_build_test.yml + gaia-linter: + allowed_build_tasks: + tasks/builds/b2g_flame_kk_opt.yml: + task: tasks/tests/b2g_linter.yml + tasks/builds/b2g_flame_kk_eng.yml: + task: tasks/tests/b2g_linter.yml +