Backed out 11 changesets (bug 920551) for landing on the wrong branch. a=backout
authorRyan VanderMeulen <ryanvm@gmail.com>
Thu, 31 Oct 2013 10:18:01 -0400
changeset 166337 9535f227ec8079448d56ed731de45e04bb8b878a
parent 166336 597f9dffdc9726494ea3b363c3d1a37f87ab9850
child 166338 dfff1f403d29c6f0655032adfd5159cec6691a32
push idunknown
push userunknown
push dateunknown
reviewersbackout
bugs920551
milestone27.0a2
backs outd70b80fb400d5f71a256e878f0d29d5aa999f934
a2c2a0b7626ed626c135ed2aed9f6b3e27bc6ce6
fdc1b9ae7b8c6467898053428291c2d37e5d2eb1
7223b4bc24f79d8150d29813331f1a04a4f75d43
89e114a843965281d9def56b2614886da624427e
c57a2291acaac7b4b294452c6c90bfa54c31eb57
fcb5a4dfe061eb4ab4716ea0df8553040e72e359
da509068de16864fc9c7c7e0c9e041aff34f54b8
3424107aeace21e9691cebe9319848ace41717a5
e3442ce8ca07d90556666e16914cfeaca9fba903
373cd1f52f7f0c283307822aa49aea57585c712b
Backed out 11 changesets (bug 920551) for landing on the wrong branch. a=backout Backed out changeset d70b80fb400d (bug 920551) Backed out changeset a2c2a0b7626e (bug 920551) Backed out changeset fdc1b9ae7b8c (bug 920551) Backed out changeset 7223b4bc24f7 (bug 920551) Backed out changeset 89e114a84396 (bug 920551) Backed out changeset c57a2291acaa (bug 920551) Backed out changeset fcb5a4dfe061 (bug 920551) Backed out changeset da509068de16 (bug 920551) Backed out changeset 3424107aeace (bug 920551) Backed out changeset e3442ce8ca07 (bug 920551) Backed out changeset 373cd1f52f7f (bug 920551)
b2g/app/b2g.js
b2g/chrome/content/shell.js
b2g/installer/package-manifest.in
configure.in
content/events/src/Makefile.in
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/base/moz.build
dom/bluetooth/BluetoothAdapter.cpp
dom/bluetooth/BluetoothHfpManager.cpp
dom/bluetooth/BluetoothHfpManager.h
dom/bluetooth/BluetoothService.h
dom/bluetooth/ipc/BluetoothParent.cpp
dom/bluetooth/ipc/BluetoothParent.h
dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
dom/bluetooth/ipc/BluetoothServiceChildProcess.h
dom/bluetooth/linux/BluetoothDBusService.cpp
dom/bluetooth/linux/BluetoothDBusService.h
dom/mobilemessage/interfaces/moz.build
dom/mobilemessage/src/SmsServicesFactory.cpp
dom/mobilemessage/src/moz.build
dom/mobilemessage/tests/Makefile.in
dom/mobilemessage/tests/test_smsdatabaseservice.xul
dom/mobilemessage/tests/xpcshell.ini
dom/moz.build
dom/network/interfaces/moz.build
dom/network/src/MobileConnection.cpp
dom/network/src/moz.build
dom/network/tests/Makefile.in
dom/system/gonk/GonkGPSGeolocationProvider.cpp
dom/system/gonk/GonkGPSGeolocationProvider.h
dom/system/gonk/NetworkManager.js
dom/system/gonk/SystemWorkerManager.cpp
dom/system/gonk/SystemWorkerManager.h
dom/system/gonk/moz.build
dom/system/moz.build
dom/telephony/TelephonyFactory.cpp
dom/telephony/moz.build
dom/wappush/moz.build
dom/wappush/src/moz.build
dom/webidl/Navigator.webidl
dom/webidl/moz.build
ipc/moz.build
ipc/ril/Ril.cpp
ipc/ril/Ril.h
js/xpconnect/src/event_impl_gen.conf.in
layout/build/Makefile.in
layout/build/nsLayoutModule.cpp
modules/libpref/src/init/all.js
toolkit/library/Makefile.in
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -425,17 +425,17 @@ pref("services.push.retryBaseInterval", 
 // is considered closed.
 pref("services.push.pingInterval", 1800000); // 30 minutes
 // How long before a DOMRequest errors as timeout
 pref("services.push.requestTimeout", 10000);
 // enable udp wakeup support
 pref("services.push.udp.wakeupEnabled", true);
 
 // NetworkStats
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_RIL
 pref("dom.mozNetworkStats.enabled", true);
 pref("dom.webapps.firstRunWithSIM", true);
 #endif
 
 // WebSettings
 pref("dom.mozSettings.enabled", true);
 pref("dom.navigator-property.disable.mozSettings", false);
 pref("dom.mozPermissionSettings.enabled", true);
@@ -816,16 +816,29 @@ pref("gfx.canvas.azure.backends", "skia"
 pref("gfx.canvas.azure.accelerated", true);
 
 // Turn on dynamic cache size for Skia
 pref("gfx.canvas.skiagl.dynamic-cache", true);
 
 // enable fence with readpixels for SurfaceStream
 pref("gfx.gralloc.fence-with-readpixels", true);
 
+// Enable Telephony API
+pref("dom.telephony.enabled", true);
+
 // Cell Broadcast API
+pref("dom.cellbroadcast.enabled", true);
 pref("ril.cellbroadcast.disabled", false);
 
+// ICC API
+pref("dom.icc.enabled", true);
+
+// Mobile Connection API
+pref("dom.mobileconnection.enabled", true);
+
+// Voice Mail API
+pref("dom.voicemail.enabled", true);
+
 // The url of the page used to display network error details.
 pref("b2g.neterror.url", "app://system.gaiamobile.org/net_error.html");
 
 // Enable Web Speech synthesis API
 pref("media.webspeech.synth.enabled", true);
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -13,17 +13,17 @@ Cu.import('resource://gre/modules/Permis
 Cu.import('resource://gre/modules/ObjectWrapper.jsm');
 Cu.import('resource://gre/modules/NotificationDB.jsm');
 Cu.import('resource://gre/modules/accessibility/AccessFu.jsm');
 Cu.import('resource://gre/modules/Payment.jsm');
 Cu.import("resource://gre/modules/AppsUtils.jsm");
 Cu.import('resource://gre/modules/UserAgentOverrides.jsm');
 Cu.import('resource://gre/modules/Keyboard.jsm');
 Cu.import('resource://gre/modules/ErrorPage.jsm');
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_RIL
 Cu.import('resource://gre/modules/NetworkStatsService.jsm');
 #endif
 
 // identity
 Cu.import('resource://gre/modules/SignInToWebsite.jsm');
 SignInToWebsiteController.init();
 
 XPCOMUtils.defineLazyServiceGetter(Services, 'env',
@@ -606,17 +606,17 @@ var shell = {
 
     this.reportCrash(true);
 
     Cu.import('resource://gre/modules/Webapps.jsm');
     DOMApplicationRegistry.allAppsLaunchable = true;
 
     this.sendEvent(window, 'ContentStart');
 
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_RIL
     Cu.import('resource://gre/modules/OperatorApps.jsm');
 #endif
 
     content.addEventListener('load', function shell_homeLoaded() {
       content.removeEventListener('load', shell_homeLoaded);
       shell.isHomeLoaded = true;
 
 #ifdef MOZ_WIDGET_GONK
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -159,22 +159,20 @@
 @BINPATH@/components/diskspacewatcher.xpt
 @BINPATH@/components/docshell.xpt
 @BINPATH@/components/dom.xpt
 @BINPATH@/components/dom_activities.xpt
 @BINPATH@/components/dom_apps.xpt
 @BINPATH@/components/dom_audiochannel.xpt
 @BINPATH@/components/dom_base.xpt
 @BINPATH@/components/dom_system.xpt
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_RIL
+@BINPATH@/components/dom_voicemail.xpt
 @BINPATH@/components/dom_wifi.xpt
 @BINPATH@/components/dom_system_gonk.xpt
-#endif
-#ifdef MOZ_B2G_RIL
-@BINPATH@/components/dom_voicemail.xpt
 @BINPATH@/components/dom_icc.xpt
 @BINPATH@/components/dom_cellbroadcast.xpt
 @BINPATH@/components/dom_wappush.xpt
 #endif
 #ifdef MOZ_B2G_BT
 @BINPATH@/components/dom_bluetooth.xpt
 #endif
 @BINPATH@/components/dom_camera.xpt
@@ -396,46 +394,16 @@
 @BINPATH@/components/jsconsole-clhandler.manifest
 @BINPATH@/components/jsconsole-clhandler.js
 @BINPATH@/components/nsHelperAppDlg.manifest
 @BINPATH@/components/nsHelperAppDlg.js
 @BINPATH@/components/nsDownloadManagerUI.manifest
 @BINPATH@/components/nsDownloadManagerUI.js
 @BINPATH@/components/nsSidebar.manifest
 @BINPATH@/components/nsSidebar.js
-
-; WiFi, NetworkManager, NetworkStats
-#ifdef MOZ_WIDGET_GONK
-@BINPATH@/components/DOMWifiManager.js
-@BINPATH@/components/DOMWifiManager.manifest
-@BINPATH@/components/NetworkInterfaceListService.js
-@BINPATH@/components/NetworkInterfaceListService.manifest
-@BINPATH@/components/NetworkManager.js
-@BINPATH@/components/NetworkManager.manifest
-@BINPATH@/components/NetworkStatsManager.js
-@BINPATH@/components/NetworkStatsManager.manifest
-@BINPATH@/components/NetworkStatsServiceProxy.js
-@BINPATH@/components/NetworkStatsServiceProxy.manifest
-@BINPATH@/components/WifiWorker.js
-@BINPATH@/components/WifiWorker.manifest
-#endif // MOZ_WIDGET_GONK
-
-; RIL
-#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
-@BINPATH@/components/MmsService.js
-@BINPATH@/components/MmsService.manifest
-@BINPATH@/components/MobileMessageDatabaseService.js
-@BINPATH@/components/MobileMessageDatabaseService.manifest
-@BINPATH@/components/RadioInterfaceLayer.js
-@BINPATH@/components/RadioInterfaceLayer.manifest
-@BINPATH@/components/RILContentHelper.js
-@BINPATH@/components/TelephonyProvider.js
-@BINPATH@/components/TelephonyProvider.manifest
-#endif // MOZ_WIDGET_GONK && MOZ_B2G_RIL
-
 #ifndef MOZ_WIDGET_GONK
 @BINPATH@/components/extensions.manifest
 @BINPATH@/components/addonManager.js
 @BINPATH@/components/amContentHandler.js
 @BINPATH@/components/amWebInstallListener.js
 @BINPATH@/components/nsBlocklistService.js
 #endif
 
@@ -491,16 +459,39 @@
 @BINPATH@/components/messageWakeupService.manifest
 @BINPATH@/components/SettingsManager.js
 @BINPATH@/components/SettingsManager.manifest
 @BINPATH@/components/SettingsService.js
 @BINPATH@/components/SettingsService.manifest
 @BINPATH@/components/webvtt.xpt
 @BINPATH@/components/WebVTT.manifest
 @BINPATH@/components/WebVTTParserWrapper.js
+#ifdef MOZ_B2G_RIL
+@BINPATH@/components/NetworkManager.manifest
+@BINPATH@/components/NetworkManager.js
+@BINPATH@/components/RadioInterfaceLayer.manifest
+@BINPATH@/components/RadioInterfaceLayer.js
+@BINPATH@/components/MmsService.manifest
+@BINPATH@/components/MmsService.js
+@BINPATH@/components/RILContentHelper.js
+@BINPATH@/components/MobileMessageDatabaseService.manifest
+@BINPATH@/components/MobileMessageDatabaseService.js
+@BINPATH@/components/WifiWorker.js
+@BINPATH@/components/WifiWorker.manifest
+@BINPATH@/components/DOMWifiManager.js
+@BINPATH@/components/DOMWifiManager.manifest
+@BINPATH@/components/NetworkStatsManager.js
+@BINPATH@/components/NetworkStatsManager.manifest
+@BINPATH@/components/NetworkInterfaceListService.manifest
+@BINPATH@/components/NetworkInterfaceListService.js
+@BINPATH@/components/TelephonyProvider.manifest
+@BINPATH@/components/TelephonyProvider.js
+@BINPATH@/components/NetworkStatsServiceProxy.manifest
+@BINPATH@/components/NetworkStatsServiceProxy.js
+#endif
 #ifdef MOZ_ENABLE_DBUS
 @BINPATH@/components/@DLL_PREFIX@dbusservice@DLL_SUFFIX@
 #endif
 @BINPATH@/components/nsINIProcessor.manifest
 @BINPATH@/components/nsINIProcessor.js
 @BINPATH@/components/nsPrompter.manifest
 @BINPATH@/components/nsPrompter.js
 #ifdef MOZ_SERVICES_SYNC
--- a/configure.in
+++ b/configure.in
@@ -1936,17 +1936,17 @@ ia64*-hpux*)
     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
     ;;
 
 *-android*|*-linuxandroid*)
     AC_DEFINE(NO_PW_GECOS)
     no_x=yes
     if test -n "$gonkdir"; then
         _PLATFORM_DEFAULT_TOOLKIT=cairo-gonk
-        _PLATFORM_HAVE_RIL=1
+        MOZ_B2G_RIL=1
         MOZ_B2G_FM=1
         MOZ_SYNTH_PICO=1
     else
         _PLATFORM_DEFAULT_TOOLKIT=cairo-android
         MOZ_LINKER=1
     fi
     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
 
@@ -7269,24 +7269,19 @@ if test -n "$MOZ_REFLOW_PERF"; then
 fi
 
 dnl ========================================================
 dnl = Enable Radio Interface for B2G (Gonk usually)
 dnl ========================================================
 MOZ_ARG_ENABLE_BOOL(b2g-ril,
 [  --enable-b2g-ril      Set compile flags necessary for testing B2G Radio Interface Layer via network sockets ],
     MOZ_B2G_RIL=1,
-    MOZ_B2G_RIL=,
-    MOZ_B2G_RIL=$_PLATFORM_HAVE_RIL )
+    MOZ_B2G_RIL= )
 if test -n "$MOZ_B2G_RIL"; then
-    if test -n "$_PLATFORM_HAVE_RIL"; then
-        AC_DEFINE(MOZ_B2G_RIL)
-    else
-        AC_MSG_ERROR([b2g-ril cannot be enabled because target platform doesn't support it.])
-    fi
+    AC_DEFINE(MOZ_B2G_RIL)
 fi
 AC_SUBST(MOZ_B2G_RIL)
 
 dnl ========================================================
 dnl = Enable Radio FM for B2G (Gonk usually)
 dnl ========================================================
 if test -n "$MOZ_B2G_FM"; then
     AC_DEFINE(MOZ_B2G_FM)
--- a/content/events/src/Makefile.in
+++ b/content/events/src/Makefile.in
@@ -13,17 +13,17 @@ LOCAL_INCLUDES	+= \
              -I$(srcdir)/../../../dom/base \
              -I$(srcdir)/../../../dom/settings \
              -I$(srcdir)/../../../dom/src/storage \
              -I$(srcdir)/../../../layout/generic \
              -I$(srcdir)/../../../layout/xul/base/src \
              -I$(srcdir)/../../../layout/xul/tree/ \
              $(NULL)
 
-ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
+ifdef MOZ_B2G_RIL
 LOCAL_INCLUDES += \
               -I$(srcdir)/../../../dom/wifi \
               $(NULL)
 endif
 
 ifdef MOZ_JSDEBUGGER
 DEFINES += -DMOZ_JSDEBUGGER
 endif
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -24,28 +24,28 @@
 #include "nsUnicharUtils.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
 #include "BatteryManager.h"
 #include "mozilla/dom/PowerManager.h"
 #include "nsIDOMWakeLock.h"
 #include "nsIPowerManagerService.h"
 #include "mozilla/dom/MobileMessageManager.h"
-#include "mozilla/dom/Telephony.h"
 #include "mozilla/Hal.h"
 #include "nsISiteSpecificUserAgent.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/StaticPtr.h"
 #include "Connection.h"
 #include "nsDOMEvent.h"
 #include "nsGlobalWindow.h"
 #ifdef MOZ_B2G_RIL
 #include "mozilla/dom/IccManager.h"
+#include "MobileConnection.h"
 #include "mozilla/dom/CellBroadcast.h"
-#include "mozilla/dom/network/MobileConnection.h"
+#include "mozilla/dom/Telephony.h"
 #include "mozilla/dom/Voicemail.h"
 #endif
 #include "nsIIdleObserver.h"
 #include "nsIPermissionManager.h"
 #include "nsNetUtil.h"
 #include "nsIHttpChannel.h"
 #include "TimeManager.h"
 #include "DeviceStorage.h"
@@ -133,22 +133,22 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Navigator)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPlugins)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMimeTypes)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGeolocation)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNotification)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBatteryManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPowerManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMobileMessageManager)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTelephony)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mConnection)
 #ifdef MOZ_B2G_RIL
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMobileConnection)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCellBroadcast)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIccManager)
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTelephony)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVoicemail)
 #endif
 #ifdef MOZ_B2G_BT
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBluetooth)
 #endif
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAudioChannelManager)
 #endif
@@ -204,20 +204,16 @@ Navigator::Invalidate()
     mPowerManager = nullptr;
   }
 
   if (mMobileMessageManager) {
     mMobileMessageManager->Shutdown();
     mMobileMessageManager = nullptr;
   }
 
-  if (mTelephony) {
-    mTelephony = nullptr;
-  }
-
   if (mConnection) {
     mConnection->Shutdown();
     mConnection = nullptr;
   }
 
 #ifdef MOZ_B2G_RIL
   if (mMobileConnection) {
     mMobileConnection->Shutdown();
@@ -228,16 +224,20 @@ Navigator::Invalidate()
     mCellBroadcast = nullptr;
   }
 
   if (mIccManager) {
     mIccManager->Shutdown();
     mIccManager = nullptr;
   }
 
+  if (mTelephony) {
+    mTelephony = nullptr;
+  }
+
   if (mVoicemail) {
     mVoicemail = nullptr;
   }
 #endif
 
 #ifdef MOZ_B2G_BT
   if (mBluetooth) {
     mBluetooth = nullptr;
@@ -1160,46 +1160,46 @@ Navigator::GetMozMobileMessage()
 
     mMobileMessageManager = new MobileMessageManager();
     mMobileMessageManager->Init(mWindow);
   }
 
   return mMobileMessageManager;
 }
 
-Telephony*
-Navigator::GetMozTelephony(ErrorResult& aRv)
-{
-  if (!mTelephony) {
-    if (!mWindow) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
-    }
-    mTelephony = Telephony::Create(mWindow, aRv);
-  }
-
-  return mTelephony;
-}
-
 #ifdef MOZ_B2G_RIL
 
 CellBroadcast*
 Navigator::GetMozCellBroadcast(ErrorResult& aRv)
 {
   if (!mCellBroadcast) {
     if (!mWindow) {
       aRv.Throw(NS_ERROR_UNEXPECTED);
       return nullptr;
     }
     mCellBroadcast = CellBroadcast::Create(mWindow, aRv);
   }
 
   return mCellBroadcast;
 }
 
