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

This commit is contained in:
Vicamo Yang 2013-10-25 11:07:20 +08:00
parent 5e0e6a9e20
commit 17aac2e402
8 changed files with 48 additions and 47 deletions

View File

@ -817,9 +817,6 @@ pref("gfx.canvas.azure.accelerated", true);
// Turn on dynamic cache size for Skia
pref("gfx.canvas.skiagl.dynamic-cache", true);
// Enable Telephony API
pref("dom.telephony.enabled", true);
// Cell Broadcast API
pref("dom.cellbroadcast.enabled", true);
pref("ril.cellbroadcast.disabled", false);

View File

@ -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

View File

@ -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,6 +1165,20 @@ Navigator::GetMozMobileMessage()
return mMobileMessageManager;
}
Telephony*
Navigator::GetMozTelephony(ErrorResult& aRv)
{
if (!mTelephony) {
if (!mWindow) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
mTelephony = Telephony::Create(mWindow, aRv);
}
return mTelephony;
}
#ifdef MOZ_B2G_RIL
CellBroadcast*
@ -1181,20 +1195,6 @@ Navigator::GetMozCellBroadcast(ErrorResult& aRv)
return mCellBroadcast;
}
Telephony*
Navigator::GetMozTelephony(ErrorResult& aRv)
{
if (!mTelephony) {
if (!mWindow) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
mTelephony = Telephony::Create(mWindow, aRv);
}
return mTelephony;
}
Voicemail*
Navigator::GetMozVoicemail(ErrorResult& aRv)
{
@ -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 */,

View File

@ -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

View File

@ -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

View File

@ -45,7 +45,7 @@ IPDL_SOURCES += [
'ipc/TelephonyTypes.ipdlh'
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']:
XPIDL_SOURCES += [
'nsIGonkTelephonyProvider.idl',
]

View File

@ -255,11 +255,6 @@ partial interface Navigator {
};
#ifdef MOZ_B2G_RIL
partial interface Navigator {
[Throws, Func="Navigator::HasTelephonySupport"]
readonly attribute Telephony? mozTelephony;
};
// nsIMozNavigatorMobileConnection
interface MozMobileConnection;
partial interface Navigator {
@ -285,6 +280,11 @@ partial interface Navigator {
};
#endif // MOZ_B2G_RIL
partial interface Navigator {
[Throws, Func="Navigator::HasTelephonySupport"]
readonly attribute Telephony? mozTelephony;
};
#ifdef MOZ_GAMEPAD
// https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension
partial interface Navigator {

View File

@ -4485,7 +4485,11 @@ pref("dom.mozInputMethod.enabled", false);
pref("dom.datastore.enabled", false);
// Telephony API
#ifdef MOZ_B2G_RIL
pref("dom.telephony.enabled", true);
#else
pref("dom.telephony.enabled", false);
#endif
// Numeric default service id for WebTelephony API calls with |serviceId|
// parameter omitted.
pref("dom.telephony.defaultServiceId", 0);