Commit 48828345 authored by Vicamo Yang's avatar Vicamo Yang
Browse files

Bug 920551 - 2.b/2: fix Telephony. r=hsinyi,khuey, a=koi+

parent 917339d7
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -821,9 +821,6 @@ pref("gfx.canvas.skiagl.dynamic-cache", true);
// enable fence with readpixels for SurfaceStream
pref("gfx.gralloc.fence-with-readpixels", true);

// Enable Telephony API
pref("dom.telephony.enabled", true);

// Cell Broadcast API
pref("dom.cellbroadcast.enabled", true);
pref("ril.cellbroadcast.disabled", false);
+2 −2
Original line number Diff line number Diff line
@@ -405,6 +405,8 @@
@BINPATH@/components/MmsService.manifest
@BINPATH@/components/MobileMessageDatabaseService.js
@BINPATH@/components/MobileMessageDatabaseService.manifest
@BINPATH@/components/TelephonyProvider.js
@BINPATH@/components/TelephonyProvider.manifest
#endif // MOZ_WIDGET_GONK && MOZ_B2G_RIL

#ifndef MOZ_WIDGET_GONK
@@ -486,8 +488,6 @@
@BINPATH@/components/NetworkStatsManager.manifest
@BINPATH@/components/NetworkInterfaceListService.manifest
@BINPATH@/components/NetworkInterfaceListService.js
@BINPATH@/components/TelephonyProvider.manifest
@BINPATH@/components/TelephonyProvider.js
@BINPATH@/components/NetworkStatsServiceProxy.manifest
@BINPATH@/components/NetworkStatsServiceProxy.js
#endif
+27 −27
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include "nsIDOMWakeLock.h"
#include "nsIPowerManagerService.h"
#include "mozilla/dom/MobileMessageManager.h"
#include "mozilla/dom/Telephony.h"
#include "mozilla/Hal.h"
#include "nsISiteSpecificUserAgent.h"
#include "mozilla/ClearOnShutdown.h"
@@ -40,7 +41,6 @@
#include "mozilla/dom/IccManager.h"
#include "MobileConnection.h"
#include "mozilla/dom/CellBroadcast.h"
#include "mozilla/dom/Telephony.h"
#include "mozilla/dom/Voicemail.h"
#endif
#include "nsIIdleObserver.h"
@@ -138,12 +138,12 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Navigator)
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBatteryManager)
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPowerManager)
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMobileMessageManager)
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTelephony)
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mConnection)
#ifdef MOZ_B2G_RIL
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMobileConnection)
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCellBroadcast)
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIccManager)
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTelephony)
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVoicemail)
#endif
#ifdef MOZ_B2G_BT
@@ -209,6 +209,10 @@ Navigator::Invalidate()
    mMobileMessageManager = nullptr;
  }

  if (mTelephony) {
    mTelephony = nullptr;
  }

  if (mConnection) {
    mConnection->Shutdown();
    mConnection = nullptr;
@@ -229,10 +233,6 @@ Navigator::Invalidate()
    mIccManager = nullptr;
  }

  if (mTelephony) {
    mTelephony = nullptr;
  }

  if (mVoicemail) {
    mVoicemail = nullptr;
  }
@@ -1165,34 +1165,34 @@ Navigator::GetMozMobileMessage()
  return mMobileMessageManager;
}

#ifdef MOZ_B2G_RIL

CellBroadcast*
Navigator::GetMozCellBroadcast(ErrorResult& aRv)
Telephony*
Navigator::GetMozTelephony(ErrorResult& aRv)
{
  if (!mCellBroadcast) {
  if (!mTelephony) {
    if (!mWindow) {
      aRv.Throw(NS_ERROR_UNEXPECTED);
      return nullptr;
    }
    mCellBroadcast = CellBroadcast::Create(mWindow, aRv);
    mTelephony = Telephony::Create(mWindow, aRv);
  }

  return mCellBroadcast;
  return mTelephony;
}

Telephony*
Navigator::GetMozTelephony(ErrorResult& aRv)
#ifdef MOZ_B2G_RIL

CellBroadcast*
Navigator::GetMozCellBroadcast(ErrorResult& aRv)
{
  if (!mTelephony) {
  if (!mCellBroadcast) {
    if (!mWindow) {
      aRv.Throw(NS_ERROR_UNEXPECTED);
      return nullptr;
    }
    mTelephony = Telephony::Create(mWindow, aRv);
    mCellBroadcast = CellBroadcast::Create(mWindow, aRv);
  }

  return mTelephony;
  return mCellBroadcast;
}

Voicemail*
@@ -1697,15 +1697,6 @@ Navigator::HasMobileMessageSupport(JSContext* /* unused */, JSObject* aGlobal)
  return true;
}

/* static */
bool
Navigator::HasCameraSupport(JSContext* /* unused */, JSObject* aGlobal)
{
  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
  return win && nsDOMCameraManager::CheckPermission(win);
}

#ifdef MOZ_B2G_RIL
/* static */
bool
Navigator::HasTelephonySupport(JSContext* /* unused */, JSObject* aGlobal)
@@ -1719,6 +1710,15 @@ Navigator::HasTelephonySupport(JSContext* /* unused */, JSObject* aGlobal)
  return win && CheckPermission(win, "telephony");
}