+Telephony*
+Navigator::GetMozTelephony(ErrorResult& aRv)
+{
+  if (!mTelephony) {
+    if (!mWindow) {
+      aRv.Throw(NS_ERROR_UNEXPECTED);
+      return nullptr;
+    }
+    mTelephony = Telephony::Create(mWindow, aRv);
+  }
+
+  return mTelephony;
+}
+
 Voicemail*
 Navigator::GetMozVoicemail(ErrorResult& aRv)
 {
   if (!mVoicemail) {
     if (!mWindow) {
       aRv.Throw(NS_ERROR_UNEXPECTED);
       return nullptr;
     }
@@ -1694,38 +1694,38 @@ Navigator::HasMobileMessageSupport(JSCon
     return false;
   }
 
   return true;
 }
 
 /* static */
 bool
+Navigator::HasCameraSupport(JSContext* /* unused */, JSObject* aGlobal)
+{
+  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
+  return win && nsDOMCameraManager::CheckPermission(win);
+}
+
+#ifdef MOZ_B2G_RIL
+/* static */
+bool
 Navigator::HasTelephonySupport(JSContext* /* unused */, JSObject* aGlobal)
 {
   // First of all, the general pref has to be turned on.
   bool enabled = false;
   Preferences::GetBool("dom.telephony.enabled", &enabled);
   NS_ENSURE_TRUE(enabled, false);
 
   nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
   return win && CheckPermission(win, "telephony");
 }
 
 /* static */
 bool
-Navigator::HasCameraSupport(JSContext* /* unused */, JSObject* aGlobal)
-{
-  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
-  return win && nsDOMCameraManager::CheckPermission(win);
-}
-
-#ifdef MOZ_B2G_RIL
-/* static */
-bool
 Navigator::HasMobileConnectionSupport(JSContext* /* unused */,
                                       JSObject* aGlobal)
 {
   // First of all, the general pref has to be turned on.
   bool enabled = false;
   Preferences::GetBool("dom.mobileconnection.enabled", &enabled);
   NS_ENSURE_TRUE(enabled, false);
 
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -81,21 +81,21 @@ class MobileConnection;
 namespace bluetooth {
 class BluetoothManager;
 } // namespace bluetooth
 #endif // MOZ_B2G_BT
 
 #ifdef MOZ_B2G_RIL
 class CellBroadcast;
 class IccManager;
+class Telephony;
 class Voicemail;
 #endif
 
 class PowerManager;
-class Telephony;
 
 namespace time {
 class TimeManager;
 } // namespace time
 
 namespace system {
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
 class AudioChannelManager;
@@ -206,24 +206,24 @@ public:
                                        ErrorResult& aRv);
   void GetDeviceStorages(const nsAString& aType,
                          nsTArray<nsRefPtr<nsDOMDeviceStorage> >& aStores,
                          ErrorResult& aRv);
   DesktopNotificationCenter* GetMozNotification(ErrorResult& aRv);
   bool MozIsLocallyAvailable(const nsAString& aURI, bool aWhenOffline,
                              ErrorResult& aRv);
   nsIDOMMozMobileMessageManager* GetMozMobileMessage();
-  Telephony* GetMozTelephony(ErrorResult& aRv);
   nsIDOMMozConnection* GetMozConnection();
   nsDOMCameraManager* GetMozCameras(ErrorResult& aRv);
   void MozSetMessageHandler(const nsAString& aType,
                             systemMessageCallback* aCallback,
                             ErrorResult& aRv);
   bool MozHasPendingMessage(const nsAString& aType, ErrorResult& aRv);
 #ifdef MOZ_B2G_RIL
+  Telephony* GetMozTelephony(ErrorResult& aRv);
   nsIDOMMozMobileConnection* GetMozMobileConnection(ErrorResult& aRv);
   CellBroadcast* GetMozCellBroadcast(ErrorResult& aRv);
   Voicemail* GetMozVoicemail(ErrorResult& aRv);
   nsIDOMMozIccManager* GetMozIccManager(ErrorResult& aRv);
 #endif // MOZ_B2G_RIL
 #ifdef MOZ_GAMEPAD
   void GetGamepads(nsTArray<nsRefPtr<Gamepad> >& aGamepads, ErrorResult& aRv);
 #endif // MOZ_GAMEPAD
@@ -263,21 +263,21 @@ public:
   static bool HasWakeLockSupport(JSContext* /* unused*/, JSObject* /*unused */);
   static bool HasDesktopNotificationSupport(JSContext* /* unused*/,
                                             JSObject* /*unused */)
   {
     return HasDesktopNotificationSupport();
   }
   static bool HasMobileMessageSupport(JSContext* /* unused */,
                                       JSObject* aGlobal);
-  static bool HasTelephonySupport(JSContext* /* unused */,
-                                  JSObject* aGlobal);
   static bool HasCameraSupport(JSContext* /* unused */,
                                JSObject* aGlobal);
 #ifdef MOZ_B2G_RIL
+  static bool HasTelephonySupport(JSContext* /* unused */,
+                                  JSObject* aGlobal);
   static bool HasMobileConnectionSupport(JSContext* /* unused */,
                                          JSObject* aGlobal);
   static bool HasCellBroadcastSupport(JSContext* /* unused */,
                                       JSObject* aGlobal);
   static bool HasVoicemailSupport(JSContext* /* unused */,
                                   JSObject* aGlobal);
   static bool HasIccManagerSupport(JSContext* /* unused */,
                                    JSObject* aGlobal);
@@ -321,22 +321,22 @@ private:
   nsRefPtr<Geolocation> mGeolocation;
   nsRefPtr<DesktopNotificationCenter> mNotification;
   nsRefPtr<battery::BatteryManager> mBatteryManager;
 #ifdef MOZ_B2G_FM
   nsRefPtr<FMRadio> mFMRadio;
 #endif
   nsRefPtr<PowerManager> mPowerManager;
   nsRefPtr<MobileMessageManager> mMobileMessageManager;
-  nsRefPtr<Telephony> mTelephony;
   nsRefPtr<network::Connection> mConnection;
 #ifdef MOZ_B2G_RIL
   nsRefPtr<network::MobileConnection> mMobileConnection;
   nsRefPtr<CellBroadcast> mCellBroadcast;
   nsRefPtr<IccManager> mIccManager;
+  nsRefPtr<Telephony> mTelephony;
   nsRefPtr<Voicemail> mVoicemail;
 #endif
 #ifdef MOZ_B2G_BT
   nsCOMPtr<bluetooth::BluetoothManager> mBluetooth;
 #endif
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
   nsRefPtr<system::AudioChannelManager> mAudioChannelManager;
 #endif
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -123,30 +123,31 @@ LIBXUL_LIBRARY = True
 
 MSVC_ENABLE_PGO = True
 
 LIBRARY_NAME = 'jsdombase_s'
 
 LOCAL_INCLUDES += [
     '../battery',
     '../bluetooth',
+    '../icc/src',
     '../media',
     '../network/src',
     '../src/geolocation',
     '../src/storage',
     '../time',
     '/content/base/src',
     '/content/events/src',
     '/content/html/document/src',
     '/content/xbl/src',
     '/content/xul/document/src',
     '/layout/generic',
     '/layout/style',
     '/layout/xul/base/src',
 ]
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
+if CONFIG['MOZ_B2G_RIL']:
     LOCAL_INCLUDES += [
         '../fmradio',
         '../system/gonk',
     ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
--- a/dom/bluetooth/BluetoothAdapter.cpp
+++ b/dom/bluetooth/BluetoothAdapter.cpp
@@ -876,17 +876,16 @@ BluetoothAdapter::IsScoConnected(ErrorRe
   bs->IsScoConnected(results);
 
   return request.forget();
 }
 
 already_AddRefed<DOMRequest>
 BluetoothAdapter::AnswerWaitingCall(ErrorResult& aRv)
 {
-#ifdef MOZ_B2G_RIL
   nsCOMPtr<nsPIDOMWindow> win = GetOwner();
   if (!win) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   nsRefPtr<DOMRequest> request = new DOMRequest(win);
   nsRefPtr<BluetoothVoidReplyRunnable> results =
@@ -895,26 +894,21 @@ BluetoothAdapter::AnswerWaitingCall(Erro
   BluetoothService* bs = BluetoothService::Get();
   if (!bs) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
   bs->AnswerWaitingCall(results);
 
   return request.forget();
-#else
-  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
-  return nullptr;
-#endif // MOZ_B2G_RIL
 }
 
 already_AddRefed<DOMRequest>
 BluetoothAdapter::IgnoreWaitingCall(ErrorResult& aRv)
 {
-#ifdef MOZ_B2G_RIL
   nsCOMPtr<nsPIDOMWindow> win = GetOwner();
   if (!win) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   nsRefPtr<DOMRequest> request = new DOMRequest(win);
   nsRefPtr<BluetoothVoidReplyRunnable> results =
@@ -923,26 +917,21 @@ BluetoothAdapter::IgnoreWaitingCall(Erro
   BluetoothService* bs = BluetoothService::Get();
   if (!bs) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
   bs->IgnoreWaitingCall(results);
 
   return request.forget();
-#else
-  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
-  return nullptr;
-#endif // MOZ_B2G_RIL
 }
 
 already_AddRefed<DOMRequest>
 BluetoothAdapter::ToggleCalls(ErrorResult& aRv)
 {
-#ifdef MOZ_B2G_RIL
   nsCOMPtr<nsPIDOMWindow> win = GetOwner();
   if (!win) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   nsRefPtr<DOMRequest> request = new DOMRequest(win);
   nsRefPtr<BluetoothVoidReplyRunnable> results =
@@ -951,20 +940,16 @@ BluetoothAdapter::ToggleCalls(ErrorResul
   BluetoothService* bs = BluetoothService::Get();
   if (!bs) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
   bs->ToggleCalls(results);
 
   return request.forget();
-#else
-  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
-  return nullptr;
-#endif // MOZ_B2G_RIL
 }
 
 already_AddRefed<DOMRequest>
 BluetoothAdapter::SendMediaMetaData(const MediaMetaData& aMediaMetaData, ErrorResult& aRv)
 {
   nsCOMPtr<nsPIDOMWindow> win = GetOwner();
   if (!win) {
     aRv.Throw(NS_ERROR_FAILURE);
--- a/dom/bluetooth/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/BluetoothHfpManager.cpp
@@ -10,92 +10,82 @@
 
 #include "BluetoothProfileController.h"
 #include "BluetoothReplyRunnable.h"
 #include "BluetoothService.h"
 #include "BluetoothSocket.h"
 #include "BluetoothUtils.h"
 #include "BluetoothUuid.h"
 
-#include "jsapi.h"
+#include "MobileConnection.h"
 #include "mozilla/dom/bluetooth/BluetoothTypes.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "nsContentUtils.h"
 #include "nsIAudioManager.h"
+#include "nsIDOMIccInfo.h"
+#include "nsIIccProvider.h"
 #include "nsIObserverService.h"
 #include "nsISettingsService.h"
-#include "nsServiceManagerUtils.h"
-
-#ifdef MOZ_B2G_RIL
-#include "nsIDOMIccInfo.h"
-#include "nsIDOMMobileConnection.h"
-#include "nsIIccProvider.h"
-#include "nsIMobileConnectionProvider.h"
 #include "nsITelephonyProvider.h"
 #include "nsRadioInterfaceLayer.h"
-#endif
+#include "nsServiceManagerUtils.h"
 
 /**
  * BRSF bitmask of AG supported features. See 4.34.1 "Bluetooth Defined AT
  * Capabilities" in Bluetooth hands-free profile 1.6
  */
 #define BRSF_BIT_THREE_WAY_CALLING         1
 #define BSRF_BIT_EC_NR_FUNCTION            (1 << 1)
 #define BRSF_BIT_VOICE_RECOGNITION         (1 << 2)
 #define BRSF_BIT_IN_BAND_RING_TONE         (1 << 3)
 #define BRSF_BIT_ATTACH_NUM_TO_VOICE_TAG   (1 << 4)
 #define BRSF_BIT_ABILITY_TO_REJECT_CALL    (1 << 5)
 #define BRSF_BIT_ENHANCED_CALL_STATUS      (1 << 6)
 #define BRSF_BIT_ENHANCED_CALL_CONTROL     (1 << 7)
 #define BRSF_BIT_EXTENDED_ERR_RESULT_CODES (1 << 8)
 #define BRSF_BIT_CODEC_NEGOTIATION         (1 << 9)
 
-#ifdef MOZ_B2G_RIL
 /**
  * These constants are used in result code such as +CLIP and +CCWA. The value
  * of these constants is the same as TOA_INTERNATIONAL/TOA_UNKNOWN defined in
  * ril_consts.js
  */
 #define TOA_UNKNOWN 0x81
 #define TOA_INTERNATIONAL 0x91
-#endif
 
 #define CR_LF "\xd\xa";
 
 #define MOZSETTINGS_CHANGED_ID               "mozsettings-changed"
 #define AUDIO_VOLUME_BT_SCO_ID               "audio.volume.bt_sco"
 
 using namespace mozilla;
 using namespace mozilla::ipc;
 USING_BLUETOOTH_NAMESPACE
 
 namespace {
   StaticRefPtr<BluetoothHfpManager> sBluetoothHfpManager;
   bool sInShutdown = false;
   static const char kHfpCrlf[] = "\xd\xa";
 
-#ifdef MOZ_B2G_RIL
   // Sending ringtone related
   static bool sStopSendingRingFlag = true;
   static int sRingInterval = 3000; //unit: ms
 
   // Wait for 2 seconds for Dialer processing event 'BLDN'. '2' seconds is a
   // magic number. The mechanism should be revised once we can get call history.
   static int sWaitingForDialingInterval = 2000; //unit: ms
 
   // Wait 3.7 seconds until Dialer stops playing busy tone. '3' seconds is the
   // time window set in Dialer and the extra '0.7' second is a magic number.
   // The mechanism should be revised once we know the exact time at which
   // Dialer stops playing.
   static int sBusyToneInterval = 3700; //unit: ms
-#endif // MOZ_B2G_RIL
 } // anonymous namespace
 
-#ifdef MOZ_B2G_RIL
 /* CallState for sCINDItems[CINDType::CALL].value
  * - NO_CALL: there are no calls in progress
  * - IN_PROGRESS: at least one call is in progress
  */
 enum CallState {
   NO_CALL,
   IN_PROGRESS
 };
@@ -118,48 +108,43 @@ enum CallSetupState {
  * - ONHOLD_ACTIVE: both an active and a held call
  * - ONHOLD_NOACTIVE: call on hold, no active call
  */
 enum CallHeldState {
   NO_CALLHELD,
   ONHOLD_ACTIVE,
   ONHOLD_NOACTIVE
 };
-#endif // MOZ_B2G_RIL
 
 typedef struct {
   const char* name;
   const char* range;
   int value;
   bool activated;
 } CINDItem;
 
 enum CINDType {
   BATTCHG = 1,
-#ifdef MOZ_B2G_RIL
   CALL,
   CALLHELD,
   CALLSETUP,
   SERVICE,
   SIGNAL,
   ROAM
-#endif
 };
 
 static CINDItem sCINDItems[] = {
   {},
   {"battchg", "0-5", 5, true},
-#ifdef MOZ_B2G_RIL
   {"call", "0,1", CallState::NO_CALL, true},
   {"callheld", "0-2", CallHeldState::NO_CALLHELD, true},
   {"callsetup", "0-3", CallSetupState::NO_CALLSETUP, true},
   {"service", "0,1", 0, true},
   {"signal", "0-5", 0, true},
   {"roam", "0,1", 0, true}
-#endif
 };
 
 class BluetoothHfpManager::GetVolumeTask : public nsISettingsServiceCallback
 {
 public:
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD
@@ -216,17 +201,16 @@ BluetoothHfpManager::Notify(const hal::B
   // Range of CIND::BATTCHG: [0, 5], int
   int level = ceil(aBatteryInfo.level() * 5.0);
   if (level != sCINDItems[CINDType::BATTCHG].value) {
     sCINDItems[CINDType::BATTCHG].value = level;
     SendCommand("+CIEV:", CINDType::BATTCHG);
   }
 }
 
-#ifdef MOZ_B2G_RIL
 class BluetoothHfpManager::RespondToBLDNTask : public Task
 {
 private:
   void Run() MOZ_OVERRIDE
   {
     MOZ_ASSERT(sBluetoothHfpManager);
 
     if (!sBluetoothHfpManager->mDialingRequestProcessed) {
@@ -276,30 +260,28 @@ public:
                       new SendRingIndicatorTask(mNumber, mType),
                       sRingInterval);
   }
 
 private:
   nsString mNumber;
   int mType;
 };
-#endif // MOZ_B2G_RIL
 
 class BluetoothHfpManager::CloseScoTask : public Task
 {
 private:
   void Run() MOZ_OVERRIDE
   {
     MOZ_ASSERT(sBluetoothHfpManager);
 
     sBluetoothHfpManager->DisconnectSco();
   }
 };
 
-#ifdef MOZ_B2G_RIL
 static bool
 IsValidDtmf(const char aChar) {
   // Valid DTMF: [*#0-9ABCD]
   if (aChar == '*' || aChar == '#') {
     return true;
   } else if (aChar >= '0' && aChar <= '9') {
     return true;
   } else if (aChar >= 'A' && aChar <= 'D') {
@@ -332,74 +314,65 @@ Call::Reset()
   mType = TOA_UNKNOWN;
 }
 
 bool
 Call::IsActive()
 {
   return (mState == nsITelephonyProvider::CALL_STATE_CONNECTED);
 }
-#endif // MOZ_B2G_RIL
 
 /**
  *  BluetoothHfpManager
  */
 BluetoothHfpManager::BluetoothHfpManager() : mController(nullptr)
 {
   Reset();
 }
 
-#ifdef MOZ_B2G_RIL
 void
 BluetoothHfpManager::ResetCallArray()
 {
   mCurrentCallArray.Clear();
   // Append a call object at the beginning of mCurrentCallArray since call
   // index from RIL starts at 1.
   Call call;
   mCurrentCallArray.AppendElement(call);
 
   if (mPhoneType == PhoneType::CDMA) {
     mCdmaSecondCall.Reset();
   }
 }
-#endif // MOZ_B2G_RIL
 
 void
 BluetoothHfpManager::Reset()
 {
-#ifdef MOZ_B2G_RIL
   sStopSendingRingFlag = true;
   sCINDItems[CINDType::CALL].value = CallState::NO_CALL;
   sCINDItems[CINDType::CALLSETUP].value = CallSetupState::NO_CALLSETUP;
   sCINDItems[CINDType::CALLHELD].value = CallHeldState::NO_CALLHELD;
-#endif
   for (uint8_t i = 1; i < ArrayLength(sCINDItems); i++) {
     sCINDItems[i].activated = true;
   }
 
-#ifdef MOZ_B2G_RIL
   mCCWA = false;
   mCLIP = false;
-  mDialingRequestProcessed = true;
-#endif
   mCMEE = false;
   mCMER = false;
   mReceiveVgsFlag = false;
+  mDialingRequestProcessed = true;
 
-#ifdef MOZ_B2G_RIL
   // We disable BSIR by default as it requires OEM implement BT SCO + SPEAKER
   // output audio path in audio driver. OEM can enable BSIR by setting
   // mBSIR=true here.
   //
   // Please see Bug 878728 for more information.
   mBSIR = false;
 
   ResetCallArray();
-#endif
 }
 
 bool
 BluetoothHfpManager::Init()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
@@ -408,23 +381,21 @@ BluetoothHfpManager::Init()
   if (NS_FAILED(obs->AddObserver(this, MOZSETTINGS_CHANGED_ID, false)) ||
       NS_FAILED(obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false))) {
     BT_WARNING("Failed to add observers!");
     return false;
   }
 
   hal::RegisterBatteryObserver(this);
 
-#ifdef MOZ_B2G_RIL
   mListener = new BluetoothRilListener();
   if (!mListener->StartListening()) {
     BT_WARNING("Failed to start listening RIL");
     return false;
   }
-#endif
 
   nsCOMPtr<nsISettingsService> settings =
     do_GetService("@mozilla.org/settingsService;1");
   NS_ENSURE_TRUE(settings, false);
 
   nsCOMPtr<nsISettingsServiceLock> settingsLock;
   nsresult rv = settings->CreateLock(getter_AddRefs(settingsLock));
   NS_ENSURE_SUCCESS(rv, false);
@@ -441,22 +412,20 @@ BluetoothHfpManager::Init()
                                    false);
   mScoSocketStatus = mScoSocket->GetConnectionStatus();
   ListenSco();
   return true;
 }
 
 BluetoothHfpManager::~BluetoothHfpManager()
 {
-#ifdef MOZ_B2G_RIL
   if (!mListener->StopListening()) {
     BT_WARNING("Failed to stop listening RIL");
   }
   mListener = nullptr;
-#endif
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   NS_ENSURE_TRUE_VOID(obs);
 
   if (NS_FAILED(obs->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) ||
       NS_FAILED(obs->RemoveObserver(this, MOZSETTINGS_CHANGED_ID))) {
     BT_WARNING("Failed to remove observers!");
   }
@@ -512,34 +481,32 @@ BluetoothHfpManager::NotifyConnectionSta
   } else {
     MOZ_ASSERT(false);
     return;
   }
 
   DispatchStatusChangedEvent(eventName, mDeviceAddress, status);
 }
 
-#ifdef MOZ_B2G_RIL
 void
 BluetoothHfpManager::NotifyDialer(const nsAString& aCommand)
 {
   nsString type, name;
   BluetoothValue v;
   InfallibleTArray<BluetoothNamedValue> parameters;
   type.AssignLiteral("bluetooth-dialer-command");
 
   name.AssignLiteral("command");
   v = nsString(aCommand);
   parameters.AppendElement(BluetoothNamedValue(name, v));
 
   if (!BroadcastSystemMessage(type, parameters)) {
     BT_WARNING("Failed to broadcast system message to dialer");
   }
 }
-#endif // MOZ_B2G_RIL
 
 void
 BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // The string that we're interested in will be a JSON string that looks like:
   //  {"key":"volumeup", "value":10}
@@ -579,17 +546,16 @@ BluetoothHfpManager::HandleVolumeChanged
   }
 
   // Only send volume back when there's a connected headset
   if (IsConnected()) {
     SendCommand("+VGS: ", mCurrentVgs);
   }
 }
 
-#ifdef MOZ_B2G_RIL
 void
 BluetoothHfpManager::HandleVoiceConnectionChanged()
 {
   nsCOMPtr<nsIMobileConnectionProvider> connection =
     do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
   NS_ENSURE_TRUE_VOID(connection);
 
   nsCOMPtr<nsIDOMMozMobileConnectionInfo> voiceInfo;
@@ -665,17 +631,16 @@ BluetoothHfpManager::HandleIccInfoChange
   nsCOMPtr<nsIDOMMozIccInfo> iccInfo;
   icc->GetIccInfo(getter_AddRefs(iccInfo));
   NS_ENSURE_TRUE_VOID(iccInfo);
 
   nsCOMPtr<nsIDOMMozGsmIccInfo> gsmIccInfo = do_QueryInterface(iccInfo);
   NS_ENSURE_TRUE_VOID(gsmIccInfo);
   gsmIccInfo->GetMsisdn(mMsisdn);
 }
-#endif // MOZ_B2G_RIL
 
 void
 BluetoothHfpManager::HandleShutdown()
 {
   MOZ_ASSERT(NS_IsMainThread());
   sInShutdown = true;
   Disconnect(nullptr);
   DisconnectSco();
@@ -693,32 +658,28 @@ BluetoothHfpManager::ReceiveSocketData(B
   nsAutoCString msg((const char*)aMessage->mData.get(), aMessage->mSize);
   msg.StripWhitespace();
 
   nsTArray<nsCString> atCommandValues;
 
   // For more information, please refer to 4.34.1 "Bluetooth Defined AT
   // Capabilities" in Bluetooth hands-free profile 1.6
   if (msg.Find("AT+BRSF=") != -1) {
-#ifdef MOZ_B2G_RIL
     uint32_t brsf = BRSF_BIT_ABILITY_TO_REJECT_CALL |
                     BRSF_BIT_ENHANCED_CALL_STATUS;
 
     // No support for three way calling in CDMA since
     // CDMA disallows to hang existing call for CHLD=1
     if (mPhoneType != PhoneType::CDMA) {
       brsf |= BRSF_BIT_THREE_WAY_CALLING;
     }
 
     if (mBSIR) {
       brsf |= BRSF_BIT_IN_BAND_RING_TONE;
     }
-#else
-    uint32_t brsf = 0;
-#endif // MOZ_B2G_RIL
 
     SendCommand("+BRSF: ", brsf);
   } else if (msg.Find("AT+CIND=?") != -1) {
     // Asking for CIND range
     SendCommand("+CIND: ", 0);
   } else if (msg.Find("AT+CIND?") != -1) {
     // Asking for CIND value
     SendCommand("+CIND: ", 1);
@@ -749,17 +710,16 @@ BluetoothHfpManager::ReceiveSocketData(B
       BT_WARNING("Could't get the value of command [AT+CMEE=]");
       goto respond_with_ok;
     }
 
     // AT+CMEE = 0: +CME ERROR shall not be used
     // AT+CMEE = 1: use numeric <err>
     // AT+CMEE = 2: use verbose <err>
     mCMEE = !atCommandValues[0].EqualsLiteral("0");
-#ifdef MOZ_B2G_RIL
   } else if (msg.Find("AT+COPS=") != -1) {
     ParseAtCommand(msg, 8, atCommandValues);
 
     if (atCommandValues.Length() != 2) {
       BT_WARNING("Could't get the value of command [AT+COPS=]");
       goto respond_with_ok;
     }
 
@@ -788,17 +748,16 @@ BluetoothHfpManager::ReceiveSocketData(B
       goto respond_with_ok;
     }
 
     if (IsValidDtmf(atCommandValues[0].get()[0])) {
       nsAutoCString message("VTS=");
       message += atCommandValues[0].get()[0];
       NotifyDialer(NS_ConvertUTF8toUTF16(message));
     }
-#endif // MOZ_B2G_RIL
   } else if (msg.Find("AT+VGM=") != -1) {
     ParseAtCommand(msg, 7, atCommandValues);
 
     if (atCommandValues.IsEmpty()) {
       BT_WARNING("Couldn't get the value of command [AT+VGM]");
       goto respond_with_ok;
     }
 
@@ -806,17 +765,16 @@ BluetoothHfpManager::ReceiveSocketData(B
     int vgm = atCommandValues[0].ToInteger(&rv);
     if (NS_FAILED(rv)) {
       BT_WARNING("Failed to extract microphone volume from bluetooth headset!");
       goto respond_with_ok;
     }
 
     NS_ASSERTION(vgm >= 0 && vgm <= 15, "Received invalid VGM value");
     mCurrentVgm = vgm;
-#ifdef MOZ_B2G_RIL
   } else if (msg.Find("AT+CHLD=?") != -1) {
     SendLine("+CHLD: (0,1,2)");
   } else if (msg.Find("AT+CHLD=") != -1) {
     ParseAtCommand(msg, 8, atCommandValues);
 
     if (atCommandValues.IsEmpty()) {
       BT_WARNING("Could't get the value of command [AT+CHLD=]");
       goto respond_with_ok;
@@ -857,17 +815,16 @@ BluetoothHfpManager::ReceiveSocketData(B
       BT_WARNING("Wrong value of command [AT+CHLD]");
       valid = false;
     }
 
     if (!valid) {
       SendLine("ERROR");
       return;
     }
-#endif // MOZ_B2G_RIL
   } else if (msg.Find("AT+VGS=") != -1) {
     // Adjust volume by headset
     mReceiveVgsFlag = true;
     ParseAtCommand(msg, 7, atCommandValues);
 
     if (atCommandValues.IsEmpty()) {
       BT_WARNING("Could't get the value of command [AT+VGS=]");
       goto respond_with_ok;
@@ -885,17 +842,16 @@ BluetoothHfpManager::ReceiveSocketData(B
     }
 
     NS_ASSERTION(newVgs >= 0 && newVgs <= 15, "Received invalid VGS value");
 
     nsString data;
     nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
     data.AppendInt(newVgs);
     os->NotifyObservers(nullptr, "bluetooth-volume-change", data.get());
-#ifdef MOZ_B2G_RIL
   } else if ((msg.Find("AT+BLDN") != -1) || (msg.Find("ATD>") != -1)) {
     // Dialer app of FFOS v1 does not have plan to support Memory Dailing.
     // However, in order to pass Bluetooth HFP certification, we still have to
     // make a call when we receive AT command 'ATD>n'.
     mDialingRequestProcessed = false;
 
     if (msg.Find("AT+BLDN") != -1) {
       NotifyDialer(NS_LITERAL_STRING("BLDN"));
@@ -1011,17 +967,16 @@ BluetoothHfpManager::ReceiveSocketData(B
         } else if (!atCommandValues[i].EqualsLiteral("")) {
           SendLine("ERROR");
           return;
         }
       } else {
         // Ignore requests to activate/deactivate mandatory indicators
       }
     }
-#endif // MOZ_B2G_RIL
   } else {
     nsCString warningMsg;
     warningMsg.Append(NS_LITERAL_CSTRING("Unsupported AT command: "));
     warningMsg.Append(msg);
     warningMsg.Append(NS_LITERAL_CSTRING(", reply with ERROR"));
     BT_WARNING(warningMsg.get());
 
     SendLine("ERROR");
@@ -1136,17 +1091,16 @@ BluetoothHfpManager::Disconnect(Bluetoot
   }
 
   MOZ_ASSERT(!mController);
 
   mController = aController;
   mSocket->Disconnect();
 }
 
-#ifdef MOZ_B2G_RIL
 void
 BluetoothHfpManager::SendCCWA(const nsAString& aNumber, int aType)
 {
   if (mCCWA) {
     nsAutoCString ccwaMsg("+CCWA: \"");
     ccwaMsg.Append(NS_ConvertUTF16toUTF8(aNumber));
     ccwaMsg.AppendLiteral("\",");
     ccwaMsg.AppendInt(aType);
@@ -1198,17 +1152,16 @@ BluetoothHfpManager::SendCLCC(const Call
 
   message.AppendLiteral(",0,0,\"");
   message.Append(NS_ConvertUTF16toUTF8(aCall.mNumber));
   message.AppendLiteral("\",");
   message.AppendInt(aCall.mType);
 
   return SendLine(message.get());
 }
-#endif // MOZ_B2G_RIL
 
 bool
 BluetoothHfpManager::SendLine(const char* aMessage)
 {
   MOZ_ASSERT(mSocket);
 
   nsAutoCString msg;
 
@@ -1264,42 +1217,39 @@ BluetoothHfpManager::SendCommand(const c
       for (uint8_t i = 1; i < ArrayLength(sCINDItems); i++) {
         message.AppendInt(sCINDItems[i].value);
         if (i == (ArrayLength(sCINDItems) - 1)) {
           break;
         }
         message.AppendLiteral(",");
       }
     }
-#ifdef MOZ_B2G_RIL
   } else if (!strcmp(aCommand, "+CLCC: ")) {
     bool rv = true;
     uint32_t callNumbers = mCurrentCallArray.Length();
     uint32_t i;
     for (i = 1; i < callNumbers; i++) {
       rv &= SendCLCC(mCurrentCallArray[i], i);
     }
 
     if (!mCdmaSecondCall.mNumber.IsEmpty()) {
       MOZ_ASSERT(mPhoneType == PhoneType::CDMA);
       MOZ_ASSERT(i == 2);
 
       rv &= SendCLCC(mCdmaSecondCall, 2);
     }
 
     return rv;
-#endif // MOZ_B2G_RIL
   } else {
     message.AppendInt(aValue);
   }
 
   return SendLine(message.get());
 }
 
-#ifdef MOZ_B2G_RIL
 void
 BluetoothHfpManager::UpdateCIND(uint8_t aType, uint8_t aValue, bool aSend)
 {
   if (sCINDItems[aType].value != aValue) {
     sCINDItems[aType].value = aValue;
     if (aSend) {
       SendCommand("+CIEV: ", aType);
     }
@@ -1570,25 +1520,22 @@ BluetoothHfpManager::ToggleCalls()
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mPhoneType == PhoneType::CDMA);
 
   // Toggle acitve and held calls
   mCdmaSecondCall.mState = (mCdmaSecondCall.IsActive()) ?
                              nsITelephonyProvider::CALL_STATE_HELD :
                              nsITelephonyProvider::CALL_STATE_CONNECTED;
 }
-#endif // MOZ_B2G_RIL
 
 void
 BluetoothHfpManager::OnSocketConnectSuccess(BluetoothSocket* aSocket)
 {
   MOZ_ASSERT(aSocket);
-#ifdef MOZ_B2G_RIL
   MOZ_ASSERT(mListener);
-#endif
 
   // Success to create a SCO socket
   if (aSocket == mScoSocket) {
     OnScoConnectSuccess();
     return;
   }
 
   /**
@@ -1607,22 +1554,20 @@ BluetoothHfpManager::OnSocketConnectSucc
   } else if (aSocket == mHeadsetSocket) {
     MOZ_ASSERT(!mSocket);
     mHeadsetSocket.swap(mSocket);
 
     mHandsfreeSocket->Disconnect();
     mHandsfreeSocket = nullptr;
   }
 
-#ifdef MOZ_B2G_RIL
   // Enumerate current calls
   mListener->EnumerateCalls();
 
   mFirstCKPD = true;
-#endif
 
   // Cache device path for NotifySettings() since we can't get socket address
   // when a headset disconnect with us
   mSocket->GetAddress(mDeviceAddress);
   NotifyConnectionStatusChanged(
     NS_LITERAL_STRING(BLUETOOTH_HFP_STATUS_CHANGED_ID));
 
   ListenSco();
--- a/dom/bluetooth/BluetoothHfpManager.h
+++ b/dom/bluetooth/BluetoothHfpManager.h
@@ -4,29 +4,25 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_bluetooth_bluetoothhfpmanager_h__
 #define mozilla_dom_bluetooth_bluetoothhfpmanager_h__
 
 #include "BluetoothCommon.h"
 #include "BluetoothProfileManagerBase.h"
-#ifdef MOZ_B2G_RIL
 #include "BluetoothRilListener.h"
-#endif
 #include "BluetoothSocketObserver.h"
 #include "mozilla/ipc/UnixSocket.h"
 #include "mozilla/Hal.h"
 
 BEGIN_BLUETOOTH_NAMESPACE
 
 class BluetoothReplyRunnable;
 class BluetoothSocket;
-
-#ifdef MOZ_B2G_RIL
 class Call;
 
 /**
  * These costants are defined in 4.33.2 "AT Capabilities Re-Used from GSM 07.07
  * and 3GPP 27.007" in Bluetooth hands-free profile 1.6
  */
 enum BluetoothCmeError {
   AG_FAILURE = 0,
@@ -66,17 +62,16 @@ public:
   void Reset();
   bool IsActive();
 
   uint16_t mState;
   bool mDirection; // true: incoming call; false: outgoing call
   nsString mNumber;
   int mType;
 };
-#endif // MOZ_B2G_RIL
 
 class BluetoothHfpManager : public BluetoothSocketObserver
                           , public BluetoothProfileManagerBase
                           , public BatteryObserver
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
@@ -109,110 +104,88 @@ public:
     aName.AssignLiteral("HFP/HSP");
   }
 
   bool Listen();
   bool ConnectSco(BluetoothReplyRunnable* aRunnable = nullptr);
   bool DisconnectSco();
   bool ListenSco();
 
-#ifdef MOZ_B2G_RIL
   /**
    * @param aSend A boolean indicates whether we need to notify headset or not
    */
   void HandleCallStateChanged(uint32_t aCallIndex, uint16_t aCallState,
                               const nsAString& aError, const nsAString& aNumber,
                               const bool aIsOutgoing, bool aSend);
   void HandleIccInfoChanged();
   void HandleVoiceConnectionChanged();
-#endif
 
   bool IsConnected();
   bool IsScoConnected();
 
-#ifdef MOZ_B2G_RIL
   // CDMA-specific functions
   void UpdateSecondNumber(const nsAString& aNumber);
   void AnswerWaitingCall();
   void IgnoreWaitingCall();
   void ToggleCalls();
-#endif
 
 private:
   class CloseScoTask;
   class GetVolumeTask;
-#ifdef MOZ_B2G_RIL
   class RespondToBLDNTask;
   class SendRingIndicatorTask;
-#endif
 
   friend class CloseScoTask;
   friend class GetVolumeTask;
-#ifdef MOZ_B2G_RIL
   friend class RespondToBLDNTask;
   friend class SendRingIndicatorTask;
-#endif
   friend class BluetoothHfpManagerObserver;
 
   BluetoothHfpManager();
   void HandleShutdown();
   void HandleVolumeChanged(const nsAString& aData);
 
   bool Init();
   void Notify(const hal::BatteryInformation& aBatteryInfo);
   void Reset();
-#ifdef MOZ_B2G_RIL
   void ResetCallArray();
   uint32_t FindFirstCall(uint16_t aState);
   uint32_t GetNumberOfCalls(uint16_t aState);
   PhoneType GetPhoneType(const nsAString& aType);
-#endif
 
   void NotifyConnectionStatusChanged(const nsAString& aType);
   void NotifyDialer(const nsAString& aCommand);
 
-#ifdef MOZ_B2G_RIL
   void SendCCWA(const nsAString& aNumber, int aType);
   bool SendCLCC(const Call& aCall, int aIndex);
-#endif
   bool SendCommand(const char* aCommand, uint32_t aValue = 0);
   bool SendLine(const char* aMessage);
-#ifdef MOZ_B2G_RIL
   void UpdateCIND(uint8_t aType, uint8_t aValue, bool aSend = true);
-#endif
   void OnScoConnectSuccess();
   void OnScoConnectError();
   void OnScoDisconnect();
 
   int mCurrentVgs;
   int mCurrentVgm;
-#ifdef MOZ_B2G_RIL
   bool mBSIR;
   bool mCCWA;
   bool mCLIP;
-#endif
   bool mCMEE;
   bool mCMER;
-#ifdef MOZ_B2G_RIL
   bool mFirstCKPD;
   int mNetworkSelectionMode;
   PhoneType mPhoneType;
-#endif
   bool mReceiveVgsFlag;
-#ifdef MOZ_B2G_RIL
   bool mDialingRequestProcessed;
-#endif
   nsString mDeviceAddress;
-#ifdef MOZ_B2G_RIL
   nsString mMsisdn;
   nsString mOperatorName;
 
   nsTArray<Call> mCurrentCallArray;
   nsAutoPtr<BluetoothRilListener> mListener;
-#endif
   nsRefPtr<BluetoothProfileController> mController;
   nsRefPtr<BluetoothReplyRunnable> mScoRunnable;
 
   // If a connection has been established, mSocket will be the socket
   // communicating with the remote socket. We maintain the invariant that if
   // mSocket is non-null, mHandsfreeSocket and mHeadsetSocket must be null (and
   // vice versa).
   nsRefPtr<BluetoothSocket> mSocket;
@@ -220,17 +193,15 @@ private:
   // Server sockets. Once an inbound connection is established, it will hand
   // over the ownership to mSocket, and get a new server socket while Listen()
   // is called.
   nsRefPtr<BluetoothSocket> mHandsfreeSocket;
   nsRefPtr<BluetoothSocket> mHeadsetSocket;
   nsRefPtr<BluetoothSocket> mScoSocket;
   SocketConnectionStatus mScoSocketStatus;
 
-#ifdef MOZ_B2G_RIL
   // CDMA-specific variable
   Call mCdmaSecondCall;
-#endif
 };
 
 END_BLUETOOTH_NAMESPACE
 
 #endif
--- a/dom/bluetooth/BluetoothService.h
+++ b/dom/bluetooth/BluetoothService.h
@@ -261,26 +261,24 @@ public:
   ConnectSco(BluetoothReplyRunnable* aRunnable) = 0;
 
   virtual void
   DisconnectSco(BluetoothReplyRunnable* aRunnable) = 0;
 
   virtual void
   IsScoConnected(BluetoothReplyRunnable* aRunnable) = 0;
 
-#ifdef MOZ_B2G_RIL
   virtual void
   AnswerWaitingCall(BluetoothReplyRunnable* aRunnable) = 0;
 
   virtual void
   IgnoreWaitingCall(BluetoothReplyRunnable* aRunnable) = 0;
 
   virtual void
   ToggleCalls(BluetoothReplyRunnable* aRunnable) = 0;
-#endif
 
   virtual void
   SendMetaData(const nsAString& aTitle,
                const nsAString& aArtist,
                const nsAString& aAlbum,
                int64_t aMediaNumber,
                int64_t aTotalMediaCount,
                int64_t aDuration,
--- a/dom/bluetooth/ipc/BluetoothParent.cpp
+++ b/dom/bluetooth/ipc/BluetoothParent.cpp
@@ -221,24 +221,22 @@ BluetoothParent::RecvPBluetoothRequestCo
     case Request::TDenyReceivingFileRequest:
       return actor->DoRequest(aRequest.get_DenyReceivingFileRequest());
     case Request::TConnectScoRequest:
       return actor->DoRequest(aRequest.get_ConnectScoRequest());
     case Request::TDisconnectScoRequest:
       return actor->DoRequest(aRequest.get_DisconnectScoRequest());
     case Request::TIsScoConnectedRequest:
       return actor->DoRequest(aRequest.get_IsScoConnectedRequest());
-#ifdef MOZ_B2G_RIL
     case Request::TAnswerWaitingCallRequest:
       return actor->DoRequest(aRequest.get_AnswerWaitingCallRequest());
     case Request::TIgnoreWaitingCallRequest:
       return actor->DoRequest(aRequest.get_IgnoreWaitingCallRequest());
     case Request::TToggleCallsRequest:
       return actor->DoRequest(aRequest.get_ToggleCallsRequest());
-#endif
     case Request::TSendMetaDataRequest:
       return actor->DoRequest(aRequest.get_SendMetaDataRequest());
     case Request::TSendPlayStatusRequest:
       return actor->DoRequest(aRequest.get_SendPlayStatusRequest());
     default:
       MOZ_CRASH("Unknown type!");
   }
 
@@ -578,17 +576,16 @@ BluetoothRequestParent::DoRequest(const 
 {
   MOZ_ASSERT(mService);
   MOZ_ASSERT(mRequestType == Request::TIsScoConnectedRequest);
 
   mService->IsScoConnected(mReplyRunnable.get());
   return true;
 }
 
-#ifdef MOZ_B2G_RIL
 bool
 BluetoothRequestParent::DoRequest(const AnswerWaitingCallRequest& aRequest)
 {
   MOZ_ASSERT(mService);
   MOZ_ASSERT(mRequestType == Request::TAnswerWaitingCallRequest);
 
   mService->AnswerWaitingCall(mReplyRunnable.get());
 
@@ -611,17 +608,16 @@ BluetoothRequestParent::DoRequest(const 
 {
   MOZ_ASSERT(mService);
   MOZ_ASSERT(mRequestType == Request::TAnswerWaitingCallRequest);
 
   mService->ToggleCalls(mReplyRunnable.get());
 
   return true;
 }
-#endif // MOZ_B2G_RIL
 
 bool
 BluetoothRequestParent::DoRequest(const SendMetaDataRequest& aRequest)
 {
   MOZ_ASSERT(mService);
   MOZ_ASSERT(mRequestType == Request::TSendMetaDataRequest);
 
   mService->SendMetaData(aRequest.title(),
--- a/dom/bluetooth/ipc/BluetoothParent.h
+++ b/dom/bluetooth/ipc/BluetoothParent.h
@@ -185,26 +185,24 @@ protected:
   DoRequest(const ConnectScoRequest& aRequest);
 
   bool
   DoRequest(const DisconnectScoRequest& aRequest);
 
   bool
   DoRequest(const IsScoConnectedRequest& aRequest);
 
-#ifdef MOZ_B2G_RIL
   bool
   DoRequest(const AnswerWaitingCallRequest& aRequest);
 
   bool
   DoRequest(const IgnoreWaitingCallRequest& aRequest);
 
   bool
   DoRequest(const ToggleCallsRequest& aRequest);
-#endif
 
   bool
   DoRequest(const SendMetaDataRequest& aRequest);
 
   bool
   DoRequest(const SendPlayStatusRequest& aRequest);
 };
 
--- a/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
+++ b/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
@@ -323,17 +323,16 @@ BluetoothServiceChildProcess::Disconnect
 }
 
 void
 BluetoothServiceChildProcess::IsScoConnected(BluetoothReplyRunnable* aRunnable)
 {
   SendRequest(aRunnable, IsScoConnectedRequest());
 }
 
-#ifdef MOZ_B2G_RIL
 void
 BluetoothServiceChildProcess::AnswerWaitingCall(
   BluetoothReplyRunnable* aRunnable)
 {
   SendRequest(aRunnable, AnswerWaitingCallRequest());
 }
 
 void
@@ -344,17 +343,16 @@ BluetoothServiceChildProcess::IgnoreWait
 }
 
 void
 BluetoothServiceChildProcess::ToggleCalls(
   BluetoothReplyRunnable* aRunnable)
 {
   SendRequest(aRunnable, ToggleCallsRequest());
 }
-#endif // MOZ_B2G_RIL
 
 void
 BluetoothServiceChildProcess::SendMetaData(const nsAString& aTitle,
                                            const nsAString& aArtist,
                                            const nsAString& aAlbum,
                                            int64_t aMediaNumber,
                                            int64_t aTotalMediaCount,
                                            int64_t aDuration,
--- a/dom/bluetooth/ipc/BluetoothServiceChildProcess.h
+++ b/dom/bluetooth/ipc/BluetoothServiceChildProcess.h
@@ -144,26 +144,24 @@ public:
   ConnectSco(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
 
   virtual void
   DisconnectSco(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
 
   virtual void
   IsScoConnected(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
 
-#ifdef MOZ_B2G_RIL
   virtual void
   AnswerWaitingCall(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
 
   virtual void
   IgnoreWaitingCall(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
 
   virtual void
   ToggleCalls(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
-#endif
 
   virtual void
   SendMetaData(const nsAString& aTitle,
                const nsAString& aArtist,
                const nsAString& aAlbum,
                int64_t aMediaNumber,
                int64_t aTotalMediaCount,
                int64_t aDuration,
--- a/dom/bluetooth/linux/BluetoothDBusService.cpp
+++ b/dom/bluetooth/linux/BluetoothDBusService.cpp
@@ -2622,17 +2622,16 @@ BluetoothDBusService::IsConnected(const 
     BT_WARNING(ERR_UNKNOWN_PROFILE);
     return false;
   }
 
   NS_ENSURE_TRUE(profile, false);
   return profile->IsConnected();
 }
 
-#ifdef MOZ_B2G_RIL
 void
 BluetoothDBusService::AnswerWaitingCall(BluetoothReplyRunnable* aRunnable)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
   hfp->AnswerWaitingCall();
 
@@ -2655,17 +2654,16 @@ BluetoothDBusService::ToggleCalls(Blueto
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
   hfp->ToggleCalls();
 
   DispatchBluetoothReply(aRunnable, BluetoothValue(true), EmptyString());
 }
-#endif // MOZ_B2G_RIL
 
 class OnUpdateSdpRecordsRunnable : public nsRunnable
 {
 public:
   OnUpdateSdpRecordsRunnable(const nsAString& aObjectPath,
                              BluetoothProfileManagerBase* aManager)
     : mManager(aManager)
   {
--- a/dom/bluetooth/linux/BluetoothDBusService.h
+++ b/dom/bluetooth/linux/BluetoothDBusService.h
@@ -130,26 +130,24 @@ public:
   ConnectSco(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
 
   virtual void
   DisconnectSco(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
 
   virtual void
   IsScoConnected(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
 
-#ifdef MOZ_B2G_RIL
   virtual void
   AnswerWaitingCall(BluetoothReplyRunnable* aRunnable);
 
   virtual void
   IgnoreWaitingCall(BluetoothReplyRunnable* aRunnable);
 
   virtual void
   ToggleCalls(BluetoothReplyRunnable* aRunnable);
-#endif
 
   virtual void
   SendMetaData(const nsAString& aTitle,
                const nsAString& aArtist,
                const nsAString& aAlbum,
                int64_t aMediaNumber,
                int64_t aTotalMediaCount,
                int64_t aDuration,
--- a/dom/mobilemessage/interfaces/moz.build
+++ b/dom/mobilemessage/interfaces/moz.build
@@ -17,15 +17,15 @@ XPIDL_SOURCES += [
     'nsIMobileMessageCallback.idl',
     'nsIMobileMessageCursorCallback.idl',
     'nsIMobileMessageDatabaseService.idl',
     'nsIMobileMessageService.idl',
     'nsISmsService.idl',
     'nsIWapPushApplication.idl',
 ]
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']:
+if CONFIG['MOZ_B2G_RIL']:
     XPIDL_SOURCES += [
         'nsIRilMobileMessageDatabaseService.idl',
     ]
 
 XPIDL_MODULE = 'dom_mobilemessage'
 
--- a/dom/mobilemessage/src/SmsServicesFactory.cpp
+++ b/dom/mobilemessage/src/SmsServicesFactory.cpp
@@ -5,17 +5,17 @@
 
 #include "SmsServicesFactory.h"
 #include "nsXULAppAPI.h"
 #include "ipc/SmsIPCService.h"
 #ifdef MOZ_WIDGET_ANDROID
 #include "android/MobileMessageDatabaseService.h"
 #include "android/SmsService.h"
 #include "android/MmsService.h"
-#elif defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
+#elif defined(MOZ_B2G_RIL)
 #include "gonk/SmsService.h"
 #else
 #include "fallback/MmsService.h"
 #include "fallback/MobileMessageDatabaseService.h"
 #include "fallback/SmsService.h"
 #endif
 #include "nsServiceManagerUtils.h"
 
@@ -42,17 +42,17 @@ SmsServicesFactory::CreateSmsService()
 
 /* static */ already_AddRefed<nsIMobileMessageDatabaseService>
 SmsServicesFactory::CreateMobileMessageDatabaseService()
 {
   nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService;
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
     mobileMessageDBService = new SmsIPCService();
   } else {
-#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
+#ifdef MOZ_B2G_RIL
     mobileMessageDBService = do_GetService(RIL_MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
 #else
     mobileMessageDBService = new MobileMessageDatabaseService();
 #endif
   }
 
   return mobileMessageDBService.forget();
 }
@@ -60,17 +60,17 @@ SmsServicesFactory::CreateMobileMessageD
 /* static */ already_AddRefed<nsIMmsService>
 SmsServicesFactory::CreateMmsService()
 {
   nsCOMPtr<nsIMmsService> mmsService;
 
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
     mmsService = new SmsIPCService();
   } else {
-#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
+#ifdef MOZ_B2G_RIL
     mmsService = do_CreateInstance(RIL_MMSSERVICE_CONTRACTID);
 #else
     mmsService = new MmsService();
 #endif
   }
 
   return mmsService.forget();
 }
--- a/dom/mobilemessage/src/moz.build
+++ b/dom/mobilemessage/src/moz.build
@@ -14,17 +14,17 @@ EXPORTS.mozilla.dom.mobilemessage += [
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     SOURCES += [
         'android/MmsService.cpp',
         'android/MobileMessageDatabaseService.cpp',
         'android/SmsService.cpp',
     ]
-elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']:
+elif CONFIG['MOZ_B2G_RIL']:
     EXTRA_JS_MODULES = [
         'gonk/mms_consts.js',
         'gonk/MmsPduHelper.jsm',
         'gonk/wap_consts.js',
         'gonk/WspPduHelper.jsm',
     ]
     EXTRA_COMPONENTS += [
         'gonk/MmsService.js',
--- a/dom/mobilemessage/tests/Makefile.in
+++ b/dom/mobilemessage/tests/Makefile.in
@@ -1,3 +1,9 @@
 # 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/.
+
+ifdef MOZ_B2G_RIL
+MOCHITEST_CHROME_FILES = \
+  test_smsdatabaseservice.xul \
+  $(NULL)
+endif
new file mode 100644
--- /dev/null
+++ b/dom/mobilemessage/tests/test_smsdatabaseservice.xul
@@ -0,0 +1,876 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
+                 type="text/css"?>
+
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        title="Test MobileMessageDatabaseService by SMS"
+        onload="run_test();">
+  <title>Test MobileMessageDatabaseService by SMS</title>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript"><![CDATA[
+
+function run_test() {
+  SimpleTest.waitForExplicitFinish();
+  run_next_test();
+}
+
+let gTests = [];
+
+function add_test(func) {
+  gTests.push(func);
+}
+
+function run_next_test() {
+  let func = gTests.shift();
+  if (!func) {
+    SimpleTest.finish();
+    return;
+  }
+  SimpleTest.executeSoon(func);
+}
+
+
+const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+
+let gMobileMessageDatabaseService = Cc["@mozilla.org/mobilemessage/rilmobilemessagedatabaseservice;1"]
+                                      .getService(Ci.nsIMobileMessageDatabaseService);
+
+let gRegistrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
+
+
+let SmsRequestManagerImpl = {
+  notifySmsSent: function notifySmsSent(requestId, message) {
+    ok(false, "Unexpected notifySmsSent.");
+  },
+  notifySmsSendFailed: function notifySmsSendFailed(requestId, error) {
+    ok(false, "Unexpected notifySmsSendFailed.");
+  },
+  notifyGotSms: function notifyGotSms(requestId, message) {
+    ok(false, "Unexpected notifyGotSms.");
+  },
+  notifyGetSmsFailed: function notifyGetSmsFailed(requestId, error) {
+    ok(false, "Unexpected notifyGetSmsFailed." + k);
+  },
+  notifySmsDeleted: function notifySmsDeleted(requestId, message) {
+    ok(false, "Unexpected notifySmsSent.");
+  },
+  notifySmsDeleteFailed: function notifySmsDeleteFailed(requestId, error) {
+    ok(false, "Unexpected notifySmsDeleteFailed.");
+  },
+  notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+    ok(false, "Unexpected notifyNoMessageInList.");
+  },
+  noitfyCreateMessageList: function notifyCreateMessageList(requestId,
+                                                            listId,
+                                                            message) {
+    ok(false, "Unexpected notifyCreateMessageList.");
+  },
+  notifyGotNextMessage: function notifyGotNextMessage(requestId, message) {
+    ok(false, "Unexpected notifyGotNextMessage.");
+  },
+  notifyReadMessageListFailed: function notifyReadMessageListFailed(requestId, error) {
+    ok(false, "Unexpected notifyReadMessageListFailed.");
+  }
+};
+
+let FakeSmsRequestManagerService = {
+  contractID: "@mozilla.org/sms/smsrequestmanager;1",
+  //get CID() { return gRegistrar.contractIDToCID(this.contractID); },
+  CID: Components.ID("{a97a3129-1e0b-45da-a385-cfe5b0b1c48f}"),
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsISmsRequestManager,
+                                         Ci.nsIFactory]),
+  createInstance: function createInstance(outer, iid) {
+    if (outer != null) {
+      throw Cr.NS_ERROR_NO_AGGREGATION;
+    }
+    return this;
+  },
+  __proto__: SmsRequestManagerImpl
+};
+
+/**
+ * Create and register a new fake nsISmsRequestManager service.
+ *
+ * Example:
+ *
+ *   fakeSmsRequestManager({
+ *     notifySmsSent: function notifySmsSent() {
+ *       ...
+ *     }
+ *   });
+ */
+function fakeSmsRequestManager(obj) {
+  let service = FakeSmsRequestManagerService;
+
+  // Clean previous methods from the service, then copy new ones onto it.
+  for (let name in SmsRequestManagerImpl) {
+    delete service[name];
+  }
+  for (let name in obj) {
+    service[name] = obj[name];
+  }
+
+  // Register service
+  let oldFactory = Components.manager.getClassObject(Cc[service.contractID],
+                                                     Ci.nsIFactory);
+  gRegistrar.unregisterFactory(service.CID, oldFactory);
+  gRegistrar.registerFactory(service.CID,
+                             "Fake SmsRequestManager",
+                             service.contractID,
+                             service);
+}
+
+const DB_NAME = "sms";
+const DB_VERSION = 2;
+const STORE_NAME = "sms";
+const MAX_SMS = 3;
+const LONG_MAX = 2147483647;
+
+let _db;
+function ensureDB(callback) {
+  if (_db) {
+    callback(_db);
+    return;
+  }
+  let request;
+  try {
+    request = indexedDB.open(DB_NAME, DB_VERSION);
+  } catch (ex) {
+    ok(false, ex);
+  }
+  request.onsuccess = function onsuccess(event) {
+    _db = request.result;
+    callback(_db);
+  };
+  request.onerror =
+  request.onupgradeneeded =
+  request.onblocked = function onerror(event) {
+    ok(false, "Opening DB failed: " + request.errorCode);
+  };
+};
+
+function checkDB(callback) {
+  ensureDB(function (db) {
+    let txn = db.transaction([STORE_NAME], "readwrite");
+    let store = txn.objectStore(STORE_NAME);
+    txn.oncomplete = run_next_test;
+    txn.onerror = function onerror(event) {
+      ok(false, "Transaction failed: " + event.target.errorCode);
+    };
+    callback(store);
+  });
+}
+
+function newRandomId() {
+  return Math.floor(Math.random() * LONG_MAX);
+};
+
+let sms = [
+  {
+    type: "sms",
+    sender: "+34666000000",
+    receiver: "+34666111000",
+    body: "message 0",
+    messageClass: "normal",
+    timestamp: 1329999861762
+  },
+  {
+    type: "sms",
+    sender: "+34666000111",
+    receiver: "+34666111111",
+    body: "message 1",
+    messageClass: "normal",
+    timestamp: 1329999861763
+  },
+  {
+    type: "sms",
+    sender: "+34666000222",
+    receiver: "+34666111222",
+    body: "message 2",
+    messageClass: "normal",
+    timestamp: 1329999861764
+  },
+];
+
+/**
+ * nsIMobileMessageDatabaseService.saveReceivedMessage
+ */
+add_test(function test_saveReceivedMessage() {
+  info("test_saveReceivedMessage");
+  let messageId = gMobileMessageDatabaseService.saveReceivedMessage(sms[0]);
+  checkDB(function (store) {
+    let request = store.get(messageId);
+    request.onsuccess = function onsuccess() {
+      let data = request.result;
+      isnot(data, null);
+      is(data.id,        messageId);
+      is(data.sender,    sms[0].sender);
+      is(data.receiver,  null);
+      is(data.body,      sms[0].body);
+      is(data.timestamp, sms[0].timestamp);
+      is(data.read,      false);
+    };
+  });
+});
+
+/**
+ * nsIMobileMessageDatabaseService.saveSentMessage
+ */
+add_test(function test_saveSentMessage() {
+  info("test_saveSentMessage");
+  let messageId = gMobileMessageDatabaseService.saveSentMessage(sms[1].receiver,
+                                                                sms[1].body,
+                                                                sms[1].timestamp);
+
+  checkDB(function (store) {
+    let request = store.get(messageId);
+    request.onsuccess = function onsuccess() {
+      let data = request.result;
+      isnot(data, null);
+      is(data.id,        messageId);
+      is(data.sender,    null);
+      is(data.receiver,  sms[1].receiver);
+      is(data.body,      sms[1].body);
+      is(data.timestamp, sms[1].timestamp);
+      is(data.read,      true);
+    };
+  });
+});
+
+/**
+ * nsIMobileMessageDatabaseService.getMessage
+ */
+add_test(function test_getMessage_success() {
+  info("test_getMessage_success");
+  let fakeRequestId = newRandomId();
+  fakeSmsRequestManager({
+    notifyGotSms: function notifyGotSms(requestId, message) {
+      is(requestId, fakeRequestId);
+      ok(message instanceof Ci.nsIDOMMozSmsMessage);
+      is(message.id,       messageId);
+      is(message.delivery, "received");
+      is(message.sender,   sms[2].sender);
+      is(message.receiver, null);
+      is(message.body,     sms[2].body);
+      is(message.read,     false);
+      run_next_test();
+    }
+  });
+  let messageId = gMobileMessageDatabaseService.saveReceivedMessage(sms[2]);
+  SimpleTest.executeSoon(function () {
+    gMobileMessageDatabaseService.getMessage(messageId, fakeRequestId);
+  });
+});
+
+add_test(function test_getMessage_failed() {
+  info("test_getMessage_failed");
+  let fakeRequestId = newRandomId();
+  fakeSmsRequestManager({
+    notifyGetSmsFailed: function notifyGetSmsFailed(requestId, error) {
+      is(requestId, fakeRequestId);
+      is(error, Ci.nsISmsRequestManager.NOT_FOUND_ERROR);
+      run_next_test();
+    }
+  });
+  gMobileMessageDatabaseService.getMessage(-1, fakeRequestId);
+});
+
+/**
+ * nsIMobileMessageDatabaseService.createMessageList
+ */
+function checkReceivedSms(message, i) {
+  ok(message instanceof Ci.nsIDOMMozSmsMessage);
+  is(message.sender,              sms[i].sender);
+  is(message.receiver,            null);
+  is(message.body,                sms[i].body);
+  is(message.timestamp.getTime(), sms[i].timestamp);
+  is(message.read,                false);
+}
+
+function checkSentSms(message, i) {
+  ok(message instanceof Ci.nsIDOMMozSmsMessage);
+  is(message.sender,              null);
+  is(message.receiver,            sms[i].receiver);
+  is(message.body,                sms[i].body);
+  is(message.timestamp.getTime(), sms[i].timestamp);
+  is(message.read,                true);
+}
+
+add_test(function test_createMessageList_empty_filter() {
+  info("test_createMessageList_empty_filter");
+  let fakeRequestId = newRandomId();
+  let auxListId;
+  let i = 0;
+  fakeSmsRequestManager({
+    notifyCreateMessageList: function notifyCreateMessageList(requestId,
+                                                              listId,
+                                                              message) {
+      is(requestId, fakeRequestId);
+      checkReceivedSms(message, i);
+      auxListId = listId;
+      i += 1;
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
+    },
+    notifyGotNextMessage: function notifyGotNextMessage(requestId,
+                                                        message) {
+      is(requestId, fakeRequestId);
+      ok(message instanceof Ci.nsIDOMMozSmsMessage);
+      i % 2 ? checkSentSms(message, i) : checkReceivedSms(message, i);
+      i += 1;
+      gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
+    },
+    notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      is(requestId, fakeRequestId);
+      is(i, MAX_SMS);
+      run_next_test();
+    }
+  });
+  let filter = new MozSmsFilter();
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+});
+
+add_test(function test_createMessageList_empty_filter_reverse() {
+  info("test_createMessageList_empty_filter_reverse");
+  let fakeRequestId = newRandomId();
+  let auxListId;
+  let i = 2;
+  fakeSmsRequestManager({
+    notifyCreateMessageList: function notifyCreateMessageList(requestId,
+                                                              listId,
+                                                              message) {
+      is(requestId, fakeRequestId);
+      checkReceivedSms(message, i);
+      auxListId = listId;
+      i -= 1;
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
+    },
+    notifyGotNextMessage: function notifyGotNextMessage(requestId,
+                                                        message) {
+      is(requestId, fakeRequestId);
+      ok(message instanceof Ci.nsIDOMMozSmsMessage);
+      i % 2 ? checkSentSms(message, i) : checkReceivedSms(message, i);
+      i -= 1;
+      gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
+    },
+    notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      is(requestId, fakeRequestId);
+      is(i, -1);
+      run_next_test();
+    }
+  });
+  let filter = new MozSmsFilter();
+  gMobileMessageDatabaseService.createMessageList(filter, true, fakeRequestId);
+});
+
+add_test(function test_createMessageList_complete_filter_one_result() {
+  info("test_createMessageList_complete_filter_one_result");
+  let fakeRequestId = newRandomId();
+  fakeSmsRequestManager({
+    notifyCreateMessageList: function notifyCreateMessageList(requestId,
+                                                              listId,
+                                                              message) {
+      is(requestId, fakeRequestId);
+      checkReceivedSms(message, 0);
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
+    },
+    notifyGotNextMessage: function notifyGotNextMessage(requestId,
+                                                        message) {
+      is(requestId, fakeRequestId);
+      ok(false, "No more messages expected");
+    },
+    notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      is(requestId, fakeRequestId);
+      run_next_test();
+    }
+  });
+  let filter = new MozSmsFilter();
+  filter.startDate = new Date(sms[0].timestamp);
+  filter.endDate = new Date(sms[0].timestamp);
+  filter.numbers = [sms[0].sender];
+  filter.delivery = "received";
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+});
+
+add_test(function test_createMessageList_complete_filter_multi_result() {
+  info("test_createMessageList_complete_filter_multi_result");
+  let fakeRequestId = newRandomId();
+  let auxListId;
+  let secondMessage = false;
+  fakeSmsRequestManager({
+    notifyCreateMessageList: function notifyCreateMessageList(requestId,
+                                                              listId,
+                                                              message) {
+      is(requestId, fakeRequestId);
+      checkReceivedSms(message, 0);
+      auxListId = listId;
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
+    },
+    notifyGotNextMessage: function notifyGotNextMessage(requestId, message) {
+      ok(!secondMessage);
+      is(requestId, fakeRequestId);
+      checkReceivedSms(message, 2);
+      secondMessage = true;
+      gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
+    },
+    notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      ok(secondMessage);
+      is(requestId, fakeRequestId);
+      run_next_test();
+    }
+  });
+  let filter = new MozSmsFilter();
+  filter.startDate = new Date(sms[0].timestamp);
+  filter.endDate = new Date(sms[2].timestamp);
+  filter.numbers = [sms[0].sender, sms[2].sender];
+  filter.delivery = "received";
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+});
+
+add_test(function test_createMessageList_complete_filter_no_result() {
+  info("test_createMessageList_complete_filter_no_result");
+  let fakeRequestId = newRandomId();
+  fakeSmsRequestManager({
+    notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      is(requestId, fakeRequestId);
+      run_next_test();
+    },
+  });
+  let filter = new MozSmsFilter();
+  filter.startDate = new Date(sms[0].timestamp);
+  filter.endDate = new Date(sms[0].timestamp);
+  filter.numbers = [sms[0].sender];
+  filter.delivery = "sent";
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+});
+
+add_test(function test_createMessageList_delivery_sent_filter_success() {
+  info("test_createMessageList_delivery_sent_filter_success");
+  let fakeRequestId = newRandomId();
+  fakeSmsRequestManager({
+    notifyCreateMessageList: function notifyCreateMessageList(requestId,
+                                                              listId,
+                                                              message) {
+      is(requestId, fakeRequestId);
+      checkSentSms(message, 1);
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
+    },
+    notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      is(requestId, fakeRequestId);
+      run_next_test();
+    }
+  });
+  let filter = new MozSmsFilter();
+  filter.delivery = "sent";
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+});
+
+add_test(function test_createMessageList_delivery_received_filter_success() {
+  info("test_createMessageList_delivery_received_filter_success");
+  let fakeRequestId = newRandomId();
+  let auxListId;
+  let secondMessage = false;
+  fakeSmsRequestManager({
+    notifyCreateMessageList: function notifyCreateMessageList(requestId,
+                                                              listId,
+                                                              message) {
+      is(requestId, fakeRequestId);
+      checkReceivedSms(message, 0);
+      auxListId = listId;
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
+    },
+    notifyGotNextMessage: function notifyGotNextMessage(requestId, message) {
+      ok(!secondMessage);
+      is(requestId, fakeRequestId);
+      checkReceivedSms(message, 2);
+      secondMessage = true;
+      gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
+    },
+    notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      ok(secondMessage);
+      is(requestId, fakeRequestId);
+      run_next_test();
+    }
+  });
+  let filter = new MozSmsFilter();
+  filter.delivery = "received";
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+});
+
+add_test(function test_createMessageList_startDate_filter_success() {
+  info("test_createMessageList_startDate_filter_success");
+  let fakeRequestId = newRandomId();
+  let auxListId;
+  let i = 0;
+  fakeSmsRequestManager({
+    notifyCreateMessageList: function notifyCreateMessageList(requestId,
+                                                              listId,
+                                                              message) {
+      is(requestId, fakeRequestId);
+      checkReceivedSms(message, i);
+      auxListId = listId;
+      i += 1;
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
+    },
+    notifyGotNextMessage: function notifyGotNextMessage(requestId,
+                                                        message) {
+      is(requestId, fakeRequestId);
+      i % 2 ? checkSentSms(message, i) : checkReceivedSms(message, i);
+      i += 1;
+      gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
+    },
+    notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      is(requestId, fakeRequestId);
+      is(i, MAX_SMS);
+      run_next_test();
+    }
+  });
+  let filter = new MozSmsFilter();
+  filter.startDate = new Date(sms[0].timestamp);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+});
+
+add_test(function test_createMessageList_startDate_filter_failed() {
+  info("test_createMessageList_startDate_filter_failed");
+  let fakeRequestId = newRandomId();
+  fakeSmsRequestManager({
+    notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      is(requestId, fakeRequestId);
+      run_next_test();
+    },
+  });
+  let filter = new MozSmsFilter();
+  filter.startDate = new Date(sms[2].timestamp + 1);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+});
+
+add_test(function test_createMessageList_endDate_filter_success() {
+  info("test_createMessageList_endDate_filter_success");
+  let fakeRequestId = newRandomId();
+  let auxListId;
+  let i = 0;
+  fakeSmsRequestManager({
+    notifyCreateMessageList: function notifyCreateMessageList(requestId,
+                                                              listId,
+                                                              message) {
+      is(requestId, fakeRequestId);
+      checkReceivedSms(message, i);
+      auxListId = listId;
+      i += 1;
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
+    },
+    notifyGotNextMessage: function notifyGotNextMessage(requestId,
+                                                        message) {
+      is(requestId, fakeRequestId);
+      i % 2 ? checkSentSms(message, i) : checkReceivedSms(message, i);
+      i += 1;
+      gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
+    },
+    notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      is(requestId, fakeRequestId);
+      is(i, MAX_SMS);
+      run_next_test();
+    }
+  });
+  let filter = new MozSmsFilter();
+  filter.endDate = new Date(sms[2].timestamp);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+});
+
+add_test(function test_createMessageList_endDate_filter_failed() {
+  info("test_createMessageList_endDate_filter_failed");
+  let fakeRequestId = newRandomId();
+  fakeSmsRequestManager({
+     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      is(requestId, fakeRequestId);
+      run_next_test();
+    }
+  });
+  let filter = new MozSmsFilter();
+  filter.endDate = new Date(sms[0].timestamp - 1);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+});
+
+add_test(function test_createMessageList_fullDate_filter_success() {
+  info("test_createMessageList_fullDate_filter_success");
+  let fakeRequestId = newRandomId();
+  let auxListId;
+  let i = 0;
+  fakeSmsRequestManager({
+    notifyCreateMessageList: function notifyCreateMessageList(requestId,
+                                                              listId,
+                                                              message) {
+      is(requestId, fakeRequestId);
+      checkReceivedSms(message, i);
+      auxListId = listId;
+      i += 1;
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
+    },
+    notifyGotNextMessage: function notifyGotNextMessage(requestId,
+                                                        message) {
+      is(requestId, fakeRequestId);
+      i % 2 ? checkSentSms(message, i) : checkReceivedSms(message, i);
+      i += 1;
+      gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
+    },
+    notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      is(requestId, fakeRequestId);
+      is(i, MAX_SMS);
+      run_next_test();
+    }
+  });
+  let filter = new MozSmsFilter();
+  filter.startDate = new Date(sms[0].timestamp);
+  filter.endDate = new Date(sms[MAX_SMS - 1].timestamp);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+});
+
+add_test(function test_createMessageList_fullDate_filter_failed() {
+  info("test_createMessageList_fullDate_filter_failed");
+  let fakeRequestId = newRandomId();
+  fakeSmsRequestManager({
+     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      is(requestId, fakeRequestId);
+      run_next_test();
+    }
+  });
+  let filter = new MozSmsFilter();
+  filter.startDate = new Date(sms[MAX_SMS - 1] + 1);
+  filter.endDate = new Date(sms[MAX_SMS - 1] + 1);
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+});
+
+add_test(function test_createMessageList_single_number_success() {
+  info("test_createMessageList_single_number_success");
+  let fakeRequestId = newRandomId();
+  let firstMessage = false;
+  fakeSmsRequestManager({
+    notifyCreateMessageList: function notifyCreateMessageList(requestId,
+                                                              listId,
+                                                              message) {
+      is(firstMessage, false);
+      is(requestId, fakeRequestId);
+      checkReceivedSms(message, 0);
+      firstMessage = true;
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
+    },
+    notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      ok(firstMessage);
+      is(requestId, fakeRequestId);
+      run_next_test();
+    }
+  });
+  let filter = new MozSmsFilter();
+  filter.numbers = [sms[0].sender];
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+});
+
+add_test(function test_createMessageList_single_number_failed() {
+  info("test_createMessageList_single_number_failed");
+  let fakeRequestId = newRandomId();
+  fakeSmsRequestManager({
+     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      is(requestId, fakeRequestId);
+      run_next_test();
+    }
+  });
+  let filter = new MozSmsFilter();
+  filter.numbers = ["00000000000"];
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+});
+
+add_test(function test_createMessageList_multi_number_success() {
+  info("test_createMessageList_multi_number_success");
+  let fakeRequestId = newRandomId();
+  let auxListId;
+  let secondMessage = false;
+  fakeSmsRequestManager({
+    notifyCreateMessageList: function notifyCreateMessageList(requestId,
+                                                              listId,
+                                                              message) {
+      is(requestId, fakeRequestId);
+      checkReceivedSms(message, 0);
+      auxListId = listId;
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
+    },
+    notifyGotNextMessage: function notifyGotNextMessage(requestId, message) {
+      ok(!secondMessage);
+      is(requestId, fakeRequestId);
+      checkSentSms(message, 1);
+      secondMessage = true;
+      gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
+    },
+    notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      ok(secondMessage);
+      is(requestId, fakeRequestId);
+      run_next_test();
+    }
+  });
+  let filter = new MozSmsFilter();
+  filter.numbers = [sms[0].sender, sms[1].receiver];
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+});
+
+add_test(function test_createMessageList_multi_number_wrong_number_success() {
+  info("test_createMessageList_multi_number_wrong_number_success");
+  let fakeRequestId = newRandomId();
+  let firstMessage = false;
+  fakeSmsRequestManager({
+    notifyCreateMessageList: function notifyCreateMessageList(requestId,
+                                                              listId,
+                                                              message) {
+      is(firstMessage, false);
+      is(requestId, fakeRequestId);
+      checkReceivedSms(message, 0);
+      firstMessage = true;
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
+    },
+    notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      ok(firstMessage);
+      is(requestId, fakeRequestId);
+      run_next_test();
+    }
+  });
+  let filter = new MozSmsFilter();
+  filter.numbers = ["00000000000", sms[0].sender];
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+});
+
+add_test(function test_createMessageList_multi_number_failed() {
+  info("test_createMessageList_multi_number_failed");
+  let fakeRequestId = newRandomId();
+  fakeSmsRequestManager({
+     notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      is(requestId, fakeRequestId);
+      run_next_test();
+    }
+  });
+  let filter = new MozSmsFilter();
+  filter.numbers = ["00000000000", "11111111111"];
+  gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+});
+
+
+add_test(function test_createMessageList_read_filter_success() {
+  info("test_createMessageList_read_filter_success");
+  let fakeRequestId = newRandomId();
+  let lId;
+  let secondMessage = false;
+  fakeSmsRequestManager({
+    notifyCreateMessageList: function notifyCreateMessageList(requestId,
+                                                              listId,
+                                                              message) {
+      is(requestId, fakeRequestId);
+      checkReceivedSms(message, 0);
+      lId = listId;
+      gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
+    },
+    notifyGotNextMessage: function notifyGotNextMessage(requestId, message) {
+      ok(!secondMessage);
+      is(requestId, fakeRequestId);
+      checkReceivedSms(message, 2);
+      secondMessage = true;
+      gMobileMessageDatabaseService.getNextMessageInList(lId, requestId);
+    },
+    notifyNoMessageInList: function notifyNoMessageInList(requestId) {
+      ok(secondMessage);
+      is(requestId, fakeRequestId);
+      run_next_test();
+    }
+  });
+  SimpleTest.executeSoon(function () {
+    let filter = new MozSmsFilter();
+    filter.read = false;
+    gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
+  });
+});
+
+/**
+ * nsIMobileMessageDatabaseService.getNextMessageInList
+ */
+add_test(function test_getNextMessageInList_unknown_list() {
+  info("test_getNextMessageInList_unknown_list");
+  let fakeRequestId = newRandomId();
+  fakeSmsRequestManager({
+    notifyReadMessageListFailed:
+      function notifyReadMessageListFailed(requestId) {
+      is(requestId, fakeRequestId);
+      run_next_test();
+    }
+  });
+  gMobileMessageDatabaseService.getNextMessageInList(-1, fakeRequestId);
+});
+
+/**
+ * nsIMobileMessageDatabaseService.deleteMessage
+ */
+add_test(function test_deleteMessage_success() {
+  info("test_deleteMessage_success");
+  let fakeRequestId = newRandomId();
+  fakeSmsRequestManager({
+    notifySmsDeleted: function notifySmsDeleted(requestId, deleted) {
+      is(requestId, fakeRequestId);
+      ok(deleted);
+      run_next_test();
+    }
+  });
+  let messageId = gMobileMessageDatabaseService.saveReceivedMessage(sms[0]);
+  SimpleTest.executeSoon(function () {
+    gMobileMessageDatabaseService.deleteMessage(messageId, fakeRequestId);
+  });
+});
+
+add_test(function test_deleteMessage_failed() {
+  info("test_deleteMessage_failed");
+  let fakeRequestId = newRandomId();
+  fakeSmsRequestManager({
+    notifySmsDeleted: function notifySmsDeleted(requestId, deleted) {
+      is(requestId, fakeRequestId);
+      is(deleted, false);
+      run_next_test();
+    }
+  });
+  gMobileMessageDatabaseService.deleteMessage(-1, fakeRequestId);
+});
+
+add_test(function test_markMessageRead_success() {
+  info("test_markMessageRead_success");
+  let fakeRequestId = newRandomId();
+  fakeSmsRequestManager({
+    notifyMarkedMessageRead: function notifyMarkedMessageRead(requestId, read) {
+      is(requestId, fakeRequestId);
+      is(read, true);
+      run_next_test();
+    }
+  });
+  let messageId = gMobileMessageDatabaseService.saveReceivedMessage(sms[2]); 
+  SimpleTest.executeSoon(function () {
+    gMobileMessageDatabaseService.markMessageRead(messageId, true, fakeRequestId);
+  });
+});
+
+add_test(function test_markMessageRead_failed() {
+  info("test_markMessageRead_failed");
+  let fakeRequestId = newRandomId();
+  fakeSmsRequestManager({
+    notifyMarkMessageReadFailed: function notifyMarkMessageReadFailed(requestId, error) {
+      is(requestId, fakeRequestId);
+      run_next_test();
+    }
+  });
+  SimpleTest.executeSoon(function () {
+    gMobileMessageDatabaseService.markMessageRead(-1, true, fakeRequestId);
+  });
+});
+
+]]></script>
+  <body xmlns="http://www.w3.org/1999/xhtml">
+    <p id="display"></p>
+    <div id="content" style="display: none"></div>
+    <pre id="test"></pre>
+  </body>
+</window>
--- a/dom/mobilemessage/tests/xpcshell.ini
+++ b/dom/mobilemessage/tests/xpcshell.ini
@@ -1,13 +1,14 @@
 [DEFAULT]
 head = header_helpers.js
 tail =
 support-files =
   test_sms_basics.html
+  test_smsdatabaseservice.xul
   test_smsfilter.html
 
 [test_smsservice_createsmsmessage.js]
 [test_wsp_pdu_helper.js]
 run-if = toolkit == "gonk"
 [test_mms_pdu_helper.js]
 run-if = toolkit == "gonk"
 [test_mms_service.js]
--- a/dom/moz.build
+++ b/dom/moz.build
@@ -67,33 +67,31 @@ PARALLEL_DIRS += [
     'indexedDB',
     'system',
     'ipc',
     'identity',
     'workers',
     'camera',
     'audiochannel',
     'promise',
+    'wappush',
     'telephony',
     'inputmethod',
     'webidl',
 ]
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     PARALLEL_DIRS += ['plugins/ipc/hangui']
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
-    PARALLEL_DIRS += ['wifi']
-
 if CONFIG['MOZ_B2G_RIL']:
     PARALLEL_DIRS += [
+        'wifi',
         'icc',
         'cellbroadcast',
         'voicemail',
-        'wappush',
     ]
 
 if CONFIG['MOZ_PAY']:
     PARALLEL_DIRS += ['payment']
 
 if CONFIG['MOZ_GAMEPAD']:
     PARALLEL_DIRS += ['gamepad']
 
--- a/dom/network/interfaces/moz.build
+++ b/dom/network/interfaces/moz.build
@@ -1,36 +1,32 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 XPIDL_SOURCES += [
     'nsIDOMConnection.idl',
+    'nsIDOMDataErrorEvent.idl',
     'nsIDOMTCPServerSocket.idl',
     'nsIDOMTCPSocket.idl',
+    'nsIDOMUSSDReceivedEvent.idl',
     'nsIMozNavigatorNetwork.idl',
     'nsITCPServerSocketChild.idl',
     'nsITCPServerSocketParent.idl',
     'nsITCPSocketChild.idl',
     'nsITCPSocketParent.idl',
 ]
 
 if CONFIG['MOZ_B2G_RIL']:
     XPIDL_SOURCES += [
         'nsIDOMCFStateChangeEvent.idl',
-        'nsIDOMDataErrorEvent.idl',
         'nsIDOMMobileConnection.idl',
         'nsIDOMMozEmergencyCbModeEvent.idl',
         'nsIDOMMozOtaStatusEvent.idl',
-        'nsIDOMUSSDReceivedEvent.idl',
-        'nsIMobileConnectionProvider.idl',
-    ]
-
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
-    XPIDL_SOURCES += [
         'nsIDOMNetworkStats.idl',
         'nsIDOMNetworkStatsManager.idl',
+        'nsIMobileConnectionProvider.idl',
         'nsINetworkStatsServiceProxy.idl',
     ]
 
 XPIDL_MODULE = 'dom_network'
--- a/dom/network/src/MobileConnection.cpp
+++ b/dom/network/src/MobileConnection.cpp
@@ -1,14 +1,13 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "mozilla/dom/network/MobileConnection.h"
-
+#include "MobileConnection.h"
 #include "GeneratedEvents.h"
 #include "mozilla/Preferences.h"
 #include "nsDOMEvent.h"
 #include "nsIDOMCFStateChangeEvent.h"
 #include "nsIDOMClassInfo.h"
 #include "nsIDOMDOMRequest.h"
 #include "nsIDOMDataErrorEvent.h"
 #include "nsIDOMMozEmergencyCbModeEvent.h"
--- a/dom/network/src/moz.build
+++ b/dom/network/src/moz.build
@@ -17,40 +17,35 @@ SOURCES += [
     'Connection.cpp',
     'TCPServerSocketChild.cpp',
     'TCPServerSocketParent.cpp',
     'TCPSocketChild.cpp',
     'TCPSocketParent.cpp',
 ]
 
 if CONFIG['MOZ_B2G_RIL']:
-    EXPORTS.mozilla.dom.network += [
-        'MobileConnection.h',
-    ]
     SOURCES += [
         'MobileConnection.cpp',
     ]
-
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     EXTRA_JS_MODULES = [
         'NetworkStatsDB.jsm',
         'NetworkStatsService.jsm',
     ]
 
 EXTRA_COMPONENTS += [
     'TCPServerSocket.js',
     'TCPSocket.manifest',
     'TCPSocketParentIntermediary.js',
 ]
 
 EXTRA_PP_COMPONENTS += [
     'TCPSocket.js',
 ]
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
+if CONFIG['MOZ_B2G_RIL']:
     EXTRA_COMPONENTS += [
         'NetworkStatsManager.js',
         'NetworkStatsManager.manifest',
         'NetworkStatsServiceProxy.js',
         'NetworkStatsServiceProxy.manifest',
     ]
 
 IPDL_SOURCES += [
--- a/dom/network/tests/Makefile.in
+++ b/dom/network/tests/Makefile.in
@@ -4,16 +4,16 @@
 
 MOCHITEST_FILES = \
   test_network_basics.html \
   test_tcpsocket_default_permissions.html \
   test_tcpsocket_enabled_no_perm.html \
   test_tcpsocket_enabled_with_perm.html \
   $(NULL)
 
-ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
+ifdef MOZ_B2G_RIL
 MOCHITEST_FILES = \
   test_networkstats_basics.html \
   test_networkstats_disabled.html \
   test_networkstats_enabled_no_perm.html \
   test_networkstats_enabled_perm.html \
   $(NULL)
 endif
--- a/dom/system/gonk/GonkGPSGeolocationProvider.cpp
+++ b/dom/system/gonk/GonkGPSGeolocationProvider.cpp
@@ -13,53 +13,46 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 #include <pthread.h>
 #include <hardware/gps.h>
 
 #include "GonkGPSGeolocationProvider.h"
+#include "SystemWorkerManager.h"
 #include "mozilla/Preferences.h"
 #include "nsGeoPosition.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsINetworkManager.h"
+#include "nsIRadioInterfaceLayer.h"
+#include "nsIDOMIccInfo.h"
+#include "nsIDOMMobileConnection.h"
 #include "nsJSUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
 #include "nsContentUtils.h"
 
-#ifdef MOZ_B2G_RIL
-#include "nsIDOMIccInfo.h"
-#include "nsIDOMMobileConnection.h"
-#include "nsIRadioInterfaceLayer.h"
-#endif
-
 #ifdef AGPS_TYPE_INVALID
 #define AGPS_HAVE_DUAL_APN
 #endif
 
 #define DEBUG_GPS 0
 
 using namespace mozilla;
 
 static const int kDefaultPeriod = 1000; // ms
 
 // While most methods of GonkGPSGeolocationProvider should only be
 // called from main thread, we deliberately put the Init and ShutdownGPS
 // methods off main thread to avoid blocking.
-#ifdef MOZ_B2G_RIL
 NS_IMPL_ISUPPORTS3(GonkGPSGeolocationProvider,
                    nsIGeolocationProvider,
                    nsIRILDataCallback,
                    nsISettingsServiceCallback)
-#else
-NS_IMPL_ISUPPORTS1(GonkGPSGeolocationProvider,
-                   nsIGeolocationProvider)
-#endif
 
 /* static */ GonkGPSGeolocationProvider* GonkGPSGeolocationProvider::sSingleton = nullptr;
 GpsCallbacks GonkGPSGeolocationProvider::mCallbacks = {
   sizeof(GpsCallbacks),
   LocationCallback,
   StatusCallback,
   SvStatusCallback,
   NmeaCallback,
@@ -67,30 +60,28 @@ GpsCallbacks GonkGPSGeolocationProvider:
   AcquireWakelockCallback,
   ReleaseWakelockCallback,
   CreateThreadCallback,
 #ifdef GPS_CAPABILITY_ON_DEMAND_TIME
   RequestUtcTimeCallback,
 #endif
 };
 
-#ifdef MOZ_B2G_RIL
 AGpsCallbacks
 GonkGPSGeolocationProvider::mAGPSCallbacks = {
   AGPSStatusCallback,
   CreateThreadCallback,
 };
 
 AGpsRilCallbacks
 GonkGPSGeolocationProvider::mAGPSRILCallbacks = {
   AGPSRILSetIDCallback,
   AGPSRILRefLocCallback,
   CreateThreadCallback,
 };
-#endif // MOZ_B2G_RIL
 
 void
 GonkGPSGeolocationProvider::LocationCallback(GpsLocation* location)
 {
   class UpdateLocationEvent : public nsRunnable {
   public:
     UpdateLocationEvent(nsGeoPosition* aPosition)
       : mPosition(aPosition)
@@ -150,20 +141,18 @@ GonkGPSGeolocationProvider::SetCapabilit
     UpdateCapabilitiesEvent(uint32_t aCapabilities)
       : mCapabilities(aCapabilities)
     {}
     NS_IMETHOD Run() {
       nsRefPtr<GonkGPSGeolocationProvider> provider =
         GonkGPSGeolocationProvider::GetSingleton();
 
       provider->mSupportsScheduling = mCapabilities & GPS_CAPABILITY_SCHEDULING;
-#ifdef MOZ_B2G_RIL
       provider->mSupportsMSB = mCapabilities & GPS_CAPABILITY_MSB;
       provider->mSupportsMSA = mCapabilities & GPS_CAPABILITY_MSA;
-#endif
       provider->mSupportsSingleShot = mCapabilities & GPS_CAPABILITY_SINGLE_SHOT;
 #ifdef GPS_CAPABILITY_ON_DEMAND_TIME
       provider->mSupportsTimeInjection = mCapabilities & GPS_CAPABILITY_ON_DEMAND_TIME;
 #endif
       return NS_OK;
     }
   private:
     uint32_t mCapabilities;
@@ -202,17 +191,16 @@ GonkGPSGeolocationProvider::CreateThread
   return thread;
 }
 
 void
 GonkGPSGeolocationProvider::RequestUtcTimeCallback()
 {
 }
 
-#ifdef MOZ_B2G_RIL
 void
 GonkGPSGeolocationProvider::AGPSStatusCallback(AGpsStatus* status)
 {
   MOZ_ASSERT(status);
 
   class AGPSStatusEvent : public nsRunnable {
   public:
     AGPSStatusEvent(AGpsStatusValue aStatus)
@@ -274,25 +262,22 @@ GonkGPSGeolocationProvider::AGPSRILRefLo
       return NS_OK;
     }
   };
 
   if (flags & AGPS_RIL_REQUEST_REFLOC_CELLID) {
     NS_DispatchToMainThread(new RequestRefLocEvent());
   }
 }
-#endif // MOZ_B2G_RIL
 
 GonkGPSGeolocationProvider::GonkGPSGeolocationProvider()
   : mStarted(false)
   , mSupportsScheduling(false)
-#ifdef MOZ_B2G_RIL
   , mSupportsMSB(false) 
   , mSupportsMSA(false) 
-#endif
   , mSupportsSingleShot(false)
   , mSupportsTimeInjection(false)
   , mGpsInterface(nullptr)
 {
 }
 
 GonkGPSGeolocationProvider::~GonkGPSGeolocationProvider()
 {
@@ -330,17 +315,16 @@ GonkGPSGeolocationProvider::GetGPSInterf
   const GpsInterface* result = gps_device->get_gps_interface(gps_device);
 
   if (result->size != sizeof(GpsInterface)) {
     return nullptr;
   }
   return result;
 }
 
-#ifdef MOZ_B2G_RIL
 int32_t
 GonkGPSGeolocationProvider::GetDataConnectionState()
 {
   if (!mRadioInterface) {
     return nsINetworkInterface::NETWORK_STATE_UNKNOWN;
   }
 
   int32_t state;
@@ -518,91 +502,83 @@ GonkGPSGeolocationProvider::SetReference
         }
       }
     }
     if (mAGpsRilInterface) {
       mAGpsRilInterface->set_ref_location(&location, sizeof(location));
     }
   }
 }
