Bug 1306779 - Remove DOM/fmradio and related code. r?jst draft
authorMichelangelo De Simone <mdesimone@mozilla.com>
Mon, 03 Oct 2016 16:22:41 -0700
changeset 423318 6014644800533b97765d6dd4ca539f108c5972bb
parent 423199 7be6b348c431d69f96f0765af3a0c0a0fe56d4bf
child 533427 713d139183e273378c13fbe0ea0ec549c02f3885
push id31873
push usermdesimone@mozilla.com
push dateMon, 10 Oct 2016 21:26:16 +0000
reviewersjst
bugs1306779
milestone52.0a1
Bug 1306779 - Remove DOM/fmradio and related code. r?jst MozReview-Commit-ID: EAoALauFEco
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/base/moz.build
dom/base/nsDOMClassInfo.cpp
dom/fmradio/FMRadio.cpp
dom/fmradio/FMRadio.h
dom/fmradio/FMRadioCommon.h
dom/fmradio/FMRadioService.cpp
dom/fmradio/FMRadioService.h
dom/fmradio/ipc/FMRadioChild.cpp
dom/fmradio/ipc/FMRadioChild.h
dom/fmradio/ipc/FMRadioParent.cpp
dom/fmradio/ipc/FMRadioParent.h
dom/fmradio/ipc/FMRadioRequestChild.cpp
dom/fmradio/ipc/FMRadioRequestChild.h
dom/fmradio/ipc/FMRadioRequestParent.cpp
dom/fmradio/ipc/FMRadioRequestParent.h
dom/fmradio/ipc/PFMRadio.ipdl
dom/fmradio/ipc/PFMRadioRequest.ipdl
dom/fmradio/ipc/moz.build
dom/fmradio/moz.build
dom/fmradio/test/marionette/manifest.ini
dom/fmradio/test/marionette/test_bug862672.js
dom/fmradio/test/marionette/test_bug876597.js
dom/fmradio/test/marionette/test_cancel_seek.js
dom/fmradio/test/marionette/test_enable_disable.js
dom/fmradio/test/marionette/test_one_seek_at_once.js
dom/fmradio/test/marionette/test_seek_up_and_down.js
dom/fmradio/test/marionette/test_set_frequency.js
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
dom/ipc/moz.build
dom/moz.build
dom/permission/moz.build
dom/permission/tests/mochitest-fm.ini
dom/permission/tests/test_fmradio.html
dom/webidl/FMRadio.webidl
dom/webidl/Navigator.webidl
dom/webidl/moz.build
layout/build/moz.build
old-configure.in
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -86,20 +86,16 @@
 #include "BluetoothManager.h"
 #endif
 #include "DOMCameraManager.h"
 
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
 #include "AudioChannelManager.h"
 #endif
 
-#ifdef MOZ_B2G_FM
-#include "mozilla/dom/FMRadio.h"
-#endif
-
 #include "nsIDOMGlobalPropertyInitializer.h"
 #include "nsJSUtils.h"
 
 #include "nsScriptNameSpaceManager.h"
 
 #include "mozilla/dom/NavigatorBinding.h"
 #include "mozilla/dom/Promise.h"
 
@@ -287,23 +283,16 @@ Navigator::Invalidate()
 
   if (mBatteryManager) {
     mBatteryManager->Shutdown();
     mBatteryManager = nullptr;
   }
 
   mBatteryPromise = nullptr;
 
