Merge b2g-inbound to Mozilla-Central
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 23 Oct 2013 14:51:43 +0200
changeset 165602 8803e8c0ee3efe4c0c07be612ce51c1d274b7c96
parent 165585 c0e6e76aafedbdc3852fc3fc114b8f57b7ddf851 (current diff)
parent 165601 eb18aaa10dd9cc90f53837802fbcb3266de59012 (diff)
child 165603 5ef0ca4d1068f5aa4bd5f995d16b20195a26c13e
child 165613 d91823b449d10871c3504247adf4b99907f4ac3e
child 165635 4b26a2531e86f7c2cacc4d9a0d8255122d36edd6
child 165667 124fc1fcd3ebbe8484d0a5fb66bba6336daa3300
child 170480 fb23ad2d94e8067b123fff1c70fd17c72ded720a
child 177485 c18094ecbe37c4ddb1ef0a2829b68a1dece10415
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone27.0a1
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
Merge b2g-inbound to Mozilla-Central
--- a/b2g/config/gaia.json
+++ b/b2g/config/gaia.json
@@ -1,4 +1,4 @@
 {
-    "revision": "ef355aa8244d698a5b226ac4ef2408a2eb0812bb", 
+    "revision": "a57a913f1dd723afa191124f27b8d9fc4b0cb1c0", 
     "repo_path": "/integration/gaia-central"
 }
--- a/configure.in
+++ b/configure.in
@@ -217,27 +217,34 @@ if test -n "$gonkdir" ; then
         ARCH_DIR=arch-x86
         ;;
     esac
 
     case "$ANDROID_VERSION" in
     15)
         GONK_INCLUDES="-I$gonkdir/frameworks/base/opengl/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/frameworks/base/include -I$gonkdir/frameworks/base/services/camera -I$gonkdir/frameworks/base/include/media/stagefright -I$gonkdir/frameworks/base/include/media/stagefright/openmax -I$gonkdir/frameworks/base/media/libstagefright/rtsp -I$gonkdir/frameworks/base/media/libstagefright/include -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib -I$gonkdir/dalvik/libnativehelper/include/nativehelper"
         MOZ_B2G_BT=1
+        MOZ_B2G_BT_BLUEZ=1
         MOZ_B2G_CAMERA=1
         MOZ_OMX_DECODER=1
         AC_SUBST(MOZ_OMX_DECODER)
         MOZ_RTSP=1
         ;;
     17|18)
         GONK_INCLUDES="-I$gonkdir/frameworks/native/include -I$gonkdir/frameworks/av/include -I$gonkdir/frameworks/av/include/media -I$gonkdir/frameworks/av/include/camera -I$gonkdir/frameworks/native/include/media/openmax -I$gonkdir/frameworks/av/media/libstagefright/include"
         if test -d "$gonkdir/external/bluetooth/bluez"; then
-            GONK_INCLUDES+=" -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib"
+          GONK_INCLUDES="$GONK_INCLUDES -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib"
             MOZ_B2G_BT=1
+            MOZ_B2G_BT_BLUEZ=1
         fi
+        if test -d "$gonkdir/external/bluetooth/bluedroid"; then
+            MOZ_B2G_BT=1
+            MOZ_B2G_BT_BLUEDROID=1
+        fi
+
         MOZ_B2G_CAMERA=1
         MOZ_OMX_DECODER=1
         AC_SUBST(MOZ_OMX_DECODER)
         ;;
     *)
         AC_MSG_ERROR([Unsupported platform version: $ANDROID_VERSION])
         ;;
     esac
@@ -7296,16 +7303,18 @@ dnl ====================================
 MOZ_ARG_ENABLE_BOOL(b2g-bt,
 [  --enable-b2g-bt      Set compile flags necessary for compiling Bluetooth API for B2G ],
     MOZ_B2G_BT=1,
     MOZ_B2G_BT= )
 if test -n "$MOZ_B2G_BT"; then
     AC_DEFINE(MOZ_B2G_BT)
 fi
 AC_SUBST(MOZ_B2G_BT)
+AC_SUBST(MOZ_B2G_BT_BLUEZ)
+AC_SUBST(MOZ_B2G_BT_BLUEDROID)
 
 dnl ========================================================
 dnl = Enable Pico Speech Synthesis (Gonk usually)
 dnl ========================================================
 MOZ_ARG_ENABLE_BOOL(synth-pico,
 [  --enable-synth-pico  Set compile flags necessary for compiling Pico Web Speech API ],
     MOZ_SYNTH_PICO=1,
     MOZ_SYNTH_PICO= )