-#endif // MOZ_B2G_RIL
 
 void
 GonkGPSGeolocationProvider::Init()
 {
   // Must not be main thread. Some GPS driver's first init takes very long.
   MOZ_ASSERT(!NS_IsMainThread());
 
   mGpsInterface = GetGPSInterface();
   if (!mGpsInterface) {
     return;
   }
 
   if (mGpsInterface->init(&mCallbacks) != 0) {
     return;
   }
 
-#ifdef MOZ_B2G_RIL
   mAGpsInterface =
     static_cast<const AGpsInterface*>(mGpsInterface->get_extension(AGPS_INTERFACE));
   if (mAGpsInterface) {
     mAGpsInterface->init(&mAGPSCallbacks);
   }
 
   mAGpsRilInterface =
     static_cast<const AGpsRilInterface*>(mGpsInterface->get_extension(AGPS_RIL_INTERFACE));
   if (mAGpsRilInterface) {
     mAGpsRilInterface->init(&mAGPSRILCallbacks);
   }
-#endif
 
   NS_DispatchToMainThread(NS_NewRunnableMethod(this, &GonkGPSGeolocationProvider::StartGPS));
 }
 
 void
 GonkGPSGeolocationProvider::StartGPS()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mGpsInterface);
 
   int32_t update = Preferences::GetInt("geo.default.update", kDefaultPeriod);
 