/* static */
bool
Navigator::HasCameraSupport(JSContext* /* unused */, JSObject* aGlobal)
{
  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
  return win && nsDOMCameraManager::CheckPermission(win);
}

#ifdef MOZ_B2G_RIL
/* static */
bool
Navigator::HasMobileConnectionSupport(JSContext* /* unused */,
+5 −5
Original line number Diff line number Diff line
@@ -86,11 +86,11 @@ class BluetoothManager;
#ifdef MOZ_B2G_RIL
class CellBroadcast;
class IccManager;
class Telephony;
class Voicemail;
#endif

class PowerManager;
class Telephony;

namespace time {
class TimeManager;
@@ -211,6 +211,7 @@ public:
  bool MozIsLocallyAvailable(const nsAString& aURI, bool aWhenOffline,
                             ErrorResult& aRv);
  nsIDOMMozMobileMessageManager* GetMozMobileMessage();
  Telephony* GetMozTelephony(ErrorResult& aRv);
  nsIDOMMozConnection* GetMozConnection();
  nsDOMCameraManager* GetMozCameras(ErrorResult& aRv);
  void MozSetMessageHandler(const nsAString& aType,
@@ -218,7 +219,6 @@ public:
                            ErrorResult& aRv);
  bool MozHasPendingMessage(const nsAString& aType, ErrorResult& aRv);
#ifdef MOZ_B2G_RIL
  Telephony* GetMozTelephony(ErrorResult& aRv);
  nsIDOMMozMobileConnection* GetMozMobileConnection(ErrorResult& aRv);
  CellBroadcast* GetMozCellBroadcast(ErrorResult& aRv);
  Voicemail* GetMozVoicemail(ErrorResult& aRv);
@@ -268,11 +268,11 @@ public:
  }
  static bool HasMobileMessageSupport(JSContext* /* unused */,
                                      JSObject* aGlobal);
  static bool HasTelephonySupport(JSContext* /* unused */,
                                  JSObject* aGlobal);
  static bool HasCameraSupport(JSContext* /* unused */,
                               JSObject* aGlobal);
#ifdef MOZ_B2G_RIL
  static bool HasTelephonySupport(JSContext* /* unused */,
                                  JSObject* aGlobal);
  static bool HasMobileConnectionSupport(JSContext* /* unused */,
                                         JSObject* aGlobal);
  static bool HasCellBroadcastSupport(JSContext* /* unused */,
@@ -326,12 +326,12 @@ private:
#endif
  nsRefPtr<PowerManager> mPowerManager;
  nsRefPtr<MobileMessageManager> mMobileMessageManager;
  nsRefPtr<Telephony> mTelephony;
  nsRefPtr<network::Connection> mConnection;
#ifdef MOZ_B2G_RIL
  nsRefPtr<network::MobileConnection> mMobileConnection;
  nsRefPtr<CellBroadcast> mCellBroadcast;
  nsRefPtr<IccManager> mIccManager;
  nsRefPtr<Telephony> mTelephony;
  nsRefPtr<Voicemail> mVoicemail;
#endif
#ifdef MOZ_B2G_BT
+2 −2
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "mozilla/dom/telephony/TelephonyFactory.h"
#ifdef MOZ_WIDGET_GONK
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
#include "nsIGonkTelephonyProvider.h"
#endif
#include "nsServiceManagerUtils.h"
@@ -20,7 +20,7 @@ TelephonyFactory::CreateTelephonyProvider()

  if (XRE_GetProcessType() == GeckoProcessType_Content) {
    provider = new TelephonyIPCProvider();
#ifdef MOZ_WIDGET_GONK
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
  } else {
    provider = do_CreateInstance(GONK_TELEPHONY_PROVIDER_CONTRACTID);
#endif
Loading