-#ifdef MOZ_B2G_FM
-  if (mFMRadio) {
-    mFMRadio->Shutdown();
-    mFMRadio = nullptr;
-  }
-#endif
-
   if (mPowerManager) {
     mPowerManager->Shutdown();
     mPowerManager = nullptr;
   }
 
   if (mIccManager) {
     mIccManager->Shutdown();
     mIccManager = nullptr;
@@ -1541,40 +1530,16 @@ Navigator::GetMozNotification(ErrorResul
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   mNotification = new DesktopNotificationCenter(mWindow);
   return mNotification;
 }
 
-#ifdef MOZ_B2G_FM
-
-using mozilla::dom::FMRadio;
-
-FMRadio*
-Navigator::GetMozFMRadio(ErrorResult& aRv)
-{
-  if (!mFMRadio) {
-    if (!mWindow) {
-      aRv.Throw(NS_ERROR_UNEXPECTED);
-      return nullptr;
-    }
-
-    NS_ENSURE_TRUE(mWindow->GetDocShell(), nullptr);
-
-    mFMRadio = new FMRadio();
-    mFMRadio->Init(mWindow);
-  }
-
-  return mFMRadio;
-}
-
-#endif  // MOZ_B2G_FM
-
 //*****************************************************************************
 //    Navigator::nsINavigatorBattery
 //*****************************************************************************
 
 Promise*
 Navigator::GetBattery(ErrorResult& aRv)
 {
   if (mBatteryPromise) {
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -52,20 +52,16 @@ namespace mozilla {
 namespace dom {
 
 class Permissions;
 
 namespace battery {
 class BatteryManager;
 } // namespace battery
 
-#ifdef MOZ_B2G_FM
-class FMRadio;
-#endif
-
 class Promise;
 
 class DesktopNotificationCenter;
 class MobileMessageManager;
 class MozIdleObserver;
 #ifdef MOZ_GAMEPAD
 class Gamepad;
 class GamepadServiceTest;
@@ -243,19 +239,16 @@ public:
   MobileConnectionArray* GetMozMobileConnections(ErrorResult& aRv);
 #endif // MOZ_B2G_RIL
 #ifdef MOZ_GAMEPAD
   void GetGamepads(nsTArray<RefPtr<Gamepad> >& aGamepads, ErrorResult& aRv);
   GamepadServiceTest* RequestGamepadServiceTest();
 #endif // MOZ_GAMEPAD
   already_AddRefed<Promise> GetVRDisplays(ErrorResult& aRv);
   void GetActiveVRDisplays(nsTArray<RefPtr<VRDisplay>>& aDisplays) const;
-#ifdef MOZ_B2G_FM
-  FMRadio* GetMozFMRadio(ErrorResult& aRv);
-#endif
 #ifdef MOZ_B2G_BT
   bluetooth::BluetoothManager* GetMozBluetooth(ErrorResult& aRv);
 #endif // MOZ_B2G_BT
 #ifdef MOZ_TIME_MANAGER
   time::TimeManager* GetMozTime(ErrorResult& aRv);
 #endif // MOZ_TIME_MANAGER
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
   system::AudioChannelManager* GetMozAudioChannelManager(ErrorResult& aRv);
@@ -335,19 +328,16 @@ private:
 
   RefPtr<nsMimeTypeArray> mMimeTypes;
   RefPtr<nsPluginArray> mPlugins;
   RefPtr<Permissions> mPermissions;
   RefPtr<Geolocation> mGeolocation;
   RefPtr<DesktopNotificationCenter> mNotification;
   RefPtr<battery::BatteryManager> mBatteryManager;
   RefPtr<Promise> mBatteryPromise;
-#ifdef MOZ_B2G_FM
-  RefPtr<FMRadio> mFMRadio;
-#endif
   RefPtr<PowerManager> mPowerManager;
   RefPtr<IccManager> mIccManager;
   RefPtr<MobileMessageManager> mMobileMessageManager;
   RefPtr<Telephony> mTelephony;
   RefPtr<Voicemail> mVoicemail;
   RefPtr<TVManager> mTVManager;
   RefPtr<InputPortManager> mInputPortManager;
   RefPtr<network::Connection> mConnection;
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -432,30 +432,29 @@ LOCAL_INCLUDES += [
     '/netwerk/base',
     '/security/manager/ssl',
     '/widget',
     '/xpcom/ds',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     LOCAL_INCLUDES += [
-        '../fmradio',
         '../system/gonk',
     ]
 
 if CONFIG['MOZ_WEBRTC']:
     LOCAL_INCLUDES += [
         '/netwerk/sctp/datachannel',
     ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
-for var in ('MOZ_B2G_RIL', 'MOZ_B2G_FM'):
+for var in ('MOZ_B2G_RIL'):
     if CONFIG[var]:
         DEFINES[var] = True
 
 if CONFIG['MOZ_BUILD_APP'] in ['browser', 'mobile/android', 'xulrunner']:
     DEFINES['HAVE_SIDEBAR'] = True
 
 if CONFIG['MOZ_X11']:
     CXXFLAGS += CONFIG['TK_CFLAGS']
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -95,20 +95,16 @@
 #include "nsIEventListenerService.h"
 #include "nsIMessageManager.h"
 
 #include "mozilla/dom/TouchEvent.h"
 
 #include "nsWrapperCacheInlines.h"
 #include "mozilla/dom/HTMLCollectionBinding.h"
 
-#ifdef MOZ_B2G_FM
-#include "FMRadio.h"
-#endif
-
 #include "nsDebug.h"
 
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/Likely.h"
 #include "nsIInterfaceInfoManager.h"
 
 #ifdef MOZ_TIME_MANAGER
 #include "TimeManager.h"
deleted file mode 100644
--- a/dom/fmradio/FMRadio.cpp
+++ /dev/null
@@ -1,500 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "mozilla/dom/FMRadio.h"
-#include "nsContentUtils.h"
-#include "mozilla/Hal.h"
-#include "mozilla/HalTypes.h"
-#include "mozilla/Preferences.h"
-#include "mozilla/dom/FMRadioBinding.h"
-#include "mozilla/dom/ContentChild.h"
-#include "mozilla/dom/PFMRadioChild.h"
-#include "mozilla/dom/FMRadioService.h"
-#include "mozilla/dom/TypedArray.h"
-#include "AudioChannelService.h"
-#include "DOMRequest.h"
-#include "nsDOMClassInfo.h"
-#include "nsIDocShell.h"
-#include "nsIInterfaceRequestorUtils.h"
-#include "nsIAudioManager.h"
-
-#undef LOG
-#define LOG(args...) FM_LOG("FMRadio", args)
-
-// The pref indicates if the device has an internal antenna.
-// If the pref is true, the antanna will be always available.
-#define DOM_FM_ANTENNA_INTERNAL_PREF "dom.fmradio.antenna.internal"
-
-using mozilla::Preferences;
-
-BEGIN_FMRADIO_NAMESPACE
-
-class FMRadioRequest final : public FMRadioReplyRunnable
-                           , public DOMRequest
-{
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-
-  FMRadioRequest(nsPIDOMWindowInner* aWindow, FMRadio* aFMRadio)
-    : DOMRequest(aWindow)
-    , mType(FMRadioRequestArgs::T__None)
-  {
-    // |FMRadio| inherits from |nsIDOMEventTarget| and |nsISupportsWeakReference|
-    // which both inherits from nsISupports, so |nsISupports| is an ambiguous
-    // base of |FMRadio|, we have to cast |aFMRadio| to one of the base classes.
-    mFMRadio = do_GetWeakReference(static_cast<nsIDOMEventTarget*>(aFMRadio));
-  }
-
-  FMRadioRequest(nsPIDOMWindowInner* aWindow, FMRadio* aFMRadio,
-    FMRadioRequestArgs::Type aType)
-    : DOMRequest(aWindow)
-  {
-    MOZ_ASSERT(aType >= FMRadioRequestArgs::T__None &&
-               aType <= FMRadioRequestArgs::T__Last,
-               "Wrong FMRadioRequestArgs in FMRadioRequest");
-
-    mFMRadio = do_GetWeakReference(static_cast<nsIDOMEventTarget*>(aFMRadio));
-    mType = aType;
-  }
-
-  NS_IMETHOD
-  Run() override
-  {
-    MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-
-    nsCOMPtr<nsIDOMEventTarget> target = do_QueryReferent(mFMRadio);
-    if (!target) {
-      return NS_OK;
-    }
-
-    FMRadio* fmRadio = static_cast<FMRadio*>(
-      static_cast<nsIDOMEventTarget*>(target));
-
-    if (fmRadio->mIsShutdown) {
-      return NS_OK;
-    }
-
-    switch (mResponseType.type()) {
-      case FMRadioResponseType::TErrorResponse:
-        FireError(mResponseType.get_ErrorResponse().error());
-        break;
-      case FMRadioResponseType::TSuccessResponse:
-        if (mType == FMRadioRequestArgs::TEnableRequestArgs) {
-          fmRadio->EnableAudioChannelAgent();
-        }
-
-        FireSuccess(JS::UndefinedHandleValue);
-        break;
-      default:
-        MOZ_CRASH();
-    }
-
-    return NS_OK;
-  }
-
-protected:
-  ~FMRadioRequest() { }
-
-private:
-  FMRadioRequestArgs::Type mType;
-  nsWeakPtr mFMRadio;
-};
-
-NS_IMPL_ISUPPORTS_INHERITED0(FMRadioRequest, DOMRequest)
-
-FMRadio::FMRadio()
-  : mHeadphoneState(hal::SWITCH_STATE_OFF)
-  , mRdsGroupMask(0)
-  , mAudioChannelAgentEnabled(false)
-  , mHasInternalAntenna(false)
-  , mIsShutdown(false)
-{
-  LOG("FMRadio is initialized.");
-}
-
-FMRadio::~FMRadio()
-{
-}
-
-void
-FMRadio::Init(nsPIDOMWindowInner *aWindow)
-{
-  BindToOwner(aWindow);
-
-  IFMRadioService::Singleton()->AddObserver(this);
-
-  mHasInternalAntenna = Preferences::GetBool(DOM_FM_ANTENNA_INTERNAL_PREF,
-                                             /* default = */ false);
-  if (mHasInternalAntenna) {
-    LOG("We have an internal antenna.");
-  } else {
-    mHeadphoneState = hal::GetCurrentSwitchState(hal::SWITCH_HEADPHONES);
-    hal::RegisterSwitchObserver(hal::SWITCH_HEADPHONES, this);
-  }
-
-  nsCOMPtr<nsIAudioChannelAgent> audioChannelAgent =
-    do_CreateInstance("@mozilla.org/audiochannelagent;1");
-  NS_ENSURE_TRUE_VOID(audioChannelAgent);
-
-  audioChannelAgent->InitWithWeakCallback(
-    GetOwner(),
-    nsIAudioChannelAgent::AUDIO_AGENT_CHANNEL_CONTENT,
-    this);
-
-  // Once all necessary resources are got successfully, we just enabled
-  // mAudioChannelAgent.
-  mAudioChannelAgent = audioChannelAgent;
-}
-
-void
-FMRadio::Shutdown()
-{
-  IFMRadioService::Singleton()->RemoveObserver(this);
-
-  if (!mHasInternalAntenna) {
-    hal::UnregisterSwitchObserver(hal::SWITCH_HEADPHONES, this);
-  }
-
-  mIsShutdown = true;
-}
-
-JSObject*
-FMRadio::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
-{
-  return FMRadioBinding::Wrap(aCx, this, aGivenProto);
-}
-
-void
-FMRadio::Notify(const hal::SwitchEvent& aEvent)
-{
-  MOZ_ASSERT(!mHasInternalAntenna);
-
-  if (mHeadphoneState != aEvent.status()) {
-    mHeadphoneState = aEvent.status();
-
-    DispatchTrustedEvent(NS_LITERAL_STRING("antennaavailablechange"));
-  }
-}
-
-void
-FMRadio::Notify(const FMRadioEventType& aType)
-{
-  switch (aType) {
-    case FrequencyChanged:
-      DispatchTrustedEvent(NS_LITERAL_STRING("frequencychange"));
-      break;
-    case EnabledChanged:
-      if (Enabled()) {
-        DispatchTrustedEvent(NS_LITERAL_STRING("enabled"));
-      } else {
-        if (mAudioChannelAgentEnabled) {
-          mAudioChannelAgent->NotifyStoppedPlaying();
-          mAudioChannelAgentEnabled = false;
-        }
-
-        DispatchTrustedEvent(NS_LITERAL_STRING("disabled"));
-      }
-      break;
-    case RDSEnabledChanged:
-      if (RdsEnabled()) {
-        DispatchTrustedEvent(NS_LITERAL_STRING("rdsenabled"));
-      } else {
-        DispatchTrustedEvent(NS_LITERAL_STRING("rdsdisabled"));
-      }
-      break;
-    case PIChanged:
-      DispatchTrustedEvent(NS_LITERAL_STRING("pichange"));
-      break;
-    case PSChanged:
-      DispatchTrustedEvent(NS_LITERAL_STRING("pschange"));
-      break;
-    case RadiotextChanged:
-      DispatchTrustedEvent(NS_LITERAL_STRING("rtchange"));
-      break;
-    case PTYChanged:
-      DispatchTrustedEvent(NS_LITERAL_STRING("ptychange"));
-      break;
-    case NewRDSGroup:
-      DispatchTrustedEvent(NS_LITERAL_STRING("newrdsgroup"));
-      break;
-    default:
-      MOZ_CRASH();
-  }
-}
-
-/* static */
-bool
-FMRadio::Enabled()
-{
-  return IFMRadioService::Singleton()->IsEnabled();
-}
-
-bool
-FMRadio::RdsEnabled()
-{
-  return IFMRadioService::Singleton()->IsRDSEnabled();
-}
-
-bool
-FMRadio::AntennaAvailable() const
-{
-  return mHasInternalAntenna ? true : (mHeadphoneState != hal::SWITCH_STATE_OFF) &&
-    (mHeadphoneState != hal::SWITCH_STATE_UNKNOWN);
-}
-
-Nullable<double>
-FMRadio::GetFrequency() const
-{
-  return Enabled() ?
-    Nullable<double>(IFMRadioService::Singleton()->GetFrequency()) :
-    Nullable<double>();
-}
-
-double
-FMRadio::FrequencyUpperBound() const
-{
-  return IFMRadioService::Singleton()->GetFrequencyUpperBound();
-}
-
-double
-FMRadio::FrequencyLowerBound() const
-{
-  return IFMRadioService::Singleton()->GetFrequencyLowerBound();
-}
-
-double
-FMRadio::ChannelWidth() const
-{
-  return IFMRadioService::Singleton()->GetChannelWidth();
-}
-
-uint32_t
-FMRadio::RdsGroupMask() const
-{
-  return mRdsGroupMask;
-}
-
-void
-FMRadio::SetRdsGroupMask(uint32_t aRdsGroupMask)
-{
-  mRdsGroupMask = aRdsGroupMask;
-  IFMRadioService::Singleton()->SetRDSGroupMask(aRdsGroupMask);
-}
-
-Nullable<unsigned short>
-FMRadio::GetPi() const
-{
-  return IFMRadioService::Singleton()->GetPi();
-}
-
-Nullable<uint8_t>
-FMRadio::GetPty() const
-{
-  return IFMRadioService::Singleton()->GetPty();
-}
-
-void
-FMRadio::GetPs(DOMString& aPsname) const
-{
-  if (!IFMRadioService::Singleton()->GetPs(aPsname)) {
-    aPsname.SetNull();
-  }
-}
-
-void
-FMRadio::GetRt(DOMString& aRadiotext) const
-{
-  if (!IFMRadioService::Singleton()->GetRt(aRadiotext)) {
-    aRadiotext.SetNull();
-  }
-}
-
-void
-FMRadio::GetRdsgroup(JSContext* cx, JS::MutableHandle<JSObject*> retval)
-{
-  uint64_t group;
-  if (!IFMRadioService::Singleton()->GetRdsgroup(group)) {
-    return;
-  }
-
-  JSObject *rdsgroup = Uint16Array::Create(cx, this, 4);
-  JS::AutoCheckCannotGC nogc;
-  bool isShared = false;
-  uint16_t *data = JS_GetUint16ArrayData(rdsgroup, &isShared, nogc);
-  MOZ_ASSERT(!isShared);  // Because created above.
-  data[3] = group & 0xFFFF;
-  group >>= 16;
-  data[2] = group & 0xFFFF;
-  group >>= 16;
-  data[1] = group & 0xFFFF;
-  group >>= 16;
-  data[0] = group & 0xFFFF;
-
-  JS::ExposeObjectToActiveJS(rdsgroup);
-  retval.set(rdsgroup);
-}
-
-already_AddRefed<DOMRequest>
-FMRadio::Enable(double aFrequency)
-{
-  nsCOMPtr<nsPIDOMWindowInner> win = GetOwner();
-  if (!win) {
-    return nullptr;
-  }
-
-  RefPtr<FMRadioRequest> r =
-    new FMRadioRequest(win, this, FMRadioRequestArgs::TEnableRequestArgs);
-  IFMRadioService::Singleton()->Enable(aFrequency, r);
-
-  return r.forget();
-}
-
-already_AddRefed<DOMRequest>
-FMRadio::Disable()
-{
-  nsCOMPtr<nsPIDOMWindowInner> win = GetOwner();
-  if (!win) {
-    return nullptr;
-  }
-
-  RefPtr<FMRadioRequest> r = new FMRadioRequest(win, this);
-  IFMRadioService::Singleton()->Disable(r);
-
-  return r.forget();
-}
-
-already_AddRefed<DOMRequest>
-FMRadio::SetFrequency(double aFrequency)
-{
-  nsCOMPtr<nsPIDOMWindowInner> win = GetOwner();
-  if (!win) {
-    return nullptr;
-  }
-
-  RefPtr<FMRadioRequest> r = new FMRadioRequest(win, this);
-  IFMRadioService::Singleton()->SetFrequency(aFrequency, r);
-
-  return r.forget();
-}
-
-already_AddRefed<DOMRequest>
-FMRadio::SeekUp()
-{
-  nsCOMPtr<nsPIDOMWindowInner> win = GetOwner();
-  if (!win) {
-    return nullptr;
-  }
-
-  RefPtr<FMRadioRequest> r = new FMRadioRequest(win, this);
-  IFMRadioService::Singleton()->Seek(hal::FM_RADIO_SEEK_DIRECTION_UP, r);
-
-  return r.forget();
-}
-
-already_AddRefed<DOMRequest>
-FMRadio::SeekDown()
-{
-  nsCOMPtr<nsPIDOMWindowInner> win = GetOwner();
-  if (!win) {
-    return nullptr;
-  }
-
-  RefPtr<FMRadioRequest> r = new FMRadioRequest(win, this);
-  IFMRadioService::Singleton()->Seek(hal::FM_RADIO_SEEK_DIRECTION_DOWN, r);
-
-  return r.forget();
-}
-
-already_AddRefed<DOMRequest>
-FMRadio::CancelSeek()
-{
-  nsCOMPtr<nsPIDOMWindowInner> win = GetOwner();
-  if (!win) {
-    return nullptr;
-  }
-
-  RefPtr<FMRadioRequest> r = new FMRadioRequest(win, this);
-  IFMRadioService::Singleton()->CancelSeek(r);
-
-  return r.forget();
-}
-
-already_AddRefed<DOMRequest>
-FMRadio::EnableRDS()
-{
-  nsCOMPtr<nsPIDOMWindowInner> win = GetOwner();
-  if (!win) {
-    return nullptr;
-  }
-
-  RefPtr<FMRadioRequest> r = new FMRadioRequest(win, this);
-  IFMRadioService::Singleton()->EnableRDS(r);
-  return r.forget();
-}
-
-already_AddRefed<DOMRequest>
-FMRadio::DisableRDS()
-{
-  nsCOMPtr<nsPIDOMWindowInner> win = GetOwner();
-  if (!win) {
-    return nullptr;
-  }
-
-  RefPtr<FMRadioRequest> r = new FMRadioRequest(win, this);
-  FMRadioService::Singleton()->DisableRDS(r);
-  return r.forget();
-}
-
-void
-FMRadio::EnableAudioChannelAgent()
-{
-  NS_ENSURE_TRUE_VOID(mAudioChannelAgent);
-
-  AudioPlaybackConfig config;
-  nsresult rv = mAudioChannelAgent->NotifyStartedPlaying(&config,
-                                                         AudioChannelService::AudibleState::eAudible);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return;
-  }
-
-  WindowVolumeChanged(config.mVolume, config.mMuted);
-  WindowSuspendChanged(config.mSuspend);
-
-  mAudioChannelAgentEnabled = true;
-}
-
-NS_IMETHODIMP
-FMRadio::WindowVolumeChanged(float aVolume, bool aMuted)
-{
-  // TODO : Not support to change volume now, so we just close it.
-  IFMRadioService::Singleton()->EnableAudio(!aMuted);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-FMRadio::WindowSuspendChanged(nsSuspendedTypes aSuspend)
-{
-  bool enable = (aSuspend == nsISuspendedTypes::NONE_SUSPENDED);
-  IFMRadioService::Singleton()->EnableAudio(enable);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-FMRadio::WindowAudioCaptureChanged(bool aCapture)
-{
-  return NS_OK;
-}
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FMRadio)
-  NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
-  NS_INTERFACE_MAP_ENTRY(nsIAudioChannelAgentCallback)
-NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
-
-NS_IMPL_ADDREF_INHERITED(FMRadio, DOMEventTargetHelper)
-NS_IMPL_RELEASE_INHERITED(FMRadio, DOMEventTargetHelper)
-
-END_FMRADIO_NAMESPACE
-
deleted file mode 100644
--- a/dom/fmradio/FMRadio.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_FMRadio_h
-#define mozilla_dom_FMRadio_h
-
-#include "AudioChannelAgent.h"
-#include "FMRadioCommon.h"
-#include "mozilla/DOMEventTargetHelper.h"
-#include "mozilla/HalTypes.h"
-#include "nsCycleCollectionParticipant.h"
-#include "nsWeakReference.h"
-
-BEGIN_FMRADIO_NAMESPACE
-
-class DOMRequest;
-
-class FMRadio final : public DOMEventTargetHelper
-                    , public hal::SwitchObserver
-                    , public FMRadioEventObserver
-                    , public nsSupportsWeakReference
-                    , public nsIAudioChannelAgentCallback
-
-{
-  friend class FMRadioRequest;
-
-public:
-  FMRadio();
-
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIAUDIOCHANNELAGENTCALLBACK
-
-  NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
-
-  void Init(nsPIDOMWindowInner *aWindow);
-  void Shutdown();
-
-  /* hal::SwitchObserver */
-  virtual void Notify(const hal::SwitchEvent& aEvent) override;
-  /* FMRadioEventObserver */
-  virtual void Notify(const FMRadioEventType& aType) override;
-
-  nsPIDOMWindowInner* GetParentObject() const
-  {
-    return GetOwner();
-  }
-
-  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
-  static bool Enabled();
-
-  bool RdsEnabled();
-
-  bool AntennaAvailable() const;
-
-  Nullable<double> GetFrequency() const;
-
-  double FrequencyUpperBound() const;
-
-  double FrequencyLowerBound() const;
-
-  double ChannelWidth() const;
-
-  uint32_t RdsGroupMask() const;
-
-  void SetRdsGroupMask(uint32_t aRdsGroupMask);
-
-  Nullable<unsigned short> GetPi() const;
-
-  Nullable<uint8_t> GetPty() const;
-
-  void GetPs(DOMString& aPsname) const;
-
-  void GetRt(DOMString& aRadiotext) const;
-
-  void GetRdsgroup(JSContext* cx, JS::MutableHandle<JSObject*> retval);
-
-  already_AddRefed<DOMRequest> Enable(double aFrequency);
-
-  already_AddRefed<DOMRequest> Disable();
-
-  already_AddRefed<DOMRequest> SetFrequency(double aFrequency);
-
-  already_AddRefed<DOMRequest> SeekUp();
-
-  already_AddRefed<DOMRequest> SeekDown();
-
-  already_AddRefed<DOMRequest> CancelSeek();
-
-  already_AddRefed<DOMRequest> EnableRDS();
-
-  already_AddRefed<DOMRequest> DisableRDS();
-
-  IMPL_EVENT_HANDLER(enabled);
-  IMPL_EVENT_HANDLER(disabled);
-  IMPL_EVENT_HANDLER(rdsenabled);
-  IMPL_EVENT_HANDLER(rdsdisabled);
-  IMPL_EVENT_HANDLER(antennaavailablechange);
-  IMPL_EVENT_HANDLER(frequencychange);
-  IMPL_EVENT_HANDLER(pichange);
-  IMPL_EVENT_HANDLER(ptychange);
-  IMPL_EVENT_HANDLER(pschange);
-  IMPL_EVENT_HANDLER(rtchange);
-  IMPL_EVENT_HANDLER(newrdsgroup);
-
-private:
-  ~FMRadio();
-
-  void EnableAudioChannelAgent();
-
-  hal::SwitchState mHeadphoneState;
-  uint32_t mRdsGroupMask;
-  bool mAudioChannelAgentEnabled;
-  bool mHasInternalAntenna;
-  bool mIsShutdown;
-
-  nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent;
-};
-
-END_FMRADIO_NAMESPACE
-
-#endif // mozilla_dom_FMRadio_h
-
deleted file mode 100644
--- a/dom/fmradio/FMRadioCommon.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef FMRADIOCOMMON_H_
-#define FMRADIOCOMMON_H_
-
-#include "mozilla/Observer.h"
-
-#undef FM_LOG
-#if defined(ANDROID)
-#include <android/log.h>
-#define FM_LOG(FMRADIO_LOG_INFO, args...) \
-  __android_log_print(ANDROID_LOG_INFO, \
-                      FMRADIO_LOG_INFO, \
-                      ## args)
-#else
-#define FM_LOG(args...)
-#endif
-
-#define BEGIN_FMRADIO_NAMESPACE \
-  namespace mozilla { namespace dom {
-#define END_FMRADIO_NAMESPACE \
-  } /* namespace dom */ } /* namespace mozilla */
-
-BEGIN_FMRADIO_NAMESPACE
-
-enum FMRadioEventType
-{
-  FrequencyChanged,
-  EnabledChanged,
-  RDSEnabledChanged,
-  PIChanged,
-  PSChanged,
-  PTYChanged,
-  RadiotextChanged,
-  NewRDSGroup
-};
-
-typedef mozilla::Observer<FMRadioEventType>     FMRadioEventObserver;
-typedef mozilla::ObserverList<FMRadioEventType> FMRadioEventObserverList;
-
-END_FMRADIO_NAMESPACE
-
-#endif /* FMRADIOCOMMON_H_ */
-
deleted file mode 100644
--- a/dom/fmradio/FMRadioService.cpp
+++ /dev/null
@@ -1,1221 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "FMRadioService.h"
-#include "mozilla/Hal.h"
-#include "mozilla/ClearOnShutdown.h"
-#include "nsIAudioManager.h"
-#include "AudioManager.h"
-#include "nsDOMClassInfo.h"
-#include "nsContentUtils.h"
-#include "mozilla/LazyIdleThread.h"
-#include "mozilla/Preferences.h"
-#include "mozilla/dom/FMRadioChild.h"
-#include "mozilla/dom/ScriptSettings.h"
-#include "nsIObserverService.h"
-#include "nsISettingsService.h"
-#include "nsJSUtils.h"
-#include "mozilla/dom/BindingUtils.h"
-#include "mozilla/dom/SettingChangeNotificationBinding.h"
-#include "mozilla/DebugOnly.h"
-
-#define TUNE_THREAD_TIMEOUT_MS  5000
-
-#define BAND_87500_108000_kHz 1
-#define BAND_76000_108000_kHz 2
-#define BAND_76000_90000_kHz  3
-
-#define MOZSETTINGS_CHANGED_ID "mozsettings-changed"
-#define SETTING_KEY_AIRPLANEMODE_ENABLED "airplaneMode.enabled"
-
-#define DOM_PARSED_RDS_GROUPS ((0x2 << 30) | (0x3 << 4) | (0x3 << 0))
-
-using mozilla::Preferences;
-
-BEGIN_FMRADIO_NAMESPACE
-
-// static
-IFMRadioService*
-IFMRadioService::Singleton()
-{
-  if (!XRE_IsParentProcess()) {
-    return FMRadioChild::Singleton();
-  } else {
-    return FMRadioService::Singleton();
-  }
-}
-
-StaticRefPtr<FMRadioService> FMRadioService::sFMRadioService;
-
-FMRadioService::FMRadioService()
-  : mPendingFrequencyInKHz(0)
-  , mState(Disabled)
-  , mHasReadAirplaneModeSetting(false)
-  , mAirplaneModeEnabled(false)
-  , mRDSEnabled(false)
-  , mPendingRequest(nullptr)
-  , mObserverList(FMRadioEventObserverList())
-  , mRDSGroupMask(0)
-  , mLastPI(0)
-  , mPI(0)
-  , mPTY(0)
-  , mPISet(false)
-  , mPTYSet(false)
-  , mRDSLock("FMRadioService::mRDSLock")
-  , mPSNameState(0)
-  , mRadiotextAB(false)
-  , mRDSGroupSet(false)
-  , mPSNameSet(false)
-  , mRadiotextSet(false)
-{
-  memset(mPSName, 0, sizeof(mPSName));
-  memset(mRadiotext, 0, sizeof(mRadiotext));
-  memset(mTempPSName, 0, sizeof(mTempPSName));
-  memset(mTempRadiotext, 0, sizeof(mTempRadiotext));
-
-  // Read power state and frequency from Hal.
-  mEnabled = hal::IsFMRadioOn();
-  if (mEnabled) {
-    mPendingFrequencyInKHz = hal::GetFMRadioFrequency();
-    SetState(Enabled);
-  }
-
-  switch (Preferences::GetInt("dom.fmradio.band", BAND_87500_108000_kHz)) {
-    case BAND_76000_90000_kHz:
-      mUpperBoundInKHz = 90000;
-      mLowerBoundInKHz = 76000;
-      break;
-    case BAND_76000_108000_kHz:
-      mUpperBoundInKHz = 108000;
-      mLowerBoundInKHz = 76000;
-      break;
-    case BAND_87500_108000_kHz:
-    default:
-      mUpperBoundInKHz = 108000;
-      mLowerBoundInKHz = 87500;
-      break;
-  }
-
-  mChannelWidthInKHz = Preferences::GetInt("dom.fmradio.channelWidth", 100);
-  switch (mChannelWidthInKHz) {
-    case 50:
-    case 100:
-    case 200:
-      break;
-    default:
-      NS_WARNING("Invalid channel width specified in dom.fmradio.channelwidth");
-      mChannelWidthInKHz = 100;
-      break;
-  }
-
-  mPreemphasis = Preferences::GetInt("dom.fmradio.preemphasis", 50);
-  switch (mPreemphasis) {
-    // values in microseconds
-    case 0:
-    case 50:
-    case 75:
-      break;
-    default:
-      NS_WARNING("Invalid preemphasis specified in dom.fmradio.preemphasis");
-      mPreemphasis = 50;
-      break;
-  }
-
-  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-
-  if (obs && NS_FAILED(obs->AddObserver(this,
-                                        MOZSETTINGS_CHANGED_ID,
-                                        /* useWeak */ false))) {
-    NS_WARNING("Failed to add settings change observer!");
-  }
-
-  hal::RegisterFMRadioObserver(this);
-  hal::RegisterFMRadioRDSObserver(this);
-}
-
-FMRadioService::~FMRadioService()
-{
-  hal::UnregisterFMRadioRDSObserver(this);
-  hal::UnregisterFMRadioObserver(this);
-}
-
-void
-FMRadioService::EnableFMRadio()
-{
-  hal::FMRadioSettings info;
-  info.upperLimit() = mUpperBoundInKHz;
-  info.lowerLimit() = mLowerBoundInKHz;
-  info.spaceType() = mChannelWidthInKHz;
-  info.preEmphasis() = mPreemphasis;
-
-  hal::EnableFMRadio(info);
-
-  if (!mTuneThread) {
-    // hal::FMRadioSeek and hal::SetFMRadioFrequency run on this thread. These
-    // call ioctls that can stall the main thread, so we run them here.
-    mTuneThread = new LazyIdleThread(
-      TUNE_THREAD_TIMEOUT_MS, NS_LITERAL_CSTRING("FM Tuning"));
-  }
-}
-
-/**
- * Read the airplane-mode setting, if the airplane-mode is not enabled, we
- * enable the FM radio.
- */
-class ReadAirplaneModeSettingTask final : public nsISettingsServiceCallback
-{
-public:
-  NS_DECL_ISUPPORTS
-
-  ReadAirplaneModeSettingTask(RefPtr<FMRadioReplyRunnable> aPendingRequest)
-    : mPendingRequest(aPendingRequest) { }
-
-  NS_IMETHOD
-  Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
-  {
-    RefPtr<FMRadioService> fmRadioService = FMRadioService::Singleton();
-    MOZ_ASSERT(mPendingRequest == fmRadioService->mPendingRequest);
-    
-    fmRadioService->mHasReadAirplaneModeSetting = true;
-
-    if (!aResult.isBoolean()) {
-      // Failed to read the setting value, set the state back to Disabled.
-      fmRadioService->TransitionState(
-        ErrorResponse(NS_LITERAL_STRING("Unexpected error")), Disabled);
-      return NS_OK;
-    }
-
-    fmRadioService->mAirplaneModeEnabled = aResult.toBoolean();
-    if (!fmRadioService->mAirplaneModeEnabled) {
-      NS_DispatchToMainThread(NS_NewRunnableFunction(
-        [fmRadioService] () -> void {
-          fmRadioService->EnableFMRadio();
-        }
-      ));
-    } else {
-      // Airplane mode is enabled, set the state back to Disabled.
-      fmRadioService->TransitionState(ErrorResponse(
-        NS_LITERAL_STRING("Airplane mode currently enabled")), Disabled);
-    }
-
-    return NS_OK;
-  }
-
-  NS_IMETHOD
-  HandleError(const nsAString& aName)
-  {
-    FMRadioService* fmRadioService = FMRadioService::Singleton();
-    MOZ_ASSERT(mPendingRequest == fmRadioService->mPendingRequest);
-
-    fmRadioService->TransitionState(ErrorResponse(
-      NS_LITERAL_STRING("Unexpected error")), Disabled);
-
-    return NS_OK;
-  }
-
-protected:
-  ~ReadAirplaneModeSettingTask() {}
-
-private:
-  RefPtr<FMRadioReplyRunnable> mPendingRequest;
-};
-
-NS_IMPL_ISUPPORTS(ReadAirplaneModeSettingTask, nsISettingsServiceCallback)
-
-void
-FMRadioService::DisableFMRadio()
-{
-  if (mTuneThread) {
-    mTuneThread->Shutdown();
-    mTuneThread = nullptr;
-  }
-  // Fix Bug 796733. DisableFMRadio should be called before
-  // SetFmRadioAudioEnabled to prevent the annoying beep sound.
-  hal::DisableFMRadio();
-  EnableAudio(false);
-};
-
-void
-FMRadioService::DispatchFMRadioEventToMainThread(enum FMRadioEventType aType)
-{
-  RefPtr<FMRadioService> self = this;
-  NS_DispatchToMainThread(NS_NewRunnableFunction(
-    [self, aType] () -> void {
-      self->NotifyFMRadioEvent(aType);
-    }
-  ));
-}
-
-void
-FMRadioService::TransitionState(const FMRadioResponseType& aResponse,
-                                FMRadioState aState)
-{
-  if (mPendingRequest) {
-    mPendingRequest->SetReply(aResponse);
-    NS_DispatchToMainThread(mPendingRequest);
-  }
-
-  SetState(aState);
-}
-
-void
-FMRadioService::SetState(FMRadioState aState)
-{
-  mState = aState;
-  mPendingRequest = nullptr;
-}
-
-void
-FMRadioService::AddObserver(FMRadioEventObserver* aObserver)
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-  mObserverList.AddObserver(aObserver);
-}
-
-void
-FMRadioService::RemoveObserver(FMRadioEventObserver* aObserver)
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-  mObserverList.RemoveObserver(aObserver);
-
-  if (mObserverList.Length() == 0)
-  {
-    // Turning off the FM radio HW because observer list is empty.
-    if (hal::IsFMRadioOn()) {
-      DoDisable();
-    }
-  }
-}
-
-void
-FMRadioService::EnableAudio(bool aAudioEnabled)
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-
-  nsCOMPtr<nsIAudioManager> audioManager =
-    do_GetService("@mozilla.org/telephony/audiomanager;1");
-  if (!audioManager) {
-    return;
-  }
-
-  bool audioEnabled;
-  audioManager->GetFmRadioAudioEnabled(&audioEnabled);
-  if (audioEnabled != aAudioEnabled) {
-    audioManager->SetFmRadioAudioEnabled(aAudioEnabled);
-  }
-}
-
-/**
- * Round the frequency to match the range of frequency and the channel width. If
- * the given frequency is out of range, return 0. For example:
- *  - lower: 87500KHz, upper: 108000KHz, channel width: 200KHz
- *    87.6MHz is rounded to 87700KHz
- *    87.58MHz is rounded to 87500KHz
- *    87.49MHz is rounded to 87500KHz
- *    109MHz is not rounded, 0 will be returned
- *
- * We take frequency in MHz to prevent precision losing, and return rounded
- * value in KHz for Gonk using.
- */
-int32_t
-FMRadioService::RoundFrequency(double aFrequencyInMHz)
-{
-  double halfChannelWidthInMHz = mChannelWidthInKHz / 1000.0 / 2;
-
-  // Make sure 87.49999MHz would be rounded to the lower bound when
-  // the lower bound is 87500KHz.
-  if (aFrequencyInMHz < mLowerBoundInKHz / 1000.0 - halfChannelWidthInMHz ||
-      aFrequencyInMHz > mUpperBoundInKHz / 1000.0 + halfChannelWidthInMHz) {
-    return 0;
-  }
-
-  int32_t partToBeRounded = round(aFrequencyInMHz * 1000) - mLowerBoundInKHz;
-  int32_t roundedPart = round(partToBeRounded / (double)mChannelWidthInKHz) *
-                        mChannelWidthInKHz;
-
-  return mLowerBoundInKHz + roundedPart;
-}
-
-bool
-FMRadioService::IsEnabled() const
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-  return hal::IsFMRadioOn();
-}
-
-bool
-FMRadioService::IsRDSEnabled() const
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-  return mRDSEnabled;
-}
-
-double
-FMRadioService::GetFrequency() const
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-  if (IsEnabled()) {
-    int32_t frequencyInKHz = hal::GetFMRadioFrequency();
-    return frequencyInKHz / 1000.0;
-  }
-
-  return 0;
-}
-
-double
-FMRadioService::GetFrequencyUpperBound() const
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-  return mUpperBoundInKHz / 1000.0;
-}
-
-double
-FMRadioService::GetFrequencyLowerBound() const
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-  return mLowerBoundInKHz / 1000.0;
-}
-
-double
-FMRadioService::GetChannelWidth() const
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-  return mChannelWidthInKHz / 1000.0;
-}
-
-Nullable<unsigned short>
-FMRadioService::GetPi() const
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-  if (!mPISet) {
-    return Nullable<unsigned short>();
-  }
-  return Nullable<unsigned short>(mPI);
-}
-
-Nullable<uint8_t>
-FMRadioService::GetPty() const
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-  if (!mPTYSet) {
-    return Nullable<uint8_t>();
-  }
-  return Nullable<uint8_t>(mPTY);
-}
-
-bool
-FMRadioService::GetPs(nsString& aPSName)
-{
-  MutexAutoLock lock(mRDSLock);
-  if (mPSNameSet) {
-    aPSName = nsString(mPSName);
-  }
-  return mPSNameSet;
-}
-
-bool
-FMRadioService::GetRt(nsString& aRadiotext)
-{
-  MutexAutoLock lock(mRDSLock);
-  if (mRadiotextSet) {
-    aRadiotext = nsString(mRadiotext);
-  }
-  return mRadiotextSet;
-}
-
-bool
-FMRadioService::GetRdsgroup(uint64_t& aRDSGroup)
-{
-  MutexAutoLock lock(mRDSLock);
-  aRDSGroup = mRDSGroup;
-  return mRDSGroupSet;
-}
-
-void
-FMRadioService::Enable(double aFrequencyInMHz,
-                       FMRadioReplyRunnable* aReplyRunnable)
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-  MOZ_ASSERT(aReplyRunnable);
-
-  switch (mState) {
-    case Seeking:
-    case Enabled:
-      aReplyRunnable->SetReply(
-        ErrorResponse(NS_LITERAL_STRING("FM radio currently enabled")));
-      NS_DispatchToMainThread(aReplyRunnable);
-      return;
-    case Disabling:
-      aReplyRunnable->SetReply(
-        ErrorResponse(NS_LITERAL_STRING("FM radio currently disabling")));
-      NS_DispatchToMainThread(aReplyRunnable);
-      return;
-    case Enabling:
-      aReplyRunnable->SetReply(
-        ErrorResponse(NS_LITERAL_STRING("FM radio currently enabling")));
-      NS_DispatchToMainThread(aReplyRunnable);
-      return;
-    case Disabled:
-      break;
-  }
-
-  int32_t roundedFrequency = RoundFrequency(aFrequencyInMHz);
-
-  if (!roundedFrequency) {
-    aReplyRunnable->SetReply(ErrorResponse(
-      NS_LITERAL_STRING("Frequency is out of range")));
-    NS_DispatchToMainThread(aReplyRunnable);
-    return;
-  }
-
-  if (mHasReadAirplaneModeSetting && mAirplaneModeEnabled) {
-    aReplyRunnable->SetReply(ErrorResponse(
-      NS_LITERAL_STRING("Airplane mode currently enabled")));
-    NS_DispatchToMainThread(aReplyRunnable);
-    return;
-  }
-
-  SetState(Enabling);
-  // Cache the enable request just in case disable() is called
-  // while the FM radio HW is being enabled.
-  mPendingRequest = aReplyRunnable;
-
-  // Cache the frequency value, and set it after the FM radio HW is enabled
-  mPendingFrequencyInKHz = roundedFrequency;
-
-  if (!mHasReadAirplaneModeSetting) {
-    nsCOMPtr<nsISettingsService> settings =
-      do_GetService("@mozilla.org/settingsService;1");
-
-    nsCOMPtr<nsISettingsServiceLock> settingsLock;
-    nsresult rv = settings->CreateLock(nullptr, getter_AddRefs(settingsLock));
-    if (NS_FAILED(rv)) {
-      TransitionState(ErrorResponse(
-        NS_LITERAL_STRING("Can't create settings lock")), Disabled);
-      return;
-    }
-
-    RefPtr<ReadAirplaneModeSettingTask> callback =
-      new ReadAirplaneModeSettingTask(mPendingRequest);
-
-    rv = settingsLock->Get(SETTING_KEY_AIRPLANEMODE_ENABLED, callback);
-    if (NS_FAILED(rv)) {
-      TransitionState(ErrorResponse(
-        NS_LITERAL_STRING("Can't get settings lock")), Disabled);
-    }
-
-    return;
-  }
-
-  RefPtr<FMRadioService> self = this;
-  NS_DispatchToMainThread(NS_NewRunnableFunction(
-    [self] () -> void {
-      self->EnableFMRadio();
-    }
-  ));
-}
-
-void
-FMRadioService::Disable(FMRadioReplyRunnable* aReplyRunnable)
-{
-  // When airplane-mode is enabled, we will call this function from
-  // FMRadioService::Observe without passing a FMRadioReplyRunnable,
-  // so we have to check if |aReplyRunnable| is null before we dispatch it.
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-
-  switch (mState) {
-    case Disabling:
-      if (aReplyRunnable) {
-        aReplyRunnable->SetReply(
-          ErrorResponse(NS_LITERAL_STRING("FM radio currently disabling")));
-        NS_DispatchToMainThread(aReplyRunnable);
-      }
-      return;
-    case Disabled:
-      if (aReplyRunnable) {
-        aReplyRunnable->SetReply(
-          ErrorResponse(NS_LITERAL_STRING("FM radio currently disabled")));
-        NS_DispatchToMainThread(aReplyRunnable);
-      }
-      return;
-    case Enabled:
-    case Enabling:
-    case Seeking:
-      break;
-  }
-
-  RefPtr<FMRadioReplyRunnable> enablingRequest = mPendingRequest;
-
-  // If the FM Radio is currently seeking, no fail-to-seek or similar
-  // event will be fired, execute the seek callback manually.
-  if (mState == Seeking) {
-    TransitionState(ErrorResponse(
-      NS_LITERAL_STRING("Seek action is cancelled")), Disabling);
-  }
-
-  FMRadioState preState = mState;
-  SetState(Disabling);
-  mPendingRequest = aReplyRunnable;
-
-  if (preState == Enabling) {
-    // If the radio is currently enabling, we fire the error callback on the
-    // enable request immediately. When the radio finishes enabling, we'll call
-    // DoDisable and fire the success callback on the disable request.
-    enablingRequest->SetReply(
-      ErrorResponse(NS_LITERAL_STRING("Enable action is cancelled")));
-    NS_DispatchToMainThread(enablingRequest);
-
-    // If we haven't read the airplane mode settings yet we won't enable the
-    // FM radio HW, so fail the disable request immediately.
-    if (!mHasReadAirplaneModeSetting) {
-      SetState(Disabled);
-
-      if (aReplyRunnable) {
-        aReplyRunnable->SetReply(SuccessResponse());
-        NS_DispatchToMainThread(aReplyRunnable);
-      }
-    }
-
-    return;
-  }
-
-  DoDisable();
-}
-
-void
-FMRadioService::DoDisable()
-{
-  // To make such codes work:
-  //    navigator.mozFMRadio.disable();
-  //    navigator.mozFMRadio.ondisabled = function() {
-  //      console.log("We will catch disabled event ");
-  //    };
-  // we need to call hal::DisableFMRadio() asynchronously. Same reason for
-  // EnableFMRadio and hal::SetFMRadioFrequency.
-  RefPtr<FMRadioService> self = this;
-  NS_DispatchToMainThread(NS_NewRunnableFunction(
-    [self] () -> void {
-      self->DisableFMRadio();
-    }
-  ));
-}
-
-void
-FMRadioService::SetFrequency(double aFrequencyInMHz,
-                             FMRadioReplyRunnable* aReplyRunnable)
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-  MOZ_ASSERT(aReplyRunnable);
-
-  switch (mState) {
-    case Disabled:
-      aReplyRunnable->SetReply(
-        ErrorResponse(NS_LITERAL_STRING("FM radio currently disabled")));
-      NS_DispatchToMainThread(aReplyRunnable);
-      return;
-    case Enabling:
-      aReplyRunnable->SetReply(
-        ErrorResponse(NS_LITERAL_STRING("FM radio currently enabling")));
-      NS_DispatchToMainThread(aReplyRunnable);
-      return;
-    case Disabling:
-      aReplyRunnable->SetReply(
-        ErrorResponse(NS_LITERAL_STRING("FM radio currently disabling")));
-      NS_DispatchToMainThread(aReplyRunnable);
-      return;
-    case Seeking:
-      hal::CancelFMRadioSeek();
-      TransitionState(ErrorResponse(
-        NS_LITERAL_STRING("Seek action is cancelled")), Enabled);
-      break;
-    case Enabled:
-      break;
-  }
-
-  int32_t roundedFrequency = RoundFrequency(aFrequencyInMHz);
-
-  if (!roundedFrequency) {
-    aReplyRunnable->SetReply(ErrorResponse(
-      NS_LITERAL_STRING("Frequency is out of range")));
-    NS_DispatchToMainThread(aReplyRunnable);
-    return;
-  }
-
-  mTuneThread->Dispatch(
-    NS_NewRunnableFunction(
-      [roundedFrequency] () -> void {
-        hal::SetFMRadioFrequency(roundedFrequency);
-      }
-    ), nsIThread::DISPATCH_NORMAL);
-
-  aReplyRunnable->SetReply(SuccessResponse());
-  NS_DispatchToMainThread(aReplyRunnable);
-}
-
-void
-FMRadioService::Seek(hal::FMRadioSeekDirection aDirection,
-                     FMRadioReplyRunnable* aReplyRunnable)
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-  MOZ_ASSERT(aReplyRunnable);
-
-  switch (mState) {
-    case Enabling:
-      aReplyRunnable->SetReply(
-        ErrorResponse(NS_LITERAL_STRING("FM radio currently enabling")));
-      NS_DispatchToMainThread(aReplyRunnable);
-      return;
-    case Disabled:
-      aReplyRunnable->SetReply(
-        ErrorResponse(NS_LITERAL_STRING("FM radio currently disabled")));
-      NS_DispatchToMainThread(aReplyRunnable);
-      return;
-    case Seeking:
-      aReplyRunnable->SetReply(
-        ErrorResponse(NS_LITERAL_STRING("FM radio currently seeking")));
-      NS_DispatchToMainThread(aReplyRunnable);
-      return;
-    case Disabling:
-      aReplyRunnable->SetReply(
-        ErrorResponse(NS_LITERAL_STRING("FM radio currently disabling")));
-      NS_DispatchToMainThread(aReplyRunnable);
-      return;
-    case Enabled:
-      break;
-  }
-
-  SetState(Seeking);
-  mPendingRequest = aReplyRunnable;
-
-  mTuneThread->Dispatch(
-    NS_NewRunnableFunction(
-      [aDirection] () -> void {
-        switch (aDirection) {
-          case hal::FM_RADIO_SEEK_DIRECTION_UP:
-          case hal::FM_RADIO_SEEK_DIRECTION_DOWN:
-            hal::FMRadioSeek(aDirection);
-            break;
-          default:
-            MOZ_CRASH();
-        }
-      }
-    ), nsIThread::DISPATCH_NORMAL);
-}
-
-void
-FMRadioService::CancelSeek(FMRadioReplyRunnable* aReplyRunnable)
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-  MOZ_ASSERT(aReplyRunnable);
-
-  // We accept canceling seek request only if it's currently seeking.
-  if (mState != Seeking) {
-    aReplyRunnable->SetReply(
-      ErrorResponse(NS_LITERAL_STRING("FM radio currently not seeking")));
-    NS_DispatchToMainThread(aReplyRunnable);
-    return;
-  }
-
-  // Cancel the seek immediately to prevent it from completing.
-  hal::CancelFMRadioSeek();
-
-  TransitionState(
-    ErrorResponse(NS_LITERAL_STRING("Seek action is cancelled")), Enabled);
-
-  aReplyRunnable->SetReply(SuccessResponse());
-  NS_DispatchToMainThread(aReplyRunnable);
-}
-
-void
-FMRadioService::SetRDSGroupMask(uint32_t aRDSGroupMask)
-{
-  mRDSGroupMask = aRDSGroupMask;
-  if (hal::IsFMRadioOn() && mRDSEnabled) {
-    DebugOnly<bool> enabled = hal::EnableRDS(mRDSGroupMask | DOM_PARSED_RDS_GROUPS);
-    MOZ_ASSERT(enabled);
-  }
-}
-
-void
-FMRadioService::EnableRDS(FMRadioReplyRunnable* aReplyRunnable)
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-  MOZ_ASSERT(aReplyRunnable);
-
-  if (hal::IsFMRadioOn()) {
-    if (!hal::EnableRDS(mRDSGroupMask | DOM_PARSED_RDS_GROUPS)) {
-      aReplyRunnable->SetReply(
-        ErrorResponse(NS_LITERAL_STRING("Could not enable RDS")));
-      NS_DispatchToMainThread(aReplyRunnable);
-      return;
-    }
-  }
-
-  mRDSEnabled = true;
-
-  aReplyRunnable->SetReply(SuccessResponse());
-  NS_DispatchToMainThread(aReplyRunnable);
-
-  DispatchFMRadioEventToMainThread(RDSEnabledChanged);
-}
-
-void
-FMRadioService::DisableRDS(FMRadioReplyRunnable* aReplyRunnable)
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-  MOZ_ASSERT(aReplyRunnable);
-
-  if (hal::IsFMRadioOn()) {
-    hal::DisableRDS();
-  }
-
-  aReplyRunnable->SetReply(SuccessResponse());
-  NS_DispatchToMainThread(aReplyRunnable);
-
-  if (mRDSEnabled) {
-    mRDSEnabled = false;
-
-    DispatchFMRadioEventToMainThread(RDSEnabledChanged);
-  }
-}
-
-NS_IMETHODIMP
-FMRadioService::Observe(nsISupports* aSubject,
-                        const char* aTopic,
-                        const char16_t* aData)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(sFMRadioService);
-
-  if (strcmp(aTopic, MOZSETTINGS_CHANGED_ID) != 0) {
-    return NS_OK;
-  }
-
-  // The string that we're interested in will be a JSON string looks like:
-  //  {"key":"airplaneMode.enabled","value":true}
-  RootedDictionary<dom::SettingChangeNotification> setting(RootingCx());
-  if (!WrappedJSToDictionary(aSubject, setting)) {
-    return NS_OK;
-  }
-  if (!setting.mKey.EqualsASCII(SETTING_KEY_AIRPLANEMODE_ENABLED)) {
-    return NS_OK;
-  }
-  if (!setting.mValue.isBoolean()) {
-    return NS_OK;
-  }
-
-  mAirplaneModeEnabled = setting.mValue.toBoolean();
-  mHasReadAirplaneModeSetting = true;
-
-  // Disable the FM radio HW if Airplane mode is enabled.
-  if (mAirplaneModeEnabled) {
-    Disable(nullptr);
-  }
-
-  return NS_OK;
-}
-
-void
-FMRadioService::NotifyFMRadioEvent(FMRadioEventType aType)
-{
-  mObserverList.Broadcast(aType);
-}
-
-void
-FMRadioService::Notify(const hal::FMRadioOperationInformation& aInfo)
-{
-  switch (aInfo.operation()) {
-    case hal::FM_RADIO_OPERATION_ENABLE:
-      MOZ_ASSERT(hal::IsFMRadioOn());
-      MOZ_ASSERT(mState == Disabling || mState == Enabling);
-
-      // If we're disabling, disable the radio right now.
-      if (mState == Disabling) {
-        DoDisable();
-        return;
-      }
-
-      // Fire success callback on the enable request.
-      TransitionState(SuccessResponse(), Enabled);
-
-      // To make sure the FM app will get the right frequency after the FM
-      // radio is enabled, we have to set the frequency first.
-      hal::SetFMRadioFrequency(mPendingFrequencyInKHz);
-
-      // Bug 949855: enable audio after the FM radio HW is enabled, to make sure
-      // 'hw.fm.isAnalog' could be detected as |true| during first time launch.
-      // This case is for audio output on analog path, i.e. 'ro.moz.fm.noAnalog'
-      // is not |true|.
-      EnableAudio(true);
-
-      // Update the current frequency without sending the`FrequencyChanged`
-      // event, to make sure the FM app will get the right frequency when the
-      // `EnabledChange` event is sent.
-      mPendingFrequencyInKHz = hal::GetFMRadioFrequency();
-      UpdatePowerState();
-
-      // The frequency was changed from '0' to some meaningful number, so we
-      // should send the `FrequencyChanged` event manually.
-      NotifyFMRadioEvent(FrequencyChanged);
-
-      if (mRDSEnabled) {
-        mRDSEnabled = hal::EnableRDS(mRDSGroupMask | DOM_PARSED_RDS_GROUPS);
-        if (!mRDSEnabled) {
-          NotifyFMRadioEvent(RDSEnabledChanged);
-        }
-      }
-      break;
-    case hal::FM_RADIO_OPERATION_DISABLE:
-      MOZ_ASSERT(mState == Disabling);
-
-      mPISet = false;
-      mPTYSet = false;
-      memset(mPSName, 0, sizeof(mPSName));
-      memset(mRadiotext, 0, sizeof(mRadiotext));
-      TransitionState(SuccessResponse(), Disabled);
-      UpdatePowerState();
-      break;
-    case hal::FM_RADIO_OPERATION_SEEK:
-
-      // Seek action might be cancelled by SetFrequency(), we need to check if
-      // the current state is Seeking.
-      if (mState == Seeking) {
-        TransitionState(SuccessResponse(), Enabled);
-      }
-
-      UpdateFrequency();
-      break;
-    case hal::FM_RADIO_OPERATION_TUNE:
-      UpdateFrequency();
-      break;
-    default:
-      MOZ_CRASH();
-  }
-}
-
-/* This is defined by the RDS standard */
-static const uint16_t sRDSToUnicodeMap[256] = {
-  // The lower half differs from ASCII in 0x1F, 0x24, 0x5E, 0x7E
-  // Most control characters are replaced with 0x20 (space)
-  // 0x0-
-  0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
-  0x0020, 0x0009, 0x000A, 0x000B, 0x0020, 0x00D0, 0x0020, 0x0020,
-
-  // 0x1-
-  0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020,
-  0x0020, 0x0020, 0x0020, 0x001B, 0x0020, 0x0020, 0x0020, 0x00AD,
-
-  // 0x2-
-  0x0020, 0x0021, 0x0022, 0x0023, 0x00A4, 0x0025, 0x0026, 0x0027,
-  0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
-
-  // 0x3-
-  0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
-  0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
-
-  // 0x4-
-  0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
-  0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
-
-  // 0x5-
-  0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
-  0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x2015, 0x005F,
-
-  // 0x6-
-  0x2551, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
-  0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
-
-  // 0x7-
-  0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
-  0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x00AF, 0x007F,
-
-  // 0x8-
-  0x00E1, 0x00E0, 0x00E9, 0x00E8, 0x00ED, 0x00EC, 0x00F3, 0x00F2,
-  0x00FA, 0x00F9, 0x00D1, 0x00C7, 0x015E, 0x00DF, 0x00A1, 0x0132,
-
-  // 0x9-
-  0x00E2, 0x00E4, 0x00EA, 0x00EB, 0x00EE, 0x00EF, 0x00F4, 0x00F6,
-  0x00FB, 0x00FC, 0x00F1, 0x00E7, 0x015F, 0x011F, 0x0131, 0x0133,
-
-  // 0xA-
-  0x00AA, 0x03B1, 0x00A9, 0x2030, 0x011E, 0x011B, 0x0148, 0x0151,
-  0x03C0, 0x20AC, 0x00A3, 0x0024, 0x2190, 0x2191, 0x2192, 0x2193,
-
-  // 0xB-
-  0x00BA, 0x00B9, 0x00B2, 0x00B3, 0x00B1, 0x0130, 0x0144, 0x0171,
-  0x03BC, 0x00BF, 0x00F7, 0x00B0, 0x00BC, 0x00BD, 0x00BE, 0x00A7,
-
-  // 0xC-
-  0x00C1, 0x00C0, 0x00C9, 0x00C8, 0x00CD, 0x00CC, 0x00D3, 0x00D2,
-  0x00DA, 0x00D9, 0x0158, 0x010C, 0x0160, 0x017D, 0x00D0, 0x013F,
-
-  // 0xD-
-  0x00C2, 0x00C4, 0x00CA, 0x00CB, 0x00CE, 0x00CF, 0x00D4, 0x00D6,
-  0x00DB, 0x00DC, 0x0159, 0x010D, 0x0161, 0x017E, 0x0111, 0x0140,
-
-  // 0xE-
-  0x00C3, 0x00C5, 0x00C6, 0x0152, 0x0177, 0x00DD, 0x00D5, 0x00D8,
-  0x00DE, 0x014A, 0x0154, 0x0106, 0x015A, 0x0179, 0x0166, 0x00F0,
-
-  // 0xF-
-  0x00E3, 0x00E5, 0x00E6, 0x0153, 0x0175, 0x00FD, 0x00F5, 0x00F8,
-  0x00FE, 0x014B, 0x0155, 0x0107, 0x015B, 0x017A, 0x0167, 0x0020,
-};
-
-void
-FMRadioService::Notify(const hal::FMRadioRDSGroup& aRDSGroup)
-{
-  uint16_t blocks[4];
-  blocks[0] = aRDSGroup.blockA();
-  blocks[1] = aRDSGroup.blockB();
-  blocks[2] = aRDSGroup.blockC();
-  blocks[3] = aRDSGroup.blockD();
-
-  /* Bit 11 in block B determines whether this is a type B group. */
-  uint16_t lastPI = blocks[1] & (1 << 11) ? blocks[2] : mLastPI;
-
-  /* Update PI if it's not set or if we get two PI with the new value. */
-  if ((mPI != blocks[0] && lastPI == blocks[0]) || !mPISet) {
-    mPI = blocks[0];
-    if (!mPISet) {
-      mPSNameState = 0;
-      mRadiotextState = 0;
-      memset(mTempPSName, 0, sizeof(mTempPSName));
-      memset(mTempRadiotext, 0, sizeof(mTempRadiotext));
-    }
-    mPISet = true;
-
-    DispatchFMRadioEventToMainThread(PIChanged);
-  }
-  mLastPI = blocks[0];
-
-  /* PTY is also updated using the same logic as PI */
-  uint16_t pty = (blocks[1] >> 5) & 0x1F;
-  if ((mPTY != pty && pty == mLastPTY) || !mPTYSet) {
-    mPTY = pty;
-    mPTYSet = true;
-
-    DispatchFMRadioEventToMainThread(PTYChanged);
-  }
-  mLastPTY = pty;
-
-  uint16_t grouptype = blocks[1] >> 11;
-  switch (grouptype) {
-    case 0: // 0a
-    case 1: // 0b
-    {
-      uint16_t segmentAddr = (blocks[1] & 0x3);
-      // mPSNameState is a bitmask that lets us ensure all segments
-      // are received before updating the PS name.
-      if (!segmentAddr) {
-        mPSNameState = 1;
-      } else {
-        mPSNameState |= 1 << segmentAddr;
-      }
-
-      uint16_t offset = segmentAddr << 1;
-      mTempPSName[offset] = sRDSToUnicodeMap[blocks[3] >> 8];
-      mTempPSName[offset + 1] = sRDSToUnicodeMap[blocks[3] & 0xFF];
-
-      if (mPSNameState != 0xF) {
-        break;
-      }
-
-      mPSNameState = 0;
-      if (memcmp(mTempPSName, mPSName, sizeof(mTempPSName))) {
-        MutexAutoLock lock(mRDSLock);
-        mPSNameSet = true;
-        memcpy(mPSName, mTempPSName, sizeof(mTempPSName));
-
-        DispatchFMRadioEventToMainThread(PSChanged);
-      }
-      break;
-    }
-    case 4: // 2a Radiotext
-    {
-      uint16_t segmentAddr = (blocks[1] & 0xF);
-      bool textAB = blocks[1] & (1 << 5);
-      if (textAB != mRadiotextAB) {
-        mRadiotextState = 0;
-        memset(mTempRadiotext, 0, sizeof(mTempRadiotext));
-        mRadiotextAB = textAB;
-        MutexAutoLock lock(mRDSLock);
-        memset(mRadiotext, 0, sizeof(mRadiotext));
-
-        DispatchFMRadioEventToMainThread(RadiotextChanged);
-      }
-
-      // mRadiotextState is a bitmask that lets us ensure all segments
-      // are received before updating the radiotext.
-      if (!segmentAddr) {
-        mRadiotextState = 1;
-      } else {
-        mRadiotextState |= 1 << segmentAddr;
-      }
-
-      uint8_t segment[4];
-      segment[0] = blocks[2] >> 8;
-      segment[1] = blocks[2] & 0xFF;
-      segment[2] = blocks[3] >> 8;
-      segment[3] = blocks[3] & 0xFF;
-
-      uint16_t offset = segmentAddr << 2;
-      bool done = false;
-      for (int i = 0; i < 4; i++) {
-        if (segment[i] == '\r') {
-          mTempRadiotext[offset++] = 0;
-          done = true;
-        } else {
-          mTempRadiotext[offset++] = sRDSToUnicodeMap[segment[i]];
-        }
-      }
-      if (offset == 64) {
-        done = true;
-      }
-
-      if (!done ||
-          (mRadiotextState + 1) != (1 << ((blocks[1] & 0xF) + 1)) ||
-          !memcmp(mTempRadiotext, mRadiotext, sizeof(mTempRadiotext))) {
-        break;
-      }
-
-      MutexAutoLock lock(mRDSLock);
-      mRadiotextSet = true;
-      memcpy(mRadiotext, mTempRadiotext, sizeof(mTempRadiotext));
-
-      DispatchFMRadioEventToMainThread(RadiotextChanged);
-      break;
-    }
-    case 5: // 2b Radiotext
-    {
-      uint16_t segmentAddr = (blocks[1] & 0xF);
-      bool textAB = blocks[1] & (1 << 5);
-      if (textAB != mRadiotextAB) {
-        mRadiotextState = 0;
-        memset(mTempRadiotext, 0, sizeof(mTempRadiotext));
-        mRadiotextAB = textAB;
-        MutexAutoLock lock(mRDSLock);
-        memset(mRadiotext, 0, sizeof(mRadiotext));
-
-        DispatchFMRadioEventToMainThread(RadiotextChanged);
-      }
-
-      if (!segmentAddr) {
-        mRadiotextState = 1;
-      } else {
-        mRadiotextState |= 1 << segmentAddr;
-      }
-      uint8_t segment[2];
-      segment[0] = blocks[3] >> 8;
-      segment[1] = blocks[3] & 0xFF;
-
-      uint16_t offset = segmentAddr << 1;
-      bool done = false;
-      for (int i = 0; i < 2; i++) {
-        if (segment[i] == '\r') {
-          mTempRadiotext[offset++] = 0;
-          done = true;
-        } else {
-          mTempRadiotext[offset++] = sRDSToUnicodeMap[segment[i]];
-        }
-      }
-      if (offset == 32) {
-        done = true;
-      }
-
-      if (!done ||
-          (mRadiotextState + 1) != (1 << ((blocks[1] & 0xF) + 1)) ||
-          !memcmp(mTempRadiotext, mRadiotext, sizeof(mTempRadiotext))) {
-        break;
-      }
-
-      MutexAutoLock lock(mRDSLock);
-      mRadiotextSet = true;
-      memcpy(mRadiotext, mTempRadiotext, sizeof(mTempRadiotext));
-
-      DispatchFMRadioEventToMainThread(RadiotextChanged);
-      break;
-    }
-    case 31: // 15b Fast Tuning and Switching
-    {
-      uint16_t secondPty = (blocks[3] >> 5) & 0x1F;
-      if (pty == mPTY || pty != secondPty) {
-        break;
-      }
-      mPTY = pty;
-
-      DispatchFMRadioEventToMainThread(PTYChanged);
-      break;
-    }
-  }
-
-  // Only notify users of raw RDS groups that they're interested in.
-  // We always receive DOM_PARSED_RDS_GROUPS when RDS is enabled.
-  if (!(mRDSGroupMask & (1 << grouptype))) {
-    return;
-  }
-
-  uint64_t newgroup = blocks[0];
-  newgroup <<= 16;
-  newgroup |= blocks[1];
-  newgroup <<= 16;
-  newgroup |= blocks[2];
-  newgroup <<= 16;
-  newgroup |= blocks[3];
-
-  MutexAutoLock lock(mRDSLock);
-  mRDSGroup = newgroup;
-  mRDSGroupSet = true;
-
-  DispatchFMRadioEventToMainThread(NewRDSGroup);
-}
-
-void
-FMRadioService::UpdatePowerState()
-{
-  bool enabled = hal::IsFMRadioOn();
-  if (enabled != mEnabled) {
-    mEnabled = enabled;
-    NotifyFMRadioEvent(EnabledChanged);
-  }
-}
-
-void
-FMRadioService::UpdateFrequency()
-{
-  int32_t frequency = hal::GetFMRadioFrequency();
-  if (mPendingFrequencyInKHz != frequency) {
-    mPendingFrequencyInKHz = frequency;
-    NotifyFMRadioEvent(FrequencyChanged);
-    mPISet = false;
-    mPTYSet = false;
-    memset(mPSName, 0, sizeof(mPSName));
-    memset(mRadiotext, 0, sizeof(mRadiotext));
-    mRDSGroupSet = false;
-    mPSNameSet = false;
-    mRadiotextSet = false;
-  }
-}
-
-// static
-FMRadioService*
-FMRadioService::Singleton()
-{
-  MOZ_ASSERT(XRE_IsParentProcess());
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!sFMRadioService) {
-    sFMRadioService = new FMRadioService();
-    ClearOnShutdown(&sFMRadioService);
-  }
-
-  return sFMRadioService;
-}
-
-NS_IMPL_ISUPPORTS(FMRadioService, nsIObserver)
-
-END_FMRADIO_NAMESPACE
-
deleted file mode 100644
--- a/dom/fmradio/FMRadioService.h
+++ /dev/null
@@ -1,270 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_fmradioservice_h__
-#define mozilla_dom_fmradioservice_h__
-
-#include "mozilla/dom/Nullable.h"
-#include "mozilla/dom/PFMRadioRequest.h"
-#include "FMRadioCommon.h"
-#include "mozilla/Hal.h"
-#include "mozilla/Mutex.h"
-#include "mozilla/StaticPtr.h"
-#include "mozilla/Services.h"
-#include "nsThreadUtils.h"
-#include "nsIObserver.h"
-#include "nsXULAppAPI.h"
-
-BEGIN_FMRADIO_NAMESPACE
-
-class FMRadioReplyRunnable : public Runnable
-{
-public:
-  FMRadioReplyRunnable() : mResponseType(SuccessResponse()) {}
-  virtual ~FMRadioReplyRunnable() {}
-
-  void
-  SetReply(const FMRadioResponseType& aResponseType)
-  {
-    mResponseType = aResponseType;
-  }
-
-protected:
-  FMRadioResponseType mResponseType;
-};
-
-/**
- * The FMRadio Service Interface for FMRadio.
- *
- * There are two concrete classes which implement this interface:
- *  - FMRadioService
- *    It's used in the main process, implements all the logics about FM Radio.
- *
- *  - FMRadioChild
- *    It's used in subprocess. It's a kind of proxy which just sends all
- *    the requests to main process through IPC channel.
- *
- * All the requests coming from the content page will be redirected to the
- * concrete class object.
- *
- * Consider navigator.mozFMRadio.enable(). Here is the call sequence:
- *  - OOP
- *    Child:
- *      (1) Call navigator.mozFMRadio.enable().
- *      (2) Return a DOMRequest object, and call FMRadioChild.Enable() with a
- *          FMRadioReplyRunnable object.
- *      (3) Send IPC message to main process.
- *    Parent:
- *      (4) Call FMRadioService::Enable() with a FMRadioReplyRunnable object.
- *      (5) Call hal::EnableFMRadio().
- *      (6) Notify FMRadioService object when FM radio HW is enabled.
- *      (7) Dispatch the FMRadioReplyRunnable object created in (4).
- *      (8) Send IPC message back to child process.
- *    Child:
- *      (9) Dispatch the FMRadioReplyRunnable object created in (2).
- *     (10) Fire success callback of the DOMRequest Object created in (2).
- *                     _ _ _ _ _ _ _ _ _ _ _ _ _ _
- *                    |            OOP            |
- *                    |                           |
- *   Page  FMRadio    |    FMRadioChild       IPC |    FMRadioService   Hal
- *    | (1)  |        |          |             |  |           |          |
- *    |----->|    (2) |          |             |  |           |          |
- *    |      |--------|--------->|      (3)    |  |           |          |
- *    |      |        |          |-----------> |  |   (4)     |          |
- *    |      |        |          |             |--|---------->|  (5)     |
- *    |      |        |          |             |  |           |--------->|
- *    |      |        |          |             |  |           |  (6)     |
- *    |      |        |          |             |  |   (7)     |<---------|
- *    |      |        |          |      (8)    |<-|-----------|          |
- *    |      |    (9) |          |<----------- |  |           |          |
- *    | (10) |<-------|----------|             |  |           |          |
- *    |<-----|        |          |             |  |           |          |
- *                    |                           |
- *                    |_ _ _ _ _ _ _ _ _ _ _ _ _ _|
- *  - non-OOP
- *    In non-OOP model, we don't need to send messages between processes, so
- *    the call sequences are much more simpler, it almost just follows the
- *    sequences presented in OOP model: (1) (2) (5) (6) (9) and (10).
- *
- */
-class IFMRadioService
-{
-protected:
-  virtual ~IFMRadioService() { }
-
-public:
-  virtual bool IsEnabled() const = 0;
-  virtual bool IsRDSEnabled() const = 0;
-  virtual double GetFrequency() const = 0;
-  virtual double GetFrequencyUpperBound() const = 0;
-  virtual double GetFrequencyLowerBound() const = 0;
-  virtual double GetChannelWidth() const = 0;
-  virtual Nullable<unsigned short> GetPi() const = 0;
-  virtual Nullable<uint8_t> GetPty() const = 0;
-  virtual bool GetPs(nsString& aPsname) = 0;
-  virtual bool GetRt(nsString& aRadiotext) = 0;
-  virtual bool GetRdsgroup(uint64_t& aRDSGroup) = 0;
-
-  virtual void Enable(double aFrequency, FMRadioReplyRunnable* aReplyRunnable) = 0;
-  virtual void Disable(FMRadioReplyRunnable* aReplyRunnable) = 0;
-  virtual void SetFrequency(double aFrequency, FMRadioReplyRunnable* aReplyRunnable) = 0;
-  virtual void Seek(mozilla::hal::FMRadioSeekDirection aDirection,
-                    FMRadioReplyRunnable* aReplyRunnable) = 0;
-  virtual void CancelSeek(FMRadioReplyRunnable* aReplyRunnable) = 0;
-  virtual void SetRDSGroupMask(uint32_t aRDSGroupMask) = 0;
-  virtual void EnableRDS(FMRadioReplyRunnable* aReplyRunnable) = 0;
-  virtual void DisableRDS(FMRadioReplyRunnable* aReplyRunnable) = 0;
-
-  /**
-   * Register handler to receive the FM Radio events, including:
-   *   - StateChangedEvent
-   *   - FrequencyChangedEvent
-   *
-   * Called by FMRadio and FMRadioParent.
-   */
-  virtual void AddObserver(FMRadioEventObserver* aObserver) = 0;
-  virtual void RemoveObserver(FMRadioEventObserver* aObserver) = 0;
-
-  // Enable/Disable FMRadio
-  virtual void EnableAudio(bool aAudioEnabled) = 0;
-
-  /**
-   * Static method to return the singleton instance. If it's in the child
-   * process, we will get an object of FMRadioChild.
-   */
-  static IFMRadioService* Singleton();
-};
-
-enum FMRadioState
-{
-  Disabled,
-  Disabling,
-  Enabling,
-  Enabled,
-  Seeking
-};
-
-class FMRadioService final : public IFMRadioService
-                           , public hal::FMRadioObserver
-                           , public hal::FMRadioRDSObserver
-                           , public nsIObserver
-{
-  friend class ReadAirplaneModeSettingTask;
-  friend class EnableRunnable;
-  friend class DisableRunnable;
-  friend class NotifyRunnable;
-
-public:
-  static FMRadioService* Singleton();
-
-  NS_DECL_ISUPPORTS
-
-  virtual bool IsEnabled() const override;
-  virtual bool IsRDSEnabled() const override;
-  virtual double GetFrequency() const override;
-  virtual double GetFrequencyUpperBound() const override;
-  virtual double GetFrequencyLowerBound() const override;
-  virtual double GetChannelWidth() const override;
-  virtual Nullable<unsigned short> GetPi() const override;
-  virtual Nullable<uint8_t> GetPty() const override;
-  virtual bool GetPs(nsString& aPsname) override;
-  virtual bool GetRt(nsString& aRadiotext) override;
-  virtual bool GetRdsgroup(uint64_t& aRDSGroup) override;
-
-  virtual void Enable(double aFrequency,
-                      FMRadioReplyRunnable* aReplyRunnable) override;
-  virtual void Disable(FMRadioReplyRunnable* aReplyRunnable) override;
-  virtual void SetFrequency(double aFrequency,
-                            FMRadioReplyRunnable* aReplyRunnable) override;
-  virtual void Seek(mozilla::hal::FMRadioSeekDirection aDirection,
-                    FMRadioReplyRunnable* aReplyRunnable) override;
-  virtual void CancelSeek(FMRadioReplyRunnable* aReplyRunnable) override;
-  virtual void SetRDSGroupMask(uint32_t aRDSGroupMask) override;
-  virtual void EnableRDS(FMRadioReplyRunnable* aReplyRunnable) override;
-  virtual void DisableRDS(FMRadioReplyRunnable* aReplyRunnable) override;
-
-  virtual void AddObserver(FMRadioEventObserver* aObserver) override;
-  virtual void RemoveObserver(FMRadioEventObserver* aObserver) override;
-
-  virtual void EnableAudio(bool aAudioEnabled) override;
-
-  /* FMRadioObserver */
-  void Notify(const hal::FMRadioOperationInformation& aInfo) override;
-  /* FMRadioRDSObserver */
-  void Notify(const hal::FMRadioRDSGroup& aRDSGroup) override;
-
-  void EnableFMRadio();
-  void DisableFMRadio();
-  void DispatchFMRadioEventToMainThread(enum FMRadioEventType aType);
-
-  NS_DECL_NSIOBSERVER
-
-protected:
-  FMRadioService();
-  virtual ~FMRadioService();
-
-private:
-  int32_t RoundFrequency(double aFrequencyInMHz);
-
-  void NotifyFMRadioEvent(FMRadioEventType aType);
-  void DoDisable();
-  void TransitionState(const FMRadioResponseType& aResponse, FMRadioState aState);
-  void SetState(FMRadioState aState);
-  void UpdatePowerState();
-  void UpdateFrequency();
-
-private:
-  bool mEnabled;
-
-  int32_t mPendingFrequencyInKHz;
-
-  FMRadioState mState;
-
-  bool mHasReadAirplaneModeSetting;
-  bool mAirplaneModeEnabled;
-  bool mRDSEnabled;
-
-  uint32_t mUpperBoundInKHz;
-  uint32_t mLowerBoundInKHz;
-  uint32_t mChannelWidthInKHz;
-  uint32_t mPreemphasis;
-
-  nsCOMPtr<nsIThread> mTuneThread;
-  RefPtr<FMRadioReplyRunnable> mPendingRequest;
-
-  FMRadioEventObserverList mObserverList;
-
-  static StaticRefPtr<FMRadioService> sFMRadioService;
-
-  uint32_t mRDSGroupMask;
-
-  uint16_t mLastPI;
-  uint16_t mLastPTY;
-  Atomic<uint32_t> mPI;
-  Atomic<uint32_t> mPTY;
-  Atomic<bool> mPISet;
-  Atomic<bool> mPTYSet;
-
-  /* Protects mPSName, mRadiotext, and mRDSGroup */
-  Mutex mRDSLock;
-  char16_t mPSName[9];
-  char16_t mRadiotext[65];
-  uint64_t mRDSGroup;
-
-  uint8_t mPSNameState;
-  uint16_t mRadiotextState;
-  uint16_t mTempPSName[8];
-  uint16_t mTempRadiotext[64];
-  bool mRadiotextAB;
-  bool mRDSGroupSet;
-  bool mPSNameSet;
-  bool mRadiotextSet;
-};
-
-END_FMRADIO_NAMESPACE
-
-#endif // mozilla_dom_fmradioservice_h__
-
deleted file mode 100644
--- a/dom/fmradio/ipc/FMRadioChild.cpp
+++ /dev/null
@@ -1,352 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "FMRadioChild.h"
-#include "mozilla/dom/ContentChild.h"
-#include "mozilla/dom/FMRadioRequestChild.h"
-
-using namespace mozilla::hal;
-
-BEGIN_FMRADIO_NAMESPACE
-
-StaticAutoPtr<FMRadioChild> FMRadioChild::sFMRadioChild;
-
-FMRadioChild::FMRadioChild()
-  : mEnabled(false)
-  , mRDSEnabled(false)
-  , mRDSGroupSet(false)
-  , mPSNameSet(false)
-  , mRadiotextSet(false)
-  , mFrequency(0)
-  , mRDSGroup(0)
-  , mRDSGroupMask(0)
-  , mObserverList(FMRadioEventObserverList())
-{
-  MOZ_COUNT_CTOR(FMRadioChild);
-
-  ContentChild::GetSingleton()->SendPFMRadioConstructor(this);
-
-  StatusInfo statusInfo;
-  SendGetStatusInfo(&statusInfo);
-
-  mEnabled = statusInfo.enabled();
-  mFrequency = statusInfo.frequency();
-  mUpperBound = statusInfo.upperBound();
-  mLowerBound= statusInfo.lowerBound();
-  mChannelWidth = statusInfo.channelWidth();
-}
-
-FMRadioChild::~FMRadioChild()
-{
-  MOZ_COUNT_DTOR(FMRadioChild);
-}
-
-bool
-FMRadioChild::IsEnabled() const
-{
-  return mEnabled;
-}
-
-bool
-FMRadioChild::IsRDSEnabled() const
-{
-  return mRDSEnabled;
-}
-
-double
-FMRadioChild::GetFrequency() const
-{
-  return mFrequency;
-}
-
-
-double
-FMRadioChild::GetFrequencyUpperBound() const
-{
-  return mUpperBound;
-}
-
-double
-FMRadioChild::GetFrequencyLowerBound() const
-{
-  return mLowerBound;
-}
-
-double
-FMRadioChild::GetChannelWidth() const
-{
-  return mChannelWidth;
-}
-
-Nullable<unsigned short>
-FMRadioChild::GetPi() const
-{
-  return mPI;
-}
-
-Nullable<uint8_t>
-FMRadioChild::GetPty() const
-{
-  return mPTY;
-}
-
-bool
-FMRadioChild::GetPs(nsString& aPSName)
-{
-  if (mPSNameSet) {
-    aPSName = mPSName;
-  }
-  return mPSNameSet;
-}
-
-bool
-FMRadioChild::GetRt(nsString& aRadiotext)
-{
-  if (mRadiotextSet) {
-    aRadiotext = mRadiotext;
-  }
-  return mRadiotextSet;
-}
-
-bool
-FMRadioChild::GetRdsgroup(uint64_t& aRDSGroup)
-{
-  aRDSGroup = mRDSGroup;
-  return mRDSGroupSet;
-}
-
-void
-FMRadioChild::Enable(double aFrequency, FMRadioReplyRunnable* aReplyRunnable)
-{
-  SendRequest(aReplyRunnable, EnableRequestArgs(aFrequency));
-}
-
-void
-FMRadioChild::Disable(FMRadioReplyRunnable* aReplyRunnable)
-{
-  SendRequest(aReplyRunnable, DisableRequestArgs());
-}
-
-void
-FMRadioChild::SetFrequency(double aFrequency,
-                           FMRadioReplyRunnable* aReplyRunnable)
-{
-  SendRequest(aReplyRunnable, SetFrequencyRequestArgs(aFrequency));
-}
-
-void
-FMRadioChild::Seek(FMRadioSeekDirection aDirection,
-                   FMRadioReplyRunnable* aReplyRunnable)
-{
-  SendRequest(aReplyRunnable, SeekRequestArgs(aDirection));
-}
-
-void
-FMRadioChild::CancelSeek(FMRadioReplyRunnable* aReplyRunnable)
-{
-  SendRequest(aReplyRunnable, CancelSeekRequestArgs());
-}
-
-void
-FMRadioChild::SetRDSGroupMask(uint32_t aRDSGroupMask)
-{
-  mRDSGroupMask = aRDSGroupMask;
-  SendSetRDSGroupMask(aRDSGroupMask);
-}
-
-void
-FMRadioChild::EnableRDS(FMRadioReplyRunnable* aReplyRunnable)
-{
-  SendRequest(aReplyRunnable, EnableRDSArgs());
-}
-
-void
-FMRadioChild::DisableRDS(FMRadioReplyRunnable* aReplyRunnable)
-{
-  SendRequest(aReplyRunnable, DisableRDSArgs());
-}
-
-inline void
-FMRadioChild::NotifyFMRadioEvent(FMRadioEventType aType)
-{
-  mObserverList.Broadcast(aType);
-}
-
-void
-FMRadioChild::AddObserver(FMRadioEventObserver* aObserver)
-{
-  mObserverList.AddObserver(aObserver);
-}
-
-void
-FMRadioChild::RemoveObserver(FMRadioEventObserver* aObserver)
-{
-  mObserverList.RemoveObserver(aObserver);
-}
-
-void
-FMRadioChild::SendRequest(FMRadioReplyRunnable* aReplyRunnable,
-                          FMRadioRequestArgs aArgs)
-{
-  PFMRadioRequestChild* childRequest = new FMRadioRequestChild(aReplyRunnable);
-  SendPFMRadioRequestConstructor(childRequest, aArgs);
-}
-
-bool
-FMRadioChild::RecvNotifyFrequencyChanged(const double& aFrequency)
-{
-  mFrequency = aFrequency;
-  NotifyFMRadioEvent(FrequencyChanged);
-
-  if (!mPI.IsNull()) {
-    mPI.SetNull();
-    NotifyFMRadioEvent(PIChanged);
-  }
-  if (!mPTY.IsNull()) {
-    mPTY.SetNull();
-    NotifyFMRadioEvent(PTYChanged);
-  }
-  if (mPSNameSet) {
-    mPSNameSet = false;
-    mPSName.Truncate();
-    NotifyFMRadioEvent(PSChanged);
-  }
-  if (mRadiotextSet) {
-    mRadiotextSet = false;
-    mRadiotext.Truncate();
-    NotifyFMRadioEvent(RadiotextChanged);
-  }
-  mRDSGroupSet = false;
-  return true;
-}
-
-bool
-FMRadioChild::RecvNotifyEnabledChanged(const bool& aEnabled,
-                                       const double& aFrequency)
-{
-  mEnabled = aEnabled;
-  mFrequency = aFrequency;
-  if (!mEnabled) {
-    mPI.SetNull();
-    mPTY.SetNull();
-    mPSName.Truncate();
-    mRadiotext.Truncate();
-    mRDSGroupSet = false;
-    mPSNameSet = false;
-    mRadiotextSet = false;
-  }
-  NotifyFMRadioEvent(EnabledChanged);
-  return true;
-}
-
-bool
-FMRadioChild::RecvNotifyRDSEnabledChanged(const bool& aEnabled)
-{
-  mRDSEnabled = aEnabled;
-  NotifyFMRadioEvent(RDSEnabledChanged);
-  return true;
-}
-
-bool
-FMRadioChild::RecvNotifyPIChanged(const bool& aValid,
-                                  const uint16_t& aCode)
-{
-  if (aValid) {
-    mPI.SetValue(aCode);
-  } else {
-    mPI.SetNull();
-  }
-  NotifyFMRadioEvent(PIChanged);
-  return true;
-}
-
-bool
-FMRadioChild::RecvNotifyPTYChanged(const bool& aValid,
-                                   const uint8_t& aPTY)
-{
-  if (aValid) {
-    mPTY.SetValue(aPTY);
-  } else {
-    mPTY.SetNull();
-  }
-  NotifyFMRadioEvent(PTYChanged);
-  return true;
-}
-
-bool
-FMRadioChild::RecvNotifyPSChanged(const nsString& aPSName)
-{
-  mPSNameSet = true;
-  mPSName = aPSName;
-  NotifyFMRadioEvent(PSChanged);
-  return true;
-}
-
-bool
-FMRadioChild::RecvNotifyRadiotextChanged(const nsString& aRadiotext)
-{
-  mRadiotextSet = true;
-  mRadiotext = aRadiotext;
-  NotifyFMRadioEvent(RadiotextChanged);
-  return true;
-}
-
-bool
-FMRadioChild::RecvNotifyNewRDSGroup(const uint64_t& aGroup)
-{
-  uint16_t grouptype = (aGroup >> 43) & 0x1F;
-  if (!(mRDSGroupMask & (1 << grouptype))) {
-    return true;
-  }
-
-  mRDSGroupSet = true;
-  mRDSGroup = aGroup;
-  NotifyFMRadioEvent(NewRDSGroup);
-  return true;
-}
-
-bool
-FMRadioChild::Recv__delete__()
-{
-  return true;
-}
-
-PFMRadioRequestChild*
-FMRadioChild::AllocPFMRadioRequestChild(const FMRadioRequestArgs& aArgs)
-{
-  MOZ_CRASH();
-  return nullptr;
-}
-
-bool
-FMRadioChild::DeallocPFMRadioRequestChild(PFMRadioRequestChild* aActor)
-{
-  delete aActor;
-  return true;
-}
-
-void
-FMRadioChild::EnableAudio(bool aAudioEnabled)
-{
-  SendEnableAudio(aAudioEnabled);
-}
-
-// static
-FMRadioChild*
-FMRadioChild::Singleton()
-{
-  MOZ_ASSERT(!XRE_IsParentProcess());
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!sFMRadioChild) {
-    sFMRadioChild = new FMRadioChild();
-  }
-
-  return sFMRadioChild;
-}
-
-END_FMRADIO_NAMESPACE
-
deleted file mode 100644
--- a/dom/fmradio/ipc/FMRadioChild.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_fmradiochild_h__
-#define mozilla_dom_fmradiochild_h__
-
-#include "FMRadioCommon.h"
-#include "FMRadioService.h"
-#include "mozilla/dom/PFMRadioChild.h"
-#include "mozilla/StaticPtr.h"
-
-BEGIN_FMRADIO_NAMESPACE
-
-/**
- * FMRadioChild plays two roles:
- *   - Kind of proxy of FMRadioService
- *     Redirect all the requests  coming from web content to FMRadioService
- *     in parent through IPC channel.
- *   - Child Actor of PFMRadio
- *     IPC channel to transfer the requests.
- */
-class FMRadioChild final : public IFMRadioService
-                         , public PFMRadioChild
-{
-public:
-  static FMRadioChild* Singleton();
-  ~FMRadioChild();
-
-  void SendRequest(FMRadioReplyRunnable* aReplyRunnable,
-                   FMRadioRequestArgs aArgs);
-
-  /* IFMRadioService */
-  virtual bool IsEnabled() const override;
-  virtual bool IsRDSEnabled() const override;
-  virtual double GetFrequency() const override;
-  virtual double GetFrequencyUpperBound() const override;
-  virtual double GetFrequencyLowerBound() const override;
-  virtual double GetChannelWidth() const override;
-  virtual Nullable<unsigned short> GetPi() const override;
-  virtual Nullable<uint8_t> GetPty() const override;
-  virtual bool GetPs(nsString& aPSName) override;
-  virtual bool GetRt(nsString& aRadiotext) override;
-  virtual bool GetRdsgroup(uint64_t& aRDSGroup) override;
-
-  virtual void Enable(double aFrequency,
-                      FMRadioReplyRunnable* aReplyRunnable) override;
-  virtual void Disable(FMRadioReplyRunnable* aReplyRunnable) override;
-  virtual void SetFrequency(double frequency,
-                            FMRadioReplyRunnable* aReplyRunnable) override;
-  virtual void Seek(mozilla::hal::FMRadioSeekDirection aDirection,
-                    FMRadioReplyRunnable* aReplyRunnable) override;
-  virtual void CancelSeek(FMRadioReplyRunnable* aReplyRunnable) override;
-  virtual void SetRDSGroupMask(uint32_t aRDSGroupMask) override;
-  virtual void EnableRDS(FMRadioReplyRunnable* aReplyRunnable) override;
-  virtual void DisableRDS(FMRadioReplyRunnable* aReplyRunnable) override;
-
-  virtual void AddObserver(FMRadioEventObserver* aObserver) override;
-  virtual void RemoveObserver(FMRadioEventObserver* aObserver) override;
-
-  virtual void EnableAudio(bool aAudioEnabled) override;
-
-  /* PFMRadioChild */
-  virtual bool
-  Recv__delete__() override;
-
-  virtual bool
-  RecvNotifyFrequencyChanged(const double& aFrequency) override;
-
-  virtual bool
-  RecvNotifyEnabledChanged(const bool& aEnabled,
-                           const double& aFrequency) override;
-
-  virtual bool
-  RecvNotifyRDSEnabledChanged(const bool& aEnabled) override;
-
-  virtual bool
-  RecvNotifyPIChanged(const bool& aValid,
-                      const uint16_t& aCode) override;
-
-  virtual bool
-  RecvNotifyPTYChanged(const bool& aValid,
-                       const uint8_t& aPTY) override;
-
-  virtual bool
-  RecvNotifyPSChanged(const nsString& aPSName) override;
-
-  virtual bool
-  RecvNotifyRadiotextChanged(const nsString& aRadiotext) override;
-
-  virtual bool
-  RecvNotifyNewRDSGroup(const uint64_t& aGroup) override;
-
-  virtual PFMRadioRequestChild*
-  AllocPFMRadioRequestChild(const FMRadioRequestArgs& aArgs) override;
-
-  virtual bool
-  DeallocPFMRadioRequestChild(PFMRadioRequestChild* aActor) override;
-
-private:
-  FMRadioChild();
-
-  void Init();
-
-  inline void NotifyFMRadioEvent(FMRadioEventType aType);
-
-  bool mEnabled;
-  bool mRDSEnabled;
-  bool mRDSGroupSet;
-  bool mPSNameSet;
-  bool mRadiotextSet;
-  double mFrequency;
-  double mUpperBound;
-  double mLowerBound;
-  double mChannelWidth;
-  Nullable<unsigned short> mPI;
-  Nullable<uint8_t> mPTY;
-  nsAutoString mPSName;
-  nsAutoString mRadiotext;
-  uint64_t mRDSGroup;
-  uint32_t mRDSGroupMask;
-
-  FMRadioEventObserverList mObserverList;
-
-private:
-  static StaticAutoPtr<FMRadioChild> sFMRadioChild;
-};
-
-END_FMRADIO_NAMESPACE
-
-#endif // mozilla_dom_fmradiochild_h__
-
deleted file mode 100644
--- a/dom/fmradio/ipc/FMRadioParent.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "FMRadioParent.h"
-#include "mozilla/Unused.h"
-#include "mozilla/dom/ContentParent.h"
-#include "mozilla/DebugOnly.h"
-#include "FMRadioRequestParent.h"
-#include "FMRadioService.h"
-
-BEGIN_FMRADIO_NAMESPACE
-
-FMRadioParent::FMRadioParent()
-{
-  MOZ_COUNT_CTOR(FMRadioParent);
-
-  IFMRadioService::Singleton()->AddObserver(this);
-}
-
-FMRadioParent::~FMRadioParent()
-{
-  MOZ_COUNT_DTOR(FMRadioParent);
-
-  IFMRadioService::Singleton()->RemoveObserver(this);
-}
-
-void
-FMRadioParent::ActorDestroy(ActorDestroyReason aWhy)
-{
-  // Implement me! Bug 1005146
-}
-
-bool
-FMRadioParent::RecvGetStatusInfo(StatusInfo* aStatusInfo)
-{
-  aStatusInfo->enabled() = IFMRadioService::Singleton()->IsEnabled();
-  aStatusInfo->frequency() = IFMRadioService::Singleton()->GetFrequency();
-  aStatusInfo->upperBound() =
-    IFMRadioService::Singleton()->GetFrequencyUpperBound();
-  aStatusInfo->lowerBound() =
-    IFMRadioService::Singleton()->GetFrequencyLowerBound();
-  aStatusInfo->channelWidth() =
-    IFMRadioService::Singleton()->GetChannelWidth();
-  return true;
-}
-
-PFMRadioRequestParent*
-FMRadioParent::AllocPFMRadioRequestParent(const FMRadioRequestArgs& aArgs)
-{
-  RefPtr<FMRadioRequestParent> requestParent = new FMRadioRequestParent();
-
-  switch (aArgs.type()) {
-    case FMRadioRequestArgs::TEnableRequestArgs:
-      IFMRadioService::Singleton()->Enable(
-        aArgs.get_EnableRequestArgs().frequency(), requestParent);
-      break;
-    case FMRadioRequestArgs::TDisableRequestArgs:
-      IFMRadioService::Singleton()->Disable(requestParent);
-      break;
-    case FMRadioRequestArgs::TSetFrequencyRequestArgs:
-      IFMRadioService::Singleton()->SetFrequency(
-        aArgs.get_SetFrequencyRequestArgs().frequency(), requestParent);
-      break;
-    case FMRadioRequestArgs::TSeekRequestArgs:
-      IFMRadioService::Singleton()->Seek(
-        aArgs.get_SeekRequestArgs().direction(), requestParent);
-      break;
-    case FMRadioRequestArgs::TCancelSeekRequestArgs:
-      IFMRadioService::Singleton()->CancelSeek(requestParent);
-      break;
-    case FMRadioRequestArgs::TEnableRDSArgs:
-      IFMRadioService::Singleton()->EnableRDS(requestParent);
-      break;
-    case FMRadioRequestArgs::TDisableRDSArgs:
-      IFMRadioService::Singleton()->DisableRDS(requestParent);
-      break;
-    default:
-      MOZ_CRASH();
-  }
-
-  // Balanced in DeallocPFMRadioRequestParent
-  return requestParent.forget().take();
-}
-
-bool
-FMRadioParent::DeallocPFMRadioRequestParent(PFMRadioRequestParent* aActor)
-{
-  FMRadioRequestParent* parent = static_cast<FMRadioRequestParent*>(aActor);
-  NS_RELEASE(parent);
-  return true;
-}
-
-void
-FMRadioParent::Notify(const FMRadioEventType& aType)
-{
-  switch (aType) {
-    case FrequencyChanged:
-      Unused << SendNotifyFrequencyChanged(
-        IFMRadioService::Singleton()->GetFrequency());
-      break;
-    case EnabledChanged:
-      Unused << SendNotifyEnabledChanged(
-        IFMRadioService::Singleton()->IsEnabled(),
-        IFMRadioService::Singleton()->GetFrequency());
-      break;
-    case RDSEnabledChanged:
-      Unused << SendNotifyRDSEnabledChanged(
-        IFMRadioService::Singleton()->IsRDSEnabled());
-      break;
-    case PIChanged: {
-      Nullable<unsigned short> pi =
-        IFMRadioService::Singleton()->GetPi();
-      Unused << SendNotifyPIChanged(!pi.IsNull(),
-                                    pi.IsNull() ? 0 : pi.Value());
-      break;
-    }
-    case PTYChanged: {
-      Nullable<uint8_t> pty = IFMRadioService::Singleton()->GetPty();
-      Unused << SendNotifyPTYChanged(!pty.IsNull(),
-                                     pty.IsNull() ? 0 : pty.Value());
-      break;
-    }
-    case PSChanged: {
-      nsAutoString psname;
-      IFMRadioService::Singleton()->GetPs(psname);
-      Unused << SendNotifyPSChanged(psname);
-      break;
-    }
-    case RadiotextChanged: {
-      nsAutoString radiotext;
-      IFMRadioService::Singleton()->GetRt(radiotext);
-      Unused << SendNotifyRadiotextChanged(radiotext);
-      break;
-    }
-    case NewRDSGroup: {
-      uint64_t group;
-      DebugOnly<bool> rdsgroupset =
-        IFMRadioService::Singleton()->GetRdsgroup(group);
-      MOZ_ASSERT(rdsgroupset);
-      Unused << SendNotifyNewRDSGroup(group);
-      break;
-    }
-    default:
-      NS_RUNTIMEABORT("not reached");
-      break;
-  }
-}
-
-bool
-FMRadioParent::RecvEnableAudio(const bool& aAudioEnabled)
-{
-  IFMRadioService::Singleton()->EnableAudio(aAudioEnabled);
-  return true;
-}
-
-bool
-FMRadioParent::RecvSetRDSGroupMask(const uint32_t& aRDSGroupMask)
-{
-  IFMRadioService::Singleton()->SetRDSGroupMask(aRDSGroupMask);
-  return true;
-}
-
-END_FMRADIO_NAMESPACE
-
deleted file mode 100644
--- a/dom/fmradio/ipc/FMRadioParent.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_fmradioparent_h__
-#define mozilla_dom_fmradioparent_h__
-
-#include "FMRadioCommon.h"
-#include "mozilla/dom/PFMRadioParent.h"
-#include "mozilla/HalTypes.h"
-
-BEGIN_FMRADIO_NAMESPACE
-
-class PFMRadioRequestParent;
-
-class FMRadioParent final : public PFMRadioParent
-                          , public FMRadioEventObserver
-{
-public:
-  FMRadioParent();
-  ~FMRadioParent();
-
-  virtual void
-  ActorDestroy(ActorDestroyReason aWhy) override;
-
-  virtual bool
-  RecvGetStatusInfo(StatusInfo* aStatusInfo) override;
-
-  virtual PFMRadioRequestParent*
-  AllocPFMRadioRequestParent(const FMRadioRequestArgs& aArgs) override;
-
-  virtual bool
-  DeallocPFMRadioRequestParent(PFMRadioRequestParent* aActor) override;
-
-  /* FMRadioEventObserver */
-  virtual void Notify(const FMRadioEventType& aType) override;
-
-  virtual bool
-  RecvEnableAudio(const bool& aAudioEnabled) override;
-
-  virtual bool
-  RecvSetRDSGroupMask(const uint32_t& aRDSGroupMask) override;
-};
-
-END_FMRADIO_NAMESPACE
-
-#endif // mozilla_dom_fmradioparent_h__
-
deleted file mode 100644
--- a/dom/fmradio/ipc/FMRadioRequestChild.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "mozilla/dom/PFMRadioRequestChild.h"
-#include "FMRadioRequestChild.h"
-#include "FMRadioService.h"
-
-BEGIN_FMRADIO_NAMESPACE
-
-FMRadioRequestChild::FMRadioRequestChild(FMRadioReplyRunnable* aReplyRunnable)
-  : mReplyRunnable(aReplyRunnable)
-{
-  MOZ_COUNT_CTOR(FMRadioRequestChild);
-}
-
-FMRadioRequestChild::~FMRadioRequestChild()
-{
-  MOZ_COUNT_DTOR(FMRadioRequestChild);
-}
-
-bool
-FMRadioRequestChild::Recv__delete__(const FMRadioResponseType& aType)
-{
-  mReplyRunnable->SetReply(aType);
-  NS_DispatchToMainThread(mReplyRunnable);
-
-  return true;
-}
-
-END_FMRADIO_NAMESPACE
-
deleted file mode 100644
--- a/dom/fmradio/ipc/FMRadioRequestChild.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_fmradiorequestchild_h__
-#define mozilla_dom_fmradiorequestchild_h__
-
-#include "FMRadioCommon.h"
-#include "mozilla/dom/PFMRadioRequestChild.h"
-#include "DOMRequest.h"
-
-BEGIN_FMRADIO_NAMESPACE
-
-class FMRadioReplyRunnable;
-
-class FMRadioRequestChild final : public PFMRadioRequestChild
-{
-public:
-  FMRadioRequestChild(FMRadioReplyRunnable* aReplyRunnable);
-  ~FMRadioRequestChild();
-
-  virtual bool
-  Recv__delete__(const FMRadioResponseType& aResponse) override;
-
-private:
-  RefPtr<FMRadioReplyRunnable> mReplyRunnable;
-};
-
-END_FMRADIO_NAMESPACE
-
-#endif // mozilla_dom_fmradiorequestchild_h__
-
deleted file mode 100644
--- a/dom/fmradio/ipc/FMRadioRequestParent.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "FMRadioRequestParent.h"
-#include "FMRadioService.h"
-#include "mozilla/Unused.h"
-#include "mozilla/dom/PFMRadio.h"
-
-BEGIN_FMRADIO_NAMESPACE
-
-FMRadioRequestParent::FMRadioRequestParent()
-  : mActorDestroyed(false)
-{
-  MOZ_COUNT_CTOR(FMRadioRequestParent);
-}
-
-FMRadioRequestParent::~FMRadioRequestParent()
-{
-  MOZ_COUNT_DTOR(FMRadioRequestParent);
-}
-
-void
-FMRadioRequestParent::ActorDestroy(ActorDestroyReason aWhy)
-{
-  mActorDestroyed = true;
-}
-
-nsresult
-FMRadioRequestParent::Run()
-{
-  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
-
-  if (!mActorDestroyed) {
-    Unused << Send__delete__(this, mResponseType);
-  }
-
-  return NS_OK;
-}
-
-END_FMRADIO_NAMESPACE
-
deleted file mode 100644
--- a/dom/fmradio/ipc/FMRadioRequestParent.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_fmradiorequestparent_h__
-#define mozilla_dom_fmradiorequestparent_h__
-
-#include "FMRadioCommon.h"
-#include "mozilla/dom/PFMRadioRequestParent.h"
-#include "FMRadioService.h"
-
-BEGIN_FMRADIO_NAMESPACE
-
-class FMRadioRequestParent final : public PFMRadioRequestParent
-                                 , public FMRadioReplyRunnable
-{
-public:
-  FMRadioRequestParent();
-  ~FMRadioRequestParent();
-
-  virtual void ActorDestroy(ActorDestroyReason aWhy) override;
-
-  NS_IMETHOD Run();
-
-private:
-  bool mActorDestroyed;
-};
-
-END_FMRADIO_NAMESPACE
-
-#endif // mozilla_dom_fmradiorequestparent_h__
-
deleted file mode 100644
--- a/dom/fmradio/ipc/PFMRadio.ipdl
+++ /dev/null
@@ -1,137 +0,0 @@
-/* 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 protocol PContent;
-include protocol PFMRadioRequest;
-
-using mozilla::hal::FMRadioSeekDirection from "mozilla/HalTypes.h";
-
-namespace mozilla {
-namespace dom {
-
-struct EnableRequestArgs
-{
-  double frequency;
-};
-
-struct DisableRequestArgs
-{
-};
-
-struct SetFrequencyRequestArgs
-{
-  double frequency;
-};
-
-struct SeekRequestArgs
-{
-  FMRadioSeekDirection direction;
-};
-
-struct CancelSeekRequestArgs
-{
-};
-
-struct EnableRDSArgs
-{
-};
-
-struct DisableRDSArgs
-{
-};
-
-union FMRadioRequestArgs
-{
-  EnableRequestArgs;
-  DisableRequestArgs;
-  SetFrequencyRequestArgs;
-  SeekRequestArgs;
-  CancelSeekRequestArgs;
-  EnableRDSArgs;
-  DisableRDSArgs;
-};
-
-struct StatusInfo
-{
-  bool enabled;
-  double frequency;
-  double upperBound;
-  double lowerBound;
-  double channelWidth;
-};
-
-sync protocol PFMRadio
-{
-  manager PContent;
-  manages PFMRadioRequest;
-
-child:
-  /**
-   * Sent when the frequency is changed.
-   */
-  async NotifyFrequencyChanged(double frequency);
-  /**
-   * Sent when the power state of FM radio HW is changed.
-   */
-  async NotifyEnabledChanged(bool enabled, double frequency);
-  /**
-   * Sent when RDS is enabled or disabled.
-   */
-  async NotifyRDSEnabledChanged(bool enabled);
-  /**
-   * Sent when we have a new PI code.
-   */
-  async NotifyPIChanged(bool valid, uint16_t code);
-  /**
-   * Sent when we have a new PTY
-   */
-  async NotifyPTYChanged(bool valid, uint8_t pty);
-  /**
-   * Sent when we have a new PS name.
-   */
-  async NotifyPSChanged(nsString psname);
-  /**
-   * Sent when we have new radiotext.
-   */
-  async NotifyRadiotextChanged(nsString radiotext);
-  /**
-   * Sent when a full RDS group is received.
-   */
-  async NotifyNewRDSGroup(uint64_t data);
-
-  async __delete__();
-
-parent:
-  /**
-   * Get the current status infomation of FM radio HW synchronously.
-   * Sent when the singleton object of FMRadioChild is initialized.
-   */
-  sync GetStatusInfo() returns (StatusInfo info);
-
-  /**
-   * Send request to parent process to operate the FM radio HW.
-   *
-   * We don't have separate Enable/SetFrequency/etc. methods instead here,
-   * because we can leverage the IPC messaging mechanism to manage the mapping
-   * of the asynchronous request and the DOMRequest we returned to the caller
-   * on web content, otherwise, we have to do the mapping stuff manually which
-   * is more error prone.
-   */
-  async PFMRadioRequest(FMRadioRequestArgs requestType);
-
-  /**
-   * Enable/Disable audio
-   */
-  async EnableAudio(bool audioEnabled);
-
-  /**
-   * Set RDS group mask
-   */
-  async SetRDSGroupMask(uint32_t groupMask);
-};
-
-} // namespace dom
-} // namespace mozilla
-
deleted file mode 100644
--- a/dom/fmradio/ipc/PFMRadioRequest.ipdl
+++ /dev/null
@@ -1,43 +0,0 @@
-/* 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 protocol PFMRadio;
-
-namespace mozilla {
-namespace dom {
-
-struct ErrorResponse
-{
-  nsString error;
-};
-
-struct SuccessResponse
-{
-};
-
-union FMRadioResponseType
-{
-  ErrorResponse;
-  SuccessResponse;
-};
-
-/**
- * The protocol is used for sending asynchronous operation requests of
- * FM radio HW from child to parent, and the type of the request is defined in
- * FMRadioRequestArgs.
- *
- * When the request completed, the result, i.e. FMRadioResponseType, will be
- * sent back to child from parent in the `__delete__` message.
- */
-async protocol PFMRadioRequest
-{
-  manager PFMRadio;
-
-child:
-  async __delete__(FMRadioResponseType response);
-};
-
-} // namespace dom
-} // namespace mozilla
-
deleted file mode 100644
--- a/dom/fmradio/ipc/moz.build
+++ /dev/null
@@ -1,31 +0,0 @@
-# -*- Mode: python; 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/.
-
-EXPORTS.mozilla.dom += [
-    'FMRadioChild.h',
-    'FMRadioParent.h',
-    'FMRadioRequestChild.h',
-    'FMRadioRequestParent.h',
-]
-
-UNIFIED_SOURCES += [
-    'FMRadioChild.cpp',
-    'FMRadioParent.cpp',
-    'FMRadioRequestChild.cpp',
-    'FMRadioRequestParent.cpp',
-]
-
-LOCAL_INCLUDES += [
-    '/dom/base',
-]
-
-include('/ipc/chromium/chromium-config.mozbuild')
-
-FINAL_LIBRARY = 'xul'
-
-LOCAL_INCLUDES += [
-    '/dom/fmradio',
-]
deleted file mode 100644
--- a/dom/fmradio/moz.build
+++ /dev/null
@@ -1,34 +0,0 @@
-# -*- Mode: python; 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_B2G_FM']:
-    DIRS += [
-        'ipc',
-    ]
-
-    EXPORTS.mozilla.dom += [
-        'FMRadio.h',
-        'FMRadioCommon.h',
-        'FMRadioService.h',
-    ]
-
-    UNIFIED_SOURCES += [
-        'FMRadio.cpp',
-        'FMRadioService.cpp',
-    ]
-
-    FINAL_LIBRARY = 'xul'
-
-IPDL_SOURCES += [
-    'ipc/PFMRadio.ipdl',
-    'ipc/PFMRadioRequest.ipdl',
-]
-
-LOCAL_INCLUDES += [
-    '../base',
-    '../system/gonk',
-]
-include('/ipc/chromium/chromium-config.mozbuild')
deleted file mode 100644
--- a/dom/fmradio/test/marionette/manifest.ini
+++ /dev/null
@@ -1,11 +0,0 @@
-[DEFAULT]
-run-if = buildapp == 'b2g'
-
-[test_enable_disable.js]
-[test_set_frequency.js]
-[test_cancel_seek.js]
-[test_one_seek_at_once.js]
-[test_seek_up_and_down.js]
-[test_bug862672.js]
-[test_bug876597.js]
-
deleted file mode 100644
--- a/dom/fmradio/test/marionette/test_bug862672.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-MARIONETTE_TIMEOUT = 10000;
-
-SpecialPowers.addPermission("fmradio", true, document);
-
-var FMRadio = window.navigator.mozFMRadio;
-
-function verifyInitialState() {
-  log("Verifying initial state.");
-  ok(FMRadio);
-  is(FMRadio.enabled, false);
-  enableThenDisable();
-}
-
-function enableThenDisable() {
-  log("Enable FM Radio and disable it immediately.");
-  var frequency = FMRadio.frequencyLowerBound + FMRadio.channelWidth;
-  var request = FMRadio.enable(frequency);
-  ok(request);
-
-  var failedToEnable = false;
-  request.onerror = function() {
-    failedToEnable = true;
-  };
-
-  var enableCompleted = false;
-  request.onsuccess = function() {
-    ok(!failedToEnable);
-    enableCompleted = true;
-  };
-
-  var disableReq = FMRadio.disable();
-  ok(disableReq);
-
-  disableReq.onsuccess = function() {
-    // There are two possibilities which depends on the system
-    // process scheduling (bug 911063 comment 0):
-    //   - enable fails
-    //   - enable's onsuccess fires before disable's onsucess
-    ok(failedToEnable || enableCompleted);
-    ok(!FMRadio.enabled);
-    finish();
-  };
-
-  disableReq.onerror = function() {
-    ok(false, "Disable request should not fail.");
-  };
-}
-
-verifyInitialState();
-
deleted file mode 100644
--- a/dom/fmradio/test/marionette/test_bug876597.js
+++ /dev/null
@@ -1,92 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-MARIONETTE_TIMEOUT = 10000;
-
-SpecialPowers.addPermission("fmradio", true, document);
-SpecialPowers.addPermission("settings-read", true, document);
-SpecialPowers.addPermission("settings-write", true, document);
-SpecialPowers.addPermission("settings-api-read", true, document);
-SpecialPowers.addPermission("settings-api-write", true, document);
-
-var FMRadio = window.navigator.mozFMRadio;
-var mozSettings = window.navigator.mozSettings;
-var KEY = "airplaneMode.enabled";
-
-function verifyInitialState() {
-  log("Verifying initial state.");
-  ok(FMRadio);
-  is(FMRadio.enabled, false);
-  ok(mozSettings);
-
-  checkAirplaneModeSettings();
-}
-
-function checkAirplaneModeSettings() {
-  log("Checking airplane mode settings");
-  let req = mozSettings.createLock().get(KEY);
-  req.onsuccess = function(event) {
-    ok(!req.result[KEY], "Airplane mode is disabled.");
-    enableFMRadio();
-  };
-
-  req.onerror = function() {
-    ok(false, "Error occurs when reading settings value.");
-    finish();
-  };
-}
-
-function enableFMRadio() {
-  log("Enable FM radio");
-  let frequency = FMRadio.frequencyLowerBound + FMRadio.channelWidth;
-  let req = FMRadio.enable(frequency);
-
-  req.onsuccess = function() {
-    enableAirplaneMode();
-  };
-
-  req.onerror = function() {
-    ok(false, "Failed to enable FM radio.");
-  };
-}
-
-function enableAirplaneMode() {
-  log("Enable airplane mode");
-  FMRadio.ondisabled = function() {
-    FMRadio.ondisabled = null;
-    enableFMRadioWithAirplaneModeEnabled();
-  };
-
-  let settings = {};
-  settings[KEY] = true;
-  mozSettings.createLock().set(settings);
-}
-
-function enableFMRadioWithAirplaneModeEnabled() {
-  log("Enable FM radio with airplane mode enabled");
-  let frequency = FMRadio.frequencyLowerBound + FMRadio.channelWidth;
-  let req = FMRadio.enable(frequency);
-  req.onerror = cleanUp();
-
-  req.onsuccess = function() {
-    ok(false, "FMRadio could be enabled when airplane mode is enabled.");
-  };
-}
-
-function cleanUp() {
-  let settings = {};
-  settings[KEY] = false;
-  let req = mozSettings.createLock().set(settings);
-
-  req.onsuccess = function() {
-    ok(!FMRadio.enabled);
-    finish();
-  };
-
-  req.onerror = function() {
-    ok(false, "Error occurs when setting value");
-  };
-}
-
-verifyInitialState();
-
deleted file mode 100644
--- a/dom/fmradio/test/marionette/test_cancel_seek.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-MARIONETTE_TIMEOUT = 10000;
-
-SpecialPowers.addPermission("fmradio", true, document);
-
-var FMRadio = window.navigator.mozFMRadio;
-
-function verifyInitialState() {
-  log("Verifying initial state.");
-  ok(FMRadio);
-  is(FMRadio.enabled, false);
-  setUp();
-}
-
-function setUp() {
-  let frequency = FMRadio.frequencyLowerBound + FMRadio.channelWidth;
-  FMRadio.enable(frequency);
-  FMRadio.onenabled = seek;
-}
-
-function seek() {
-  log("Seek up");
-  var request = FMRadio.seekUp();
-  ok(request);
-
-  var seekUpIsCancelled = false;
-  request.onerror = function() {
-    seekUpIsCancelled = true;
-  };
-
-  var seekUpCompleted = false;
-  request.onsuccess = function() {
-    ok(!seekUpIsCancelled);
-    seekUpCompleted = true;
-  };
-
-  log("Seek up");
-  var cancelSeekReq = FMRadio.cancelSeek();
-  ok(cancelSeekReq);
-
-  // There are two possibilities which depends on the system
-  // process scheduling (bug 911063 comment 0):
-  //   - seekup action is canceled
-  //   - seekup's onsuccess fires before cancelSeek's onerror
-
-  cancelSeekReq.onsuccess = function() {
-    ok(seekUpIsCancelled, "Seekup request failed.");
-    cleanUp();
-  };
-
-  cancelSeekReq.onerror = function() {
-    ok(seekUpCompleted);
-    cleanUp();
-  };
-}
-
-function cleanUp() {
-  FMRadio.disable();
-  FMRadio.ondisabled = function() {
-    FMRadio.ondisabled = null;
-    ok(!FMRadio.enabled);
-    finish();
-  };
-}
-
-verifyInitialState();
-
deleted file mode 100644
--- a/dom/fmradio/test/marionette/test_enable_disable.js
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-MARIONETTE_TIMEOUT = 10000;
-
-SpecialPowers.addPermission("fmradio", true, document);
-
-var FMRadio = window.navigator.mozFMRadio;
-
-function verifyInitialState() {
-  log("Verifying initial state.");
-  ok(FMRadio);
-  is(FMRadio.enabled, false);
-
-  log("Verifying attributes when disabled.");
-  is(FMRadio.frequency, null);
-  ok(FMRadio.frequencyLowerBound);
-  ok(FMRadio.frequencyUpperBound);
-  ok(FMRadio.frequencyUpperBound > FMRadio.frequencyLowerBound);
-  ok(FMRadio.channelWidth);
-
-  enableFMRadio();
-}
-
-function enableFMRadio() {
-  log("Verifying behaviors when enabled.");
-  var frequency = FMRadio.frequencyLowerBound + FMRadio.channelWidth;
-  var request = FMRadio.enable(frequency);
-  ok(request, "FMRadio.enable(r" + frequency + ") returns request");
-
-  request.onsuccess = function() {
-    ok(FMRadio.enabled);
-    ok(typeof FMRadio.frequency == "number");
-    ok(FMRadio.frequency > FMRadio.frequencyLowerBound);
-  };
-
-  request.onerror = function() {
-    ok(null, "Failed to enable");
-  };
-
-  var enabled = false;
-  FMRadio.onenabled = function() {
-    FMRadio.onenabled = null;
-    enabled = FMRadio.enabled;
-  };
-
-  FMRadio.onfrequencychange = function() {
-    log("Check if 'onfrequencychange' event is fired after the 'enabled' event");
-    FMRadio.onfrequencychange = null;
-    ok(enabled, "FMRadio is enabled when handling `onfrequencychange`");
-    disableFMRadio();
-  };
-}
-
-function disableFMRadio() {
-  log("Verify behaviors when disabled");
-
-  // There are two possibilities which depends on the system
-  // process scheduling (bug 911063 comment 0):
-  //   - seek fails
-  //   - seek's onsuccess fires before disable's onsucess
-  var seekRequest = FMRadio.seekUp();
-  var seekCompletes = false;
-  var failedToSeek = false;
-  seekRequest.onerror = function() {
-    ok(!seekCompletes);
-    failedToSeek = true;
-  };
-
-  seekRequest.onsuccess = function() {
-    ok(!failedToSeek);
-    seekCompletes = true;
-  };
-
-  FMRadio.disable();
-  FMRadio.ondisabled = function() {
-    FMRadio.ondisabled = null;
-    ok(seekCompletes || failedToSeek);
-    ok(!FMRadio.enabled);
-    finish();
-  };
-}
-
-verifyInitialState();
-
deleted file mode 100644
--- a/dom/fmradio/test/marionette/test_one_seek_at_once.js
+++ /dev/null
@@ -1,73 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-MARIONETTE_TIMEOUT = 10000;
-
-SpecialPowers.addPermission("fmradio", true, document);
-
-var FMRadio = window.navigator.mozFMRadio;
-
-function verifyInitialState() {
-  log("Verifying initial state.");
-  ok(FMRadio);
-  is(FMRadio.enabled, false);
-  setUp();
-}
-
-function setUp() {
-  let frequency = FMRadio.frequencyLowerBound + FMRadio.channelWidth;
-  FMRadio.enable(frequency);
-  FMRadio.onenabled = seek;
-}
-
-function seek() {
-  var request = FMRadio.seekUp();
-  ok(request);
-
-  // There are two possibilities which depends on the system
-  // process scheduling (bug 911063 comment 0):
-  //   - the second seek fails
-  //   - both seeks are executed
-
-  request.onerror = function() {
-    ok(!firstSeekCompletes);
-    cleanUp();
-  };
-
-  var firstSeekCompletes = false;
-  request.onsuccess = function() {
-    firstSeekCompletes = true;
-  };
-
-  var seekAgainReq = FMRadio.seekUp();
-  ok(seekAgainReq);
-
-  seekAgainReq.onerror = function() {
-    log("Cancel the first seek to finish the test");
-    let cancelReq = FMRadio.cancelSeek();
-    ok(cancelReq);
-
-    // It's possible that the first seek completes when the
-    // cancel request is handled.
-    cancelReq.onerror = function() {
-      cleanUp();
-    };
-  };
-
-  seekAgainReq.onsuccess = function() {
-    ok(firstSeekCompletes);
-    cleanUp();
-  };
-}
-
-function cleanUp() {
-  FMRadio.disable();
-  FMRadio.ondisabled = function() {
-    FMRadio.ondisabled = null;
-    ok(!FMRadio.enabled);
-    finish();
-  };
-}
-
-verifyInitialState();
-
deleted file mode 100644
--- a/dom/fmradio/test/marionette/test_seek_up_and_down.js
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-MARIONETTE_TIMEOUT = 30000;
-
-SpecialPowers.addPermission("fmradio", true, document);
-
-var FMRadio = window.navigator.mozFMRadio;
-
-function verifyInitialState() {
-  log("Verifying initial state.");
-  ok(FMRadio);
-  is(FMRadio.enabled, false);
-  setUp();
-}
-
-function setUp() {
-  let frequency = FMRadio.frequencyLowerBound + FMRadio.channelWidth;
-  FMRadio.enable(frequency);
-  FMRadio.onenabled = seekUp;
-}
-
-function seekUp() {
-  log("Seek up");
-  var request = FMRadio.seekUp();
-  ok(request);
-
-  request.onsuccess = function() {
-    seekDown();
-  };
-
-  request.onerror = function() {
-    ok(false, "Seekup request should not fail.");
-  };
-}
-
-function seekDown() {
-  log("Seek down");
-  var request = FMRadio.seekDown();
-  ok(request);
-
-  request.onsuccess = function() {
-    cleanUp();
-  };
-
-  request.onerror = function() {
-    ok(false, "Seekdown request should not fail.");
-  };
-}
-
-function cleanUp() {
-  FMRadio.disable();
-  FMRadio.ondisabled = function() {
-    FMRadio.ondisabled = null;
-    ok(!FMRadio.enabled);
-    finish();
-  };
-}
-
-verifyInitialState();
-
deleted file mode 100644
--- a/dom/fmradio/test/marionette/test_set_frequency.js
+++ /dev/null
@@ -1,87 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-MARIONETTE_TIMEOUT = 10000;
-
-SpecialPowers.addPermission("fmradio", true, document);
-
-var FMRadio = window.navigator.mozFMRadio;
-
-function verifyInitialState() {
-  log("Verifying initial state.");
-  ok(FMRadio);
-  is(FMRadio.enabled, false);
-  setUp();
-}
-
-function setUp() {
-  let frequency = FMRadio.frequencyLowerBound + FMRadio.channelWidth;
-  FMRadio.enable(frequency);
-  FMRadio.onenabled = setFrequency;
-}
-
-function setFrequency() {
-  log("Set Frequency");
-  let frequency = FMRadio.frequency + FMRadio.channelWidth;
-  var request = FMRadio.setFrequency(frequency);
-  ok(request);
-
-  request.onsuccess = setOutOfRangeFrequency;
-  request.onerror = function() {
-    ok(false, "setFrequency request should not fail.");
-  };
-}
-
-function setOutOfRangeFrequency() {
-  log("Set Frequency that out of the range");
-  var request = FMRadio.setFrequency(FMRadio.frequencyUpperBound + 1);
-  ok(request);
-
-  request.onsuccess = function() {
-    ok(false, "The request of setting an out-of-range frequency should fail.");
-  };
-  request.onerror = setFrequencyWhenSeeking;
-}
-
-function setFrequencyWhenSeeking() {
-  log("Set frequency when seeking");
-  var request = FMRadio.seekUp();
-  ok(request);
-
-  // There are two possibilities which depends on the system
-  // process scheduling (bug 911063 comment 0):
-  //   - seek fails
-  //   - seek's onsuccess fires before setFrequency's onsucess
-
-  var failedToSeek = false;
-  request.onerror = function() {
-    failedToSeek = true;
-  };
-
-  var seekCompletes = false;
-  request.onsuccess = function() {
-    ok(!failedToSeek);
-    seekCompletes = true;
-  };
-
-  var frequency = FMRadio.frequencyUpperBound - FMRadio.channelWidth;
-  var setFreqRequest = FMRadio.setFrequency(frequency);
-  ok(setFreqRequest);
-
-  setFreqRequest.onsuccess = function() {
-    ok(failedToSeek || seekCompletes);
-    cleanUp();
-  };
-}
-
-function cleanUp() {
-  FMRadio.disable();
-  FMRadio.ondisabled = function() {
-    FMRadio.ondisabled = null;
-    ok(!FMRadio.enabled);
-    finish();
-  };
-}
-
-verifyInitialState();
-
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -170,17 +170,16 @@
 #endif
 
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/icc/IccChild.h"
 #include "mozilla/dom/mobileconnection/MobileConnectionChild.h"
 #include "mozilla/dom/mobilemessage/SmsChild.h"
 #include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
 #include "mozilla/dom/bluetooth/PBluetoothChild.h"