-#ifdef MOZ_B2G_RIL
   if (mSupportsMSA || mSupportsMSB) {
     SetupAGPS();
   }
-#endif
 
   int positionMode = GPS_POSITION_MODE_STANDALONE;
   bool singleShot = false;
 
-#ifdef MOZ_B2G_RIL
   // XXX: If we know this is a single shot request, use MSA can be faster.
   if (singleShot && mSupportsMSA) {
     positionMode = GPS_POSITION_MODE_MS_ASSISTED;
   } else if (mSupportsMSB) {
     positionMode = GPS_POSITION_MODE_MS_BASED;
   }
-#endif
   if (!mSupportsScheduling) {
     update = kDefaultPeriod;
   }
 
   mGpsInterface->set_position_mode(positionMode,
                                    GPS_POSITION_RECURRENCE_PERIODIC,
                                    update, 0, 0);
 #if DEBUG_GPS
   // Delete cached data
   mGpsInterface->delete_aiding_data(GPS_DELETE_ALL);
 #endif
 
   mGpsInterface->start();
 }
 
-#ifdef MOZ_B2G_RIL
 void
 GonkGPSGeolocationProvider::SetupAGPS()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mAGpsInterface);
 
   const nsAdoptingCString& suplServer = Preferences::GetCString("geo.gps.supl_server");
   int32_t suplPort = Preferences::GetInt("geo.gps.supl_port", -1);