--- a/dom/bluetooth/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/BluetoothHfpManager.cpp
@@ -556,18 +556,17 @@ BluetoothHfpManager::HandleVolumeChanged
 void
 BluetoothHfpManager::HandleVoiceConnectionChanged()
 {
   nsCOMPtr<nsIMobileConnectionProvider> connection =
     do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
   NS_ENSURE_TRUE_VOID(connection);
 
   nsCOMPtr<nsIDOMMozMobileConnectionInfo> voiceInfo;
-  // TODO: Bug 921991 - B2G BT: support multiple sim cards
-  connection->GetVoiceConnectionInfo(0, getter_AddRefs(voiceInfo));
+  connection->GetVoiceConnectionInfo(getter_AddRefs(voiceInfo));
   NS_ENSURE_TRUE_VOID(voiceInfo);
 
   nsString type;
   voiceInfo->GetType(type);
   mPhoneType = GetPhoneType(type);
 
   bool roaming;
   voiceInfo->GetRoaming(&roaming);
@@ -593,18 +592,17 @@ BluetoothHfpManager::HandleVoiceConnecti
 
   /**
    * Possible return values for mode are:
    * - null (unknown): set mNetworkSelectionMode to 0 (auto)
    * - automatic: set mNetworkSelectionMode to 0 (auto)
    * - manual: set mNetworkSelectionMode to 1 (manual)
    */
   nsString mode;
-  // TODO: Bug 921991 - B2G BT: support multiple sim cards
-  connection->GetNetworkSelectionMode(0, mode);
+  connection->GetNetworkSelectionMode(mode);
   if (mode.EqualsLiteral("manual")) {
     mNetworkSelectionMode = 1;
   } else {
     mNetworkSelectionMode = 0;
   }
 
   nsCOMPtr<nsIDOMMozMobileNetworkInfo> network;
   voiceInfo->GetNetwork(getter_AddRefs(network));
--- a/dom/bluetooth/BluetoothRilListener.cpp
+++ b/dom/bluetooth/BluetoothRilListener.cpp
@@ -287,32 +287,30 @@ BluetoothRilListener::StopIccListening()
 
 bool
 BluetoothRilListener::StartMobileConnectionListening()
 {
   nsCOMPtr<nsIMobileConnectionProvider> provider =
     do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
   NS_ENSURE_TRUE(provider, false);
 
-  // TODO: Bug 921991 - B2G BT: support multiple sim cards
   nsresult rv = provider->
-                  RegisterMobileConnectionMsg(0, mMobileConnectionListener);
+                  RegisterMobileConnectionMsg(mMobileConnectionListener);
   return NS_SUCCEEDED(rv);
 }
 
 bool
 BluetoothRilListener::StopMobileConnectionListening()
 {
   nsCOMPtr<nsIMobileConnectionProvider> provider =
     do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
   NS_ENSURE_TRUE(provider, false);
 
-  // TODO: Bug 921991 - B2G BT: support multiple sim cards
   nsresult rv = provider->
-                  UnregisterMobileConnectionMsg(0, mMobileConnectionListener);
+                  UnregisterMobileConnectionMsg(mMobileConnectionListener);
   return NS_SUCCEEDED(rv);
 }
 
 bool
 BluetoothRilListener::StartTelephonyListening()
 {
   nsCOMPtr<nsITelephonyProvider> provider =
     do_GetService(TELEPHONY_PROVIDER_CONTRACTID);
--- a/dom/bluetooth/BluetoothService.cpp
+++ b/dom/bluetooth/BluetoothService.cpp
@@ -39,17 +39,21 @@
 #include "nsXPCOM.h"
 
 #if defined(MOZ_WIDGET_GONK)
 #include "cutils/properties.h"
 #endif
 
 #if defined(MOZ_B2G_BT)
 # if defined(MOZ_BLUETOOTH_GONK)
-#  include "BluetoothGonkService.h"
+#ifdef MOZ_B2G_BT_BLUEZ
+#include "BluetoothGonkService.h"
+#else
+#include "BluetoothServiceBluedroid.h"
+#endif
 # elif defined(MOZ_BLUETOOTH_DBUS)
 #  include "BluetoothDBusService.h"
 # else
 #  error No_suitable_backend_for_bluetooth!
 # endif
 #endif
 
 #define MOZSETTINGS_CHANGED_ID      "mozsettings-changed"
@@ -299,20 +303,26 @@ BluetoothService::Create()
 {
 #if defined(MOZ_B2G_BT)
   if (!IsMainProcess()) {
     return BluetoothServiceChildProcess::Create();
   }
 #endif
 
 #if defined(MOZ_BLUETOOTH_GONK)
+#ifdef MOZ_B2G_BT_BLUEDROID
+  return new BluetoothServiceBluedroid();
+#else
   return new BluetoothGonkService();
+#endif
 #elif defined(MOZ_BLUETOOTH_DBUS)
+#ifdef MOZ_B2G_BT_BLUEZ
   return new BluetoothDBusService();
 #endif
+#endif
   BT_WARNING("No platform support for bluetooth!");
   return nullptr;
 }
 
 bool
 BluetoothService::Init()
 {
   MOZ_ASSERT(NS_IsMainThread());
new file mode 100644
--- /dev/null
+++ b/dom/bluetooth/BluetoothServiceBluedroid.cpp
@@ -0,0 +1,341 @@
+/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*-
+/* vim: set ts=2 et sw=2 tw=80: */
+/*
+** Copyright 2006, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include "BluetoothServiceBluedroid.h"
+#include "BluetoothReplyRunnable.h"
+#include "BluetoothUtils.h"
+#include "BluetoothUuid.h"
+#include "mozilla/dom/bluetooth/BluetoothTypes.h"
+#include "mozilla/ipc/UnixSocket.h"
+
+using namespace mozilla;
+using namespace mozilla::ipc;
+USING_BLUETOOTH_NAMESPACE
+
+nsresult
+BluetoothServiceBluedroid::StartInternal()
+{
+  return NS_OK;
+}
+
+nsresult
+BluetoothServiceBluedroid::StopInternal()
+{
+  return NS_OK;
+}
+
+bool
+BluetoothServiceBluedroid::IsEnabledInternal()
+{
+  return true;
+}
+
+nsresult
+BluetoothServiceBluedroid::GetDefaultAdapterPathInternal(
+  BluetoothReplyRunnable* aRunnable)
+{
+  return NS_OK;
+}
+
+nsresult
+BluetoothServiceBluedroid::GetConnectedDevicePropertiesInternal(
+  uint16_t aProfileId, BluetoothReplyRunnable* aRunnable)
+{
+  return NS_OK;
+
+}
+
+nsresult
+BluetoothServiceBluedroid::GetPairedDevicePropertiesInternal(
+  const nsTArray<nsString>& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
+{
+  return NS_OK;
+}
+
+nsresult
+BluetoothServiceBluedroid::StartDiscoveryInternal(
+  BluetoothReplyRunnable* aRunnable)
+{
+  return NS_OK;
+}
+
+nsresult
+BluetoothServiceBluedroid::StopDiscoveryInternal(
+  BluetoothReplyRunnable* aRunnable)
+{
+  return NS_OK;
+}
+
+nsresult
+BluetoothServiceBluedroid::GetDevicePropertiesInternal(
+  const BluetoothSignal& aSignal)
+{
+  return NS_OK;
+}
+
+nsresult
+BluetoothServiceBluedroid::SetProperty(BluetoothObjectType aType,
+                                       const BluetoothNamedValue& aValue,
+                                       BluetoothReplyRunnable* aRunnable)
+{
+  return NS_OK;
+}
+
+bool
+BluetoothServiceBluedroid::GetDevicePath(const nsAString& aAdapterPath,
+                                         const nsAString& aDeviceAddress,
+                                         nsAString& aDevicePath)
+{
+  return true;
+}
+
+bool
+BluetoothServiceBluedroid::AddServiceRecords(const char* serviceName,
+                                             unsigned long long uuidMsb,
+                                             unsigned long long uuidLsb,
+                                             int channel)
+{
+  return true;
+}
+
+bool
+BluetoothServiceBluedroid::RemoveServiceRecords(const char* serviceName,
+                                                unsigned long long uuidMsb,
+                                                unsigned long long uuidLsb,
+                                                int channel)
+{
+  return true;
+}
+
+bool
+BluetoothServiceBluedroid::AddReservedServicesInternal(
+  const nsTArray<uint32_t>& aServices,
+  nsTArray<uint32_t>& aServiceHandlesContainer)
+{
+  return true;
+
+}
+
+bool
+BluetoothServiceBluedroid::RemoveReservedServicesInternal(
+  const nsTArray<uint32_t>& aServiceHandles)
+{
+  return true;
+}
+
+nsresult
+BluetoothServiceBluedroid::GetScoSocket(
+  const nsAString& aObjectPath, bool aAuth, bool aEncrypt,
+  mozilla::ipc::UnixSocketConsumer* aConsumer)
+{
+  return NS_OK;
+}
+
+nsresult
+BluetoothServiceBluedroid::GetServiceChannel(
+  const nsAString& aDeviceAddress,
+  const nsAString& aServiceUuid,
+  BluetoothProfileManagerBase* aManager)
+{
+  return NS_OK;
+}
+
+bool
+BluetoothServiceBluedroid::UpdateSdpRecords(
+  const nsAString& aDeviceAddress,
+  BluetoothProfileManagerBase* aManager)
+{
+  return true;
+}
+
+nsresult
+BluetoothServiceBluedroid::CreatePairedDeviceInternal(
+  const nsAString& aDeviceAddress, int aTimeout,
+  BluetoothReplyRunnable* aRunnable)
+{
+  return NS_OK;
+}
+
+nsresult
+BluetoothServiceBluedroid::RemoveDeviceInternal(
+  const nsAString& aDeviceObjectPath,
+  BluetoothReplyRunnable* aRunnable)
+{
+  return NS_OK;
+}
+
+bool
+BluetoothServiceBluedroid::SetPinCodeInternal(
+  const nsAString& aDeviceAddress, const nsAString& aPinCode,
+  BluetoothReplyRunnable* aRunnable)
+{
+  return true;
+}
+
+bool
+BluetoothServiceBluedroid::SetPasskeyInternal(
+  const nsAString& aDeviceAddress, uint32_t aPasskey,
+  BluetoothReplyRunnable* aRunnable)
+{
+  return true;
+}
+
+bool
+BluetoothServiceBluedroid::SetPairingConfirmationInternal(
+  const nsAString& aDeviceAddress, bool aConfirm,
+  BluetoothReplyRunnable* aRunnable)
+{
+  return true;
+}
+
+bool
+BluetoothServiceBluedroid::SetAuthorizationInternal(
+  const nsAString& aDeviceAddress, bool aAllow,
+  BluetoothReplyRunnable* aRunnable)
+{
+  return true;
+}
+
+nsresult
+BluetoothServiceBluedroid::PrepareAdapterInternal()
+{
+  return NS_OK;
+}
+
+void
+BluetoothServiceBluedroid::Connect(const nsAString& aDeviceAddress,
+                                   uint32_t aCod,
+                                   uint16_t aServiceUuid,
+                                   BluetoothReplyRunnable* aRunnable)
+{
+
+}
+
+bool
+BluetoothServiceBluedroid::IsConnected(uint16_t aProfileId)
+{
+  return true;
+}
+
+void
+BluetoothServiceBluedroid::Disconnect(
+  const nsAString& aDeviceAddress, uint16_t aServiceUuid,
+  BluetoothReplyRunnable* aRunnable)
+{
+
+}
+
+void
+BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress,
+                                    BlobParent* aBlobParent,
+                                    BlobChild* aBlobChild,
+                                    BluetoothReplyRunnable* aRunnable)
+{
+
+}
+
+void
+BluetoothServiceBluedroid::StopSendingFile(const nsAString& aDeviceAddress,
+                                           BluetoothReplyRunnable* aRunnable)
+{
+
+}
+
+void
+BluetoothServiceBluedroid::ConfirmReceivingFile(
+  const nsAString& aDeviceAddress, bool aConfirm,
+  BluetoothReplyRunnable* aRunnable)
+{
+
+}
+
+void
+BluetoothServiceBluedroid::ConnectSco(BluetoothReplyRunnable* aRunnable)
+{
+
+}
+
+void
+BluetoothServiceBluedroid::DisconnectSco(BluetoothReplyRunnable* aRunnable)
+{
+
+}
+
+void
+BluetoothServiceBluedroid::IsScoConnected(BluetoothReplyRunnable* aRunnable)
+{
+
+}
+
+void
+BluetoothServiceBluedroid::SendMetaData(const nsAString& aTitle,
+                                        const nsAString& aArtist,
+                                        const nsAString& aAlbum,
+                                        int64_t aMediaNumber,
+                                        int64_t aTotalMediaCount,
+                                        int64_t aDuration,
+                                        BluetoothReplyRunnable* aRunnable)
+{
+
+}
+
+void
+BluetoothServiceBluedroid::SendPlayStatus(
+  int64_t aDuration, int64_t aPosition,
+  const nsAString& aPlayStatus,
+  BluetoothReplyRunnable* aRunnable)
+{
+
+}
+
+void
+BluetoothServiceBluedroid::UpdatePlayStatus(
+  uint32_t aDuration, uint32_t aPosition, ControlPlayStatus aPlayStatus)
+{
+
+}
+
+nsresult
+BluetoothServiceBluedroid::SendSinkMessage(const nsAString& aDeviceAddresses,
+                                           const nsAString& aMessage)
+{
+  return NS_OK;
+}
+
+nsresult
+BluetoothServiceBluedroid::SendInputMessage(const nsAString& aDeviceAddresses,
+                                            const nsAString& aMessage)
+{
+  return NS_OK;
+}
+
+void
+BluetoothServiceBluedroid::AnswerWaitingCall(BluetoothReplyRunnable* aRunnable)
+{
+}
+
+void
+BluetoothServiceBluedroid::IgnoreWaitingCall(BluetoothReplyRunnable* aRunnable)
+{
+}
+
+void
+BluetoothServiceBluedroid::ToggleCalls(BluetoothReplyRunnable* aRunnable)
+{
+}
+
new file mode 100644
--- /dev/null
+++ b/dom/bluetooth/BluetoothServiceBluedroid.h
@@ -0,0 +1,189 @@
+/* -*- 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/. */
+
+#ifndef mozilla_dom_bluetooth_bluetoothservicebluedroid_h__
+#define mozilla_dom_bluetooth_bluetoothservicebluedroid_h__
+
+#include "BluetoothCommon.h"
+#include "BluetoothService.h"
+
+class DBusMessage;
+
+BEGIN_BLUETOOTH_NAMESPACE
+
+class BluetoothServiceBluedroid : public BluetoothService
+{
+public:
+  virtual nsresult StartInternal();
+  virtual nsresult StopInternal();
+  virtual bool IsEnabledInternal();
+
+  virtual nsresult GetDefaultAdapterPathInternal(
+                                             BluetoothReplyRunnable* aRunnable);
+
+  virtual nsresult GetConnectedDevicePropertiesInternal(uint16_t aProfileId,
+                                             BluetoothReplyRunnable* aRunnable);
+
+  virtual nsresult GetPairedDevicePropertiesInternal(
+                                     const nsTArray<nsString>& aDeviceAddress,
+                                     BluetoothReplyRunnable* aRunnable);
+
+  virtual nsresult StartDiscoveryInternal(BluetoothReplyRunnable* aRunnable);
+  virtual nsresult StopDiscoveryInternal(BluetoothReplyRunnable* aRunnable);
+
+  virtual nsresult
+  GetDevicePropertiesInternal(const BluetoothSignal& aSignal);
+
+  virtual nsresult
+  SetProperty(BluetoothObjectType aType,
+              const BluetoothNamedValue& aValue,
+              BluetoothReplyRunnable* aRunnable);
+
+  virtual bool
+  GetDevicePath(const nsAString& aAdapterPath,
+                const nsAString& aDeviceAddress,
+                nsAString& aDevicePath);
+
+  static bool
+  AddServiceRecords(const char* serviceName,
+                    unsigned long long uuidMsb,
+                    unsigned long long uuidLsb,
+                    int channel);
+
+  static bool
+  RemoveServiceRecords(const char* serviceName,
+                       unsigned long long uuidMsb,
+                       unsigned long long uuidLsb,
+                       int channel);
+
+  static bool
+  AddReservedServicesInternal(const nsTArray<uint32_t>& aServices,
+                              nsTArray<uint32_t>& aServiceHandlesContainer);
+
+  static bool
+  RemoveReservedServicesInternal(const nsTArray<uint32_t>& aServiceHandles);
+
+  virtual nsresult
+  GetScoSocket(const nsAString& aObjectPath,
+               bool aAuth,
+               bool aEncrypt,
+               mozilla::ipc::UnixSocketConsumer* aConsumer);
+
+  virtual nsresult
+  GetServiceChannel(const nsAString& aDeviceAddress,
+                    const nsAString& aServiceUuid,
+                    BluetoothProfileManagerBase* aManager);
+
+  virtual bool
+  UpdateSdpRecords(const nsAString& aDeviceAddress,
+                   BluetoothProfileManagerBase* aManager);
+
+  virtual nsresult
+  CreatePairedDeviceInternal(const nsAString& aDeviceAddress,
+                             int aTimeout,
+                             BluetoothReplyRunnable* aRunnable);
+
+  virtual nsresult
+  RemoveDeviceInternal(const nsAString& aDeviceObjectPath,
+                       BluetoothReplyRunnable* aRunnable);
+
+  virtual bool
+  SetPinCodeInternal(const nsAString& aDeviceAddress, const nsAString& aPinCode,
+                     BluetoothReplyRunnable* aRunnable);
+
+  virtual bool
+  SetPasskeyInternal(const nsAString& aDeviceAddress, uint32_t aPasskey,
+                     BluetoothReplyRunnable* aRunnable);
+
+  virtual bool
+  SetPairingConfirmationInternal(const nsAString& aDeviceAddress, bool aConfirm,
+                                 BluetoothReplyRunnable* aRunnable);
+
+  virtual bool
+  SetAuthorizationInternal(const nsAString& aDeviceAddress, bool aAllow,
+                           BluetoothReplyRunnable* aRunnable);
+
+  virtual nsresult
+  PrepareAdapterInternal();
+
+  virtual void
+  Connect(const nsAString& aDeviceAddress,
+          uint32_t aCod,
+          uint16_t aServiceUuid,
+          BluetoothReplyRunnable* aRunnable);
+
+  virtual bool
+  IsConnected(uint16_t aProfileId);
+
+  virtual void
+  Disconnect(const nsAString& aDeviceAddress, uint16_t aServiceUuid,
+             BluetoothReplyRunnable* aRunnable);
+
+  virtual void
+  SendFile(const nsAString& aDeviceAddress,
+           BlobParent* aBlobParent,
+           BlobChild* aBlobChild,
+           BluetoothReplyRunnable* aRunnable);
+
+  virtual void
+  StopSendingFile(const nsAString& aDeviceAddress,
+                  BluetoothReplyRunnable* aRunnable);
+
+  virtual void
+  ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirm,
+                       BluetoothReplyRunnable* aRunnable);
+
+  virtual void
+  ConnectSco(BluetoothReplyRunnable* aRunnable);
+
+  virtual void
+  DisconnectSco(BluetoothReplyRunnable* aRunnable);
+
+  virtual void
+  IsScoConnected(BluetoothReplyRunnable* aRunnable);
+
+  virtual void
+  AnswerWaitingCall(BluetoothReplyRunnable* aRunnable);
+
+  virtual void
+  IgnoreWaitingCall(BluetoothReplyRunnable* aRunnable);
+
+  virtual void
+  ToggleCalls(BluetoothReplyRunnable* aRunnable);
+
+  virtual void
+  SendMetaData(const nsAString& aTitle,
+               const nsAString& aArtist,
+               const nsAString& aAlbum,
+               int64_t aMediaNumber,
+               int64_t aTotalMediaCount,
+               int64_t aDuration,
+               BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
+
+  virtual void
+  SendPlayStatus(int64_t aDuration,
+                 int64_t aPosition,
+                 const nsAString& aPlayStatus,
+                 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
+
+  virtual void
+  UpdatePlayStatus(uint32_t aDuration,
+                   uint32_t aPosition,
+                   ControlPlayStatus aPlayStatus) MOZ_OVERRIDE;
+
+  virtual nsresult
+  SendSinkMessage(const nsAString& aDeviceAddresses,
+                  const nsAString& aMessage) MOZ_OVERRIDE;
+
+  virtual nsresult
+  SendInputMessage(const nsAString& aDeviceAddresses,
+                   const nsAString& aMessage) MOZ_OVERRIDE;
+};
+
+END_BLUETOOTH_NAMESPACE
+
+#endif
+
--- a/dom/bluetooth/BluetoothUnixSocketConnector.cpp
+++ b/dom/bluetooth/BluetoothUnixSocketConnector.cpp
@@ -22,32 +22,34 @@
  */
 
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <errno.h>
 
 #include <sys/socket.h>
+#ifdef MOZ_B2G_BT_BLUEZ
 #include <bluetooth/bluetooth.h>
 #include <bluetooth/l2cap.h>
 #include <bluetooth/rfcomm.h>
 #include <bluetooth/sco.h>
-
+#endif
 #include "BluetoothUnixSocketConnector.h"
 #include "nsThreadUtils.h"
 
 using namespace mozilla::ipc;
 USING_BLUETOOTH_NAMESPACE
 
 static const int RFCOMM_SO_SNDBUF = 70 * 1024;  // 70 KB send buffer
 static const int L2CAP_SO_SNDBUF = 400 * 1024;  // 400 KB send buffer
 static const int L2CAP_SO_RCVBUF = 400 * 1024;  // 400 KB receive buffer
 static const int L2CAP_MAX_MTU = 65000;
 
+#ifdef MOZ_B2G_BT_BLUEZ
 static
 int get_bdaddr(const char *str, bdaddr_t *ba)
 {
   char *d = ((char*)ba) + 5, *endp;
   for (int i = 0; i < 6; i++) {
     *d-- = strtol(str, &endp, 16);
     MOZ_ASSERT(!(*endp != ':' && i != 5));
     str = endp + 1;
@@ -57,30 +59,33 @@ int get_bdaddr(const char *str, bdaddr_t
 
 static
 void get_bdaddr_as_string(const bdaddr_t *ba, char *str) {
     const uint8_t *b = (const uint8_t *)ba;
     sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
             b[5], b[4], b[3], b[2], b[1], b[0]);
 }
 
+#endif
+
 BluetoothUnixSocketConnector::BluetoothUnixSocketConnector(
   BluetoothSocketType aType,
   int aChannel,
   bool aAuth,
   bool aEncrypt) : mType(aType)
                  , mChannel(aChannel)
                  , mAuth(aAuth)
                  , mEncrypt(aEncrypt)
 {
 }
 
 bool
 BluetoothUnixSocketConnector::SetUp(int aFd)
 {
+#ifdef MOZ_B2G_BT_BLUEZ
   int lm = 0;
   int sndbuf, rcvbuf;
 
   /* kernel does not yet support LM for SCO */
   switch (mType) {
   case BluetoothSocketType::RFCOMM:
     lm |= mAuth ? RFCOMM_LM_AUTH : 0;
     lm |= mEncrypt ? RFCOMM_LM_ENCRYPT : 0;
@@ -152,26 +157,27 @@ BluetoothUnixSocketConnector::SetUp(int 
 
       rcvbuf = L2CAP_SO_RCVBUF;
       if (setsockopt(aFd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf))) {
         BT_WARNING("setsockopt(SO_RCVBUF) failed, throwing");
         return false;
       }
     }
   }
-
+#endif
   return true;
 }
 
 int
 BluetoothUnixSocketConnector::Create()
 {
   MOZ_ASSERT(!NS_IsMainThread());
   int fd = -1;
 
+#ifdef MOZ_B2G_BT_BLUEZ
   switch (mType) {
   case BluetoothSocketType::RFCOMM:
     fd = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
     break;
   case BluetoothSocketType::SCO:
     fd = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO);
     break;
   case BluetoothSocketType::L2CAP:
@@ -188,26 +194,27 @@ BluetoothUnixSocketConnector::Create()
     BT_WARNING("Could not open bluetooth socket!");
     return -1;
   }
 
   if (!SetUp(fd)) {
     BT_WARNING("Could not set up socket!");
     return -1;
   }
-
+#endif
   return fd;
 }
 
 bool
 BluetoothUnixSocketConnector::CreateAddr(bool aIsServer,
                                          socklen_t& aAddrSize,
                                          sockaddr_any& aAddr,
                                          const char* aAddress)
 {
+#ifdef MOZ_B2G_BT_BLUEZ
   // Set to BDADDR_ANY, if it's not a server, we'll reset.
   bdaddr_t bd_address_obj = {{0, 0, 0, 0, 0, 0}};
 
   if (!aIsServer && aAddress && strlen(aAddress) > 0) {
     if (get_bdaddr(aAddress, &bd_address_obj)) {
       BT_WARNING("Can't get bluetooth address!");
       return false;
     }
@@ -237,32 +244,35 @@ BluetoothUnixSocketConnector::CreateAddr
     aAddrSize = sizeof(addr_sco);
     aAddr.sco.sco_family = AF_BLUETOOTH;
     memcpy(&aAddr.sco.sco_bdaddr, &bd_address_obj, sizeof(bd_address_obj));
     break;
   default:
     BT_WARNING("Socket type unknown!");
     return false;
   }
+#endif
   return true;
 }
 
 void
 BluetoothUnixSocketConnector::GetSocketAddr(const sockaddr_any& aAddr,
                                             nsAString& aAddrStr)
 {
+#ifdef MOZ_B2G_BT_BLUEZ
   char addr[18];
   switch (mType) {
   case BluetoothSocketType::RFCOMM:
     get_bdaddr_as_string((bdaddr_t*)(&aAddr.rc.rc_bdaddr), addr);
     break;
   case BluetoothSocketType::SCO:
     get_bdaddr_as_string((bdaddr_t*)(&aAddr.sco.sco_bdaddr), addr);
     break;
   case BluetoothSocketType::L2CAP:
   case BluetoothSocketType::EL2CAP:
     get_bdaddr_as_string((bdaddr_t*)(&aAddr.l2.l2_bdaddr), addr);
     break;
   default:
     MOZ_CRASH("Socket should be either RFCOMM or SCO!");
   }
   aAddrStr.AssignASCII(addr);
+#endif
 }
--- a/dom/bluetooth/Makefile.in
+++ b/dom/bluetooth/Makefile.in
@@ -31,16 +31,24 @@ ifdef MOZ_ENABLE_DBUS
 VPATH += $(srcdir)/linux
 LOCAL_INCLUDES += $(MOZ_DBUS_CFLAGS)
 CFLAGS += $(MOZ_DBUS_GLIB_CFLAGS)
 CXXFLAGS += $(MOZ_DBUS_GLIB_CFLAGS) -DHAVE_PTHREADS
 DEFINES += -DMOZ_BLUETOOTH_DBUS
 endif
 endif
 
+ifdef MOZ_B2G_BT_BLUEZ
+DEFINES += -DMOZ_B2G_BT_BLUEZ
+endif
+
+ifdef MOZ_B2G_BT_BLUEDROID
+DEFINES += -DMOZ_B2G_BT_BLUEDROID
+endif
+
 # Add VPATH to LOCAL_INCLUDES so we are going to include the correct backend
 # subdirectory.
 LOCAL_INCLUDES += $(VPATH:%=-I%)
 
 endif # MOZ_B2G_BT
 
 include $(topsrcdir)/config/rules.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
--- a/dom/bluetooth/linux/BluetoothDBusService.h
+++ b/dom/bluetooth/linux/BluetoothDBusService.h
@@ -19,16 +19,19 @@ BEGIN_BLUETOOTH_NAMESPACE
 /**
  * BluetoothDBusService is the implementation of BluetoothService for DBus on
  * linux/android/B2G. Function comments are in BluetoothService.h
  */
 
 class BluetoothDBusService : public BluetoothService
 {
 public:
+  BluetoothDBusService();
+  ~BluetoothDBusService();
+
   bool IsReady();
 
   virtual nsresult StartInternal() MOZ_OVERRIDE;
 
   virtual nsresult StopInternal() MOZ_OVERRIDE;
 
   virtual bool IsEnabledInternal() MOZ_OVERRIDE;
 
@@ -163,21 +166,16 @@ public:
 
   virtual nsresult
   SendSinkMessage(const nsAString& aDeviceAddresses,
                   const nsAString& aMessage) MOZ_OVERRIDE;
 
   virtual nsresult
   SendInputMessage(const nsAString& aDeviceAddresses,
                    const nsAString& aMessage) MOZ_OVERRIDE;
-
-protected:
-  BluetoothDBusService();
-  ~BluetoothDBusService();
-
 private:
   /**
    * For DBus Control method of "UpdateNotification", event id should be
    * specified as following:
    * (Please see specification of AVRCP 1.3, Table 5.28 for more details.)
    */
   enum ControlEventId {
     EVENT_PLAYBACK_STATUS_CHANGED            = 0x01,
--- a/dom/bluetooth/moz.build
+++ b/dom/bluetooth/moz.build
@@ -48,24 +48,29 @@ if CONFIG['MOZ_B2G_BT']:
     ]
 
     if CONFIG['MOZ_B2G_RIL']:
         CPP_SOURCES += [
             'BluetoothRilListener.cpp',
         ]
 
     if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
-        CPP_SOURCES += [
-            'linux/BluetoothDBusService.cpp',
-            'gonk/BluetoothGonkService.cpp',
-        ]
+        if CONFIG['MOZ_B2G_BT_BLUEZ']:
+            CPP_SOURCES += [
+               'linux/BluetoothDBusService.cpp',
+               'gonk/BluetoothGonkService.cpp',
+            ]
+        if CONFIG['MOZ_B2G_BT_BLUEDROID']:
+            CPP_SOURCES += [
+                'BluetoothServiceBluedroid.cpp',
+            ]
     else:
         if CONFIG['MOZ_ENABLE_DBUS']:
             CPP_SOURCES += [
-                'linux/BluetoothDBusService.cpp',
+                 'linux/BluetoothDBusService.cpp',
             ]
 
 EXPORTS.mozilla.dom.bluetooth.ipc += [
     'ipc/BluetoothMessageUtils.h',
 ]
 
 EXPORTS.mozilla.dom.bluetooth += [
     'BluetoothCommon.h',
--- a/dom/network/interfaces/nsIMobileConnectionProvider.idl
+++ b/dom/network/interfaces/nsIMobileConnectionProvider.idl
@@ -28,84 +28,60 @@ interface nsIMobileConnectionListener : 
                                     in unsigned long timeoutMs);
   void notifyOtaStatusChanged(in DOMString status);
 };
 
 /**
  * XPCOM component (in the content process) that provides the mobile
  * network information.
  */
-[scriptable, uuid(84278a49-0f05-4585-b3f4-c74882ae5719)]
+[scriptable, uuid(c66652e0-0628-11e3-8ffd-0800200c9a66)]
 interface nsIMobileConnectionProvider : nsISupports
 {
   /**
    * Called when a content process registers receiving unsolicited messages from
    * RadioInterfaceLayer in the chrome process. Only a content process that has
    * the 'mobileconnection' permission is allowed to register.
    */
-  void registerMobileConnectionMsg(in unsigned long clientId,
-                                   in nsIMobileConnectionListener listener);
-  void unregisterMobileConnectionMsg(in unsigned long clientId,
-                                     in nsIMobileConnectionListener listener);
-
-  nsIDOMMozMobileConnectionInfo getVoiceConnectionInfo(in unsigned long clientId);
-  nsIDOMMozMobileConnectionInfo getDataConnectionInfo(in unsigned long clientId);
-  DOMString getIccId(in unsigned long clientId);
-  DOMString getNetworkSelectionMode(in unsigned long clientId);
+  void registerMobileConnectionMsg(in nsIMobileConnectionListener listener);
+  void unregisterMobileConnectionMsg(in nsIMobileConnectionListener listener);
 
-  nsIDOMDOMRequest getNetworks(in unsigned long clientId,
-                               in nsIDOMWindow window);
-  nsIDOMDOMRequest selectNetwork(in unsigned long clientId,
-                                 in nsIDOMWindow window,
-                                 in nsIDOMMozMobileNetworkInfo network);
-  nsIDOMDOMRequest selectNetworkAutomatically(in unsigned long clientId,
-                                              in nsIDOMWindow window);
+  readonly attribute nsIDOMMozMobileConnectionInfo voiceConnectionInfo;
+  readonly attribute nsIDOMMozMobileConnectionInfo dataConnectionInfo;
+  readonly attribute DOMString networkSelectionMode;
 
-  nsIDOMDOMRequest setRoamingPreference(in unsigned long clientId,
-                                        in nsIDOMWindow window,
+  nsIDOMDOMRequest getNetworks(in nsIDOMWindow window);
+  nsIDOMDOMRequest selectNetwork(in nsIDOMWindow window, in nsIDOMMozMobileNetworkInfo network);
+  nsIDOMDOMRequest selectNetworkAutomatically(in nsIDOMWindow window);
+
+  nsIDOMDOMRequest setRoamingPreference(in nsIDOMWindow window,
                                         in DOMString mode);
-  nsIDOMDOMRequest getRoamingPreference(in unsigned long clientId,
-                                        in nsIDOMWindow window);
+  nsIDOMDOMRequest getRoamingPreference(in nsIDOMWindow window);
 
-  nsIDOMDOMRequest setVoicePrivacyMode(in unsigned long clientId,
-                                       in nsIDOMWindow window,
+  nsIDOMDOMRequest setVoicePrivacyMode(in nsIDOMWindow window,
                                        in bool enabled);
-  nsIDOMDOMRequest getVoicePrivacyMode(in unsigned long clientId,
-                                       in nsIDOMWindow window);
+  nsIDOMDOMRequest getVoicePrivacyMode(in nsIDOMWindow window);
 
-  nsIDOMDOMRequest sendMMI(in unsigned long clientId,
-                           in nsIDOMWindow window,
-                           in DOMString mmi);
-  nsIDOMDOMRequest cancelMMI(in unsigned long clientId,
-                             in nsIDOMWindow window);
+  nsIDOMDOMRequest sendMMI(in nsIDOMWindow window, in DOMString mmi);
+  nsIDOMDOMRequest cancelMMI(in nsIDOMWindow window);
 
-  nsIDOMDOMRequest getCallForwardingOption(in unsigned long clientId,
-                                           in nsIDOMWindow window,
+  nsIDOMDOMRequest getCallForwardingOption(in nsIDOMWindow   window,
                                            in unsigned short reason);
-  nsIDOMDOMRequest setCallForwardingOption(in unsigned long clientId,
-                                           in nsIDOMWindow window,
+  nsIDOMDOMRequest setCallForwardingOption(in nsIDOMWindow          window,
                                            in nsIDOMMozMobileCFInfo CFInfo);
 
-  nsIDOMDOMRequest getCallBarringOption(in unsigned long clientId,
-                                        in nsIDOMWindow window,
-                                        in jsval option);
-  nsIDOMDOMRequest setCallBarringOption(in unsigned long clientId,
-                                        in nsIDOMWindow window,
-                                        in jsval option);
-  nsIDOMDOMRequest changeCallBarringPassword(in unsigned long clientId,
-                                             in nsIDOMWindow window,
+  nsIDOMDOMRequest getCallBarringOption(in nsIDOMWindow window,
+                                        in jsval        option);
+  nsIDOMDOMRequest setCallBarringOption(in nsIDOMWindow window,
+                                        in jsval        option);
+  nsIDOMDOMRequest changeCallBarringPassword(in nsIDOMWindow window,
                                              in jsval info);
 
-  nsIDOMDOMRequest setCallWaitingOption(in unsigned long clientId,
-                                        in nsIDOMWindow window,
+  nsIDOMDOMRequest setCallWaitingOption(in nsIDOMWindow   window,
                                         in bool enabled);
-  nsIDOMDOMRequest getCallWaitingOption(in unsigned long clientId,
-                                        in nsIDOMWindow window);
+  nsIDOMDOMRequest getCallWaitingOption(in nsIDOMWindow   window);
 
-  nsIDOMDOMRequest setCallingLineIdRestriction(in unsigned long clientId,
-                                               in nsIDOMWindow window,
+  nsIDOMDOMRequest setCallingLineIdRestriction(in nsIDOMWindow   window,
                                                in unsigned short clirMode);
-  nsIDOMDOMRequest getCallingLineIdRestriction(in unsigned long clientId,
-                                               in nsIDOMWindow window);
+  nsIDOMDOMRequest getCallingLineIdRestriction(in nsIDOMWindow   window);
 
-  nsIDOMDOMRequest exitEmergencyCbMode(in unsigned long clientId,
-                                       in nsIDOMWindow window);
+  nsIDOMDOMRequest exitEmergencyCbMode(in nsIDOMWindow window);
 };
--- a/dom/network/src/MobileConnection.cpp
+++ b/dom/network/src/MobileConnection.cpp
@@ -78,19 +78,16 @@ NS_IMPL_EVENT_HANDLER(MobileConnection, 
 NS_IMPL_EVENT_HANDLER(MobileConnection, emergencycbmodechange)
 NS_IMPL_EVENT_HANDLER(MobileConnection, otastatuschange)
 
 MobileConnection::MobileConnection()
 {
   mProvider = do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
   mWindow = nullptr;
 
-  // TODO: Bug 814629 - WebMobileConnection API: support multiple sim cards
-  mClientId = 0;
-
   // Not being able to acquire the provider isn't fatal since we check
   // for it explicitly below.
   if (!mProvider) {
     NS_WARNING("Could not acquire nsIMobileConnectionProvider!");
     return;
   }
 }
 
@@ -99,30 +96,30 @@ MobileConnection::Init(nsPIDOMWindow* aW
 {
   BindToOwner(aWindow);
 
   mWindow = do_GetWeakReference(aWindow);
   mListener = new Listener(this);
 
   if (!CheckPermission("mobilenetwork") &&
       CheckPermission("mobileconnection")) {
-    DebugOnly<nsresult> rv = mProvider->RegisterMobileConnectionMsg(mClientId, mListener);
+    DebugOnly<nsresult> rv = mProvider->RegisterMobileConnectionMsg(mListener);
     NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
                      "Failed registering mobile connection messages with provider");
 
     printf_stderr("MobileConnection initialized");
   }
 }
 
 void
 MobileConnection::Shutdown()
 {
   if (mProvider && mListener) {
     mListener->Disconnect();
-    mProvider->UnregisterMobileConnectionMsg(mClientId, mListener);
+    mProvider->UnregisterMobileConnectionMsg(mListener);
     mProvider = nullptr;
     mListener = nullptr;
   }
 }
 
 // nsIDOMMozMobileConnection
 
 NS_IMETHODIMP
@@ -171,347 +168,347 @@ MobileConnection::CheckPermission(const 
 NS_IMETHODIMP
 MobileConnection::GetVoice(nsIDOMMozMobileConnectionInfo** voice)
 {
   *voice = nullptr;
 
   if (!mProvider || !CheckPermission("mobileconnection")) {
     return NS_OK;
   }
-  return mProvider->GetVoiceConnectionInfo(mClientId, voice);
+  return mProvider->GetVoiceConnectionInfo(voice);
 }
 
 NS_IMETHODIMP
 MobileConnection::GetData(nsIDOMMozMobileConnectionInfo** data)
 {
   *data = nullptr;
 
   if (!mProvider || !CheckPermission("mobileconnection")) {
     return NS_OK;
   }
-  return mProvider->GetDataConnectionInfo(mClientId, data);
+  return mProvider->GetDataConnectionInfo(data);
 }
 
 NS_IMETHODIMP
 MobileConnection::GetNetworkSelectionMode(nsAString& networkSelectionMode)
 {
   networkSelectionMode.SetIsVoid(true);
 
   if (!mProvider || !CheckPermission("mobileconnection")) {
      return NS_OK;
   }
-  return mProvider->GetNetworkSelectionMode(mClientId, networkSelectionMode);
+  return mProvider->GetNetworkSelectionMode(networkSelectionMode);
 }
 
 NS_IMETHODIMP
 MobileConnection::GetNetworks(nsIDOMDOMRequest** request)
 {
   *request = nullptr;
 
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->GetNetworks(mClientId, GetOwner(), request);
+  return mProvider->GetNetworks(GetOwner(), request);
 }
 
 NS_IMETHODIMP
 MobileConnection::SelectNetwork(nsIDOMMozMobileNetworkInfo* network, nsIDOMDOMRequest** request)
 {
   *request = nullptr;
 
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->SelectNetwork(mClientId, GetOwner(), network, request);
+  return mProvider->SelectNetwork(GetOwner(), network, request);
 }
 
 NS_IMETHODIMP
 MobileConnection::SelectNetworkAutomatically(nsIDOMDOMRequest** request)
 {
   *request = nullptr;
 
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->SelectNetworkAutomatically(mClientId, GetOwner(), request);
+  return mProvider->SelectNetworkAutomatically(GetOwner(), request);
 }
 
 NS_IMETHODIMP
 MobileConnection::SetRoamingPreference(const nsAString& aMode, nsIDOMDOMRequest** aDomRequest)
 {
   *aDomRequest = nullptr;
 
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->SetRoamingPreference(mClientId, GetOwner(), aMode, aDomRequest);
+  return mProvider->SetRoamingPreference(GetOwner(), aMode, aDomRequest);
 }
 
 NS_IMETHODIMP
 MobileConnection::GetRoamingPreference(nsIDOMDOMRequest** aDomRequest)
 {
   *aDomRequest = nullptr;
 
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->GetRoamingPreference(mClientId, GetOwner(), aDomRequest);
+  return mProvider->GetRoamingPreference(GetOwner(), aDomRequest);
 }
 
 NS_IMETHODIMP
 MobileConnection::SetVoicePrivacyMode(bool aEnabled, nsIDOMDOMRequest** aDomRequest)
 {
   *aDomRequest = nullptr;
 
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->SetVoicePrivacyMode(mClientId, GetOwner(), aEnabled, aDomRequest);
+  return mProvider->SetVoicePrivacyMode(GetOwner(), aEnabled, aDomRequest);
 }
 
 NS_IMETHODIMP
 MobileConnection::GetVoicePrivacyMode(nsIDOMDOMRequest** aDomRequest)
 {
   *aDomRequest = nullptr;
 
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->GetVoicePrivacyMode(mClientId, GetOwner(), aDomRequest);
+  return mProvider->GetVoicePrivacyMode(GetOwner(), aDomRequest);
 }
 
 NS_IMETHODIMP
 MobileConnection::SendMMI(const nsAString& aMMIString,
                           nsIDOMDOMRequest** aRequest)
 {
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->SendMMI(mClientId, GetOwner(), aMMIString, aRequest);
+  return mProvider->SendMMI(GetOwner(), aMMIString, aRequest);
 }
 
 NS_IMETHODIMP
 MobileConnection::CancelMMI(nsIDOMDOMRequest** aRequest)
 {
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->CancelMMI(mClientId, GetOwner(),aRequest);
+  return mProvider->CancelMMI(GetOwner(), aRequest);
 }
 
 NS_IMETHODIMP
 MobileConnection::GetCallForwardingOption(uint16_t aReason,
                                           nsIDOMDOMRequest** aRequest)
 {
   *aRequest = nullptr;
 
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->GetCallForwardingOption(mClientId, GetOwner(), aReason, aRequest);
+  return mProvider->GetCallForwardingOption(GetOwner(), aReason, aRequest);
 }
 
 NS_IMETHODIMP
 MobileConnection::SetCallForwardingOption(nsIDOMMozMobileCFInfo* aCFInfo,
                                           nsIDOMDOMRequest** aRequest)
 {
   *aRequest = nullptr;
 
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->SetCallForwardingOption(mClientId, GetOwner(), aCFInfo, aRequest);
+  return mProvider->SetCallForwardingOption(GetOwner(), aCFInfo, aRequest);
 }
 
 NS_IMETHODIMP
 MobileConnection::GetCallBarringOption(const JS::Value& aOption,
                                        nsIDOMDOMRequest** aRequest)
 {
   *aRequest = nullptr;
 
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->GetCallBarringOption(mClientId, GetOwner(), aOption, aRequest);
+  return mProvider->GetCallBarringOption(GetOwner(), aOption, aRequest);
 }
 
 NS_IMETHODIMP
 MobileConnection::SetCallBarringOption(const JS::Value& aOption,
                                        nsIDOMDOMRequest** aRequest)
 {
   *aRequest = nullptr;
 
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->SetCallBarringOption(mClientId, GetOwner(), aOption, aRequest);
+  return mProvider->SetCallBarringOption(GetOwner(), aOption, aRequest);
 }
 
 NS_IMETHODIMP
 MobileConnection::ChangeCallBarringPassword(const JS::Value& aInfo,
                                             nsIDOMDOMRequest** aRequest)
 {
   *aRequest = nullptr;
 
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->ChangeCallBarringPassword(mClientId, GetOwner(), aInfo, aRequest);
+  return mProvider->ChangeCallBarringPassword(GetOwner(), aInfo, aRequest);
 }
 
 NS_IMETHODIMP
 MobileConnection::GetCallWaitingOption(nsIDOMDOMRequest** aRequest)
 {
   *aRequest = nullptr;
 
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->GetCallWaitingOption(mClientId, GetOwner(), aRequest);
+  return mProvider->GetCallWaitingOption(GetOwner(), aRequest);
 }
 
 NS_IMETHODIMP
 MobileConnection::SetCallWaitingOption(bool aEnabled,
                                        nsIDOMDOMRequest** aRequest)
 {
   *aRequest = nullptr;
 
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->SetCallWaitingOption(mClientId, GetOwner(), aEnabled, aRequest);
+  return mProvider->SetCallWaitingOption(GetOwner(), aEnabled, aRequest);
 }
 
 NS_IMETHODIMP
 MobileConnection::GetCallingLineIdRestriction(nsIDOMDOMRequest** aRequest)
 {
   *aRequest = nullptr;
 
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->GetCallingLineIdRestriction(mClientId, GetOwner(), aRequest);
+  return mProvider->GetCallingLineIdRestriction(GetOwner(), aRequest);
 }
 
 NS_IMETHODIMP
 MobileConnection::SetCallingLineIdRestriction(unsigned short aClirMode,
                                               nsIDOMDOMRequest** aRequest)
 {
   *aRequest = nullptr;
 
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->SetCallingLineIdRestriction(mClientId, GetOwner(), aClirMode, aRequest);
+  return mProvider->SetCallingLineIdRestriction(GetOwner(), aClirMode, aRequest);
 }
 
 NS_IMETHODIMP
 MobileConnection::ExitEmergencyCbMode(nsIDOMDOMRequest** aRequest)
 {
   *aRequest = nullptr;
 
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
-  return mProvider->ExitEmergencyCbMode(mClientId, GetOwner(), aRequest);
+  return mProvider->ExitEmergencyCbMode(GetOwner(), aRequest);
 }
 
 // nsIMobileConnectionListener
 
 NS_IMETHODIMP
 MobileConnection::NotifyVoiceChanged()
 {
   if (!CheckPermission("mobileconnection")) {
--- a/dom/network/src/MobileConnection.h
+++ b/dom/network/src/MobileConnection.h
@@ -43,18 +43,16 @@ public:
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MobileConnection,
                                            nsDOMEventTargetHelper)
 
 private:
   nsCOMPtr<nsIMobileConnectionProvider> mProvider;
   nsRefPtr<Listener> mListener;
   nsWeakPtr mWindow;
 
-  uint32_t mClientId;
-
   bool CheckPermission(const char* type);
 };
 
 } // namespace network
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_network_MobileConnection_h
--- a/dom/phonenumberutils/PhoneNumberUtils.jsm
+++ b/dom/phonenumberutils/PhoneNumberUtils.jsm
@@ -39,18 +39,17 @@ this.PhoneNumberUtils = {
   _mcc: '724',
 
   getCountryName: function getCountryName() {
     let mcc;
     let countryName;
 
 #ifdef MOZ_B2G_RIL
     // Get network mcc
-    // TODO: Bug 926740 - PhoneNumberUtils for multisim
-    let voice = mobileConnection.getVoiceConnectionInfo(0);
+    let voice = mobileConnection.voiceConnectionInfo;
     if (voice && voice.network && voice.network.mcc) {
       mcc = voice.network.mcc;
     }
 
     // Get SIM mcc
     let iccInfo = icc.iccInfo;
     if (!mcc && iccInfo && iccInfo.mcc) {
       mcc = iccInfo.mcc;
--- a/dom/system/gonk/RILContentHelper.js
+++ b/dom/system/gonk/RILContentHelper.js
@@ -83,23 +83,23 @@ const RIL_IPC_MSG_NAMES = [
   "RIL:CardLockResult",
   "RIL:CardLockRetryCount",
   "RIL:USSDReceived",
   "RIL:SendMMI",
   "RIL:CancelMMI",
   "RIL:StkCommand",
   "RIL:StkSessionEnd",
   "RIL:DataError",
-  "RIL:SetCallForwardingOptions",
-  "RIL:GetCallForwardingOptions",
-  "RIL:SetCallBarringOptions",
-  "RIL:GetCallBarringOptions",
+  "RIL:SetCallForwardingOption",
+  "RIL:GetCallForwardingOption",
+  "RIL:SetCallBarringOption",
+  "RIL:GetCallBarringOption",
   "RIL:ChangeCallBarringPassword",
-  "RIL:SetCallWaitingOptions",
-  "RIL:GetCallWaitingOptions",
+  "RIL:SetCallWaitingOption",
+  "RIL:GetCallWaitingOption",
   "RIL:SetCallingLineIdRestriction",
   "RIL:GetCallingLineIdRestriction",
   "RIL:CellBroadcastReceived",
   "RIL:CfStateChanged",
   "RIL:IccOpenChannel",
   "RIL:IccCloseChannel",
   "RIL:IccExchangeAPDU",
   "RIL:ReadIccContacts",
@@ -379,23 +379,23 @@ CellBroadcastEtwsInfo.prototype = {
 
   // nsIDOMMozCellBroadcastEtwsInfo
 
   warningType: null,
   emergencyUserAlert: null,
   popup: null
 };
 
-function CallBarringOptions(options) {
-  this.program = options.program;
-  this.enabled = options.enabled;
-  this.password = options.password;
-  this.serviceClass = options.serviceClass;
+function CallBarringOption(option) {
+  this.program = option.program;
+  this.enabled = option.enabled;
+  this.password = option.password;
+  this.serviceClass = option.serviceClass;
 }
-CallBarringOptions.prototype = {
+CallBarringOption.prototype = {
   __exposedProps__ : {program: 'r',
                       enabled: 'r',
                       password: 'r',
                       serviceClass: 'r'}
 };
 
 function DOMMMIResult(result) {
   this.serviceCode = result.serviceCode;
@@ -444,40 +444,27 @@ IccCardLockError.prototype = {
   __init: function(lockType, errorMsg, retryCount) {
     this.__DOM_IMPL__.init(errorMsg);
     this.lockType = lockType;
     this.retryCount = retryCount;
   },
 };
 
 function RILContentHelper() {
-
-  this.numClients = gNumRadioInterfaces;
-  debug("Number of clients: " + this.numClients);
-
-  this.rilContexts = [];
-  for (let clientId = 0; clientId < this.numClients; clientId++) {
-    this.rilContexts[clientId] = {
-      cardState:            RIL.GECKO_CARDSTATE_UNKNOWN,
-      networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN,
-      iccInfo:              null,
-      voiceConnectionInfo:  new MobileConnectionInfo(),
-      dataConnectionInfo:   new MobileConnectionInfo()
-    };
-  }
+  this.rilContext = {
+    cardState:            RIL.GECKO_CARDSTATE_UNKNOWN,
+    networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN,
+    iccInfo:              null,
+    voiceConnectionInfo:  new MobileConnectionInfo(),
+    dataConnectionInfo:   new MobileConnectionInfo()
+  };
   this.voicemailInfo = new VoicemailInfo();
 
   this.initDOMRequestHelper(/* aWindow */ null, RIL_IPC_MSG_NAMES);
   this._windowsMap = [];
-  this._selectingNetworks = [];
-  this._mobileConnectionListeners = [];
-  this._cellBroadcastListeners = [];
-  this._voicemailListeners = [];
-  this._iccListeners = [];
-
   Services.obs.addObserver(this, "xpcom-shutdown", false);
 }
 
 RILContentHelper.prototype = {
   __proto__: DOMRequestIpcHelper.prototype,
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionProvider,
                                          Ci.nsICellBroadcastProvider,
@@ -533,138 +520,123 @@ RILContentHelper.prototype = {
     this.updateInfo(srcNetwork, network);
   },
 
   /**
    * We need to consider below cases when update iccInfo:
    * 1. Should clear iccInfo to null if there is no card detected.
    * 2. Need to create corresponding object based on iccType.
    */
-  updateIccInfo: function updateIccInfo(clientId, newInfo) {
-    let rilContext = this.rilContexts[clientId];
-
+  updateIccInfo: function updateIccInfo(newInfo) {
     // Card is not detected, clear iccInfo to null.
     if (!newInfo || !newInfo.iccType) {
-      rilContext.iccInfo = null;
+      this.rilContext.iccInfo = null;
       return;
     }
 
     // If iccInfo is null, new corresponding object based on iccType.
-    if (!rilContext.iccInfo) {
+    if (!this.rilContext.iccInfo) {
       if (newInfo.iccType === "ruim" || newInfo.iccType === "csim") {
-        rilContext.iccInfo = new CdmaIccInfo();
+        this.rilContext.iccInfo = new CdmaIccInfo();
       } else {
-        rilContext.iccInfo = new GsmIccInfo();
+        this.rilContext.iccInfo = new GsmIccInfo();
       }
     }
 
-    this.updateInfo(newInfo, rilContext.iccInfo);
+    this.updateInfo(newInfo, this.rilContext.iccInfo);
   },
 
   _windowsMap: null,
 
-  rilContexts: null,
+  rilContext: null,
 
-  getRilContext: function getRilContext(clientId) {
-    // Update ril contexts by sending IPC message to chrome only when the first
+  getRilContext: function getRilContext() {
+    // Update ril context by sending IPC message to chrome only when the first
     // time we require it. The information will be updated by following info
     // changed messages.
-    this.getRilContext = function getRilContext(clientId) {
-      return this.rilContexts[clientId];
+    this.getRilContext = function getRilContext() {
+      return this.rilContext;
     };
 
-    for (let cId = 0; cId < this.numClients; cId++) {
-      let rilContext =
-        cpmm.sendSyncMessage("RIL:GetRilContext", {clientId: cId})[0];
-      if (!rilContext) {
-        debug("Received null rilContext from chrome process.");
-        continue;
-      }
-      this.rilContexts[cId].cardState = rilContext.cardState;
-      this.rilContexts[cId].networkSelectionMode = rilContext.networkSelectionMode;
-      this.updateIccInfo(cId, rilContext.iccInfo);
-      this.updateConnectionInfo(rilContext.voice, this.rilContexts[cId].voiceConnectionInfo);
-      this.updateConnectionInfo(rilContext.data, this.rilContexts[cId].dataConnectionInfo);
+    let rilContext =
+      cpmm.sendSyncMessage("RIL:GetRilContext", {clientId: 0})[0];
+    if (!rilContext) {
+      debug("Received null rilContext from chrome process.");
+      return;
     }
+    this.rilContext.cardState = rilContext.cardState;
+    this.rilContext.networkSelectionMode = rilContext.networkSelectionMode;
+    this.updateIccInfo(rilContext.iccInfo);
+    this.updateConnectionInfo(rilContext.voice, this.rilContext.voiceConnectionInfo);
+    this.updateConnectionInfo(rilContext.data, this.rilContext.dataConnectionInfo);
 
-    return this.rilContexts[clientId];
-  },
-
-  /**
-   * nsIIccProvider
-   */
-
-  get iccInfo() {
-    //TODO: Bug 814637 - WebIccManager API: support multiple sim cards.
-    let context = this.getRilContext(0);
-    return context && context.iccInfo;
-  },
-
-  get cardState() {
-    //TODO: Bug 814637 - WebIccManager API: support multiple sim cards.
-    let context = this.getRilContext(0);
-    return context && context.cardState;
+    return this.rilContext;
   },
 
   /**
    * nsIMobileConnectionProvider
    */
 
-  getVoiceConnectionInfo: function getVoiceConnectionInfo(clientId) {
-    let context = this.getRilContext(clientId);
+  get iccInfo() {
+    let context = this.getRilContext();
+    return context && context.iccInfo;
+  },
+
+  get voiceConnectionInfo() {
+    let context = this.getRilContext();
     return context && context.voiceConnectionInfo;
   },
 
-  getDataConnectionInfo: function getDataConnectionInfo(clientId) {
-    let context = this.getRilContext(clientId);
+  get dataConnectionInfo() {
+    let context = this.getRilContext();
     return context && context.dataConnectionInfo;
   },
 
-  getIccId: function getIccId(clientId) {
-    let context = this.getRilContext(clientId);
-    return context && context.iccInfo.iccid;
+  get cardState() {
+    let context = this.getRilContext();
+    return context && context.cardState;
   },
 
-  getNetworkSelectionMode: function getNetworkSelectionMode(clientId) {
-    let context = this.getRilContext(clientId);
+  get networkSelectionMode() {
+    let context = this.getRilContext();
     return context && context.networkSelectionMode;
   },
 
   /**
-   * The networks that are currently trying to be selected (or "automatic").
-   * This helps ensure that only one network per client is selected at a time.
+   * The network that is currently trying to be selected (or "automatic").
+   * This helps ensure that only one network is selected at a time.
    */
-  _selectingNetworks: null,
+  _selectingNetwork: null,
 
-  getNetworks: function getNetworks(clientId, window) {
+  getNetworks: function getNetworks(window) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
 
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
 
     cpmm.sendAsyncMessage("RIL:GetAvailableNetworks", {
-      clientId: clientId,
+      clientId: 0,
       data: {
         requestId: requestId
       }
     });
     return request;
   },
 
-  selectNetwork: function selectNetwork(clientId, window, network) {
+  selectNetwork: function selectNetwork(window, network) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
 
-    if (this._selectingNetworks[clientId]) {
-      throw new Error("Already selecting a network: " + this._selectingNetworks[clientId]);
+    if (this._selectingNetwork) {
+      throw new Error("Already selecting a network: " + this._selectingNetwork);
     }
 
     if (!network) {
       throw new Error("Invalid network provided: " + network);
     }
 
     if (isNaN(parseInt(network.mnc, 10))) {
       throw new Error("Invalid network MNC: " + network.mnc);
@@ -672,143 +644,143 @@ RILContentHelper.prototype = {
 
     if (isNaN(parseInt(network.mcc, 10))) {
       throw new Error("Invalid network MCC: " + network.mcc);
     }
 
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
 
-    if (this.rilContexts[clientId].networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_MANUAL &&
-        this.rilContexts[clientId].voiceConnectionInfo.network === network) {
+    if (this.rilContext.networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_MANUAL &&
+        this.rilContext.voiceConnectionInfo.network === network) {
 
       // Already manually selected this network, so schedule
       // onsuccess to be fired on the next tick
       this.dispatchFireRequestSuccess(requestId, null);
       return request;
     }
 
-    this._selectingNetworks[clientId] = network;
+    this._selectingNetwork = network;
 
     cpmm.sendAsyncMessage("RIL:SelectNetwork", {
-      clientId: clientId,
+      clientId: 0,
       data: {
         requestId: requestId,
         mnc: network.mnc,
         mcc: network.mcc
       }
     });
 
     return request;
   },
 
-  selectNetworkAutomatically: function selectNetworkAutomatically(clientId, window) {
+  selectNetworkAutomatically: function selectNetworkAutomatically(window) {
 
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
 
-    if (this._selectingNetworks[clientId]) {
-      throw new Error("Already selecting a network: " + this._selectingNetworks[clientId]);
+    if (this._selectingNetwork) {
+      throw new Error("Already selecting a network: " + this._selectingNetwork);
     }
 
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
 
-    if (this.rilContexts[clientId].networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_AUTOMATIC) {
+    if (this.rilContext.networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_AUTOMATIC) {
       // Already using automatic selection mode, so schedule
       // onsuccess to be be fired on the next tick
       this.dispatchFireRequestSuccess(requestId, null);
       return request;
     }
 
-    this._selectingNetworks[clientId] = "automatic";
+    this._selectingNetwork = "automatic";
     cpmm.sendAsyncMessage("RIL:SelectNetworkAuto", {
-      clientId: clientId,
+      clientId: 0,
       data: {
         requestId: requestId
       }
     });
     return request;
   },
 
-  setRoamingPreference: function setRoamingPreference(clientId, window, mode) {
+  setRoamingPreference: function setRoamingPreference(window, mode) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
 
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
 
     if (!mode) {
       this.dispatchFireRequestError(requestId,
                                     RIL.GECKO_ERROR_INVALID_PARAMETER);
       return request;
     }
 
     cpmm.sendAsyncMessage("RIL:SetRoamingPreference", {
-      clientId: clientId,
+      clientId: 0,
       data: {
         requestId: requestId,
         mode: mode
       }
     });
     return request;
   },
 
-  getRoamingPreference: function getRoamingPreference(clientId, window) {
+  getRoamingPreference: function getRoamingPreference(window) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
 
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
 
     cpmm.sendAsyncMessage("RIL:GetRoamingPreference", {
-      clientId: clientId,
+      clientId: 0,
       data: {
         requestId: requestId
       }
     });
     return request;
   },
 
-  setVoicePrivacyMode: function setVoicePrivacyMode(clientId, window, enabled) {
+  setVoicePrivacyMode: function setVoicePrivacyMode(window, enabled) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
 
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
 
     cpmm.sendAsyncMessage("RIL:SetVoicePrivacyMode", {
-      clientId: clientId,
+      clientId: 0,
       data: {
         requestId: requestId,
         enabled: enabled
       }
     });
     return request;
   },
 
-  getVoicePrivacyMode: function getVoicePrivacyMode(clientId, window) {
+  getVoicePrivacyMode: function getVoicePrivacyMode(window) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
 
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
 
     cpmm.sendAsyncMessage("RIL:GetVoicePrivacyMode", {
-      clientId: clientId,
+      clientId: 0,
       data: {
         requestId: requestId
       }
     });
     return request;
   },
 
   getCardLockState: function getCardLockState(window, lockType) {
@@ -874,48 +846,48 @@ RILContentHelper.prototype = {
       data: {
         lockType: lockType,
         requestId: requestId
       }
     });
     return request;
   },
 
-  sendMMI: function sendMMI(clientId, window, mmi) {
+  sendMMI: function sendMMI(window, mmi) {
     debug("Sending MMI " + mmi);
     if (!window) {
       throw Components.Exception("Can't get window object",
                                  Cr.NS_ERROR_UNEXPECTED);
     }
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
     // We need to save the global window to get the proper MMIError
     // constructor once we get the reply from the parent process.
     this._windowsMap[requestId] = window;
 
     cpmm.sendAsyncMessage("RIL:SendMMI", {
-      clientId: clientId,
+      clientId: 0,
       data: {
         mmi: mmi,
         requestId: requestId
       }
     });
     return request;
   },
 
-  cancelMMI: function cancelMMI(clientId, window) {
+  cancelMMI: function cancelMMI(window) {
     debug("Cancel MMI");
     if (!window) {
       throw Components.Exception("Can't get window object",
                                  Cr.NS_ERROR_UNEXPECTED);
     }
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
     cpmm.sendAsyncMessage("RIL:CancelMMI", {
-      clientId: clientId,
+      clientId: 0,
       data: {
         requestId: requestId
       }
     });
     return request;
   },
 
   sendStkResponse: function sendStkResponse(window, command, response) {
@@ -1099,128 +1071,128 @@ RILContentHelper.prototype = {
         contact: iccContact,
         pin2: pin2
       }
     });
 
     return request;
   },
 
-  getCallForwardingOption: function getCallForwardingOption(clientId, window, reason) {
+  getCallForwardingOption: function getCallForwardingOption(window, reason) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
 
     if (!this._isValidCFReason(reason)){
       this.dispatchFireRequestError(requestId,
                                     RIL.GECKO_ERROR_INVALID_PARAMETER);
       return request;
     }
 
-    cpmm.sendAsyncMessage("RIL:GetCallForwardingOptions", {
-      clientId: clientId,
+    cpmm.sendAsyncMessage("RIL:GetCallForwardingOption", {
+      clientId: 0,
       data: {
         requestId: requestId,
         reason: reason
       }
     });
 
     return request;
   },
 
-  setCallForwardingOption: function setCallForwardingOption(clientId, window, cfInfo) {
+  setCallForwardingOption: function setCallForwardingOption(window, cfInfo) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
 
     if (!cfInfo ||
         !this._isValidCFReason(cfInfo.reason) ||
         !this._isValidCFAction(cfInfo.action)){
       this.dispatchFireRequestError(requestId,
                                     RIL.GECKO_ERROR_INVALID_PARAMETER);
       return request;
     }
 
-    cpmm.sendAsyncMessage("RIL:SetCallForwardingOptions", {
-      clientId: clientId,
+    cpmm.sendAsyncMessage("RIL:SetCallForwardingOption", {
+      clientId: 0,
       data: {
         requestId: requestId,
         active: cfInfo.active,
         action: cfInfo.action,
         reason: cfInfo.reason,
         number: cfInfo.number,
         timeSeconds: cfInfo.timeSeconds
       }
     });
 
     return request;
   },
 
-  getCallBarringOption: function getCallBarringOption(clientId, window, option) {
+  getCallBarringOption: function getCallBarringOption(window, option) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
 
     if (DEBUG) debug("getCallBarringOption: " + JSON.stringify(option));
-    if (!this._isValidCallBarringOptions(option)) {
+    if (!this._isValidCallBarringOption(option)) {
       this.dispatchFireRequestError(requestId,
                                     RIL.GECKO_ERROR_INVALID_PARAMETER);
       return request;
     }
 
-    cpmm.sendAsyncMessage("RIL:GetCallBarringOptions", {
-      clientId: clientId,
+    cpmm.sendAsyncMessage("RIL:GetCallBarringOption", {
+      clientId: 0,
       data: {
         requestId: requestId,
         program: option.program,
         password: option.password,
         serviceClass: option.serviceClass
       }
     });
     return request;
   },
 
-  setCallBarringOption: function setCallBarringOption(clientId, window, option) {
+  setCallBarringOption: function setCallBarringOption(window, option) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
 
     if (DEBUG) debug("setCallBarringOption: " + JSON.stringify(option));
-    if (!this._isValidCallBarringOptions(option, true)) {
+    if (!this._isValidCallBarringOption(option, true)) {
       this.dispatchFireRequestError(requestId,
                                     RIL.GECKO_ERROR_INVALID_PARAMETER);
       return request;
     }
 
-    cpmm.sendAsyncMessage("RIL:SetCallBarringOptions", {
-      clientId: clientId,
+    cpmm.sendAsyncMessage("RIL:SetCallBarringOption", {
+      clientId: 0,
       data: {
         requestId: requestId,
         program: option.program,
         enabled: option.enabled,
         password: option.password,
         serviceClass: option.serviceClass
       }
     });
     return request;
   },
 
-  changeCallBarringPassword: function changeCallBarringPassword(clientId, window, info) {
+  changeCallBarringPassword: function changeCallBarringPassword(window, info) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
 
     // Checking valid PIN for supplementary services. See TS.22.004 clause 5.2.
@@ -1228,109 +1200,109 @@ RILContentHelper.prototype = {
         info.newPin == null || !info.newPin.match(/^\d{4}$/)) {
       this.dispatchFireRequestError(requestId, "InvalidPassword");
       return request;
     }
 
     if (DEBUG) debug("changeCallBarringPassword: " + JSON.stringify(info));
     info.requestId = requestId;
     cpmm.sendAsyncMessage("RIL:ChangeCallBarringPassword", {
-      clientId: clientId,
+      clientId: 0,
       data: info
     });
 
     return request;
   },
 
-  getCallWaitingOption: function getCallWaitingOption(clientId, window) {
+  getCallWaitingOption: function getCallWaitingOption(window) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
 
-    cpmm.sendAsyncMessage("RIL:GetCallWaitingOptions", {
-      clientId: clientId,
+    cpmm.sendAsyncMessage("RIL:GetCallWaitingOption", {
+      clientId: 0,
       data: {
         requestId: requestId
       }
     });
 
     return request;
   },
 
-  setCallWaitingOption: function setCallWaitingOption(clientId, window, enabled) {
+  setCallWaitingOption: function setCallWaitingOption(window, enabled) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
 
-    cpmm.sendAsyncMessage("RIL:SetCallWaitingOptions", {
-      clientId: clientId,
+    cpmm.sendAsyncMessage("RIL:SetCallWaitingOption", {
+      clientId: 0,
       data: {
         requestId: requestId,
         enabled: enabled
       }
     });
 
     return request;
   },
 
-  getCallingLineIdRestriction: function getCallingLineIdRestriction(clientId, window) {
+  getCallingLineIdRestriction: function getCallingLineIdRestriction(window) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
 
     cpmm.sendAsyncMessage("RIL:GetCallingLineIdRestriction", {
-      clientId: clientId,
+      clientId: 0,
       data: {
         requestId: requestId
       }
     });
 
     return request;
   },
 
   setCallingLineIdRestriction:
-    function setCallingLineIdRestriction(clientId, window, clirMode) {
+    function setCallingLineIdRestriction(window, clirMode) {
 
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
 
     cpmm.sendAsyncMessage("RIL:SetCallingLineIdRestriction", {
-      clientId: clientId,
+      clientId: 0,
       data: {
         requestId: requestId,
         clirMode: clirMode
       }
     });
 
     return request;
   },
 
-  exitEmergencyCbMode: function exitEmergencyCbMode(clientId, window) {
+  exitEmergencyCbMode: function exitEmergencyCbMode(window) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
 
     cpmm.sendAsyncMessage("RIL:ExitEmergencyCbMode", {
-      clientId: clientId,
+      clientId: 0,
       data: {
         requestId: requestId,
       }
     });
 
     return request;
   },
 
@@ -1357,93 +1329,81 @@ RILContentHelper.prototype = {
   },
   get voicemailNumber() {
     return this.getVoicemailInfo().number;
   },
   get voicemailDisplayName() {
     return this.getVoicemailInfo().displayName;
   },
 
-  registerListener: function registerListener(listenerType, clientId, listener) {
-    if (!this[listenerType]) {
-      return;
-    }
-    let listeners = this[listenerType][clientId];
+  registerListener: function registerListener(listenerType, listener) {
+    let listeners = this[listenerType];
     if (!listeners) {
-      listeners = this[listenerType][clientId] = [];
+      listeners = this[listenerType] = [];
     }
 
     if (listeners.indexOf(listener) != -1) {
       throw new Error("Already registered this listener!");
     }
 
     listeners.push(listener);
     if (DEBUG) debug("Registered " + listenerType + " listener: " + listener);
   },
 
-  unregisterListener: function unregisterListener(listenerType, clientId, listener) {
-    if (!this[listenerType]) {
-      return;
-    }
-    let listeners = this[listenerType][clientId];
+  unregisterListener: function unregisterListener(listenerType, listener) {
+    let listeners = this[listenerType];
     if (!listeners) {
       return;
     }
 
     let index = listeners.indexOf(listener);
     if (index != -1) {
       listeners.splice(index, 1);
       if (DEBUG) debug("Unregistered listener: " + listener);
     }
   },
 
-  registerMobileConnectionMsg: function registerMobileConnectionMsg(clientId, listener) {
+  registerMobileConnectionMsg: function registerMobileConnectionMsg(listener) {
     debug("Registering for mobile connection related messages");
-    this.registerListener("_mobileConnectionListeners", clientId, listener);
+    this.registerListener("_mobileConnectionListeners", listener);
     cpmm.sendAsyncMessage("RIL:RegisterMobileConnectionMsg");
   },
 
-  unregisterMobileConnectionMsg: function unregisteMobileConnectionMsg(clientId, listener) {
-    this.unregisterListener("_mobileConnectionListeners", clientId, listener);
+  unregisterMobileConnectionMsg: function unregisteMobileConnectionMsg(listener) {
+    this.unregisterListener("_mobileConnectionListeners", listener);
   },
 
   registerVoicemailMsg: function registerVoicemailMsg(listener) {
     debug("Registering for voicemail-related messages");
-    //TODO: Bug 814634 - WebVoicemail API: support multiple sim cards.
-    this.registerListener("_voicemailListeners", 0, listener);
+    this.registerListener("_voicemailListeners", listener);
     cpmm.sendAsyncMessage("RIL:RegisterVoicemailMsg");
   },
 
   unregisterVoicemailMsg: function unregisteVoicemailMsg(listener) {
-    //TODO: Bug 814634 - WebVoicemail API: support multiple sim cards.
-    this.unregisterListener("_voicemailListeners", 0, listener);
+    this.unregisterListener("_voicemailListeners", listener);
   },
 
   registerCellBroadcastMsg: function registerCellBroadcastMsg(listener) {
     debug("Registering for Cell Broadcast related messages");
-    //TODO: Bug 921326 - Cellbroadcast API: support multiple sim cards
-    this.registerListener("_cellBroadcastListeners", 0, listener);
+    this.registerListener("_cellBroadcastListeners", listener);
     cpmm.sendAsyncMessage("RIL:RegisterCellBroadcastMsg");
   },
 
   unregisterCellBroadcastMsg: function unregisterCellBroadcastMsg(listener) {
-    //TODO: Bug 921326 - Cellbroadcast API: support multiple sim cards
-    this.unregisterListener("_cellBroadcastListeners", 0, listener);
+    this.unregisterListener("_cellBroadcastListeners", listener);
   },
 
   registerIccMsg: function registerIccMsg(listener) {
     debug("Registering for ICC related messages");
-    //TODO: Bug 814637 - WebIccManager API: support multiple sim cards.
-    this.registerListener("_iccListeners", 0, listener);
+    this.registerListener("_iccListeners", listener);
     cpmm.sendAsyncMessage("RIL:RegisterIccMsg");
   },
 
   unregisterIccMsg: function unregisterIccMsg(listener) {
-    //TODO: Bug 814637 - WebIccManager API: support multiple sim cards.
-    this.unregisterListener("_iccListeners", 0, listener);
+    this.unregisterListener("_iccListeners", listener);
   },
 
   // nsIObserver
 
   observe: function observe(subject, topic, data) {
     if (topic == "xpcom-shutdown") {
       this.destroyDOMRequestHelper();
       Services.obs.removeObserver(this, "xpcom-shutdown");
@@ -1513,72 +1473,64 @@ RILContentHelper.prototype = {
     Services.DOMRequest.fireDetailedError(request, detailedError);
   },
 
   receiveMessage: function receiveMessage(msg) {
     let request;
     debug("Received message '" + msg.name + "': " + JSON.stringify(msg.json));
 
     let data = msg.json.data;
-    let clientId = msg.json.clientId;
     switch (msg.name) {
       case "RIL:CardStateChanged":
-        if (this.rilContexts[clientId].cardState != data.cardState) {
-          this.rilContexts[clientId].cardState = data.cardState;
-          this._deliverEvent(clientId,
-                             "_iccListeners",
+        if (this.rilContext.cardState != data.cardState) {
+          this.rilContext.cardState = data.cardState;
+          this._deliverEvent("_iccListeners",
                              "notifyCardStateChanged",
                              null);
         }
         break;
       case "RIL:IccInfoChanged":
-        this.updateIccInfo(clientId, data);
-        this._deliverEvent(clientId,
-                           "_iccListeners",
-                           "notifyIccInfoChanged",
-                           null);
+        this.updateIccInfo(data);
+        this._deliverEvent("_iccListeners", "notifyIccInfoChanged", null);
         break;
       case "RIL:VoiceInfoChanged":
         this.updateConnectionInfo(data,
-                                  this.rilContexts[clientId].voiceConnectionInfo);
-        this._deliverEvent(clientId,
-                           "_mobileConnectionListeners",
+                                  this.rilContext.voiceConnectionInfo);
+        this._deliverEvent("_mobileConnectionListeners",
                            "notifyVoiceChanged",
                            null);
         break;
       case "RIL:DataInfoChanged":
         this.updateConnectionInfo(data,
-                                  this.rilContexts[clientId].dataConnectionInfo);
-        this._deliverEvent(clientId,
-                           "_mobileConnectionListeners",
+                                  this.rilContext.dataConnectionInfo);
+        this._deliverEvent("_mobileConnectionListeners",
                            "notifyDataChanged",
                            null);
         break;
       case "RIL:OtaStatusChanged":
-        this._deliverEvent(clientId,
-                           "_mobileConnectionListeners",
+        this._deliverEvent("_mobileConnectionListeners",
                            "notifyOtaStatusChanged",
                            [data]);
         break;
       case "RIL:GetAvailableNetworks":
         this.handleGetAvailableNetworks(data);
         break;
       case "RIL:NetworkSelectionModeChanged":
-        this.rilContexts[clientId].networkSelectionMode = data.mode;
+        this.rilContext.networkSelectionMode = data.mode;
         break;
       case "RIL:SelectNetwork":
-        this.handleSelectNetwork(clientId, data,
+        this.handleSelectNetwork(data,
                                  RIL.GECKO_NETWORK_SELECTION_MANUAL);
         break;
       case "RIL:SelectNetworkAuto":
-        this.handleSelectNetwork(clientId, data,
+        this.handleSelectNetwork(data,
                                  RIL.GECKO_NETWORK_SELECTION_AUTOMATIC);
         break;
       case "RIL:VoicemailNotification":
-        this.handleVoicemailNotification(clientId, data);
+        this.handleVoicemailNotification(data);
         break;
       case "RIL:VoicemailInfoChanged":
         this.updateInfo(data, this.voicemailInfo);
         break;
       case "RIL:CardLockResult": {
         let requestId = data.requestId;
         let requestWindow = this._windowsMap[requestId];
         delete this._windowsMap[requestId];
@@ -1603,31 +1555,30 @@ RILContentHelper.prototype = {
         if (data.success) {
           let result = new MobileIccCardLockRetryCount(data);
           this.fireRequestSuccess(data.requestId, result);
         } else {
           this.fireRequestError(data.requestId, data.errorMsg);
         }
         break;
       case "RIL:USSDReceived":
-        this._deliverEvent(clientId,
-                           "_mobileConnectionListeners",
+        this._deliverEvent("_mobileConnectionListeners",
                            "notifyUssdReceived",
                            [data.message, data.sessionEnded]);
         break;
       case "RIL:SendMMI":
       case "RIL:CancelMMI":
         this.handleSendCancelMMI(data);
         break;
       case "RIL:StkCommand":
-        this._deliverEvent(clientId, "_iccListeners", "notifyStkCommand",
+        this._deliverEvent("_iccListeners", "notifyStkCommand",
                            [JSON.stringify(data)]);
         break;
       case "RIL:StkSessionEnd":
-        this._deliverEvent(clientId, "_iccListeners", "notifyStkSessionEnd", null);
+        this._deliverEvent("_iccListeners", "notifyStkSessionEnd", null);
         break;
       case "RIL:IccOpenChannel":
         this.handleSimpleRequest(data.requestId, data.errorMsg,
                                  data.channel);
         break;
       case "RIL:IccCloseChannel":
         this.handleSimpleRequest(data.requestId, data.errorMsg, null);
         break;
@@ -1636,77 +1587,74 @@ RILContentHelper.prototype = {
         break;
       case "RIL:ReadIccContacts":
         this.handleReadIccContacts(data);
         break;
       case "RIL:UpdateIccContact":
         this.handleSimpleRequest(data.requestId, data.errorMsg, null);
         break;
       case "RIL:DataError":
-        this.updateConnectionInfo(data, this.rilContexts[clientId].dataConnectionInfo);
-        this._deliverEvent(clientId, "_mobileConnectionListeners", "notifyDataError",
+        this.updateConnectionInfo(data, this.rilContext.dataConnectionInfo);
+        this._deliverEvent("_mobileConnectionListeners", "notifyDataError",
                            [data.errorMsg]);
         break;
-      case "RIL:GetCallForwardingOptions":
-        this.handleGetCallForwardingOptions(data);
+      case "RIL:GetCallForwardingOption":
+        this.handleGetCallForwardingOption(data);
         break;
-      case "RIL:SetCallForwardingOptions":
+      case "RIL:SetCallForwardingOption":
         this.handleSimpleRequest(data.requestId, data.errorMsg, null);
         break;
-      case "RIL:GetCallBarringOptions":
-        this.handleGetCallBarringOptions(data);
+      case "RIL:GetCallBarringOption":
+        this.handleGetCallBarringOption(data);
         break;
-      case "RIL:SetCallBarringOptions":
+      case "RIL:SetCallBarringOption":
         this.handleSimpleRequest(data.requestId, data.errorMsg, null);
         break;
       case "RIL:ChangeCallBarringPassword":
         this.handleSimpleRequest(data.requestId, data.errorMsg, null);
         break;
-      case "RIL:GetCallWaitingOptions":
+      case "RIL:GetCallWaitingOption":
         this.handleSimpleRequest(data.requestId, data.errorMsg,
                                  data.enabled);
         break;
-      case "RIL:SetCallWaitingOptions":
+      case "RIL:SetCallWaitingOption":
         this.handleSimpleRequest(data.requestId, data.errorMsg, null);
         break;
       case "RIL:CfStateChanged":
-        this._deliverEvent(clientId,
-                           "_mobileConnectionListeners",
+        this._deliverEvent("_mobileConnectionListeners",
                            "notifyCFStateChange",
                            [data.success, data.action,
                             data.reason, data.number,
                             data.timeSeconds, data.serviceClass]);
         break;
       case "RIL:GetCallingLineIdRestriction":
         this.handleGetCallingLineIdRestriction(data);
         break;
       case "RIL:SetCallingLineIdRestriction":
         this.handleSimpleRequest(data.requestId, data.errorMsg, null);
         break;
       case "RIL:CellBroadcastReceived": {
         let message = new CellBroadcastMessage(data);
-        this._deliverEvent(clientId,
-                           "_cellBroadcastListeners",
+        this._deliverEvent("_cellBroadcastListeners",
                            "notifyMessageReceived",
                            [message]);
         break;
       }
       case "RIL:SetRoamingPreference":
         this.handleSimpleRequest(data.requestId, data.errorMsg, null);
         break;
       case "RIL:GetRoamingPreference":
         this.handleSimpleRequest(data.requestId, data.errorMsg,
                                  data.mode);
         break;
       case "RIL:ExitEmergencyCbMode":
         this.handleExitEmergencyCbMode(data);
         break;
       case "RIL:EmergencyCbModeChanged":
-        this._deliverEvent(clientId,
-                           "_mobileConnectionListeners",
+        this._deliverEvent("_mobileConnectionListeners",
                            "notifyEmergencyCbModeChanged",
                            [data.active, data.timeoutMs]);
         break;
       case "RIL:SetVoicePrivacyMode":
         this.handleSimpleRequest(data.requestId, data.errorMsg, null);
         break;
       case "RIL:GetVoicePrivacyMode":
         this.handleSimpleRequest(data.requestId, data.errorMsg,
@@ -1737,19 +1685,19 @@ RILContentHelper.prototype = {
       let info = new MobileNetworkInfo();
       this.updateInfo(network, info);
       networks[i] = info;
     }
 
     this.fireRequestSuccess(message.requestId, networks);
   },
 
-  handleSelectNetwork: function handleSelectNetwork(clientId, message, mode) {
-    this._selectingNetworks[clientId] = null;
-    this.rilContexts[clientId].networkSelectionMode = mode;
+  handleSelectNetwork: function handleSelectNetwork(message, mode) {
+    this._selectingNetwork = null;
+    this.rilContext.networkSelectionMode = mode;
 
     if (message.errorMsg) {
       this.fireRequestError(message.requestId, message.errorMsg);
     } else {
       this.fireRequestSuccess(message.requestId, null);
     }
   },
 
@@ -1788,18 +1736,17 @@ RILContentHelper.prototype = {
       contact.id = message.iccid + c.recordId;
       return contact;
     });
 
     this.fireRequestSuccess(message.requestId,
                             ObjectWrapper.wrap(result, window));
   },
 
-  handleVoicemailNotification: function handleVoicemailNotification(clientId, message) {
-    // TODO: Bug 818352 - B2G Multi-SIM: voicemail - add subscription id in nsIRILContentHelper
+  handleVoicemailNotification: function handleVoicemailNotification(message) {
     let changed = false;
     if (!this.voicemailStatus) {
       this.voicemailStatus = new VoicemailStatus();
     }
 
     if (this.voicemailStatus.hasMessages != message.active) {
       changed = true;
       this.voicemailStatus.hasMessages = message.active;
@@ -1819,48 +1766,47 @@ RILContentHelper.prototype = {
     }
 
     if (this.voicemailStatus.returnMessage != message.returnMessage) {
       changed = true;
       this.voicemailStatus.returnMessage = message.returnMessage;
     }
 
     if (changed) {
-      this._deliverEvent(clientId,
-                         "_voicemailListeners",
+      this._deliverEvent("_voicemailListeners",
                          "notifyStatusChanged",
                          [this.voicemailStatus]);
     }
   },
 
   _cfRulesToMobileCfInfo: function _cfRulesToMobileCfInfo(rules) {
     for (let i = 0; i < rules.length; i++) {
       let rule = rules[i];
       let info = new MobileCFInfo();
       this.updateInfo(rule, info);
       rules[i] = info;
     }
   },
 
-  handleGetCallForwardingOptions: function handleGetCallForwardingOptions(message) {
+  handleGetCallForwardingOption: function handleGetCallForwardingOption(message) {
     if (message.errorMsg) {
       this.fireRequestError(message.requestId, message.errorMsg);
       return;
     }
 
     this._cfRulesToMobileCfInfo(message.rules);
     this.fireRequestSuccess(message.requestId, message.rules);
   },
 
-  handleGetCallBarringOptions: function handleGetCallBarringOptions(message) {
+  handleGetCallBarringOption: function handleGetCallBarringOption(message) {
     if (!message.success) {
       this.fireRequestError(message.requestId, message.errorMsg);
     } else {
-      let options = new CallBarringOptions(message);
-      this.fireRequestSuccess(message.requestId, options);
+      let option = new CallBarringOption(message);
+      this.fireRequestSuccess(message.requestId, option);
     }
   },
 
   handleGetCallingLineIdRestriction:
     function handleGetCallingLineIdRestriction(message) {
     if (message.errorMsg) {
       this.fireRequestError(message.requestId, message.errorMsg);
       return;
@@ -1926,21 +1872,18 @@ RILContentHelper.prototype = {
       let mmiError = new requestWindow.DOMMMIError(result.serviceCode,
                                                    message.errorMsg,
                                                    null,
                                                    result.additionalInformation);
       Services.DOMRequest.fireDetailedError(request, mmiError);
     }
   },
 
-  _deliverEvent: function _deliverEvent(clientId, listenerType, name, args) {
-    if (!this[listenerType]) {
-      return;
-    }
-    let thisListeners = this[listenerType][clientId];
+  _deliverEvent: function _deliverEvent(listenerType, name, args) {
+    let thisListeners = this[listenerType];
     if (!thisListeners) {
       return;
     }
 
     let listeners = thisListeners.slice();
     for (let listener of listeners) {
       if (thisListeners.indexOf(listener) == -1) {
         continue;
@@ -2001,28 +1944,28 @@ RILContentHelper.prototype = {
       case Ci.nsIDOMMozMobileConnection.CALL_BARRING_PROGRAM_INCOMING_ROAMING:
         return true;
       default:
         return false;
     }
   },
 
   /**
-   * Helper for guarding us against invalid options for call barring.
+   * Helper for guarding us against invalid option for call barring.
    */
-  _isValidCallBarringOptions:
-      function _isValidCallBarringOptions(options, usedForSetting) {
-    if (!options ||
-        options.serviceClass == null ||
-        !this._isValidCallBarringProgram(options.program)) {
+  _isValidCallBarringOption:
+      function _isValidCallBarringOption(option, usedForSetting) {
+    if (!option ||
+        option.serviceClass == null ||
+        !this._isValidCallBarringProgram(option.program)) {
       return false;
     }
 
-    // For setting callbarring options, |enabled| and |password| are required.
-    if (usedForSetting && (options.enabled == null || options.password == null)) {
+    // For setting callbarring option, |enabled| and |password| are required.
+    if (usedForSetting && (option.enabled == null || option.password == null)) {
       return false;
     }
 
     return true;
   }
 };
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RILContentHelper,
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -85,23 +85,23 @@ const RIL_IPC_MOBILECONNECTION_MSG_NAMES
   "RIL:GetNumRadioInterfaces",
   "RIL:GetRilContext",
   "RIL:GetAvailableNetworks",
   "RIL:SelectNetwork",
   "RIL:SelectNetworkAuto",
   "RIL:SendMMI",
   "RIL:CancelMMI",
   "RIL:RegisterMobileConnectionMsg",
-  "RIL:SetCallForwardingOptions",
-  "RIL:GetCallForwardingOptions",
-  "RIL:SetCallBarringOptions",
-  "RIL:GetCallBarringOptions",
+  "RIL:SetCallForwardingOption",
+  "RIL:GetCallForwardingOption",
+  "RIL:SetCallBarringOption",
+  "RIL:GetCallBarringOption",
   "RIL:ChangeCallBarringPassword",
-  "RIL:SetCallWaitingOptions",
-  "RIL:GetCallWaitingOptions",
+  "RIL:SetCallWaitingOption",
+  "RIL:GetCallWaitingOption",
   "RIL:SetCallingLineIdRestriction",
   "RIL:GetCallingLineIdRestriction",
   "RIL:SetRoamingPreference",
   "RIL:GetRoamingPreference",
   "RIL:ExitEmergencyCbMode",
   "RIL:SetVoicePrivacyMode",
   "RIL:GetVoicePrivacyMode"
 ];
@@ -930,35 +930,35 @@ RadioInterface.prototype = {
         this.workerMessenger.sendWithIPCMessage(msg, "iccExchangeAPDU");
         break;
       case "RIL:ReadIccContacts":
         this.workerMessenger.sendWithIPCMessage(msg, "readICCContacts");
         break;
       case "RIL:UpdateIccContact":
         this.workerMessenger.sendWithIPCMessage(msg, "updateICCContact");
         break;
-      case "RIL:SetCallForwardingOptions":
-        this.setCallForwardingOptions(msg.target, msg.json.data);
+      case "RIL:SetCallForwardingOption":
+        this.setCallForwardingOption(msg.target, msg.json.data);
         break;
-      case "RIL:GetCallForwardingOptions":
+      case "RIL:GetCallForwardingOption":
         this.workerMessenger.sendWithIPCMessage(msg, "queryCallForwardStatus");
         break;
-      case "RIL:SetCallBarringOptions":
+      case "RIL:SetCallBarringOption":
         this.workerMessenger.sendWithIPCMessage(msg, "setCallBarring");
         break;
-      case "RIL:GetCallBarringOptions":
+      case "RIL:GetCallBarringOption":
         this.workerMessenger.sendWithIPCMessage(msg, "queryCallBarringStatus");
         break;
       case "RIL:ChangeCallBarringPassword":
         this.workerMessenger.sendWithIPCMessage(msg, "changeCallBarringPassword");
         break;
-      case "RIL:SetCallWaitingOptions":
+      case "RIL:SetCallWaitingOption":
         this.workerMessenger.sendWithIPCMessage(msg, "setCallWaiting");
         break;
-      case "RIL:GetCallWaitingOptions":
+      case "RIL:GetCallWaitingOption":
         this.workerMessenger.sendWithIPCMessage(msg, "queryCallWaiting");
         break;
       case "RIL:SetCallingLineIdRestriction":
         this.setCallingLineIdRestriction(msg.target, msg.json.data);
         break;
       case "RIL:GetCallingLineIdRestriction":
         this.workerMessenger.sendWithIPCMessage(msg, "getCLIR");
         break;
@@ -2401,22 +2401,22 @@ RadioInterface.prototype = {
       target.sendAsyncMessage("RIL:SendMMI", {
         clientId: this.clientId,
         data: response
       });
       return false;
     }).bind(this));
   },
 
-  setCallForwardingOptions: function setCallForwardingOptions(target, message) {
-    if (DEBUG) this.debug("setCallForwardingOptions: " + JSON.stringify(message));
+  setCallForwardingOption: function setCallForwardingOption(target, message) {
+    if (DEBUG) this.debug("setCallForwardingOption: " + JSON.stringify(message));
     message.serviceClass = RIL.ICC_SERVICE_CLASS_VOICE;
     this.workerMessenger.send("setCallForward", message, (function(response) {
       this._sendCfStateChanged(response);
-      target.sendAsyncMessage("RIL:SetCallForwardingOptions", {
+      target.sendAsyncMessage("RIL:SetCallForwardingOption", {
         clientId: this.clientId,
         data: response
       });
       return false;
     }).bind(this));
   },
 
   setCallingLineIdRestriction: function setCallingLineIdRestriction(target,
--- a/ipc/moz.build
+++ b/ipc/moz.build
@@ -9,17 +9,17 @@ DIRS += [
     'glue',
     'ipdl',
     'testshell',
 ]
 
 if CONFIG['MOZ_B2G_RIL']:
     DIRS += ['ril']
 
-if CONFIG['MOZ_B2G_BT']:
+if CONFIG['MOZ_B2G_BT_BLUEZ']:
     DIRS += ['dbus']
 
 if CONFIG['MOZ_B2G_RIL'] or CONFIG['MOZ_B2G_BT']:
     DIRS += ['unixsocket', 'keystore']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     DIRS += ['netd']
 
--- a/ipc/unixsocket/UnixSocket.h
+++ b/ipc/unixsocket/UnixSocket.h
@@ -7,17 +7,17 @@
 #ifndef mozilla_ipc_UnixSocket_h
 #define mozilla_ipc_UnixSocket_h
 
 
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <sys/un.h>
 #include <netinet/in.h>
-#ifdef MOZ_B2G_BT
+#ifdef MOZ_B2G_BT_BLUEZ
 #include <bluetooth/bluetooth.h>
 #include <bluetooth/sco.h>
 #include <bluetooth/l2cap.h>
 #include <bluetooth/rfcomm.h>
 #endif
 #include <stdlib.h>
 #include "nsString.h"
 #include "nsAutoPtr.h"
@@ -26,17 +26,17 @@
 namespace mozilla {
 namespace ipc {
 
 union sockaddr_any {
   sockaddr_storage storage; // address-family only
   sockaddr_un un;
   sockaddr_in in;
   sockaddr_in6 in6;
-#ifdef MOZ_B2G_BT
+#ifdef MOZ_B2G_BT_BLUEZ
   sockaddr_sco sco;
   sockaddr_rc rc;
   sockaddr_l2 l2;
 #endif
   // ... others
 };
 
 class UnixSocketRawData
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/Makefile.in
@@ -84,17 +84,17 @@ STATIC_LIBS += \
 ifdef MOZ_CONTENT_SANDBOX #{
 STATIC_LIBS += sandbox_s
 endif #}
 
 ifdef MOZ_B2G_RIL #{
 STATIC_LIBS += mozril_s
 endif #}
 
-ifdef MOZ_B2G_BT #{
+ifdef MOZ_B2G_BT_BLUEZ #{
 STATIC_LIBS += mozdbus_s
 ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
 OS_LIBS += -ldbus
 endif
 endif #}
 
 ifneq ($(strip $(MOZ_B2G_RIL)$(MOZ_B2G_BT)),) #{
 STATIC_LIBS += mozipcunixsocket_s mozkeystore_s