-#include "mozilla/dom/PFMRadioChild.h"
 #include "mozilla/dom/PPresentationChild.h"
 #include "mozilla/dom/PresentationIPCService.h"
 #include "mozilla/ipc/InputStreamUtils.h"
 
 #ifdef MOZ_WEBSPEECH
 #include "mozilla/dom/PSpeechSynthesisChild.h"
 #endif
 
@@ -2073,40 +2072,16 @@ ContentChild::DeallocPBluetoothChild(PBl
 #ifdef MOZ_B2G_BT
   delete aActor;
   return true;
 #else
   MOZ_CRASH("No support for bluetooth on this platform!");
 #endif
 }
 
-PFMRadioChild*
-ContentChild::AllocPFMRadioChild()
-{
-#ifdef MOZ_B2G_FM
-  NS_RUNTIMEABORT("No one should be allocating PFMRadioChild actors");
-  return nullptr;
-#else
-  NS_RUNTIMEABORT("No support for FMRadio on this platform!");
-  return nullptr;
-#endif
-}
-
-bool
-ContentChild::DeallocPFMRadioChild(PFMRadioChild* aActor)
-{
-#ifdef MOZ_B2G_FM
-  delete aActor;
-  return true;
-#else
-  NS_RUNTIMEABORT("No support for FMRadio on this platform!");
-  return false;
-#endif
-}
-
 PSpeechSynthesisChild*
 ContentChild::AllocPSpeechSynthesisChild()
 {
 #ifdef MOZ_WEBSPEECH
   MOZ_CRASH("No one should be allocating PSpeechSynthesisChild actors");
 #else
   return nullptr;
 #endif
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -356,20 +356,16 @@ public:
   virtual PStorageChild* AllocPStorageChild() override;
 
   virtual bool DeallocPStorageChild(PStorageChild* aActor) override;
 
   virtual PBluetoothChild* AllocPBluetoothChild() override;
 
   virtual bool DeallocPBluetoothChild(PBluetoothChild* aActor) override;
 
-  virtual PFMRadioChild* AllocPFMRadioChild() override;
-
-  virtual bool DeallocPFMRadioChild(PFMRadioChild* aActor) override;
-
   virtual PPresentationChild* AllocPPresentationChild() override;
 
   virtual bool DeallocPPresentationChild(PPresentationChild* aActor) override;
 
   virtual PFlyWebPublishedServerChild*
     AllocPFlyWebPublishedServerChild(const nsString& name,
                                      const FlyWebPublishOptions& params) override;
 
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -49,17 +49,16 @@
 #include "mozilla/dom/ExternalHelperAppParent.h"
 #include "mozilla/dom/GetFilesHelper.h"
 #include "mozilla/dom/GeolocationBinding.h"
 #include "mozilla/dom/MediaKeySystemAccess.h"
 #include "mozilla/dom/Notification.h"
 #include "mozilla/dom/PContentBridgeParent.h"
 #include "mozilla/dom/PContentPermissionRequestParent.h"
 #include "mozilla/dom/PCycleCollectWithLogsParent.h"
-#include "mozilla/dom/PFMRadioParent.h"
 #include "mozilla/dom/PMemoryReportRequestParent.h"
 #include "mozilla/dom/ServiceWorkerRegistrar.h"
 #include "mozilla/dom/bluetooth/PBluetoothParent.h"
 #include "mozilla/dom/devicestorage/DeviceStorageRequestParent.h"
 #include "mozilla/dom/icc/IccParent.h"
 #include "mozilla/dom/mobileconnection/MobileConnectionParent.h"
 #include "mozilla/dom/mobilemessage/SmsParent.h"
 #include "mozilla/dom/power/PowerManagerService.h"
@@ -231,20 +230,16 @@ using namespace mozilla::system;
 
 #ifdef MOZ_B2G_BT
 #include "BluetoothParent.h"
 #include "BluetoothService.h"
 #endif
 
 #include "mozilla/RemoteSpellCheckEngineParent.h"
 
-#ifdef MOZ_B2G_FM
-#include "mozilla/dom/FMRadioParent.h"
-#endif
-
 #include "Crypto.h"
 
 #ifdef MOZ_WEBSPEECH
 #include "mozilla/dom/SpeechSynthesisParent.h"
 #endif
 
 #if defined(MOZ_CONTENT_SANDBOX) && defined(XP_LINUX)
 #include "mozilla/SandboxInfo.h"
@@ -3591,42 +3586,16 @@ ContentParent::RecvPBluetoothConstructor
   NS_ENSURE_TRUE(btService, false);
 
   return static_cast<BluetoothParent*>(aActor)->InitWithService(btService);
 #else
   MOZ_CRASH("No support for bluetooth on this platform!");
 #endif
 }
 