@@ -618,18 +594,19 @@ GonkGPSGeolocationProvider::SetupAGPS()
   if (ril) {
     // TODO: Bug 878748 - B2G GPS: acquire correct RadioInterface instance in
     // MultiSIM configuration
     ril->GetRadioInterface(0 /* clientId */, getter_AddRefs(mRadioInterface));
     if (mRadioInterface) {
       mRadioInterface->RegisterDataCallCallback(this);
     }
   }
+
+  return;
 }
-#endif // MOZ_B2G_RIL
 
 NS_IMETHODIMP
 GonkGPSGeolocationProvider::Startup()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mStarted) {
     return NS_OK;
@@ -661,21 +638,19 @@ GonkGPSGeolocationProvider::Shutdown()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!mStarted) {
     return NS_OK;
   }
   mStarted = false;
 
-#ifdef MOZ_B2G_RIL
   if (mRadioInterface) {
     mRadioInterface->UnregisterDataCallCallback(this);
   }
-#endif
 
   mInitThread->Dispatch(NS_NewRunnableMethod(this, &GonkGPSGeolocationProvider::ShutdownGPS),
                         NS_DISPATCH_NORMAL);
 
   return NS_OK;
 }
 
 void
@@ -690,17 +665,16 @@ GonkGPSGeolocationProvider::ShutdownGPS(
 }
 
 NS_IMETHODIMP
 GonkGPSGeolocationProvider::SetHighAccuracy(bool)
 {
   return NS_OK;
 }
 
