Backed out changeset 9302086dcead (bug 920551)
authorEd Morley <emorley@mozilla.com>
Fri, 25 Oct 2013 10:52:17 +0100
changeset 166951 5bebff43ffbdc595d0ef5d93053c6c0e8e58a7c2
parent 166950 71f7ca5ba7f85ee1e5cef7b9d03f0740aa2e4543
child 166952 ab8db0fa3da7d0931794932c0c9153e45bf6908c
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs920551
milestone27.0a1
backs out9302086dcead5bd88b6968aca824963a178d9093
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 9302086dcead (bug 920551)
dom/bluetooth/BluetoothAdapter.cpp
dom/bluetooth/BluetoothHfpManager.cpp
dom/bluetooth/BluetoothHfpManager.h
dom/bluetooth/BluetoothService.h
dom/bluetooth/ipc/BluetoothParent.cpp
dom/bluetooth/ipc/BluetoothParent.h
dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
dom/bluetooth/ipc/BluetoothServiceChildProcess.h
dom/bluetooth/linux/BluetoothDBusService.cpp
dom/bluetooth/linux/BluetoothDBusService.h
--- a/dom/bluetooth/BluetoothAdapter.cpp
+++ b/dom/bluetooth/BluetoothAdapter.cpp
@@ -876,17 +876,16 @@ BluetoothAdapter::IsScoConnected(ErrorRe
   bs->IsScoConnected(results);
 
   return request.forget();
 }
 
 already_AddRefed<DOMRequest>
 BluetoothAdapter::AnswerWaitingCall(ErrorResult& aRv)
 {
-#ifdef MOZ_B2G_RIL
   nsCOMPtr<nsPIDOMWindow> win = GetOwner();
   if (!win) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   nsRefPtr<DOMRequest> request = new DOMRequest(win);
   nsRefPtr<BluetoothVoidReplyRunnable> results =
@@ -895,26 +894,21 @@ BluetoothAdapter::AnswerWaitingCall(Erro
   BluetoothService* bs = BluetoothService::Get();
   if (!bs) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
   bs->AnswerWaitingCall(results);
 
   return request.forget();
-#else
-  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
-  return nullptr;
-#endif // MOZ_B2G_RIL
 }
 
 already_AddRefed<DOMRequest>
 BluetoothAdapter::IgnoreWaitingCall(ErrorResult& aRv)
 {
-#ifdef MOZ_B2G_RIL
   nsCOMPtr<nsPIDOMWindow> win = GetOwner();
   if (!win) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   nsRefPtr<DOMRequest> request = new DOMRequest(win);
   nsRefPtr<BluetoothVoidReplyRunnable> results =
@@ -923,26 +917,21 @@ BluetoothAdapter::IgnoreWaitingCall(Erro
   BluetoothService* bs = BluetoothService::Get();
   if (!bs) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
   bs->IgnoreWaitingCall(results);
 
   return request.forget();
-#else
-  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
-  return nullptr;
-#endif // MOZ_B2G_RIL
 }
 
 already_AddRefed<DOMRequest>
 BluetoothAdapter::ToggleCalls(ErrorResult& aRv)
 {
-#ifdef MOZ_B2G_RIL
   nsCOMPtr<nsPIDOMWindow> win = GetOwner();
   if (!win) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   nsRefPtr<DOMRequest> request = new DOMRequest(win);
   nsRefPtr<BluetoothVoidReplyRunnable> results =
@@ -951,20 +940,16 @@ BluetoothAdapter::ToggleCalls(ErrorResul
   BluetoothService* bs = BluetoothService::Get();
   if (!bs) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
   bs->ToggleCalls(results);
 
   return request.forget();
-#else
-  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
-  return nullptr;
-#endif // MOZ_B2G_RIL
 }
 
 already_AddRefed<DOMRequest>
 BluetoothAdapter::SendMediaMetaData(const MediaMetaData& aMediaMetaData, ErrorResult& aRv)
 {
   nsCOMPtr<nsPIDOMWindow> win = GetOwner();
   if (!win) {
     aRv.Throw(NS_ERROR_FAILURE);
--- a/dom/bluetooth/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/BluetoothHfpManager.cpp
@@ -10,92 +10,82 @@
 
 #include "BluetoothProfileController.h"
 #include "BluetoothReplyRunnable.h"
 #include "BluetoothService.h"
 #include "BluetoothSocket.h"
 #include "BluetoothUtils.h"
 #include "BluetoothUuid.h"
 
-#include "jsapi.h"
+#include "MobileConnection.h"
 #include "mozilla/dom/bluetooth/BluetoothTypes.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "nsContentUtils.h"
 #include "nsIAudioManager.h"
+#include "nsIDOMIccInfo.h"
+#include "nsIIccProvider.h"
 #include "nsIObserverService.h"
 #include "nsISettingsService.h"
-#include "nsServiceManagerUtils.h"
-
-#ifdef MOZ_B2G_RIL
-#include "nsIDOMIccInfo.h"
-#include "nsIDOMMobileConnection.h"
-#include "nsIIccProvider.h"
-#include "nsIMobileConnectionProvider.h"
 #include "nsITelephonyProvider.h"
 #include "nsRadioInterfaceLayer.h"
-#endif
+#include "nsServiceManagerUtils.h"
 
 /**
  * BRSF bitmask of AG supported features. See 4.34.1 "Bluetooth Defined AT
  * Capabilities" in Bluetooth hands-free profile 1.6
  */
 #define BRSF_BIT_THREE_WAY_CALLING         1
 #define BSRF_BIT_EC_NR_FUNCTION            (1 << 1)
 #define BRSF_BIT_VOICE_RECOGNITION         (1 << 2)
 #define BRSF_BIT_IN_BAND_RING_TONE         (1 << 3)
 #define BRSF_BIT_ATTACH_NUM_TO_VOICE_TAG   (1 << 4)
 #define BRSF_BIT_ABILITY_TO_REJECT_CALL    (1 << 5)
 #define BRSF_BIT_ENHANCED_CALL_STATUS      (1 << 6)
 #define BRSF_BIT_ENHANCED_CALL_CONTROL     (1 << 7)
 #define BRSF_BIT_EXTENDED_ERR_RESULT_CODES (1 << 8)
 #define BRSF_BIT_CODEC_NEGOTIATION         (1 << 9)
 
-#ifdef MOZ_B2G_RIL
 /**
  * These constants are used in result code such as +CLIP and +CCWA. The value
  * of these constants is the same as TOA_INTERNATIONAL/TOA_UNKNOWN defined in
  * ril_consts.js
  */
 #define TOA_UNKNOWN 0x81
 #define TOA_INTERNATIONAL 0x91
-#endif
 
 #define CR_LF "\xd\xa";
 
 #define MOZSETTINGS_CHANGED_ID               "mozsettings-changed"
 #define AUDIO_VOLUME_BT_SCO_ID               "audio.volume.bt_sco"
 
 using namespace mozilla;
 using namespace mozilla::ipc;
 USING_BLUETOOTH_NAMESPACE
 
 namespace {
   StaticRefPtr<BluetoothHfpManager> sBluetoothHfpManager;
   bool sInShutdown = false;
   static const char kHfpCrlf[] = "\xd\xa";
 
-#ifdef MOZ_B2G_RIL
   // Sending ringtone related
   static bool sStopSendingRingFlag = true;
   static int sRingInterval = 3000; //unit: ms
 
   // Wait for 2 seconds for Dialer processing event 'BLDN'. '2' seconds is a
   // magic number. The mechanism should be revised once we can get call history.
   static int sWaitingForDialingInterval = 2000; //unit: ms
 
   // Wait 3.7 seconds until Dialer stops playing busy tone. '3' seconds is the
   // time window set in Dialer and the extra '0.7' second is a magic number.
   // The mechanism should be revised once we know the exact time at which
   // Dialer stops playing.
   static int sBusyToneInterval = 3700; //unit: ms
-#endif // MOZ_B2G_RIL
 } // anonymous namespace
 
-#ifdef MOZ_B2G_RIL
 /* CallState for sCINDItems[CINDType::CALL].value
  * - NO_CALL: there are no calls in progress
  * - IN_PROGRESS: at least one call is in progress
  */
 enum CallState {
   NO_CALL,
   IN_PROGRESS
 };
@@ -118,48 +108,43 @@ enum CallSetupState {
  * - ONHOLD_ACTIVE: both an active and a held call
  * - ONHOLD_NOACTIVE: call on hold, no active call
  */
 enum CallHeldState {
   NO_CALLHELD,
   ONHOLD_ACTIVE,
   ONHOLD_NOACTIVE
 };
-#endif // MOZ_B2G_RIL
 
 typedef struct {
   const char* name;
   const char* range;
   int value;
   bool activated;
 } CINDItem;
 
 enum CINDType {
   BATTCHG = 1,
-#ifdef MOZ_B2G_RIL
   CALL,
   CALLHELD,
   CALLSETUP,
   SERVICE,
   SIGNAL,
   ROAM
-#endif
 };
 
 static CINDItem sCINDItems[] = {
   {},
   {"battchg", "0-5", 5, true},
-#ifdef MOZ_B2G_RIL
   {"call", "0,1", CallState::NO_CALL, true},
   {"callheld", "0-2", CallHeldState::NO_CALLHELD, true},
   {"callsetup", "0-3", CallSetupState::NO_CALLSETUP, true},
   {"service", "0,1", 0, true},
   {"signal", "0-5", 0, true},
   {"roam", "0,1", 0, true}
-#endif
 };
 
 class BluetoothHfpManager::GetVolumeTask : public nsISettingsServiceCallback
 {
 public:
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD
@@ -216,17 +201,16 @@ BluetoothHfpManager::Notify(const hal::B
   // Range of CIND::BATTCHG: [0, 5], int
   int level = ceil(aBatteryInfo.level() * 5.0);
   if (level != sCINDItems[CINDType::BATTCHG].value) {
     sCINDItems[CINDType::BATTCHG].value = level;
     SendCommand("+CIEV:", CINDType::BATTCHG);
   }
 }
 
-#ifdef MOZ_B2G_RIL
 class BluetoothHfpManager::RespondToBLDNTask : public Task
 {
 private:
   void Run() MOZ_OVERRIDE
   {
     MOZ_ASSERT(sBluetoothHfpManager);
 
     if (!sBluetoothHfpManager->mDialingRequestProcessed) {
@@ -276,30 +260,28 @@ public:
                       new SendRingIndicatorTask(mNumber, mType),
                       sRingInterval);
   }
 
 private:
   nsString mNumber;
   int mType;
 };
-#endif // MOZ_B2G_RIL
 
 class BluetoothHfpManager::CloseScoTask : public Task
 {
 private:
   void Run() MOZ_OVERRIDE
   {
     MOZ_ASSERT(sBluetoothHfpManager);
 
     sBluetoothHfpManager->DisconnectSco();
   }
 };
 
-#ifdef MOZ_B2G_RIL
 static bool
 IsValidDtmf(const char aChar) {
   // Valid DTMF: [*#0-9ABCD]
   if (aChar == '*' || aChar == '#') {
     return true;
   } else if (aChar >= '0' && aChar <= '9') {
     return true;
   } else if (aChar >= 'A' && aChar <= 'D') {
@@ -332,78 +314,67 @@ Call::Reset()
   mType = TOA_UNKNOWN;
 }
 
 bool
 Call::IsActive()
 {
   return (mState == nsITelephonyProvider::CALL_STATE_CONNECTED);
 }
-#endif // MOZ_B2G_RIL
 
 /**
  *  BluetoothHfpManager
  */
 BluetoothHfpManager::BluetoothHfpManager()
 {
   Reset();
 }
 
-#ifdef MOZ_B2G_RIL
 void
 BluetoothHfpManager::ResetCallArray()
 {
   mCurrentCallArray.Clear();
   // Append a call object at the beginning of mCurrentCallArray since call
   // index from RIL starts at 1.
   Call call;
   mCurrentCallArray.AppendElement(call);
 
   if (mPhoneType == PhoneType::CDMA) {
     mCdmaSecondCall.Reset();
   }
 }
-#endif // MOZ_B2G_RIL
 
 void
 BluetoothHfpManager::Reset()
 {
-#ifdef MOZ_B2G_RIL
   sStopSendingRingFlag = true;
   sCINDItems[CINDType::CALL].value = CallState::NO_CALL;
   sCINDItems[CINDType::CALLSETUP].value = CallSetupState::NO_CALLSETUP;
   sCINDItems[CINDType::CALLHELD].value = CallHeldState::NO_CALLHELD;
-#endif
   for (uint8_t i = 1; i < ArrayLength(sCINDItems); i++) {
     sCINDItems[i].activated = true;
   }
 
-#ifdef MOZ_B2G_RIL
   mCCWA = false;
   mCLIP = false;
-  mDialingRequestProcessed = true;
-#endif
   mCMEE = false;
   mCMER = false;
   mReceiveVgsFlag = false;
+  mDialingRequestProcessed = true;
 
-#ifdef MOZ_B2G_RIL
   // We disable BSIR by default as it requires OEM implement BT SCO + SPEAKER
   // output audio path in audio driver. OEM can enable BSIR by setting
   // mBSIR=true here.
   //
   // Please see Bug 878728 for more information.
   mBSIR = false;
-#endif
 
   mController = nullptr;
 
-#ifdef MOZ_B2G_RIL
   ResetCallArray();
-#endif
 }
 
 bool
 BluetoothHfpManager::Init()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
@@ -412,23 +383,21 @@ BluetoothHfpManager::Init()
   if (NS_FAILED(obs->AddObserver(this, MOZSETTINGS_CHANGED_ID, false)) ||
       NS_FAILED(obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false))) {
     BT_WARNING("Failed to add observers!");
     return false;
   }
 
   hal::RegisterBatteryObserver(this);
 
-#ifdef MOZ_B2G_RIL
   mListener = new BluetoothRilListener();
   if (!mListener->StartListening()) {
     BT_WARNING("Failed to start listening RIL");
     return false;
   }
-#endif
 
   nsCOMPtr<nsISettingsService> settings =
     do_GetService("@mozilla.org/settingsService;1");
   NS_ENSURE_TRUE(settings, false);
 
   nsCOMPtr<nsISettingsServiceLock> settingsLock;
   nsresult rv = settings->CreateLock(getter_AddRefs(settingsLock));
   NS_ENSURE_SUCCESS(rv, false);
@@ -445,22 +414,20 @@ BluetoothHfpManager::Init()
                                    false);
   mScoSocketStatus = mScoSocket->GetConnectionStatus();
   ListenSco();
   return true;
 }
 
 BluetoothHfpManager::~BluetoothHfpManager()
 {
-#ifdef MOZ_B2G_RIL
   if (!mListener->StopListening()) {
     BT_WARNING("Failed to stop listening RIL");
   }
   mListener = nullptr;
-#endif
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   NS_ENSURE_TRUE_VOID(obs);
 
   if (NS_FAILED(obs->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) ||
       NS_FAILED(obs->RemoveObserver(this, MOZSETTINGS_CHANGED_ID))) {
     BT_WARNING("Failed to remove observers!");
   }
@@ -516,34 +483,32 @@ BluetoothHfpManager::NotifyConnectionSta
   } else {
     MOZ_ASSERT(false);
     return;
   }
 
   DispatchStatusChangedEvent(eventName, mDeviceAddress, status);
 }
 
-#ifdef MOZ_B2G_RIL
 void
 BluetoothHfpManager::NotifyDialer(const nsAString& aCommand)
 {
   nsString type, name;
   BluetoothValue v;
   InfallibleTArray<BluetoothNamedValue> parameters;
   type.AssignLiteral("bluetooth-dialer-command");
 
   name.AssignLiteral("command");
   v = nsString(aCommand);
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   if (!BroadcastSystemMessage(type, parameters)) {
     BT_WARNING("Failed to broadcast system message to dialer");
   }
 }
-#endif // MOZ_B2G_RIL
 
 void
 BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // The string that we're interested in will be a JSON string that looks like:
   //  {"key":"volumeup", "value":10}
@@ -583,17 +548,16 @@ BluetoothHfpManager::HandleVolumeChanged
   }
 
   // Only send volume back when there's a connected headset
   if (IsConnected()) {
     SendCommand("+VGS: ", mCurrentVgs);
   }
 }
 
-#ifdef MOZ_B2G_RIL
 void
 BluetoothHfpManager::HandleVoiceConnectionChanged()
 {
   nsCOMPtr<nsIMobileConnectionProvider> connection =
     do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
   NS_ENSURE_TRUE_VOID(connection);
 
   nsCOMPtr<nsIDOMMozMobileConnectionInfo> voiceInfo;
@@ -669,17 +633,16 @@ BluetoothHfpManager::HandleIccInfoChange
   nsCOMPtr<nsIDOMMozIccInfo> iccInfo;
   icc->GetIccInfo(getter_AddRefs(iccInfo));
   NS_ENSURE_TRUE_VOID(iccInfo);
 
   nsCOMPtr<nsIDOMMozGsmIccInfo> gsmIccInfo = do_QueryInterface(iccInfo);
   NS_ENSURE_TRUE_VOID(gsmIccInfo);
   gsmIccInfo->GetMsisdn(mMsisdn);
 }
-#endif // MOZ_B2G_RIL
 
 void
 BluetoothHfpManager::HandleShutdown()
 {
   MOZ_ASSERT(NS_IsMainThread());
   sInShutdown = true;
   Disconnect(nullptr);
   DisconnectSco();
@@ -697,32 +660,28 @@ BluetoothHfpManager::ReceiveSocketData(B
   nsAutoCString msg((const char*)aMessage->mData.get(), aMessage->mSize);
   msg.StripWhitespace();
 
   nsTArray<nsCString> atCommandValues;
 
   // For more information, please refer to 4.34.1 "Bluetooth Defined AT
   // Capabilities" in Bluetooth hands-free profile 1.6
   if (msg.Find("AT+BRSF=") != -1) {
-#ifdef MOZ_B2G_RIL
     uint32_t brsf = BRSF_BIT_ABILITY_TO_REJECT_CALL |
                     BRSF_BIT_ENHANCED_CALL_STATUS;
 
     // No support for three way calling in CDMA since
     // CDMA disallows to hang existing call for CHLD=1
     if (mPhoneType != PhoneType::CDMA) {
       brsf |= BRSF_BIT_THREE_WAY_CALLING;
     }
 
     if (mBSIR) {
       brsf |= BRSF_BIT_IN_BAND_RING_TONE;
     }
-#else
-    uint32_t brsf = 0;
-#endif // MOZ_B2G_RIL
 
     SendCommand("+BRSF: ", brsf);
   } else if (msg.Find("AT+CIND=?") != -1) {
     // Asking for CIND range
     SendCommand("+CIND: ", 0);
   } else if (msg.Find("AT+CIND?") != -1) {
     // Asking for CIND value
     SendCommand("+CIND: ", 1);
@@ -753,17 +712,16 @@ BluetoothHfpManager::ReceiveSocketData(B
       BT_WARNING("Could't get the value of command [AT+CMEE=]");
       goto respond_with_ok;
     }
 
     // AT+CMEE = 0: +CME ERROR shall not be used
     // AT+CMEE = 1: use numeric <err>
     // AT+CMEE = 2: use verbose <err>
     mCMEE = !atCommandValues[0].EqualsLiteral("0");
-#ifdef MOZ_B2G_RIL
   } else if (msg.Find("AT+COPS=") != -1) {
     ParseAtCommand(msg, 8, atCommandValues);
 
     if (atCommandValues.Length() != 2) {
       BT_WARNING("Could't get the value of command [AT+COPS=]");
       goto respond_with_ok;
     }
 
@@ -792,17 +750,16 @@ BluetoothHfpManager::ReceiveSocketData(B
       goto respond_with_ok;
     }
 
     if (IsValidDtmf(atCommandValues[0].get()[0])) {
       nsAutoCString message("VTS=");
       message += atCommandValues[0].get()[0];
       NotifyDialer(NS_ConvertUTF8toUTF16(message));
     }
-#endif // MOZ_B2G_RIL
   } else if (msg.Find("AT+VGM=") != -1) {
     ParseAtCommand(msg, 7, atCommandValues);
 
     if (atCommandValues.IsEmpty()) {
       BT_WARNING("Couldn't get the value of command [AT+VGM]");
       goto respond_with_ok;
     }
 
@@ -810,17 +767,16 @@ BluetoothHfpManager::ReceiveSocketData(B
     int vgm = atCommandValues[0].ToInteger(&rv);
     if (NS_FAILED(rv)) {
       BT_WARNING("Failed to extract microphone volume from bluetooth headset!");
       goto respond_with_ok;
     }
 
     NS_ASSERTION(vgm >= 0 && vgm <= 15, "Received invalid VGM value");
     mCurrentVgm = vgm;
-#ifdef MOZ_B2G_RIL
   } else if (msg.Find("AT+CHLD=?") != -1) {
     SendLine("+CHLD: (0,1,2)");
   } else if (msg.Find("AT+CHLD=") != -1) {
     ParseAtCommand(msg, 8, atCommandValues);
 
     if (atCommandValues.IsEmpty()) {
       BT_WARNING("Could't get the value of command [AT+CHLD=]");
       goto respond_with_ok;
@@ -861,17 +817,16 @@ BluetoothHfpManager::ReceiveSocketData(B
       BT_WARNING("Wrong value of command [AT+CHLD]");
       valid = false;
     }
 
     if (!valid) {
       SendLine("ERROR");
       return;
     }
-#endif // MOZ_B2G_RIL
   } else if (msg.Find("AT+VGS=") != -1) {
     // Adjust volume by headset
     mReceiveVgsFlag = true;
     ParseAtCommand(msg, 7, atCommandValues);
 
     if (atCommandValues.IsEmpty()) {
       BT_WARNING("Could't get the value of command [AT+VGS=]");
       goto respond_with_ok;
@@ -889,17 +844,16 @@ BluetoothHfpManager::ReceiveSocketData(B
     }
 
     NS_ASSERTION(newVgs >= 0 && newVgs <= 15, "Received invalid VGS value");
 
     nsString data;
     nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
     data.AppendInt(newVgs);
     os->NotifyObservers(nullptr, "bluetooth-volume-change", data.get());
-#ifdef MOZ_B2G_RIL
   } else if ((msg.Find("AT+BLDN") != -1) || (msg.Find("ATD>") != -1)) {
     // Dialer app of FFOS v1 does not have plan to support Memory Dailing.
     // However, in order to pass Bluetooth HFP certification, we still have to
     // make a call when we receive AT command 'ATD>n'.
     mDialingRequestProcessed = false;
 
     if (msg.Find("AT+BLDN") != -1) {
       NotifyDialer(NS_LITERAL_STRING("BLDN"));
@@ -1015,17 +969,16 @@ BluetoothHfpManager::ReceiveSocketData(B
         } else if (!atCommandValues[i].EqualsLiteral("")) {
           SendLine("ERROR");
           return;
         }
       } else {
         // Ignore requests to activate/deactivate mandatory indicators
       }
     }
-#endif // MOZ_B2G_RIL
   } else {
     nsCString warningMsg;
     warningMsg.Append(NS_LITERAL_CSTRING("Unsupported AT command: "));
     warningMsg.Append(msg);
     warningMsg.Append(NS_LITERAL_CSTRING(", reply with ERROR"));
     BT_WARNING(warningMsg.get());
 
     SendLine("ERROR");
@@ -1141,17 +1094,16 @@ BluetoothHfpManager::Disconnect(Bluetoot
 
   MOZ_ASSERT(!mController);
 
   mController = aController;
   mSocket->Disconnect();
   mSocket = nullptr;
 }
 
-#ifdef MOZ_B2G_RIL
 void
 BluetoothHfpManager::SendCCWA(const nsAString& aNumber, int aType)
 {
   if (mCCWA) {
     nsAutoCString ccwaMsg("+CCWA: \"");
     ccwaMsg.Append(NS_ConvertUTF16toUTF8(aNumber));
     ccwaMsg.AppendLiteral("\",");
     ccwaMsg.AppendInt(aType);
@@ -1203,17 +1155,16 @@ BluetoothHfpManager::SendCLCC(const Call
 
   message.AppendLiteral(",0,0,\"");
   message.Append(NS_ConvertUTF16toUTF8(aCall.mNumber));
   message.AppendLiteral("\",");
   message.AppendInt(aCall.mType);
 
   return SendLine(message.get());
 }
-#endif // MOZ_B2G_RIL
 
 bool
 BluetoothHfpManager::SendLine(const char* aMessage)
 {
   MOZ_ASSERT(mSocket);
 
   nsAutoCString msg;
 
@@ -1269,42 +1220,39 @@ BluetoothHfpManager::SendCommand(const c
       for (uint8_t i = 1; i < ArrayLength(sCINDItems); i++) {
         message.AppendInt(sCINDItems[i].value);
         if (i == (ArrayLength(sCINDItems) - 1)) {
           break;
         }
         message.AppendLiteral(",");
       }
     }
-#ifdef MOZ_B2G_RIL
   } else if (!strcmp(aCommand, "+CLCC: ")) {
     bool rv = true;
     uint32_t callNumbers = mCurrentCallArray.Length();
     uint32_t i;
     for (i = 1; i < callNumbers; i++) {
       rv &= SendCLCC(mCurrentCallArray[i], i);
     }
 
     if (!mCdmaSecondCall.mNumber.IsEmpty()) {
       MOZ_ASSERT(mPhoneType == PhoneType::CDMA);
       MOZ_ASSERT(i == 2);
 
       rv &= SendCLCC(mCdmaSecondCall, 2);
     }
 
     return rv;
-#endif // MOZ_B2G_RIL
   } else {
     message.AppendInt(aValue);
   }
 
   return SendLine(message.get());
 }
 
-#ifdef MOZ_B2G_RIL
 void
 BluetoothHfpManager::UpdateCIND(uint8_t aType, uint8_t aValue, bool aSend)
 {
   if (sCINDItems[aType].value != aValue) {
     sCINDItems[aType].value = aValue;
     if (aSend) {
       SendCommand("+CIEV: ", aType);
     }
@@ -1575,25 +1523,22 @@ BluetoothHfpManager::ToggleCalls()
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mPhoneType == PhoneType::CDMA);
 
   // Toggle acitve and held calls
   mCdmaSecondCall.mState = (mCdmaSecondCall.IsActive()) ?
                              nsITelephonyProvider::CALL_STATE_HELD :
                              nsITelephonyProvider::CALL_STATE_CONNECTED;
 }
-#endif // MOZ_B2G_RIL
 
 void
 BluetoothHfpManager::OnSocketConnectSuccess(BluetoothSocket* aSocket)
 {
   MOZ_ASSERT(aSocket);
-#ifdef MOZ_B2G_RIL
   MOZ_ASSERT(mListener);
-#endif
 
   // Success to create a SCO socket
   if (aSocket == mScoSocket) {
     OnScoConnectSuccess();
     return;
   }
 
   /**
@@ -1612,22 +1557,20 @@ BluetoothHfpManager::OnSocketConnectSucc
   } else if (aSocket == mHeadsetSocket) {
     MOZ_ASSERT(!mSocket);
     mHeadsetSocket.swap(mSocket);
 
     mHandsfreeSocket->Disconnect();
     mHandsfreeSocket = nullptr;
   }
 
-#ifdef MOZ_B2G_RIL
   // Enumerate current calls
   mListener->EnumerateCalls();
 
   mFirstCKPD = true;
-#endif
 
   // Cache device path for NotifySettings() since we can't get socket address
   // when a headset disconnect with us
   mSocket->GetAddress(mDeviceAddress);
   NotifyConnectionStatusChanged(
     NS_LITERAL_STRING(BLUETOOTH_HFP_STATUS_CHANGED_ID));
 
   ListenSco();
--- a/dom/bluetooth/BluetoothHfpManager.h
+++ b/dom/bluetooth/BluetoothHfpManager.h
@@ -4,29 +4,25 @@
  * 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/. */
 
 #ifndef mozilla_dom_bluetooth_bluetoothhfpmanager_h__
 #define mozilla_dom_bluetooth_bluetoothhfpmanager_h__
 
 #include "BluetoothCommon.h"
 #include "BluetoothProfileManagerBase.h"
-#ifdef MOZ_B2G_RIL
 #include "BluetoothRilListener.h"
-#endif
 #include "BluetoothSocketObserver.h"
 #include "mozilla/ipc/UnixSocket.h"
 #include "mozilla/Hal.h"
 
 BEGIN_BLUETOOTH_NAMESPACE
 
 class BluetoothReplyRunnable;
 class BluetoothSocket;
-
-#ifdef MOZ_B2G_RIL
 class Call;
 
 /**
  * These costants are defined in 4.33.2 "AT Capabilities Re-Used from GSM 07.07
  * and 3GPP 27.007" in Bluetooth hands-free profile 1.6
  */
 enum BluetoothCmeError {
   AG_FAILURE = 0,
@@ -66,17 +62,16 @@ public:
   void Reset();
   bool IsActive();
 
   uint16_t mState;
   bool mDirection; // true: incoming call; false: outgoing call
   nsString mNumber;
   int mType;
 };
-#endif // MOZ_B2G_RIL
 
 class BluetoothHfpManager : public BluetoothSocketObserver
                           , public BluetoothProfileManagerBase
                           , public BatteryObserver
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
@@ -109,110 +104,88 @@ public:
     aName.AssignLiteral("HFP/HSP");
   }
 
   bool Listen();
   bool ConnectSco(BluetoothReplyRunnable* aRunnable = nullptr);
   bool DisconnectSco();
   bool ListenSco();
 
-#ifdef MOZ_B2G_RIL
   /**
    * @param aSend A boolean indicates whether we need to notify headset or not
    */
   void HandleCallStateChanged(uint32_t aCallIndex, uint16_t aCallState,
                               const nsAString& aError, const nsAString& aNumber,
                               const bool aIsOutgoing, bool aSend);
   void HandleIccInfoChanged();
   void HandleVoiceConnectionChanged();
-#endif
 
   bool IsConnected();
   bool IsScoConnected();
 
-#ifdef MOZ_B2G_RIL
   // CDMA-specific functions
   void UpdateSecondNumber(const nsAString& aNumber);
   void AnswerWaitingCall();
   void IgnoreWaitingCall();
   void ToggleCalls();
-#endif
 
 private:
   class CloseScoTask;
   class GetVolumeTask;
-#ifdef MOZ_B2G_RIL
   class RespondToBLDNTask;
   class SendRingIndicatorTask;
-#endif
 
   friend class CloseScoTask;
   friend class GetVolumeTask;
-#ifdef MOZ_B2G_RIL
   friend class RespondToBLDNTask;
   friend class SendRingIndicatorTask;
-#endif
   friend class BluetoothHfpManagerObserver;
 
   BluetoothHfpManager();
   void HandleShutdown();
   void HandleVolumeChanged(const nsAString& aData);
 
   bool Init();
   void Notify(const hal::BatteryInformation& aBatteryInfo);
   void Reset();
-#ifdef MOZ_B2G_RIL
   void ResetCallArray();
   uint32_t FindFirstCall(uint16_t aState);
   uint32_t GetNumberOfCalls(uint16_t aState);
   PhoneType GetPhoneType(const nsAString& aType);
-#endif
 
   void NotifyConnectionStatusChanged(const nsAString& aType);
   void NotifyDialer(const nsAString& aCommand);
 
-#ifdef MOZ_B2G_RIL
   void SendCCWA(const nsAString& aNumber, int aType);
   bool SendCLCC(const Call& aCall, int aIndex);
-#endif
   bool SendCommand(const char* aCommand, uint32_t aValue = 0);
   bool SendLine(const char* aMessage);
-#ifdef MOZ_B2G_RIL
   void UpdateCIND(uint8_t aType, uint8_t aValue, bool aSend = true);
-#endif
   void OnScoConnectSuccess();
   void OnScoConnectError();
   void OnScoDisconnect();
 
   int mCurrentVgs;
   int mCurrentVgm;
-#ifdef MOZ_B2G_RIL
   bool mBSIR;
   bool mCCWA;
   bool mCLIP;
-#endif
   bool mCMEE;
   bool mCMER;
-#ifdef MOZ_B2G_RIL
   bool mFirstCKPD;
   int mNetworkSelectionMode;
   PhoneType mPhoneType;
-#endif
   bool mReceiveVgsFlag;
-#ifdef MOZ_B2G_RIL
   bool mDialingRequestProcessed;
-#endif
   nsString mDeviceAddress;
-#ifdef MOZ_B2G_RIL
   nsString mMsisdn;
   nsString mOperatorName;
 
   nsTArray<Call> mCurrentCallArray;
   nsAutoPtr<BluetoothRilListener> mListener;
-#endif
   nsRefPtr<BluetoothReplyRunnable> mRunnable;
   nsRefPtr<BluetoothProfileController> mController;
   nsRefPtr<BluetoothReplyRunnable> mScoRunnable;
 
   // If a connection has been established, mSocket will be the socket
   // communicating with the remote socket. We maintain the invariant that if
   // mSocket is non-null, mHandsfreeSocket and mHeadsetSocket must be null (and
   // vice versa).
@@ -221,17 +194,15 @@ private:
   // Server sockets. Once an inbound connection is established, it will hand
   // over the ownership to mSocket, and get a new server socket while Listen()
   // is called.
   nsRefPtr<BluetoothSocket> mHandsfreeSocket;
   nsRefPtr<BluetoothSocket> mHeadsetSocket;
   nsRefPtr<BluetoothSocket> mScoSocket;
   SocketConnectionStatus mScoSocketStatus;
 
-#ifdef MOZ_B2G_RIL
   // CDMA-specific variable
   Call mCdmaSecondCall;
-#endif
 };
 
 END_BLUETOOTH_NAMESPACE
 
 #endif
--- a/dom/bluetooth/BluetoothService.h
+++ b/dom/bluetooth/BluetoothService.h
@@ -261,26 +261,24 @@ public:
   ConnectSco(BluetoothReplyRunnable* aRunnable) = 0;
 
   virtual void
   DisconnectSco(BluetoothReplyRunnable* aRunnable) = 0;
 
   virtual void
   IsScoConnected(BluetoothReplyRunnable* aRunnable) = 0;
 
-#ifdef MOZ_B2G_RIL
   virtual void
   AnswerWaitingCall(BluetoothReplyRunnable* aRunnable) = 0;
 
   virtual void
   IgnoreWaitingCall(BluetoothReplyRunnable* aRunnable) = 0;
 
   virtual void
   ToggleCalls(BluetoothReplyRunnable* aRunnable) = 0;
-#endif
 
   virtual void
   SendMetaData(const nsAString& aTitle,
                const nsAString& aArtist,
                const nsAString& aAlbum,
                int64_t aMediaNumber,
                int64_t aTotalMediaCount,
                int64_t aDuration,
--- a/dom/bluetooth/ipc/BluetoothParent.cpp
+++ b/dom/bluetooth/ipc/BluetoothParent.cpp
@@ -221,24 +221,22 @@ BluetoothParent::RecvPBluetoothRequestCo
     case Request::TDenyReceivingFileRequest:
       return actor->DoRequest(aRequest.get_DenyReceivingFileRequest());
     case Request::TConnectScoRequest:
       return actor->DoRequest(aRequest.get_ConnectScoRequest());
     case Request::TDisconnectScoRequest:
       return actor->DoRequest(aRequest.get_DisconnectScoRequest());
     case Request::TIsScoConnectedRequest:
       return actor->DoRequest(aRequest.get_IsScoConnectedRequest());
-#ifdef MOZ_B2G_RIL
     case Request::TAnswerWaitingCallRequest:
       return actor->DoRequest(aRequest.get_AnswerWaitingCallRequest());
     case Request::TIgnoreWaitingCallRequest:
       return actor->DoRequest(aRequest.get_IgnoreWaitingCallRequest());
     case Request::TToggleCallsRequest:
       return actor->DoRequest(aRequest.get_ToggleCallsRequest());
-#endif
     case Request::TSendMetaDataRequest:
       return actor->DoRequest(aRequest.get_SendMetaDataRequest());
     case Request::TSendPlayStatusRequest:
       return actor->DoRequest(aRequest.get_SendPlayStatusRequest());
     default:
       MOZ_CRASH("Unknown type!");
   }
 
@@ -578,17 +576,16 @@ BluetoothRequestParent::DoRequest(const 
 {
   MOZ_ASSERT(mService);
   MOZ_ASSERT(mRequestType == Request::TIsScoConnectedRequest);
 
   mService->IsScoConnected(mReplyRunnable.get());
   return true;
 }
 
-#ifdef MOZ_B2G_RIL
 bool
 BluetoothRequestParent::DoRequest(const AnswerWaitingCallRequest& aRequest)
 {
   MOZ_ASSERT(mService);
   MOZ_ASSERT(mRequestType == Request::TAnswerWaitingCallRequest);
 
   mService->AnswerWaitingCall(mReplyRunnable.get());
 
@@ -611,17 +608,16 @@ BluetoothRequestParent::DoRequest(const 
 {
   MOZ_ASSERT(mService);
   MOZ_ASSERT(mRequestType == Request::TAnswerWaitingCallRequest);
 
   mService->ToggleCalls(mReplyRunnable.get());
 
   return true;
 }
-#endif // MOZ_B2G_RIL
 
 bool
 BluetoothRequestParent::DoRequest(const SendMetaDataRequest& aRequest)
 {
   MOZ_ASSERT(mService);
   MOZ_ASSERT(mRequestType == Request::TSendMetaDataRequest);
 
   mService->SendMetaData(aRequest.title(),
--- a/dom/bluetooth/ipc/BluetoothParent.h
+++ b/dom/bluetooth/ipc/BluetoothParent.h
@@ -185,26 +185,24 @@ protected:
   DoRequest(const ConnectScoRequest& aRequest);
 
   bool
   DoRequest(const DisconnectScoRequest& aRequest);
 
   bool
   DoRequest(const IsScoConnectedRequest& aRequest);
 
-#ifdef MOZ_B2G_RIL
   bool
   DoRequest(const AnswerWaitingCallRequest& aRequest);
 
   bool
   DoRequest(const IgnoreWaitingCallRequest& aRequest);
 
   bool
   DoRequest(const ToggleCallsRequest& aRequest);
-#endif
 
   bool
   DoRequest(const SendMetaDataRequest& aRequest);
 
   bool
   DoRequest(const SendPlayStatusRequest& aRequest);
 };
 
--- a/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
+++ b/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
@@ -323,17 +323,16 @@ BluetoothServiceChildProcess::Disconnect
 }
 
 void
 BluetoothServiceChildProcess::IsScoConnected(BluetoothReplyRunnable* aRunnable)
 {
   SendRequest(aRunnable, IsScoConnectedRequest());
 }
 
-#ifdef MOZ_B2G_RIL
 void
 BluetoothServiceChildProcess::AnswerWaitingCall(
   BluetoothReplyRunnable* aRunnable)
 {
   SendRequest(aRunnable, AnswerWaitingCallRequest());
 }
 
 void
@@ -344,17 +343,16 @@ BluetoothServiceChildProcess::IgnoreWait
 }
 
 void
 BluetoothServiceChildProcess::ToggleCalls(
   BluetoothReplyRunnable* aRunnable)
 {
   SendRequest(aRunnable, ToggleCallsRequest());
 }
-#endif // MOZ_B2G_RIL
 
 void
 BluetoothServiceChildProcess::SendMetaData(const nsAString& aTitle,
                                            const nsAString& aArtist,
                                            const nsAString& aAlbum,
                                            int64_t aMediaNumber,
                                            int64_t aTotalMediaCount,
                                            int64_t aDuration,
--- a/dom/bluetooth/ipc/BluetoothServiceChildProcess.h
+++ b/dom/bluetooth/ipc/BluetoothServiceChildProcess.h
@@ -144,26 +144,24 @@ public:
   ConnectSco(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
 
   virtual void
   DisconnectSco(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
 
   virtual void
   IsScoConnected(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
 
-#ifdef MOZ_B2G_RIL
   virtual void
   AnswerWaitingCall(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
 
   virtual void
   IgnoreWaitingCall(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
 
   virtual void
   ToggleCalls(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
-#endif
 
   virtual void
   SendMetaData(const nsAString& aTitle,
                const nsAString& aArtist,
                const nsAString& aAlbum,
                int64_t aMediaNumber,
                int64_t aTotalMediaCount,
                int64_t aDuration,
--- a/dom/bluetooth/linux/BluetoothDBusService.cpp
+++ b/dom/bluetooth/linux/BluetoothDBusService.cpp
@@ -2630,17 +2630,16 @@ BluetoothDBusService::IsConnected(const 
     BT_WARNING(ERR_UNKNOWN_PROFILE);
     return false;
   }
 
   NS_ENSURE_TRUE(profile, false);
   return profile->IsConnected();
 }
 
-#ifdef MOZ_B2G_RIL
 void
 BluetoothDBusService::AnswerWaitingCall(BluetoothReplyRunnable* aRunnable)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
   hfp->AnswerWaitingCall();
 
@@ -2663,17 +2662,16 @@ BluetoothDBusService::ToggleCalls(Blueto
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
   hfp->ToggleCalls();
 
   DispatchBluetoothReply(aRunnable, BluetoothValue(true), EmptyString());
 }
-#endif // MOZ_B2G_RIL
 
 class OnUpdateSdpRecordsRunnable : public nsRunnable
 {
 public:
   OnUpdateSdpRecordsRunnable(const nsAString& aObjectPath,
                              BluetoothProfileManagerBase* aManager)
     : mManager(aManager)
   {
--- a/dom/bluetooth/linux/BluetoothDBusService.h
+++ b/dom/bluetooth/linux/BluetoothDBusService.h
@@ -130,26 +130,24 @@ public:
   ConnectSco(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
 
   virtual void
   DisconnectSco(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
 
   virtual void
   IsScoConnected(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
 
-#ifdef MOZ_B2G_RIL
   virtual void
   AnswerWaitingCall(BluetoothReplyRunnable* aRunnable);
 
   virtual void
   IgnoreWaitingCall(BluetoothReplyRunnable* aRunnable);
 
   virtual void
   ToggleCalls(BluetoothReplyRunnable* aRunnable);
-#endif
 
   virtual void
   SendMetaData(const nsAString& aTitle,
                const nsAString& aArtist,
                const nsAString& aAlbum,
                int64_t aMediaNumber,
                int64_t aTotalMediaCount,
                int64_t aDuration,