-PFMRadioParent*
-ContentParent::AllocPFMRadioParent()
-{
-#ifdef MOZ_B2G_FM
-  if (!AssertAppProcessPermission(this, "fmradio")) {
-  return nullptr;
-  }
-  return new FMRadioParent();
-#else
-  NS_WARNING("No support for FMRadio on this platform!");
-  return nullptr;
-#endif
-}
-
-bool
-ContentParent::DeallocPFMRadioParent(PFMRadioParent* aActor)
-{
-#ifdef MOZ_B2G_FM
-  delete aActor;
-  return true;
-#else
-  NS_WARNING("No support for FMRadio on this platform!");
-  return false;
-#endif
-}
-
 PPresentationParent*
 ContentParent::AllocPPresentationParent()
 {
   RefPtr<PresentationParent> actor = new PresentationParent();
   return actor.forget().take();
 }
 
 bool
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -876,20 +876,16 @@ private:
   virtual bool DeallocPStorageParent(PStorageParent* aActor) override;
 
   virtual PBluetoothParent* AllocPBluetoothParent() override;
 
   virtual bool DeallocPBluetoothParent(PBluetoothParent* aActor) override;
 
   virtual bool RecvPBluetoothConstructor(PBluetoothParent* aActor) override;
 
-  virtual PFMRadioParent* AllocPFMRadioParent() override;
-
-  virtual bool DeallocPFMRadioParent(PFMRadioParent* aActor) override;
-
   virtual PPresentationParent* AllocPPresentationParent() override;
 
   virtual bool DeallocPPresentationParent(PPresentationParent* aActor) override;
 
   virtual bool RecvPPresentationConstructor(PPresentationParent* aActor) override;
 
   virtual PFlyWebPublishedServerParent*
     AllocPFlyWebPublishedServerParent(const nsString& name,
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -13,17 +13,16 @@ include protocol PContentBridge;
 include protocol PContentPermissionRequest;
 include protocol PCycleCollectWithLogs;
 include protocol PCrashReporter;
 include protocol PPSMContentDownloader;
 include protocol PExternalHelperApp;
 include protocol PHandlerService;
 include protocol PDeviceStorageRequest;
 include protocol PFileDescriptorSet;
-include protocol PFMRadio;
 include protocol PHal;
 include protocol PHeapSnapshotTempFileHelper;
 include protocol PIcc;
 include protocol PProcessHangMonitor;
 include protocol PImageBridge;
 include protocol PMedia;
 include protocol PMemoryReportRequest;
 include protocol PMobileConnection;
@@ -233,50 +232,16 @@ struct DeviceStorageLocationInfo {
   nsString music;
   nsString pictures;
   nsString videos;
   nsString sdcard;
   nsString apps;
   nsString crashes;
 };
 
-struct FMRadioRequestEnableParams
-{
-  double frequency;
-};
-
-struct FMRadioRequestDisableParams
-{
-
-};
-
-struct FMRadioRequestSetFrequencyParams
-{
-  double frequency;
-};
-
-struct FMRadioRequestSeekParams
-{
-  bool upward;
-};
-
-struct FMRadioRequestCancelSeekParams
-{
-
-};
-
-union FMRadioRequestParams
-{
-  FMRadioRequestEnableParams;
-  FMRadioRequestDisableParams;
-  FMRadioRequestSetFrequencyParams;
-  FMRadioRequestSeekParams;
-  FMRadioRequestCancelSeekParams;
-};
-
 union PrefValue {
   nsCString;
   int32_t;
   bool;
 };
 
 union MaybePrefValue {
   PrefValue;
@@ -390,17 +355,16 @@ nested(upto inside_cpow) sync protocol P
     manages PBrowser;
     manages PContentPermissionRequest;
     manages PCrashReporter;
     manages PCycleCollectWithLogs;
     manages PDeviceStorageRequest;
     manages PPSMContentDownloader;
     manages PExternalHelperApp;
     manages PFileDescriptorSet;
-    manages PFMRadio;
     manages PHal;
     manages PHandlerService;
     manages PHeapSnapshotTempFileHelper;
     manages PIcc;
     manages PMedia;
     manages PMemoryReportRequest;
     manages PMobileConnection;
     manages PNecko;
@@ -869,18 +833,16 @@ parent:
     async PTelephony();
 
     async PVoicemail();
 
     async PMedia();
 
     async PBluetooth();
 
-    async PFMRadio();
-
     async PWebrtcGlobal();
 
     async PPresentation();
 
     async PFlyWebPublishedServer(nsString name, FlyWebPublishOptions params);
 
     // Services remoting
 
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -125,17 +125,16 @@ LOCAL_INCLUDES += [
     '/chrome',
     '/docshell/base',
     '/dom/base',
     '/dom/bluetooth/common',
     '/dom/bluetooth/ipc',
     '/dom/devicestorage',
     '/dom/events',
     '/dom/filesystem',
-    '/dom/fmradio/ipc',
     '/dom/geolocation',
     '/dom/media/webspeech/synth/ipc',
     '/dom/mobilemessage/ipc',
     '/dom/security',
     '/dom/storage',
     '/dom/workers',
     '/embedding/components/printingui/ipc',
     '/extensions/cookie',
--- a/dom/moz.build
+++ b/dom/moz.build
@@ -52,17 +52,16 @@ DIRS += [
     'phonenumberutils',
     'devicestorage',
     'encoding',
     'events',
     'fetch',
     'filehandle',
     'filesystem',
     'flyweb',
-    'fmradio',
     'gamepad',
     'geolocation',
     'grid',
     'html',
     'icc',
     'inputport',
     'json',
     'jsurl',
--- a/dom/permission/moz.build
+++ b/dom/permission/moz.build
@@ -29,19 +29,16 @@ EXTRA_JS_MODULES += [
 
 XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
 
 MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
 
 if CONFIG['MOZ_B2G_RIL']:
     MOCHITEST_MANIFESTS += ['tests/mochitest-ril.ini']
 
-if CONFIG['MOZ_B2G_FM']:
-    MOCHITEST_MANIFESTS += ['tests/mochitest-fm.ini']
-
 if CONFIG['MOZ_B2G_BT']:
     MOCHITEST_MANIFESTS += ['tests/mochitest-bt.ini']
 
 if CONFIG['MOZ_WEBSMS_BACKEND']:
     MOCHITEST_MANIFESTS += ['tests/mochitest-websms.ini']
 
 if CONFIG['MOZ_TIME_MANAGER']:
     MOCHITEST_MANIFESTS += ['tests/mochitest-time.ini']
deleted file mode 100644
--- a/dom/permission/tests/mochitest-fm.ini
+++ /dev/null
@@ -1,1 +0,0 @@
-[test_fmradio.html]
deleted file mode 100644
--- a/dom/permission/tests/test_fmradio.html
+++ /dev/null
@@ -1,31 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=815105
--->
-<head>
-  <meta charset="utf-8">
-  <title>Test for Bug 815105 </title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=815105">Mozilla Bug 815105 </a>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-<script type="application/javascript;version=1.8" src="file_framework.js"></script>
-<script type="application/javascript;version=1.8">
-var gData = [
-  {
-    perm: ["fmradio"],
-    needParentPerm: true,
-    obj: "mozFMRadio",
-    webidl: "FMRadio",
-  },
-]
-</script>
-</pre>
-</body>
-</html>
-
deleted file mode 100644
--- a/dom/webidl/FMRadio.webidl
+++ /dev/null
@@ -1,176 +0,0 @@
-/* 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/. */
-
-interface FMRadio : EventTarget {
-  /* Indicates if the FM radio is enabled. */
-  readonly attribute boolean enabled;
-
-  /* Indicates if RDS reception is enabled */
-  readonly attribute boolean rdsEnabled;
-
-  /* Indicates if the antenna is plugged and available. */
-  readonly attribute boolean antennaAvailable;
-
-  /**
-   * Current frequency in MHz. The value will be null if the FM radio is
-   * disabled.
-   */
-  readonly attribute double? frequency;
-
-  /* The upper bound of frequency in MHz. */
-  readonly attribute double frequencyUpperBound;
-
-  /* The lower bound of frequency in MHz. */
-  readonly attribute double frequencyLowerBound;
-
-  /**
-   * The difference in frequency between two "adjacent" channels, in MHz. That
-   * is, any two radio channels' frequencies differ by at least channelWidth
-   * MHz. Usually, the value is one of:
-   *  - 0.05 MHz
-   *  - 0.1  MHz
-   *  - 0.2  MHz
-   */
-  readonly attribute double channelWidth;
-
-  /**
-   * This is a mask consisting of bits corresponding to
-   * (1 << groupcode) that can be specified to receive
-   * raw RDS groups of specific group types. Note that
-   * groupcode corresponds to the upper 5 bits in block B.
-   */
-  attribute unsigned long rdsGroupMask;
-
-  /**
-   * The Program Identification (PI) code.
-   * Available if RDS is enabled on both the station and on this device.
-   * The value is null otherwise.
-   */
-  readonly attribute unsigned short? pi;
-
-  /**
-   * The Program Type (PTY) code.
-   * Available if RDS is enabled on both the station and on this device.
-   * The value is null otherwise.
-   */
-  readonly attribute octet? pty;
-
-  /**
-   * The Program Service (PS) name.
-   * Available if RDS is enabled on the station and on this device
-   */
-  readonly attribute DOMString? ps;
-
-  /**
-   * The radiotext, as provided by group 2A/2B.
-   * Available if RDS is enabled on the station and on this device
-   */
-  readonly attribute DOMString? rt;
-
-  /**
-   * The last RDS group received.
-   * Available if RDS is enabled on the station and on this device
-   */
-  readonly attribute Uint16Array? rdsgroup;
-
-  /* Fired when the FM radio is enabled. */
-  attribute EventHandler onenabled;
-
-  /* Fired when the FM radio is disabled. */
-  attribute EventHandler ondisabled;
-
-  /* Fired when the RDS is enabled. */
-  attribute EventHandler onrdsenabled;
-
-  /* Fired when the RDS is disabled. */
-  attribute EventHandler onrdsdisabled;
-
-  /**
-   * Fired when the antenna becomes available or unavailable, i.e., fired when
-   * the antennaAvailable attribute changes.
-   */
-  attribute EventHandler onantennaavailablechange;
-
-  /* Fired when the FM radio's frequency is changed. */
-  attribute EventHandler onfrequencychange;
-
-  /* Fired when the PI code changes */
-  attribute EventHandler onpichange;
-
-  /* Fired when the PTY changes */
-  attribute EventHandler onptychange;
-
-  /* Fired when the PS name changes */
-  attribute EventHandler onpschange;
-
-  /* Fired when the radiotext changes */
-  attribute EventHandler onrtchange;
-
-  /* Fired when we get a new RDS group */
-  attribute EventHandler onnewrdsgroup;
-
-  /**
-   * Power the FM radio off. The disabled event will be fired if this request
-   * completes successfully.
-   */
-  DOMRequest disable();
-
-  /**
-   * Power the FM radio on, and tune the radio to the given frequency in MHz.
-   * This will fail if the given frequency is out of range. The enabled event
-   * and frequencychange event will be fired if this request completes
-   * successfully.
-   */
-  DOMRequest enable(double frequency);
-
-  /**
-   * Tune the FM radio to the given frequency. This will fail if the given
-   * frequency is out of range.
-   *
-   * Note that the FM radio may not tuned to the exact frequency given. To get
-   * the frequency the radio is actually tuned to, wait for the request to fire
-   * sucess (or wait for the frequencychange event to fire), and then read the
-   * frequency attribute.
-   */
-  DOMRequest setFrequency(double frequency);
-
-  /**
-   * Tell the FM radio to seek up to the next channel. If the frequency is
-   * successfully changed, the frequencychange event will be triggered.
-   *
-   * Only one seek is allowed at once: If the radio is seeking when the seekUp
-   * is called, error will be fired.
-   */
-  DOMRequest seekUp();
-
-  /**
-   * Tell the FM radio to seek down to the next channel. If the frequency is
-   * successfully changed, the frequencychange event will be triggered.
-   *
-   * Only one seek is allowed at once: If the radio is seeking when the
-   * seekDown is called, error will be fired.
-   */
-  DOMRequest seekDown();
-
-  /**
-   * Cancel the seek action. If the radio is not currently seeking up or down,
-   * error will be fired.
-   */
-  DOMRequest cancelSeek();
-
-  /**
-   * Enable RDS reception.
-   *
-   * If the radio is off, RDS will be enabled when the radio is turned on.
-   */
-  DOMRequest enableRDS();
-
-  /**
-   * Disable RDS reception.
-   *
-   * If the radio is off, RDS will not be enabled when the radio is turned on.
-   */
-  DOMRequest disableRDS();
-};
-
--- a/dom/webidl/Navigator.webidl
+++ b/dom/webidl/Navigator.webidl
@@ -322,23 +322,16 @@ partial interface Navigator {
 
 #ifdef MOZ_B2G_BT
 partial interface Navigator {
   [Throws, ChromeOnly, UnsafeInPrerendering]
   readonly attribute BluetoothManager mozBluetooth;
 };
 #endif // MOZ_B2G_BT
 
-#ifdef MOZ_B2G_FM
-partial interface Navigator {
-  [Throws, ChromeOnly, UnsafeInPrerendering]
-  readonly attribute FMRadio mozFMRadio;
-};
-#endif // MOZ_B2G_FM
-
 #ifdef MOZ_TIME_MANAGER
 // nsIDOMMozNavigatorTime
 partial interface Navigator {
   [Throws, ChromeOnly, UnsafeInPrerendering]
   readonly attribute MozTimeManager mozTime;
 };
 #endif // MOZ_TIME_MANAGER
 
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -762,21 +762,16 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk
         'MozWifiManager.webidl',
         'MozWifiP2pManager.webidl',
     ]
 else:
     WEBIDL_FILES += [
         'InstallTrigger.webidl',
     ]
 
-if CONFIG['MOZ_B2G_FM']:
-    WEBIDL_FILES += [
-        'FMRadio.webidl',
-    ]
-
 GENERATED_EVENTS_WEBIDL_FILES = [
     'AddonEvent.webidl',
     'AnimationPlaybackEvent.webidl',
     'AutocompleteErrorEvent.webidl',
     'BlobEvent.webidl',
     'CallEvent.webidl',
     'CallGroupErrorEvent.webidl',
     'CameraClosedEvent.webidl',
--- a/layout/build/moz.build
+++ b/layout/build/moz.build
@@ -80,21 +80,16 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'an
         '/dom/system',
         '/dom/system/android',
     ]
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     LOCAL_INCLUDES += [
         '/dom/system/gonk',
     ]
 
-if CONFIG['MOZ_B2G_FM']:
-    LOCAL_INCLUDES += [
-        '/dom/fmradio',
-    ]
-
 if CONFIG['MOZ_B2G_BT']:
     LOCAL_INCLUDES += [
         '/dom/bluetooth/common',
     ]
 
 if CONFIG['MOZ_WEBSPEECH']:
     LOCAL_INCLUDES += [
         '/dom/media/webspeech/recognition',
--- a/old-configure.in
+++ b/old-configure.in
@@ -965,17 +965,16 @@ case "$target" in
 
     MOZ_FIX_LINK_PATHS="-Wl,-executable_path,${DIST}/bin"
     ;;
 
 *-android*|*-linuxandroid*)
     AC_DEFINE(NO_PW_GECOS)
     if test -n "$gonkdir"; then
         _PLATFORM_HAVE_RIL=1
-        MOZ_B2G_FM=1
         MOZ_SYNTH_PICO=1
     else
         if test "$COMPILE_ENVIRONMENT"; then
             MOZ_LINKER=1
         fi
     fi
 
     MOZ_GFX_OPTIMIZE_MOBILE=1
@@ -4808,24 +4807,16 @@ if test -n "$MOZ_B2G_RIL"; then
         AC_DEFINE(MOZ_B2G_RIL)
     else
         AC_MSG_ERROR([b2g-ril cannot be enabled because target platform doesn't support it.])
     fi
 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)
-fi
-AC_SUBST(MOZ_B2G_FM)
-
-dnl ========================================================
 dnl = Enable Bluetooth Interface for B2G (Gonk usually)
 dnl ========================================================
 MOZ_ARG_ENABLE_BOOL(b2g-bt,
 [  --enable-b2g-bt      Set compile flags necessary for compiling Bluetooth API for B2G ],
     MOZ_B2G_BT=1,
     MOZ_B2G_BT= )
 if test -n "$MOZ_B2G_BT"; then
     AC_DEFINE(MOZ_B2G_BT)