-#ifdef MOZ_B2G_RIL
 /** nsIRILDataCallback interface **/
 
 NS_IMETHODIMP
 GonkGPSGeolocationProvider::DataCallStateChanged(nsIRILDataCallInfo* aDataCall)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aDataCall);
 
@@ -742,9 +716,8 @@ GonkGPSGeolocationProvider::Handle(const
   return NS_OK;
 }
 
 NS_IMETHODIMP
 GonkGPSGeolocationProvider::HandleError(const nsAString& aErrorMessage)
 {
   return NS_OK;
 }
-#endif // MOZ_B2G_RIL
--- a/dom/system/gonk/GonkGPSGeolocationProvider.h
+++ b/dom/system/gonk/GonkGPSGeolocationProvider.h
@@ -15,42 +15,37 @@
  */
 
 #ifndef GonkGPSGeolocationProvider_h
 #define GonkGPSGeolocationProvider_h
 
 #include <hardware/gps.h> // for GpsInterface
 #include "nsCOMPtr.h"
 #include "nsIGeolocationProvider.h"
-#ifdef MOZ_B2G_RIL
 #include "nsIRadioInterfaceLayer.h"
+#include "nsString.h"
 #include "nsISettingsService.h"
-#endif
 
 class nsIThread;
 
 #define GONK_GPS_GEOLOCATION_PROVIDER_CID \
 { 0x48525ec5, 0x5a7f, 0x490a, { 0x92, 0x77, 0xba, 0x66, 0xe0, 0xd2, 0x2c, 0x8b } }
 
 #define GONK_GPS_GEOLOCATION_PROVIDER_CONTRACTID \
 "@mozilla.org/gonk-gps-geolocation-provider;1"
 
 class GonkGPSGeolocationProvider : public nsIGeolocationProvider
-#ifdef MOZ_B2G_RIL
                                  , public nsIRILDataCallback
                                  , public nsISettingsServiceCallback
-#endif
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIGEOLOCATIONPROVIDER
-#ifdef MOZ_B2G_RIL
   NS_DECL_NSIRILDATACALLBACK
   NS_DECL_NSISETTINGSSERVICECALLBACK
-#endif
 
   static already_AddRefed<GonkGPSGeolocationProvider> GetSingleton();
 
 private:
 
   /* Client should use GetSingleton() to get the provider instance. */
   GonkGPSGeolocationProvider();
   GonkGPSGeolocationProvider(const GonkGPSGeolocationProvider &);
@@ -61,59 +56,49 @@ private:
   static void StatusCallback(GpsStatus* status);
   static void SvStatusCallback(GpsSvStatus* sv_info);
   static void NmeaCallback(GpsUtcTime timestamp, const char* nmea, int length);
   static void SetCapabilitiesCallback(uint32_t capabilities);
   static void AcquireWakelockCallback();
   static void ReleaseWakelockCallback();
   static pthread_t CreateThreadCallback(const char* name, void (*start)(void*), void* arg);
   static void RequestUtcTimeCallback();
-#ifdef MOZ_B2G_RIL
   static void AGPSStatusCallback(AGpsStatus* status);
   static void AGPSRILSetIDCallback(uint32_t flags);
   static void AGPSRILRefLocCallback(uint32_t flags);
-#endif
 
   static GpsCallbacks mCallbacks;
-#ifdef MOZ_B2G_RIL
   static AGpsCallbacks mAGPSCallbacks;
   static AGpsRilCallbacks mAGPSRILCallbacks;
-#endif
 
+  int32_t GetDataConnectionState();
+  void SetAGpsDataConn(nsAString& aApn);
+  void RequestSettingValue(char* aKey);
   void Init();
+  void SetupAGPS();
   void StartGPS();
   void ShutdownGPS();
-#ifdef MOZ_B2G_RIL
-  void SetupAGPS();
-  int32_t GetDataConnectionState();
-  void SetAGpsDataConn(nsAString& aApn);
   void RequestDataConnection();
   void ReleaseDataConnection();
-  void RequestSettingValue(char* aKey);
   void RequestSetID(uint32_t flags);
   void SetReferenceLocation();
-#endif
 
   const GpsInterface* GetGPSInterface();
 
   static GonkGPSGeolocationProvider* sSingleton;
 
   bool mStarted;
 
   bool mSupportsScheduling;
-#ifdef MOZ_B2G_RIL
   bool mSupportsMSB;
   bool mSupportsMSA;
-#endif
   bool mSupportsSingleShot;
   bool mSupportsTimeInjection;
 
   const GpsInterface* mGpsInterface;
-#ifdef MOZ_B2G_RIL
   const AGpsInterface* mAGpsInterface;
   const AGpsRilInterface* mAGpsRilInterface;
-  nsCOMPtr<nsIRadioInterface> mRadioInterface;
-#endif
   nsCOMPtr<nsIGeolocationUpdate> mLocationCallback;
   nsCOMPtr<nsIThread> mInitThread;
+  nsCOMPtr<nsIRadioInterface> mRadioInterface;
 };
 
 #endif /* GonkGPSGeolocationProvider_h */
--- a/dom/system/gonk/NetworkManager.js
+++ b/dom/system/gonk/NetworkManager.js
@@ -128,20 +128,18 @@ function defineLazyRegExp(obj, name, pat
 
 /**
  * This component watches for network interfaces changing state and then
  * adjusts routes etc. accordingly.
  */
 function NetworkManager() {
   this.networkInterfaces = {};
   Services.obs.addObserver(this, TOPIC_INTERFACE_STATE_CHANGED, true);
-#ifdef MOZ_B2G_RIL
   Services.obs.addObserver(this, TOPIC_INTERFACE_REGISTERED, true);
   Services.obs.addObserver(this, TOPIC_INTERFACE_UNREGISTERED, true);
-#endif
   Services.obs.addObserver(this, TOPIC_XPCOM_SHUTDOWN, false);
   Services.obs.addObserver(this, TOPIC_MOZSETTINGS_CHANGED, false);
 
   debug("Starting worker.");
   this.worker = new ChromeWorker("resource://gre/modules/net_worker.js");
   this.worker.onmessage = this.handleWorkerMessage.bind(this);
   this.worker.onerror = function onerror(event) {
     debug("Received error from worker: " + event.filename +
@@ -226,123 +224,105 @@ NetworkManager.prototype = {
 
   observe: function observe(subject, topic, data) {
     switch (topic) {
       case TOPIC_INTERFACE_STATE_CHANGED:
         let network = subject.QueryInterface(Ci.nsINetworkInterface);
         debug("Network " + network.name + " changed state to " + network.state);
         switch (network.state) {
           case Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED:
-#ifdef MOZ_B2G_RIL
             // Add host route for data calls
             if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
                 network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
                 network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
               this.removeHostRoutes(network.name);
               this.addHostRoute(network);
             }
             // Add extra host route. For example, mms proxy or mmsc.
             this.setExtraHostRoute(network);
-#endif
             // Remove pre-created default route and let setAndConfigureActive()
             // to set default route only on preferred network
             this.removeDefaultRoute(network.name);
             this.setAndConfigureActive();
-#ifdef MOZ_B2G_RIL
             // Update data connection when Wifi connected/disconnected
             if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
               this.mRIL.getRadioInterface(0).updateRILNetworkInterface();
             }
-#endif
 
             this.onConnectionChanged(network);
 
             // Probing the public network accessibility after routing table is ready
             CaptivePortalDetectionHelper.notify(CaptivePortalDetectionHelper.EVENT_CONNECT, this.active);
             break;
           case Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED:
-#ifdef MOZ_B2G_RIL
             // Remove host route for data calls
             if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
                 network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
                 network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
               this.removeHostRoute(network);
             }
             // Remove extra host route. For example, mms proxy or mmsc.
             this.removeExtraHostRoute(network);
-#endif
             // Remove routing table in /proc/net/route
             if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
               this.resetRoutingTable(network);
-#ifdef MOZ_B2G_RIL
             } else if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
               this.removeDefaultRoute(network.name);
-#endif
             }
             // Abort ongoing captive portal detection on the wifi interface
             CaptivePortalDetectionHelper.notify(CaptivePortalDetectionHelper.EVENT_DISCONNECT, network);
             this.setAndConfigureActive();
-#ifdef MOZ_B2G_RIL
             // Update data connection when Wifi connected/disconnected
             if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
               this.mRIL.getRadioInterface(0).updateRILNetworkInterface();
             }
-#endif
             break;
         }
         break;
-#ifdef MOZ_B2G_RIL
       case TOPIC_INTERFACE_REGISTERED:
         let regNetwork = subject.QueryInterface(Ci.nsINetworkInterface);
         // Add extra host route. For example, mms proxy or mmsc.
         this.setExtraHostRoute(regNetwork);
         break;
       case TOPIC_INTERFACE_UNREGISTERED:
         let unregNetwork = subject.QueryInterface(Ci.nsINetworkInterface);
         // Remove extra host route. For example, mms proxy or mmsc.
         this.removeExtraHostRoute(unregNetwork);
         break;
-#endif
       case TOPIC_MOZSETTINGS_CHANGED:
         let setting = JSON.parse(data);
         this.handle(setting.key, setting.value);
         break;
       case TOPIC_PREF_CHANGED:
         this._manageOfflineStatus =
           Services.prefs.getBoolPref(PREF_MANAGE_OFFLINE_STATUS);
         debug(PREF_MANAGE_OFFLINE_STATUS + " has changed to " + this._manageOfflineStatus);
         break;
       case TOPIC_XPCOM_SHUTDOWN:
         Services.obs.removeObserver(this, TOPIC_XPCOM_SHUTDOWN);
         Services.obs.removeObserver(this, TOPIC_MOZSETTINGS_CHANGED);
-#ifdef MOZ_B2G_RIL
         Services.obs.removeObserver(this, TOPIC_INTERFACE_REGISTERED);
         Services.obs.removeObserver(this, TOPIC_INTERFACE_UNREGISTERED);
-#endif
         Services.obs.removeObserver(this, TOPIC_INTERFACE_STATE_CHANGED);
         break;
     }
   },
 
   receiveMessage: function receiveMessage(aMsg) {
     switch (aMsg.name) {
       case "NetworkInterfaceList:ListInterface": {
-#ifdef MOZ_B2G_RIL
         let excludeMms = aMsg.json.exculdeMms;
         let excludeSupl = aMsg.json.exculdeSupl;
-#endif
         let interfaces = [];
 
         for each (let i in this.networkInterfaces) {
-#ifdef MOZ_B2G_RIL
           if ((i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS && excludeMms) ||
               (i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL && excludeSupl)) {
             continue;
           }
-#endif
           interfaces.push({
             state: i.state,
             type: i.type,
             name: i.name,
             ip: i.ip,
             netmask: i.netmask,
             broadcast: i.broadcast,
             gateway: i.gateway,
@@ -364,24 +344,22 @@ NetworkManager.prototype = {
       throw Components.Exception("Argument must be nsINetworkInterface.",
                                  Cr.NS_ERROR_INVALID_ARG);
     }
     if (network.name in this.networkInterfaces) {
       throw Components.Exception("Network with that name already registered!",
                                  Cr.NS_ERROR_INVALID_ARG);
     }
     this.networkInterfaces[network.name] = network;
-#ifdef MOZ_B2G_RIL
     // Add host route for data calls
     if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
         network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
         network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
       this.addHostRoute(network);
     }
-#endif
     // Remove pre-created default route and let setAndConfigureActive()
     // to set default route only on preferred network
     this.removeDefaultRoute(network.name);
     this.setAndConfigureActive();
     Services.obs.notifyObservers(network, TOPIC_INTERFACE_REGISTERED, null);
     debug("Network '" + network.name + "' registered.");
   },
 
@@ -390,62 +368,54 @@ NetworkManager.prototype = {
       throw Components.Exception("Argument must be nsINetworkInterface.",
                                  Cr.NS_ERROR_INVALID_ARG);
     }
     if (!(network.name in this.networkInterfaces)) {
       throw Components.Exception("No network with that name registered.",
                                  Cr.NS_ERROR_INVALID_ARG);
     }
     delete this.networkInterfaces[network.name];
-#ifdef MOZ_B2G_RIL
     // Remove host route for data calls
     if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
         network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
         network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
       this.removeHostRoute(network);
     }
-#endif
     this.setAndConfigureActive();
     Services.obs.notifyObservers(network, TOPIC_INTERFACE_UNREGISTERED, null);
     debug("Network '" + network.name + "' unregistered.");
   },
 
   _manageOfflineStatus: true,
 
   networkInterfaces: null,
 
   _preferredNetworkType: DEFAULT_PREFERRED_NETWORK_TYPE,
   get preferredNetworkType() {
     return this._preferredNetworkType;
   },
   set preferredNetworkType(val) {
-#ifdef MOZ_B2G_RIL
     if ([Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
          Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE].indexOf(val) == -1) {
-#else
-    if (val != Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
-#endif
       throw "Invalid network type";
     }
     this._preferredNetworkType = val;
   },
 
   active: null,
   _overriddenActive: null,
 
   // Clone network info so we can still get information when network is disconnected
   _activeInfo: null,
 
   overrideActive: function overrideActive(network) {
-#ifdef MOZ_B2G_RIL
     if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
         network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
       throw "Invalid network type";
     }
-#endif
     this._overriddenActive = network;
     this.setAndConfigureActive();
   },
 
   getNetworkInterfaceStats: function getNetworkInterfaceStats(networkName, callback) {
     debug("getNetworkInterfaceStats for " + networkName);
 
     let params = {
@@ -507,17 +477,16 @@ NetworkManager.prototype = {
     }
     let callback = this.controlCallbacks[id];
     if (callback) {
       callback.call(this, response);
       delete this.controlCallbacks[id];
     }
   },
 
-#ifdef MOZ_B2G_RIL
   setExtraHostRoute: function setExtraHostRoute(network) {
     if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS) {
       debug("Network '" + network.name + "' registered, adding mmsproxy and/or mmsc route");
       let mmsHosts = this.resolveHostname(
                        [Services.prefs.getCharPref("ril.mms.mmsproxy"),
                         Services.prefs.getCharPref("ril.mms.mmsc")]);
       this.addHostRouteWithResolve(network, mmsHosts);
     }
@@ -527,24 +496,24 @@ NetworkManager.prototype = {
     if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS) {
       debug("Network '" + network.name + "' unregistered, removing mmsproxy and/or mmsc route");
       let mmsHosts = this.resolveHostname(
                        [Services.prefs.getCharPref("ril.mms.mmsproxy"),
                         Services.prefs.getCharPref("ril.mms.mmsc")]);
       this.removeHostRouteWithResolve(network, mmsHosts);
     }
   },
-#endif // MOZ_B2G_RIL
 
   /**
    * Determine the active interface and configure it.
    */
   setAndConfigureActive: function setAndConfigureActive() {
     debug("Evaluating whether active network needs to be changed.");
     let oldActive = this.active;
+    let defaultDataNetwork;
 
     if (this._overriddenActive) {
       debug("We have an override for the active network: " +
             this._overriddenActive.name);
       // The override was just set, so reconfigure the network.
       if (this.active != this._overriddenActive) {
         this.active = this._overriddenActive;
         this.setDefaultRouteAndDNS(oldActive);
@@ -560,56 +529,47 @@ NetworkManager.prototype = {
       debug("Active network is already our preferred type.");
       this.setDefaultRouteAndDNS(oldActive);
       return;
     }
 
     // Find a suitable network interface to activate.
     this.active = null;
     this._activeInfo = Object.create(null);
-#ifdef MOZ_B2G_RIL
-    let defaultDataNetwork;
-#endif
     for each (let network in this.networkInterfaces) {
       if (network.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
         continue;
       }
-#ifdef MOZ_B2G_RIL
       if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
         defaultDataNetwork = network;
       }
-#endif
       this.active = network;
       this._activeInfo = {name:network.name, ip:network.ip, netmask:network.netmask};
       if (network.type == this.preferredNetworkType) {
         debug("Found our preferred type of network: " + network.name);
         break;
       }
     }
     if (this.active) {
-#ifdef MOZ_B2G_RIL
       // Give higher priority to default data APN than seconary APN.
       // If default data APN is not connected, we still set default route
       // and DNS on seconary APN.
       if (defaultDataNetwork &&
           (this.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
            this.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) &&
           this.active.type != this.preferredNetworkType) {
         this.active = defaultDataNetwork;
       }
       // Don't set default route on secondary APN
       if (this.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
           this.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
         this.setDNS(this.active);
       } else {
-#endif // MOZ_B2G_RIL
         this.setDefaultRouteAndDNS(oldActive);
-#ifdef MOZ_B2G_RIL
       }
-#endif
       if (this.active != oldActive) {
         Services.obs.notifyObservers(this.active, TOPIC_ACTIVE_CHANGED, null);
       }
     }
 
     if (this._manageOfflineStatus) {
       Services.io.offline = !this.active;
     }
@@ -624,28 +584,26 @@ NetworkManager.prototype = {
       cmd: "removeNetworkRoute",
       ifname: network.name,
       ip : network.ip,
       netmask: network.netmask,
     };
     this.worker.postMessage(options);
   },
 
-#ifdef MOZ_B2G_RIL
   setDNS: function setDNS(networkInterface) {
     debug("Going DNS to " + networkInterface.name);
     let options = {
       cmd: "setDNS",
       ifname: networkInterface.name,
       dns1_str: networkInterface.dns1,
       dns2_str: networkInterface.dns2
     };
     this.worker.postMessage(options);
   },
-#endif
 
   setDefaultRouteAndDNS: function setDefaultRouteAndDNS(oldInterface) {
     debug("Going to change route and DNS to " + this.active.name);
     let options = {
       cmd: "setDefaultRouteAndDNS",
       ifname: this.active.name,
       oldIfname: (oldInterface && oldInterface != this.active) ? oldInterface.name : null,
       gateway_str: this.active.gateway,
@@ -660,17 +618,16 @@ NetworkManager.prototype = {
     debug("Remove default route for " + ifname);
     let options = {
       cmd: "removeDefaultRoute",
       ifname: ifname
     }
     this.worker.postMessage(options);
   },
 
-#ifdef MOZ_B2G_RIL
   addHostRoute: function addHostRoute(network) {
     debug("Going to add host route on " + network.name);
     let options = {
       cmd: "addHostRoute",
       ifname: network.name,
       gateway: network.gateway,
       hostnames: [network.dns1, network.dns2, network.httpProxyHost]
     };
@@ -740,17 +697,16 @@ NetworkManager.prototype = {
     let options = {
       cmd: "removeHostRoute",
       ifname: network.name,
       gateway: network.gateway,
       hostnames: hosts
     };
     this.worker.postMessage(options);
   },
-#endif // MOZ_B2G_RIL
 
   setNetworkProxy: function setNetworkProxy(network) {
     try {
       if (!network.httpProxyHost || network.httpProxyHost == "") {
         // Sets direct connection to internet.
         Services.prefs.clearUserPref("network.proxy.type");
         Services.prefs.clearUserPref("network.proxy.share_proxy_settings");
         Services.prefs.clearUserPref("network.proxy.http");
@@ -1259,21 +1215,19 @@ let CaptivePortalDetectionHelper = (func
             _abort(network.name);
           }
           break;
       }
     }
   };
 }());
 
-#ifdef MOZ_B2G_RIL
 XPCOMUtils.defineLazyServiceGetter(NetworkManager.prototype, "mRIL",
                                    "@mozilla.org/ril;1",
                                    "nsIRadioInterfaceLayer");
-#endif
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([NetworkManager]);
 
 
 let debug;
 if (DEBUG) {
   debug = function (s) {
     dump("-*- NetworkManager: " + s + "\n");
--- a/dom/system/gonk/SystemWorkerManager.cpp
+++ b/dom/system/gonk/SystemWorkerManager.cpp
@@ -19,50 +19,153 @@
 
 #include "nsINetworkManager.h"
 #include "nsIWifi.h"
 #include "nsIWorkerHolder.h"
 #include "nsIXPConnect.h"
 
 #include "jsfriendapi.h"
 #include "mozilla/dom/workers/Workers.h"
+#ifdef MOZ_WIDGET_GONK
 #include "mozilla/ipc/Netd.h"
 #include "AutoMounter.h"
 #include "TimeZoneSettingObserver.h"
 #include "AudioManager.h"
-#ifdef MOZ_B2G_RIL
+#endif
 #include "mozilla/ipc/Ril.h"
-#endif
 #include "mozilla/ipc/KeyStore.h"
 #include "nsIObserverService.h"
 #include "nsCxPusher.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
 #include "nsRadioInterfaceLayer.h"
 #include "WifiWorker.h"
 #include "mozilla/Services.h"
 
 USING_WORKERS_NAMESPACE
 
 using namespace mozilla::dom::gonk;
 using namespace mozilla::ipc;
+#ifdef MOZ_WIDGET_GONK
 using namespace mozilla::system;
+#endif
 
 #define NS_NETWORKMANAGER_CID \
   { 0x33901e46, 0x33b8, 0x11e1, \
   { 0x98, 0x69, 0xf4, 0x6d, 0x04, 0xd2, 0x5b, 0xcc } }
 
 namespace {
 
 NS_DEFINE_CID(kWifiWorkerCID, NS_WIFIWORKER_CID);
 NS_DEFINE_CID(kNetworkManagerCID, NS_NETWORKMANAGER_CID);
 
 // Doesn't carry a reference, we're owned by services.
 SystemWorkerManager *gInstance = nullptr;
 
+class ConnectWorkerToRIL : public WorkerTask
+{
+public:
+  ConnectWorkerToRIL()
+  { }
+
+  virtual bool RunTask(JSContext *aCx);
+};
+
+class SendRilSocketDataTask : public nsRunnable
+{
+public:
+  SendRilSocketDataTask(unsigned long aClientId,
+                        UnixSocketRawData *aRawData)
+    : mRawData(aRawData)
+    , mClientId(aClientId)
+  { }
+
+  NS_IMETHOD Run()
+  {
+    MOZ_ASSERT(NS_IsMainThread());
+    SystemWorkerManager::SendRilRawData(mClientId, mRawData);
+    return NS_OK;
+  }
+
+private:
+  UnixSocketRawData *mRawData;
+  unsigned long mClientId;
+};
+
+bool
+PostToRIL(JSContext *cx, unsigned argc, JS::Value *vp)
+{
+  NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread");
+
+  if (argc != 2) {
+    JS_ReportError(cx, "Expecting two arguments with the RIL message");
+    return false;
+  }
+
+  JS::Value cv = JS_ARGV(cx, vp)[0];
+  int clientId = cv.toInt32();
+
+  JS::Value v = JS_ARGV(cx, vp)[1];
+
+  JSAutoByteString abs;
+  void *data;
+  size_t size;
+  if (JSVAL_IS_STRING(v)) {
+    JSString *str = JSVAL_TO_STRING(v);
+    if (!abs.encodeUtf8(cx, str)) {
+      return false;
+    }
+
+    data = abs.ptr();
+    size = abs.length();
+  } else if (!JSVAL_IS_PRIMITIVE(v)) {
+    JSObject *obj = JSVAL_TO_OBJECT(v);
+    if (!JS_IsTypedArrayObject(obj)) {
+      JS_ReportError(cx, "Object passed in wasn't a typed array");
+      return false;
+    }
+
+    uint32_t type = JS_GetArrayBufferViewType(obj);
+    if (type != js::ArrayBufferView::TYPE_INT8 &&
+        type != js::ArrayBufferView::TYPE_UINT8 &&
+        type != js::ArrayBufferView::TYPE_UINT8_CLAMPED) {
+      JS_ReportError(cx, "Typed array data is not octets");
+      return false;
+    }
+
+    size = JS_GetTypedArrayByteLength(obj);
+    data = JS_GetArrayBufferViewData(obj);
+  } else {
+    JS_ReportError(cx,
+                   "Incorrect argument. Expecting a string or a typed array");
+    return false;
+  }
+
+  UnixSocketRawData* raw = new UnixSocketRawData(data, size);
+
+  nsRefPtr<SendRilSocketDataTask> task = new SendRilSocketDataTask(clientId, raw);
+  NS_DispatchToMainThread(task);
+  return true;
+}
+
+bool
+ConnectWorkerToRIL::RunTask(JSContext *aCx)
+{
+  // Set up the postRILMessage on the function for worker -> RIL thread
+  // communication.
+  NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread");
+  NS_ASSERTION(!JS_IsRunning(aCx), "Are we being called somehow?");
+  JSObject *workerGlobal = JS::CurrentGlobalOrNull(aCx);
+
+  return !!JS_DefineFunction(aCx, workerGlobal, "postRILMessage", PostToRIL, 1,
+                             0);
+}
+
+#ifdef MOZ_WIDGET_GONK
+
 bool
 DoNetdCommand(JSContext *cx, unsigned argc, JS::Value *vp)
 {
   NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread");
 
   if (argc != 1) {
     JS_ReportError(cx, "Expecting a single argument with the Netd message");
     return false;
@@ -198,16 +301,18 @@ NetdReceiver::DispatchNetdEvent::RunTask
   }
 
   memcpy(JS_GetUint8ArrayData(array), mMessage->mData, mMessage->mSize);
   JS::Value argv[] = { OBJECT_TO_JSVAL(array) };
   return JS_CallFunctionName(aCx, obj, "onNetdMessage", NS_ARRAY_LENGTH(argv),
                              argv, argv);
 }
 
+#endif // MOZ_WIDGET_GONK
+
 } // anonymous namespace
 
 SystemWorkerManager::SystemWorkerManager()
   : mShutdown(false)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   NS_ASSERTION(!gInstance, "There should only be one instance!");
 }
@@ -235,22 +340,24 @@ SystemWorkerManager::Init()
   nsresult rv = InitWifi(cx);
   if (NS_FAILED(rv)) {
     NS_WARNING("Failed to initialize WiFi Networking!");
     return rv;
   }
 
   InitKeyStore(cx);
 
+#ifdef MOZ_WIDGET_GONK
   InitAutoMounter();
   InitializeTimeZoneSettingObserver();
   rv = InitNetd(cx);
   NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr<nsIAudioManager> audioManager =
     do_GetService(NS_AUDIOMANAGER_CONTRACTID);
+#endif
 
   nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
   if (!obs) {
     NS_WARNING("Failed to get observer service!");
     return NS_ERROR_FAILURE;
   }
 
   rv = obs->AddObserver(this, WORKERS_SHUTDOWN_TOPIC, false);
@@ -264,24 +371,31 @@ SystemWorkerManager::Init()
 
 void
 SystemWorkerManager::Shutdown()
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   mShutdown = true;
 
+#ifdef MOZ_WIDGET_GONK
   ShutdownAutoMounter();
-
-#ifdef MOZ_B2G_RIL
-  RilConsumer::Shutdown();
 #endif
 
+  for (unsigned long i = 0; i < mRilConsumers.Length(); i++) {
+    if (mRilConsumers[i]) {
+      mRilConsumers[i]->Shutdown();
+      mRilConsumers[i] = nullptr;
+    }
+  }
+
+#ifdef MOZ_WIDGET_GONK
   StopNetd();
   mNetdWorker = nullptr;
+#endif
 
   nsCOMPtr<nsIWifi> wifi(do_QueryInterface(mWifiWorker));
   if (wifi) {
     wifi->Shutdown();
     wifi = nullptr;
   }
   mWifiWorker = nullptr;
 
@@ -314,58 +428,86 @@ SystemWorkerManager::FactoryCreate()
 
 // static
 nsIInterfaceRequestor*
 SystemWorkerManager::GetInterfaceRequestor()
 {
   return gInstance;
 }
 
+bool
+SystemWorkerManager::SendRilRawData(unsigned long aClientId,
+                                    UnixSocketRawData* aRaw)
+{
+  if ((gInstance->mRilConsumers.Length() <= aClientId) ||
+      !gInstance->mRilConsumers[aClientId] ||
+      gInstance->mRilConsumers[aClientId]->GetConnectionStatus() != SOCKET_CONNECTED) {
+    // Probably shuting down.
+    delete aRaw;
+    return true;
+  }
+  return gInstance->mRilConsumers[aClientId]->SendSocketData(aRaw);
+}
+
 NS_IMETHODIMP
 SystemWorkerManager::GetInterface(const nsIID &aIID, void **aResult)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   if (aIID.Equals(NS_GET_IID(nsIWifi))) {
     return CallQueryInterface(mWifiWorker,
                               reinterpret_cast<nsIWifi**>(aResult));
   }
 
+#ifdef MOZ_WIDGET_GONK
   if (aIID.Equals(NS_GET_IID(nsINetworkManager))) {
     return CallQueryInterface(mNetdWorker,
                               reinterpret_cast<nsINetworkManager**>(aResult));
   }
+#endif
 
   NS_WARNING("Got nothing for the requested IID!");
   return NS_ERROR_NO_INTERFACE;
 }
 
 nsresult
 SystemWorkerManager::RegisterRilWorker(unsigned int aClientId,
                                        const JS::Value& aWorker,
                                        JSContext *aCx)
 {
-#ifndef MOZ_B2G_RIL
-  return NS_ERROR_NOT_IMPLEMENTED;
-#else
   NS_ENSURE_TRUE(!JSVAL_IS_PRIMITIVE(aWorker), NS_ERROR_UNEXPECTED);
 
+  mRilConsumers.EnsureLengthAtLeast(aClientId + 1);
+
+  if (mRilConsumers[aClientId]) {
+    NS_WARNING("RilConsumer already registered");
+    return NS_ERROR_FAILURE;
+  }
+
   JSAutoCompartment ac(aCx, JSVAL_TO_OBJECT(aWorker));
 
   WorkerCrossThreadDispatcher *wctd =
     GetWorkerCrossThreadDispatcher(aCx, aWorker);
   if (!wctd) {
     NS_WARNING("Failed to GetWorkerCrossThreadDispatcher for ril");
     return NS_ERROR_FAILURE;
   }
 
-  return RilConsumer::Register(aClientId, wctd);
-#endif // MOZ_B2G_RIL
+  nsRefPtr<ConnectWorkerToRIL> connection = new ConnectWorkerToRIL();
+  if (!wctd->PostTask(connection)) {
+    NS_WARNING("Failed to connect worker to ril");
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  // Now that we're set up, connect ourselves to the RIL thread.
+  mRilConsumers[aClientId] = new RilConsumer(aClientId, wctd);
+  return NS_OK;
 }
 
+#ifdef MOZ_WIDGET_GONK
 nsresult
 SystemWorkerManager::InitNetd(JSContext *cx)
 {
   nsCOMPtr<nsIWorkerHolder> worker = do_GetService(kNetworkManagerCID);
   NS_ENSURE_TRUE(worker, NS_ERROR_FAILURE);
 
   JS::Value workerval;
   nsresult rv = worker->GetWorker(&workerval);
@@ -388,16 +530,17 @@ SystemWorkerManager::InitNetd(JSContext 
   }
 
   // Now that we're set up, connect ourselves to the Netd process.
   mozilla::RefPtr<NetdReceiver> receiver = new NetdReceiver(wctd);
   StartNetd(receiver);
   mNetdWorker = worker;
   return NS_OK;
 }
+#endif
 
 nsresult
 SystemWorkerManager::InitWifi(JSContext *cx)
 {
   nsCOMPtr<nsIWorkerHolder> worker = do_CreateInstance(kWifiWorkerCID);
   NS_ENSURE_TRUE(worker, NS_ERROR_FAILURE);
 
   mWifiWorker = worker;
--- a/dom/system/gonk/SystemWorkerManager.h
+++ b/dom/system/gonk/SystemWorkerManager.h
@@ -18,23 +18,28 @@
 #ifndef mozilla_dom_system_b2g_systemworkermanager_h__
 #define mozilla_dom_system_b2g_systemworkermanager_h__
 
 #include "nsIInterfaceRequestor.h"
 #include "nsISystemWorkerManager.h"
 #include "nsIObserver.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
-#include "nsXULAppAPI.h" // For XRE_GetProcessType
+#include "nsDebug.h"
+#include "nsDOMEventTargetHelper.h"
+#include "nsString.h"
+#include "nsTArray.h"
 
 class nsIWorkerHolder;
 
 namespace mozilla {
 
 namespace ipc {
+  class RilConsumer;
+  class UnixSocketRawData;
   class KeyStore;
 }
 
 namespace dom {
 namespace gonk {
 
 class SystemWorkerManager : public nsIObserver,
                             public nsIInterfaceRequestor,
@@ -50,27 +55,35 @@ public:
   void Shutdown();
 
   static already_AddRefed<SystemWorkerManager>
   FactoryCreate();
 
   static nsIInterfaceRequestor*
   GetInterfaceRequestor();
 
+  static bool SendRilRawData(unsigned long aClientId,
+                             ipc::UnixSocketRawData* aRaw);
+
 private:
   SystemWorkerManager();
   ~SystemWorkerManager();
 
+#ifdef MOZ_WIDGET_GONK
   nsresult InitNetd(JSContext *cx);
+#endif
   nsresult InitWifi(JSContext *cx);
   nsresult InitKeyStore(JSContext *cx);
 
+#ifdef MOZ_WIDGET_GONK
   nsCOMPtr<nsIWorkerHolder> mNetdWorker;
+#endif
   nsCOMPtr<nsIWorkerHolder> mWifiWorker;
 
+  nsTArray<nsRefPtr<ipc::RilConsumer> > mRilConsumers;
   nsRefPtr<ipc::KeyStore> mKeyStore;
 
   bool mShutdown;
 };
 
 }
 }
 }
--- a/dom/system/gonk/moz.build
+++ b/dom/system/gonk/moz.build
@@ -13,82 +13,77 @@
 # 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.
 
 XPIDL_SOURCES += [
     'nsIAudioManager.idl',
     'nsINetworkInterfaceListService.idl',
     'nsINetworkManager.idl',
+    'nsIRadioInterfaceLayer.idl',
     'nsISystemWorkerManager.idl',
     'nsIVolume.idl',
     'nsIVolumeMountLock.idl',
     'nsIVolumeService.idl',
     'nsIVolumeStat.idl',
     'nsIWorkerHolder.idl',
 ]
 
 XPIDL_MODULE = 'dom_system_gonk'
 
 MODULE = 'dom'
 
-EXPORTS += [
-    'GonkGPSGeolocationProvider.h',
-    'nsVolume.h',
-    'nsVolumeService.h',
-]
-SOURCES += [
-    'AudioChannelManager.cpp',
-    'AudioManager.cpp',
-    'AutoMounter.cpp',
-    'AutoMounterSetting.cpp',
-    'GonkGPSGeolocationProvider.cpp',
-    'nsVolume.cpp',
-    'nsVolumeMountLock.cpp',
-    'nsVolumeService.cpp',
-    'nsVolumeStat.cpp',
-    'OpenFileFinder.cpp',
-    'SystemWorkerManager.cpp',
-    'TimeZoneSettingObserver.cpp',
-    'Volume.cpp',
-    'VolumeCommand.cpp',
-    'VolumeManager.cpp',
-    'VolumeServiceIOThread.cpp',
-    'VolumeServiceTest.cpp',
-]
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
+    EXPORTS += [
+        'GonkGPSGeolocationProvider.h',
+        'nsVolume.h',
+        'nsVolumeService.h',
+    ]
+    SOURCES += [
+        'AudioChannelManager.cpp',
+        'AudioManager.cpp',
+        'AutoMounter.cpp',
+        'AutoMounterSetting.cpp',
+        'GonkGPSGeolocationProvider.cpp',
+        'nsVolume.cpp',
+        'nsVolumeMountLock.cpp',
+        'nsVolumeService.cpp',
+        'nsVolumeStat.cpp',
+        'OpenFileFinder.cpp',
+        'TimeZoneSettingObserver.cpp',
+        'Volume.cpp',
+        'VolumeCommand.cpp',
+        'VolumeManager.cpp',
+        'VolumeServiceIOThread.cpp',
+        'VolumeServiceTest.cpp',
+    ]
 
 if CONFIG['ENABLE_TESTS']:
     XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell.ini']
 
+SOURCES += [
+    'SystemWorkerManager.cpp',
+]
+
 EXTRA_COMPONENTS += [
     'NetworkInterfaceListService.js',
     'NetworkInterfaceListService.manifest',
+    'NetworkManager.js',
     'NetworkManager.manifest',
-]
-EXTRA_PP_COMPONENTS += [
-    'NetworkManager.js',
-]
-EXTRA_JS_MODULES += [
-    'net_worker.js',
-    'systemlibs.js',
+    'RadioInterfaceLayer.js',
+    'RadioInterfaceLayer.manifest',
+    'RILContentHelper.js',
 ]
 
-if CONFIG['MOZ_B2G_RIL']:
-    XPIDL_SOURCES += [
-        'nsIRadioInterfaceLayer.idl',
-    ]
-    EXTRA_COMPONENTS += [
-        'RadioInterfaceLayer.js',
-        'RadioInterfaceLayer.manifest',
-        'RILContentHelper.js',
-    ]
-    EXTRA_JS_MODULES += [
-        'ril_consts.js',
-        'ril_worker.js',
-    ]
+EXTRA_JS_MODULES += [
+    'net_worker.js',
+    'ril_consts.js',
+    'ril_worker.js',
+    'systemlibs.js',
+]
 
 FAIL_ON_WARNINGS = True
 
 LIBXUL_LIBRARY = True
 
 LIBRARY_NAME = 'domsystemgonk_s'
 
 include('/ipc/chromium/chromium-config.mozbuild')
--- a/dom/system/moz.build
+++ b/dom/system/moz.build
@@ -9,17 +9,18 @@ toolkit = CONFIG['MOZ_WIDGET_TOOLKIT']
 if toolkit in ('qt', 'gtk2', 'gtk3'):
     DIRS += ['unix']
 elif toolkit == 'windows':
     DIRS += ['windows']
 elif toolkit == 'cocoa':
     DIRS += ['mac']
 elif toolkit == 'android':
     DIRS += ['android']
-elif toolkit == 'gonk':
+
+if CONFIG['MOZ_B2G_RIL']:
     DIRS += ['gonk']
 
 TEST_DIRS += ['tests']
 
 XPIDL_SOURCES += [
     'nsIOSFileConstantsService.idl',
 ]
 
--- a/dom/telephony/TelephonyFactory.cpp
+++ b/dom/telephony/TelephonyFactory.cpp
@@ -1,30 +1,30 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/telephony/TelephonyFactory.h"
-#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
+#ifdef MOZ_WIDGET_GONK
 #include "nsIGonkTelephonyProvider.h"
 #endif
 #include "nsServiceManagerUtils.h"
 #include "nsXULAppAPI.h"
 #include "ipc/TelephonyIPCProvider.h"
 
 USING_TELEPHONY_NAMESPACE
 
 /* static */ already_AddRefed<nsITelephonyProvider>
 TelephonyFactory::CreateTelephonyProvider()
 {
   nsCOMPtr<nsITelephonyProvider> provider;
 
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
     provider = new TelephonyIPCProvider();
-#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
+#ifdef MOZ_WIDGET_GONK
   } else {
     provider = do_CreateInstance(GONK_TELEPHONY_PROVIDER_CONTRACTID);
 #endif
   }
 
   return provider.forget();
 }
--- a/dom/telephony/moz.build
+++ b/dom/telephony/moz.build
@@ -40,17 +40,17 @@ SOURCES += [
 ]
 
 IPDL_SOURCES += [
     'ipc/PTelephony.ipdl',
     'ipc/PTelephonyRequest.ipdl',
     'ipc/TelephonyTypes.ipdlh'
 ]
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']:
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     XPIDL_SOURCES += [
         'nsIGonkTelephonyProvider.idl',
     ]
     EXTRA_COMPONENTS += [
         'gonk/TelephonyProvider.js',
         'gonk/TelephonyProvider.manifest',
     ]
 
--- a/dom/wappush/moz.build
+++ b/dom/wappush/moz.build
@@ -1,9 +1,9 @@
 # vim: set filetype=python:
 # 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/.
 
 PARALLEL_DIRS += ['interfaces', 'src']
 
-if CONFIG['ENABLE_TESTS']:
+if CONFIG['MOZ_B2G_RIL'] and CONFIG['ENABLE_TESTS']:
     XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell.ini']
--- a/dom/wappush/src/moz.build
+++ b/dom/wappush/src/moz.build
@@ -1,14 +1,14 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']:
+if CONFIG['MOZ_B2G_RIL']:
     EXTRA_JS_MODULES = [
         'gonk/CpPduHelper.jsm',
         'gonk/SiPduHelper.jsm',
         'gonk/SlPduHelper.jsm',
         'gonk/WapPushManager.js',
         'gonk/WbxmlPduHelper.jsm'
     ]
--- a/dom/webidl/Navigator.webidl
+++ b/dom/webidl/Navigator.webidl
@@ -250,16 +250,21 @@ callback systemMessageCallback = void (o
 partial interface Navigator {
   [Throws, Pref="dom.sysmsg.enabled"]
   void    mozSetMessageHandler (DOMString type, systemMessageCallback? callback);
   [Throws, Pref="dom.sysmsg.enabled"]
   boolean mozHasPendingMessage (DOMString type);
 };
 
 #ifdef MOZ_B2G_RIL
+partial interface Navigator {
+  [Throws, Func="Navigator::HasTelephonySupport"]
+  readonly attribute Telephony? mozTelephony;
+};
+
 // nsIMozNavigatorMobileConnection
 interface MozMobileConnection;
 partial interface Navigator {
   [Throws, Func="Navigator::HasMobileConnectionSupport"]
   readonly attribute MozMobileConnection mozMobileConnection;
 };
 
 partial interface Navigator {
@@ -275,21 +280,16 @@ partial interface Navigator {
 // nsIMozNavigatorIccManager
 interface MozIccManager;
 partial interface Navigator {
   [Throws, Func="Navigator::HasIccManagerSupport"]
   readonly attribute MozIccManager? mozIccManager;
 };
 #endif // MOZ_B2G_RIL
 
-partial interface Navigator {
-  [Throws, Func="Navigator::HasTelephonySupport"]
-  readonly attribute Telephony? mozTelephony;
-};
-
 #ifdef MOZ_GAMEPAD
 // https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension
 partial interface Navigator {
   [Throws, Pref="dom.gamepad.enabled"]
   sequence<Gamepad?> getGamepads();
 };
 #endif // MOZ_GAMEPAD
 
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -463,16 +463,22 @@ if CONFIG['MOZ_WEBSPEECH']:
         'SpeechSynthesisVoice.webidl',
     ]
 
 if CONFIG['MOZ_GAMEPAD']:
     WEBIDL_FILES += [
         'Gamepad.webidl',
     ]
 
+if CONFIG['MOZ_B2G_RIL']:
+    WEBIDL_FILES += [
+        'MozStkCommandEvent.webidl',
+        'MozVoicemail.webidl',
+    ]
+
 WEBIDL_FILES += [
     'CloseEvent.webidl',
     'CustomEvent.webidl',
     'DeviceOrientationEvent.webidl',
     'DeviceStorageChangeEvent.webidl',
     'DOMTransactionEvent.webidl',
     'ElementReplaceEvent.webidl',
     'HashChangeEvent.webidl',
@@ -505,26 +511,20 @@ if CONFIG['MOZ_B2G_RIL']:
     WEBIDL_FILES += [
         'CFStateChangeEvent.webidl',
         'DataErrorEvent.webidl',
         'IccCardLockError.webidl',
         'MozCellBroadcast.webidl',
         'MozCellBroadcastEvent.webidl',
         'MozEmergencyCbModeEvent.webidl',
         'MozOtaStatusEvent.webidl',
-        'MozStkCommandEvent.webidl',
-        'MozVoicemail.webidl',
         'MozVoicemailEvent.webidl',
-        'USSDReceivedEvent.webidl',
-    ]
-
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
-    WEBIDL_FILES += [
         'MozWifiConnectionInfoEvent.webidl',
         'MozWifiStatusChangeEvent.webidl',
+        'USSDReceivedEvent.webidl',
     ]
 
 if CONFIG['MOZ_WEBSPEECH']:
     WEBIDL_FILES += [
         'SpeechRecognitionError.webidl',
         'SpeechRecognitionEvent.webidl',
     ]
 
--- a/ipc/moz.build
+++ b/ipc/moz.build
@@ -12,15 +12,15 @@ DIRS += [
 ]
 
 if CONFIG['MOZ_B2G_RIL']:
     DIRS += ['ril']
 
 if CONFIG['MOZ_B2G_BT_BLUEZ']:
     DIRS += ['dbus']
 
-if CONFIG['MOZ_B2G_RIL'] or CONFIG['MOZ_B2G_BT'] or CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
-    DIRS += ['unixsocket']
+if CONFIG['MOZ_B2G_RIL'] or CONFIG['MOZ_B2G_BT']:
+    DIRS += ['unixsocket', 'keystore']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
-    DIRS += ['netd', 'keystore']
+    DIRS += ['netd']
 
 TOOL_DIRS += ['app']
--- a/ipc/ril/Ril.cpp
+++ b/ipc/ril/Ril.cpp
@@ -1,168 +1,53 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* vim: set sw=4 ts=8 et ft=cpp: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "mozilla/ipc/Ril.h"
-
 #include <fcntl.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <netdb.h> // For gethostbyname.
 
 #undef LOG
 #if defined(MOZ_WIDGET_GONK)
 #include <android/log.h>
 #define LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "Gonk", args)
 #else
 #define LOG(args...)  printf(args);
 #endif
 
 #include "jsfriendapi.h"
-#include "nsTArray.h"
 #include "nsThreadUtils.h" // For NS_IsMainThread.
+#include "Ril.h"
 
 USING_WORKERS_NAMESPACE
 using namespace mozilla::ipc;
 
 namespace {
 
 const char* RIL_SOCKET_NAME = "/dev/socket/rilproxy";
 
 // Network port to connect to for adb forwarded sockets when doing
 // desktop development.
 const uint32_t RIL_TEST_PORT = 6200;
 
-nsTArray<nsRefPtr<mozilla::ipc::RilConsumer> > sRilConsumers;
-
-class ConnectWorkerToRIL : public WorkerTask
+class DispatchRILEvent : public WorkerTask
 {
 public:
-    ConnectWorkerToRIL()
+    DispatchRILEvent(UnixSocketRawData* aMessage)
+      : mMessage(aMessage)
     { }
 
     virtual bool RunTask(JSContext *aCx);
-};
-
-class SendRilSocketDataTask : public nsRunnable
-{
-public:
-    SendRilSocketDataTask(unsigned long aClientId,
-                          UnixSocketRawData *aRawData)
-        : mRawData(aRawData)
-        , mClientId(aClientId)
-    { }
-
-    NS_IMETHOD Run()
-    {
-        MOZ_ASSERT(NS_IsMainThread());
-
-        if (sRilConsumers.Length() <= mClientId ||
-            !sRilConsumers[mClientId] ||
-            sRilConsumers[mClientId]->GetConnectionStatus() != SOCKET_CONNECTED) {
-            // Probably shuting down.
-            delete mRawData;
-            return NS_OK;
-        }
-
-        sRilConsumers[mClientId]->SendSocketData(mRawData);
-        return NS_OK;
-    }
 
 private:
-    UnixSocketRawData *mRawData;
-    unsigned long mClientId;
-};
-
-bool
-PostToRIL(JSContext *aCx,
-          unsigned aArgc,
-          JS::Value *aArgv)
-{
-    NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread");
-
-    if (aArgc != 2) {
-        JS_ReportError(aCx, "Expecting two arguments with the RIL message");
-        return false;
-    }
-
-    JS::Value cv = JS_ARGV(aCx, aArgv)[0];
-    int clientId = cv.toInt32();
-
-    JS::Value v = JS_ARGV(aCx, aArgv)[1];
-
-    JSAutoByteString abs;
-    void *data;
-    size_t size;
-    if (JSVAL_IS_STRING(v)) {
-        JSString *str = JSVAL_TO_STRING(v);
-        if (!abs.encodeUtf8(aCx, str)) {
-            return false;
-        }
-
-        data = abs.ptr();
-        size = abs.length();
-    } else if (!JSVAL_IS_PRIMITIVE(v)) {
-        JSObject *obj = JSVAL_TO_OBJECT(v);
-        if (!JS_IsTypedArrayObject(obj)) {
-            JS_ReportError(aCx, "Object passed in wasn't a typed array");
-            return false;
-        }
-
-        uint32_t type = JS_GetArrayBufferViewType(obj);
-        if (type != js::ArrayBufferView::TYPE_INT8 &&
-            type != js::ArrayBufferView::TYPE_UINT8 &&
-            type != js::ArrayBufferView::TYPE_UINT8_CLAMPED) {
-            JS_ReportError(aCx, "Typed array data is not octets");
-            return false;
-        }
-
-        size = JS_GetTypedArrayByteLength(obj);
-        data = JS_GetArrayBufferViewData(obj);
-    } else {
-        JS_ReportError(aCx,
-                       "Incorrect argument. Expecting a string or a typed array");
-        return false;
-    }
-
-    UnixSocketRawData* raw = new UnixSocketRawData(data, size);
-
-    nsRefPtr<SendRilSocketDataTask> task =
-        new SendRilSocketDataTask(clientId, raw);
-    NS_DispatchToMainThread(task);
-    return true;
-}
-
-bool
-ConnectWorkerToRIL::RunTask(JSContext *aCx)
-{
-    // Set up the postRILMessage on the function for worker -> RIL thread
-    // communication.
-    NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread");
-    NS_ASSERTION(!JS_IsRunning(aCx), "Are we being called somehow?");
-    JSObject *workerGlobal = JS::CurrentGlobalOrNull(aCx);
-
-    return !!JS_DefineFunction(aCx, workerGlobal,
-                               "postRILMessage", PostToRIL, 1, 0);
-}
-
-class DispatchRILEvent : public WorkerTask
-{
-public:
-        DispatchRILEvent(UnixSocketRawData* aMessage)
-            : mMessage(aMessage)
-        { }
-
-        virtual bool RunTask(JSContext *aCx);
-
-private:
-        nsAutoPtr<UnixSocketRawData> mMessage;
+    nsAutoPtr<UnixSocketRawData> mMessage;
 };
 
 bool
 DispatchRILEvent::RunTask(JSContext *aCx)
 {
     JSObject *obj = JS::CurrentGlobalOrNull(aCx);
 
     JSObject *array = JS_NewUint8Array(aCx, mMessage->mSize);
@@ -302,83 +187,49 @@ RilConsumer::RilConsumer(unsigned long a
         snprintf(addr_un.sun_path, sizeof addr_un.sun_path, "%s%lu",
                  RIL_SOCKET_NAME, aClientId);
         mAddress = addr_un.sun_path;
     }
 
     ConnectSocket(new RilConnector(mClientId), mAddress.get());
 }
 
-nsresult
-RilConsumer::Register(unsigned int aClientId,
-                      WorkerCrossThreadDispatcher* aDispatcher)
-{
-    MOZ_ASSERT(NS_IsMainThread());
-
-    sRilConsumers.EnsureLengthAtLeast(aClientId + 1);
-
-    if (sRilConsumers[aClientId]) {
-        NS_WARNING("RilConsumer already registered");
-        return NS_ERROR_FAILURE;
-    }
-
-    nsRefPtr<ConnectWorkerToRIL> connection = new ConnectWorkerToRIL();
-    if (!aDispatcher->PostTask(connection)) {
-        NS_WARNING("Failed to connect worker to ril");
-        return NS_ERROR_UNEXPECTED;
-    }
-
-    // Now that we're set up, connect ourselves to the RIL thread.
-    sRilConsumers[aClientId] = new RilConsumer(aClientId, aDispatcher);
-    return NS_OK;
-}
-
 void
 RilConsumer::Shutdown()
 {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    for (unsigned long i = 0; i < sRilConsumers.Length(); i++) {
-        nsRefPtr<RilConsumer>& instance = sRilConsumers[i];
-        if (!instance) {
-            continue;
-        }
-
-        instance->mShutdown = true;
-        instance->CloseSocket();
-        instance = nullptr;
-    }
+    mShutdown = true;
+    CloseSocket();
 }
 
 void
 RilConsumer::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
 {
     MOZ_ASSERT(NS_IsMainThread());
 
     nsRefPtr<DispatchRILEvent> dre(new DispatchRILEvent(aMessage.forget()));
     mDispatcher->PostTask(dre);
 }
 
 void
 RilConsumer::OnConnectSuccess()
 {
     // Nothing to do here.
-    LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
+    LOG("RIL[%u]: %s\n", mClientId, __FUNCTION__);
 }
 
 void
 RilConsumer::OnConnectError()
 {
-    LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
+    LOG("RIL[%u]: %s\n", mClientId, __FUNCTION__);
     CloseSocket();
 }
 
 void
 RilConsumer::OnDisconnect()
 {
-    LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
+    LOG("RIL[%u]: %s\n", mClientId, __FUNCTION__);
     if (!mShutdown) {
         ConnectSocket(new RilConnector(mClientId), mAddress.get(), 1000);
     }
 }
 
 } // namespace ipc
 } // namespace mozilla
--- a/ipc/ril/Ril.h
+++ b/ipc/ril/Ril.h
@@ -11,26 +11,23 @@
 #include <mozilla/ipc/UnixSocket.h>
 
 namespace mozilla {
 namespace ipc {
 
 class RilConsumer : public mozilla::ipc::UnixSocketConsumer
 {
 public:
+  RilConsumer(unsigned long aClientId,
+              mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher);
   virtual ~RilConsumer() { }
 
-  static nsresult Register(unsigned int aClientId,
-                           mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher);
-  static void Shutdown();
+  void Shutdown();
 
 private:
-  RilConsumer(unsigned long aClientId,
-              mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher);
-
   virtual void ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage);
 
   virtual void OnConnectSuccess();
   virtual void OnConnectError();
   virtual void OnDisconnect();
 
 private:
   nsRefPtr<mozilla::dom::workers::WorkerCrossThreadDispatcher> mDispatcher;
--- a/js/xpconnect/src/event_impl_gen.conf.in
+++ b/js/xpconnect/src/event_impl_gen.conf.in
@@ -18,29 +18,27 @@ simple_events = [
     'HashChangeEvent',
     'CloseEvent',
     'DeviceOrientationEvent',
     'MozApplicationEvent',
     'SmartCardEvent',
     'StyleRuleChangeEvent',
     'StyleSheetChangeEvent',
     'StyleSheetApplicableStateChangeEvent',
-#ifdef MOZ_WIDGET_GONK
-    'MozWifiStatusChangeEvent',
-    'MozWifiConnectionInfoEvent',
-#endif
 #ifdef MOZ_B2G_BT
     'BluetoothDeviceEvent',
     'BluetoothStatusChangedEvent',
 #endif
 #ifdef MOZ_B2G_RIL
     'CFStateChangeEvent',
     'DataErrorEvent',
     'MozEmergencyCbModeEvent',
     'MozOtaStatusEvent',
+    'MozWifiStatusChangeEvent',
+    'MozWifiConnectionInfoEvent',
     'MozCellBroadcastEvent',
     'MozVoicemailEvent',
     'USSDReceivedEvent',
 #endif
     'ElementReplaceEvent',
     'MozSmsEvent',
     'MozMmsEvent',
 #ifdef MOZ_WEBSPEECH
--- a/layout/build/Makefile.in
+++ b/layout/build/Makefile.in
@@ -122,24 +122,19 @@ SHARED_LIBRARY_LIBS	+= \
 endif #}
 
 ifdef MOZ_B2G_BT #{
 SHARED_LIBRARY_LIBS += $(DEPTH)/dom/bluetooth/$(LIB_PREFIX)dombluetooth_s.$(LIB_SUFFIX)
 endif #}
 
 SHARED_LIBRARY_LIBS	+= $(DEPTH)/dom/camera/$(LIB_PREFIX)domcamera_s.$(LIB_SUFFIX)
 
-ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
+ifdef MOZ_B2G_RIL #{
 SHARED_LIBRARY_LIBS	+= \
   $(DEPTH)/dom/system/gonk/$(LIB_PREFIX)domsystemgonk_s.$(LIB_SUFFIX) \
-  $(NULL)
-endif #}
-
-ifdef MOZ_B2G_RIL #{
-SHARED_LIBRARY_LIBS	+= \
   $(DEPTH)/dom/icc/src/$(LIB_PREFIX)dom_icc_s.$(LIB_SUFFIX) \
   $(DEPTH)/dom/cellbroadcast/src/$(LIB_PREFIX)dom_cellbroadcast_s.$(LIB_SUFFIX) \
   $(DEPTH)/dom/voicemail/$(LIB_PREFIX)domvoicemail_s.$(LIB_SUFFIX) \
   $(NULL)
 endif #}
 
 ifdef MOZ_OGG
 SHARED_LIBRARY_LIBS 	+= \
@@ -326,17 +321,17 @@ LOCAL_INCLUDES	+= -I$(srcdir)/../base \
 		   -I$(topsrcdir)/extensions/cookie \
 		   -I$(topsrcdir)/netwerk/cookie \
 		   $(NULL)
 
 ifdef MOZ_GSTREAMER
 LOCAL_INCLUDES	+= $(GSTREAMER_CFLAGS)
 endif
 
-ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
+ifdef MOZ_B2G_RIL #{
 LOCAL_INCLUDES	+= -I$(topsrcdir)/dom/system/gonk
 endif #}
 
 ifdef MOZ_B2G_FM #{
 LOCAL_INCLUDES	+= -I$(topsrcdir)/dom/fmradio
 endif #}
 
 ifdef MOZ_B2G_BT #{
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -96,17 +96,17 @@
 #include "mozilla/OSFileConstants.h"
 #include "mozilla/Services.h"
 
 #ifdef MOZ_WEBSPEECH
 #include "mozilla/dom/FakeSpeechRecognitionService.h"
 #include "mozilla/dom/nsSynthVoiceRegistry.h"
 #endif
 
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_RIL
 #include "SystemWorkerManager.h"
 using mozilla::dom::gonk::SystemWorkerManager;
 #define SYSTEMWORKERMANAGER_CID \
   {0xd53b6524, 0x6ac3, 0x42b0, {0xae, 0xca, 0x62, 0xb3, 0xc4, 0xe5, 0x2b, 0x04}}
 #define SYSTEMWORKERMANAGER_CONTRACTID \
   "@mozilla.org/telephony/system-worker-manager;1"
 #endif
 
@@ -283,17 +283,17 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(DOMSessio
 NS_GENERIC_FACTORY_CONSTRUCTOR(DOMLocalStorageManager)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsChannelPolicy)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(IndexedDatabaseManager,
                                          IndexedDatabaseManager::FactoryCreate)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(DOMRequestService,
                                          DOMRequestService::FactoryCreate)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(QuotaManager,
                                          QuotaManager::FactoryCreate)
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_RIL
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(SystemWorkerManager,
                                          SystemWorkerManager::FactoryCreate)
 #endif
 #ifdef MOZ_B2G_BT
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(BluetoothService,
                                          BluetoothService::FactoryCreate)
 #endif
 
@@ -749,17 +749,17 @@ NS_DEFINE_NAMED_CID(NS_DOMACTIVITY_CID);
 NS_DEFINE_NAMED_CID(NS_DOMPARSER_CID);
 NS_DEFINE_NAMED_CID(NS_DOMSESSIONSTORAGEMANAGER_CID);
 NS_DEFINE_NAMED_CID(NS_DOMLOCALSTORAGEMANAGER_CID);
 NS_DEFINE_NAMED_CID(NS_DOMJSON_CID);
 NS_DEFINE_NAMED_CID(NS_TEXTEDITOR_CID);
 NS_DEFINE_NAMED_CID(INDEXEDDB_MANAGER_CID);
 NS_DEFINE_NAMED_CID(DOMREQUEST_SERVICE_CID);
 NS_DEFINE_NAMED_CID(QUOTA_MANAGER_CID);
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_RIL
 NS_DEFINE_NAMED_CID(SYSTEMWORKERMANAGER_CID);
 #endif
 #ifdef MOZ_B2G_BT
 NS_DEFINE_NAMED_CID(BLUETOOTHSERVICE_CID);
 #endif
 #ifdef MOZ_WIDGET_GONK
 NS_DEFINE_NAMED_CID(NS_AUDIOMANAGER_CID);
 NS_DEFINE_NAMED_CID(NS_VOLUMESERVICE_CID);
@@ -1038,17 +1038,17 @@ static const mozilla::Module::CIDEntry k
   { &kNS_XPCEXCEPTION_CID, false, nullptr, ExceptionConstructor },
   { &kNS_DOMSESSIONSTORAGEMANAGER_CID, false, nullptr, DOMSessionStorageManagerConstructor },
   { &kNS_DOMLOCALSTORAGEMANAGER_CID, false, nullptr, DOMLocalStorageManagerConstructor },
   { &kNS_DOMJSON_CID, false, nullptr, NS_NewJSON },
   { &kNS_TEXTEDITOR_CID, false, nullptr, nsPlaintextEditorConstructor },
   { &kINDEXEDDB_MANAGER_CID, false, nullptr, IndexedDatabaseManagerConstructor },
   { &kDOMREQUEST_SERVICE_CID, false, nullptr, DOMRequestServiceConstructor },
   { &kQUOTA_MANAGER_CID, false, nullptr, QuotaManagerConstructor },
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_RIL
   { &kSYSTEMWORKERMANAGER_CID, true, nullptr, SystemWorkerManagerConstructor },
 #endif
 #ifdef MOZ_B2G_BT
   { &kBLUETOOTHSERVICE_CID, true, nullptr, BluetoothServiceConstructor },
 #endif
 #ifdef MOZ_WIDGET_GONK
   { &kNS_AUDIOMANAGER_CID, true, nullptr, AudioManagerConstructor },
   { &kNS_VOLUMESERVICE_CID, true, nullptr, nsVolumeServiceConstructor },
@@ -1196,17 +1196,17 @@ static const mozilla::Module::ContractID
   // Keeping the old ContractID for backward compatibility
   { "@mozilla.org/dom/storagemanager;1", &kNS_DOMLOCALSTORAGEMANAGER_CID },
   { "@mozilla.org/dom/sessionStorage-manager;1", &kNS_DOMSESSIONSTORAGEMANAGER_CID },
   { "@mozilla.org/dom/json;1", &kNS_DOMJSON_CID },
   { "@mozilla.org/editor/texteditor;1", &kNS_TEXTEDITOR_CID },
   { INDEXEDDB_MANAGER_CONTRACTID, &kINDEXEDDB_MANAGER_CID },
   { DOMREQUEST_SERVICE_CONTRACTID, &kDOMREQUEST_SERVICE_CID },
   { QUOTA_MANAGER_CONTRACTID, &kQUOTA_MANAGER_CID },
-#ifdef MOZ_WIDGET_GONK
+#ifdef MOZ_B2G_RIL
   { SYSTEMWORKERMANAGER_CONTRACTID, &kSYSTEMWORKERMANAGER_CID },
 #endif
 #ifdef MOZ_B2G_BT
   { BLUETOOTHSERVICE_CONTRACTID, &kBLUETOOTHSERVICE_CID },
 #endif
 #ifdef MOZ_WIDGET_GONK
   { NS_AUDIOMANAGER_CONTRACTID, &kNS_AUDIOMANAGER_CID },
   { NS_VOLUMESERVICE_CONTRACTID, &kNS_VOLUMESERVICE_CID },
@@ -1281,18 +1281,18 @@ static const mozilla::Module::CategoryEn
   { "net-channel-event-sinks", "CSPService", CSPSERVICE_CONTRACTID },
   { JAVASCRIPT_GLOBAL_STATIC_NAMESET_CATEGORY, "PrivilegeManager", NS_SECURITYNAMESET_CONTRACTID },
   { "app-startup", "Script Security Manager", "service," NS_SCRIPTSECURITYMANAGER_CONTRACTID },
   { TOPIC_WEB_APP_CLEAR_DATA, "QuotaManager", "service," QUOTA_MANAGER_CONTRACTID },
 #ifdef MOZ_WIDGET_GONK
   { "app-startup", "Volume Service", "service," NS_VOLUMESERVICE_CONTRACTID },
 #endif
   CONTENTDLF_CATEGORIES
-#ifdef MOZ_WIDGET_GONK
-  { "profile-after-change", "Gonk System Worker Manager", SYSTEMWORKERMANAGER_CONTRACTID },
+#ifdef MOZ_B2G_RIL
+  { "profile-after-change", "Telephony System Worker Manager", SYSTEMWORKERMANAGER_CONTRACTID },
 #endif
 #ifdef MOZ_B2G_BT
   { "profile-after-change", "Bluetooth Service", BLUETOOTHSERVICE_CONTRACTID },
 #endif
   { nullptr }
 };
 
 static void
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -4507,52 +4507,32 @@ pref("dom.forms.inputmode", true);
 
 // InputMethods for soft keyboards in B2G
 pref("dom.mozInputMethod.enabled", false);
 
 // DataStore is disabled by default
 pref("dom.datastore.enabled", false);
 
 // Telephony API
-#ifdef MOZ_B2G_RIL
-pref("dom.telephony.enabled", true);
-#else
 pref("dom.telephony.enabled", false);
-#endif
 // Numeric default service id for WebTelephony API calls with |serviceId|
 // parameter omitted.
 pref("dom.telephony.defaultServiceId", 0);
 
 // Cell Broadcast API
-#ifdef MOZ_B2G_RIL
-pref("dom.cellbroadcast.enabled", true);
-#else
 pref("dom.cellbroadcast.enabled", false);
-#endif
 
 // ICC API
-#ifdef MOZ_B2G_RIL
-pref("dom.icc.enabled", true);
-#else
 pref("dom.icc.enabled", false);
-#endif
 
 // Mobile Connection API
-#ifdef MOZ_B2G_RIL
-pref("dom.mobileconnection.enabled", true);
-#else
 pref("dom.mobileconnection.enabled", false);
-#endif
 
 // Voice Mail API
-#ifdef MOZ_B2G_RIL
-pref("dom.voicemail.enabled", true);
-#else
 pref("dom.voicemail.enabled", false);
-#endif
 // Numeric default service id for Voice Mail API calls with |serviceId|
 // parameter omitted.
 pref("dom.voicemail.defaultServiceId", 0);
 
 // DOM Inter-App Communication API.
 pref("dom.inter-app-communication-api.enabled", false);
 
 // The tables used for Safebrowsing phishing and malware checks.
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/Makefile.in
@@ -91,22 +91,22 @@ endif #}
 
 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)$(filter gonk,$(MOZ_WIDGET_TOOLKIT))),) #{
-STATIC_LIBS += mozipcunixsocket_s
+ifneq ($(strip $(MOZ_B2G_RIL)$(MOZ_B2G_BT)),) #{
+STATIC_LIBS += mozipcunixsocket_s mozkeystore_s
 endif #}
 
 ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
-STATIC_LIBS += moznetd_s mozkeystore_s
+STATIC_LIBS += moznetd_s
 endif
 
 ifdef MOZ_B2G_CAMERA #{
 OS_LIBS += -lstagefright -lstagefright_omx
 endif #}
 
 ifdef MOZ_IPDL_TESTS
 STATIC_LIBS += ipdlunittest_s