Merge b2g-inbound to m-c.

This commit is contained in:
Ryan VanderMeulen 2014-01-17 15:04:32 -05:00
commit e216abf30b
46 changed files with 1149 additions and 62 deletions

View File

@ -12,7 +12,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ef8bb31b462f364b57432a0724c78034d3f4f303"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="73a7e0c15969a058964e92fad1925efead38dcfc"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9b6626eddbc85873eaa2a9174a9bd5101e5c05f"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="eda08beb3ba9a159843c70ffde0f9660ec351eb9"/>

View File

@ -11,7 +11,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="ef8bb31b462f364b57432a0724c78034d3f4f303"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="73a7e0c15969a058964e92fad1925efead38dcfc"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9b6626eddbc85873eaa2a9174a9bd5101e5c05f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="96d2d00165f4561fbde62d1062706eab74b3a01f"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="221bcaecbbbc9d185f691471b64aed9e75b0c11d"/>

View File

@ -12,7 +12,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ef8bb31b462f364b57432a0724c78034d3f4f303"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="73a7e0c15969a058964e92fad1925efead38dcfc"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9b6626eddbc85873eaa2a9174a9bd5101e5c05f"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="eda08beb3ba9a159843c70ffde0f9660ec351eb9"/>

View File

@ -1,4 +1,4 @@
{
"revision": "18bd82325a82f5b9a3a4b976e213515cd3e5866b",
"revision": "f1421b9d57e81c3823a32eb02e6ab6e3c74b12f1",
"repo_path": "/integration/gaia-central"
}

View File

@ -11,7 +11,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ef8bb31b462f364b57432a0724c78034d3f4f303"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="73a7e0c15969a058964e92fad1925efead38dcfc"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9b6626eddbc85873eaa2a9174a9bd5101e5c05f"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>

View File

@ -10,7 +10,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ef8bb31b462f364b57432a0724c78034d3f4f303"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="73a7e0c15969a058964e92fad1925efead38dcfc"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9b6626eddbc85873eaa2a9174a9bd5101e5c05f"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>

View File

@ -12,7 +12,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ef8bb31b462f364b57432a0724c78034d3f4f303"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="73a7e0c15969a058964e92fad1925efead38dcfc"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9b6626eddbc85873eaa2a9174a9bd5101e5c05f"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>

View File

@ -11,7 +11,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ef8bb31b462f364b57432a0724c78034d3f4f303"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="73a7e0c15969a058964e92fad1925efead38dcfc"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9b6626eddbc85873eaa2a9174a9bd5101e5c05f"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>

View File

@ -11,7 +11,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="ef8bb31b462f364b57432a0724c78034d3f4f303"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="73a7e0c15969a058964e92fad1925efead38dcfc"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9b6626eddbc85873eaa2a9174a9bd5101e5c05f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="96d2d00165f4561fbde62d1062706eab74b3a01f"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="221bcaecbbbc9d185f691471b64aed9e75b0c11d"/>

View File

@ -11,7 +11,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ef8bb31b462f364b57432a0724c78034d3f4f303"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="73a7e0c15969a058964e92fad1925efead38dcfc"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9b6626eddbc85873eaa2a9174a9bd5101e5c05f"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>

View File

@ -166,6 +166,7 @@
@BINPATH@/components/dom_icc.xpt
@BINPATH@/components/dom_cellbroadcast.xpt
@BINPATH@/components/dom_wappush.xpt
@BINPATH@/components/dom_mobileconnection.xpt
#endif
#ifdef MOZ_B2G_BT
@BINPATH@/components/dom_bluetooth.xpt

View File

@ -40,7 +40,7 @@
#ifdef MOZ_B2G_RIL
#include "mozilla/dom/IccManager.h"
#include "mozilla/dom/CellBroadcast.h"
#include "mozilla/dom/network/MobileConnectionArray.h"
#include "mozilla/dom/MobileConnectionArray.h"
#include "mozilla/dom/Voicemail.h"
#endif
#include "nsIIdleObserver.h"
@ -1180,7 +1180,7 @@ Navigator::GetMozTelephony(ErrorResult& aRv)
#ifdef MOZ_B2G_RIL
network::MobileConnectionArray*
MobileConnectionArray*
Navigator::GetMozMobileConnections(ErrorResult& aRv)
{
if (!mMobileConnections) {
@ -1188,7 +1188,7 @@ Navigator::GetMozMobileConnections(ErrorResult& aRv)
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
mMobileConnections = new network::MobileConnectionArray(mWindow);
mMobileConnections = new MobileConnectionArray(mWindow);
}
return mMobileConnections;

View File

@ -72,9 +72,6 @@ class MozGetUserMediaDevicesSuccessCallback;
namespace network {
class Connection;
#ifdef MOZ_B2G_RIL
class MobileConnectionArray;
#endif
} // namespace Connection;
#ifdef MOZ_B2G_BT
@ -86,6 +83,7 @@ class BluetoothManager;
#ifdef MOZ_B2G_RIL
class CellBroadcast;
class IccManager;
class MobileConnectionArray;
class Voicemail;
#endif
@ -202,7 +200,7 @@ public:
ErrorResult& aRv);
bool MozHasPendingMessage(const nsAString& aType, ErrorResult& aRv);
#ifdef MOZ_B2G_RIL
network::MobileConnectionArray* GetMozMobileConnections(ErrorResult& aRv);
MobileConnectionArray* GetMozMobileConnections(ErrorResult& aRv);
CellBroadcast* GetMozCellBroadcast(ErrorResult& aRv);
Voicemail* GetMozVoicemail(ErrorResult& aRv);
nsIDOMMozIccManager* GetMozIccManager(ErrorResult& aRv);
@ -318,7 +316,7 @@ private:
nsRefPtr<Telephony> mTelephony;
nsRefPtr<network::Connection> mConnection;
#ifdef MOZ_B2G_RIL
nsRefPtr<network::MobileConnectionArray> mMobileConnections;
nsRefPtr<MobileConnectionArray> mMobileConnections;
nsRefPtr<CellBroadcast> mCellBroadcast;
nsRefPtr<IccManager> mIccManager;
nsRefPtr<Voicemail> mVoicemail;

View File

@ -809,7 +809,7 @@ DOMInterfaces = {
},
'MozMobileConnectionArray': {
'nativeType': 'mozilla::dom::network::MobileConnectionArray',
'nativeType': 'mozilla::dom::MobileConnectionArray',
'resultNotAddRefed': [ 'item' ]
},

View File

@ -0,0 +1,12 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
XPIDL_SOURCES += [
'nsIDOMMobileConnection.idl',
'nsIMobileConnectionProvider.idl',
]
XPIDL_MODULE = 'dom_mobileconnection'

View File

@ -0,0 +1,7 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
PARALLEL_DIRS += ['interfaces', 'src']

View File

@ -0,0 +1,738 @@
/* 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/MobileConnection.h"
#include "GeneratedEvents.h"
#include "mozilla/dom/CFStateChangeEvent.h"
#include "mozilla/dom/DataErrorEvent.h"
#include "mozilla/dom/MozEmergencyCbModeEvent.h"
#include "mozilla/dom/MozOtaStatusEvent.h"
#include "mozilla/dom/USSDReceivedEvent.h"
#include "mozilla/Preferences.h"
#include "nsDOMEvent.h"
#include "nsIDOMClassInfo.h"
#include "nsIDOMDOMRequest.h"
#include "nsIPermissionManager.h"
#include "nsIVariant.h"
#include "nsJSUtils.h"
#include "nsJSON.h"
#include "mozilla/Services.h"
#define NS_RILCONTENTHELPER_CONTRACTID "@mozilla.org/ril/content-helper;1"
using namespace mozilla::dom;
class MobileConnection::Listener MOZ_FINAL : public nsIMobileConnectionListener
{
MobileConnection* mMobileConnection;
public:
NS_DECL_ISUPPORTS
NS_FORWARD_SAFE_NSIMOBILECONNECTIONLISTENER(mMobileConnection)
Listener(MobileConnection* aMobileConnection)
: mMobileConnection(aMobileConnection)
{
MOZ_ASSERT(mMobileConnection);
}
void Disconnect()
{
MOZ_ASSERT(mMobileConnection);
mMobileConnection = nullptr;
}
};
NS_IMPL_ISUPPORTS1(MobileConnection::Listener, nsIMobileConnectionListener)
DOMCI_DATA(MozMobileConnection, MobileConnection)
NS_IMPL_CYCLE_COLLECTION_CLASS(MobileConnection)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MobileConnection,
nsDOMEventTargetHelper)
// Don't traverse mListener because it doesn't keep any reference to
// MobileConnection but a raw pointer instead. Neither does mProvider because
// it's an xpcom service and is only released at shutting down.
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MobileConnection,
nsDOMEventTargetHelper)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MobileConnection)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozMobileConnection)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozMobileConnection)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(MobileConnection, nsDOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(MobileConnection, nsDOMEventTargetHelper)
NS_IMPL_EVENT_HANDLER(MobileConnection, voicechange)
NS_IMPL_EVENT_HANDLER(MobileConnection, datachange)
NS_IMPL_EVENT_HANDLER(MobileConnection, ussdreceived)
NS_IMPL_EVENT_HANDLER(MobileConnection, dataerror)
NS_IMPL_EVENT_HANDLER(MobileConnection, cfstatechange)
NS_IMPL_EVENT_HANDLER(MobileConnection, emergencycbmodechange)
NS_IMPL_EVENT_HANDLER(MobileConnection, otastatuschange)
NS_IMPL_EVENT_HANDLER(MobileConnection, iccchange)
NS_IMPL_EVENT_HANDLER(MobileConnection, radiostatechange)
MobileConnection::MobileConnection(uint32_t aClientId)
: mClientId(aClientId)
{
mProvider = do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
mWindow = nullptr;
// Not being able to acquire the provider isn't fatal since we check
// for it explicitly below.
if (!mProvider) {
NS_WARNING("Could not acquire nsIMobileConnectionProvider!");
return;
}
}
void
MobileConnection::Init(nsPIDOMWindow* aWindow)
{
BindToOwner(aWindow);
mWindow = do_GetWeakReference(aWindow);
mListener = new Listener(this);
if (CheckPermission("mobileconnection")) {
DebugOnly<nsresult> rv = mProvider->RegisterMobileConnectionMsg(mClientId, mListener);
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"Failed registering mobile connection messages with provider");
printf_stderr("MobileConnection initialized");
}
}
void
MobileConnection::Shutdown()
{
if (mProvider && mListener) {
mListener->Disconnect();
mProvider->UnregisterMobileConnectionMsg(mClientId, mListener);
mProvider = nullptr;
mListener = nullptr;
}
}
// nsIDOMMozMobileConnection
NS_IMETHODIMP
MobileConnection::GetLastKnownNetwork(nsAString& aNetwork)
{
aNetwork.SetIsVoid(true);
if (!CheckPermission("mobilenetwork")) {
return NS_OK;
}
return mProvider->GetLastKnownNetwork(mClientId, aNetwork);
}
NS_IMETHODIMP
MobileConnection::GetLastKnownHomeNetwork(nsAString& aNetwork)
{
aNetwork.SetIsVoid(true);
if (!CheckPermission("mobilenetwork")) {
return NS_OK;
}
return mProvider->GetLastKnownHomeNetwork(mClientId, aNetwork);
}
// All fields below require the "mobileconnection" permission.
bool
MobileConnection::CheckPermission(const char* aType)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_TRUE(window, false);
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
NS_ENSURE_TRUE(permMgr, false);
uint32_t permission = nsIPermissionManager::DENY_ACTION;
permMgr->TestPermissionFromWindow(window, aType, &permission);
return permission == nsIPermissionManager::ALLOW_ACTION;
}
NS_IMETHODIMP
MobileConnection::GetVoice(nsIDOMMozMobileConnectionInfo** aVoice)
{
*aVoice = nullptr;
if (!mProvider || !CheckPermission("mobileconnection")) {
return NS_OK;
}
return mProvider->GetVoiceConnectionInfo(mClientId, aVoice);
}
NS_IMETHODIMP
MobileConnection::GetData(nsIDOMMozMobileConnectionInfo** aData)
{
*aData = nullptr;
if (!mProvider || !CheckPermission("mobileconnection")) {
return NS_OK;
}
return mProvider->GetDataConnectionInfo(mClientId, aData);
}
NS_IMETHODIMP
MobileConnection::GetIccId(nsAString& aIccId)
{
aIccId.SetIsVoid(true);
if (!mProvider || !CheckPermission("mobileconnection")) {
return NS_OK;
}
return mProvider->GetIccId(mClientId, aIccId);
}
NS_IMETHODIMP
MobileConnection::GetNetworkSelectionMode(nsAString& aNetworkSelectionMode)
{
aNetworkSelectionMode.SetIsVoid(true);
if (!mProvider || !CheckPermission("mobileconnection")) {
return NS_OK;
}
return mProvider->GetNetworkSelectionMode(mClientId, aNetworkSelectionMode);
}
NS_IMETHODIMP
MobileConnection::GetRadioState(nsAString& aRadioState)
{
aRadioState.SetIsVoid(true);
if (!mProvider || !CheckPermission("mobileconnection")) {
return NS_OK;
}
return mProvider->GetRadioState(mClientId, aRadioState);
}
NS_IMETHODIMP
MobileConnection::GetSupportedNetworkTypes(nsIVariant** aSupportedNetworkTypes)
{
*aSupportedNetworkTypes = nullptr;
if (!mProvider || !CheckPermission("mobileconnection")) {
return NS_OK;
}
return mProvider->GetSupportedNetworkTypes(mClientId, aSupportedNetworkTypes);
}
NS_IMETHODIMP
MobileConnection::GetNetworks(nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->GetNetworks(mClientId, GetOwner(), aRequest);
}
NS_IMETHODIMP
MobileConnection::SelectNetwork(nsIDOMMozMobileNetworkInfo* aNetwork, nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->SelectNetwork(mClientId, GetOwner(), aNetwork, aRequest);
}
NS_IMETHODIMP
MobileConnection::SelectNetworkAutomatically(nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->SelectNetworkAutomatically(mClientId, GetOwner(), aRequest);
}
NS_IMETHODIMP
MobileConnection::SetPreferredNetworkType(const nsAString& aType,
nsIDOMDOMRequest** aDomRequest)
{
*aDomRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->SetPreferredNetworkType(mClientId, GetOwner(), aType, aDomRequest);
}
NS_IMETHODIMP
MobileConnection::GetPreferredNetworkType(nsIDOMDOMRequest** aDomRequest)
{
*aDomRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->GetPreferredNetworkType(mClientId, GetOwner(), aDomRequest);
}
NS_IMETHODIMP
MobileConnection::SetRoamingPreference(const nsAString& aMode, nsIDOMDOMRequest** aDomRequest)
{
*aDomRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->SetRoamingPreference(mClientId, GetOwner(), aMode, aDomRequest);
}
NS_IMETHODIMP
MobileConnection::GetRoamingPreference(nsIDOMDOMRequest** aDomRequest)
{
*aDomRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->GetRoamingPreference(mClientId, GetOwner(), aDomRequest);
}
NS_IMETHODIMP
MobileConnection::SetVoicePrivacyMode(bool aEnabled, nsIDOMDOMRequest** aDomRequest)
{
*aDomRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->SetVoicePrivacyMode(mClientId, GetOwner(), aEnabled, aDomRequest);
}
NS_IMETHODIMP
MobileConnection::GetVoicePrivacyMode(nsIDOMDOMRequest** aDomRequest)
{
*aDomRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->GetVoicePrivacyMode(mClientId, GetOwner(), aDomRequest);
}
NS_IMETHODIMP
MobileConnection::SendMMI(const nsAString& aMMIString,
nsIDOMDOMRequest** aRequest)
{
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->SendMMI(mClientId, GetOwner(), aMMIString, aRequest);
}
NS_IMETHODIMP
MobileConnection::CancelMMI(nsIDOMDOMRequest** aRequest)
{
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->CancelMMI(mClientId, GetOwner(),aRequest);
}
NS_IMETHODIMP
MobileConnection::GetCallForwardingOption(uint16_t aReason,
nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->GetCallForwardingOption(mClientId, GetOwner(), aReason, aRequest);
}
NS_IMETHODIMP
MobileConnection::SetCallForwardingOption(nsIDOMMozMobileCFInfo* aCFInfo,
nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->SetCallForwardingOption(mClientId, GetOwner(), aCFInfo, aRequest);
}
NS_IMETHODIMP
MobileConnection::GetCallBarringOption(JS::Handle<JS::Value> aOption,
nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->GetCallBarringOption(mClientId, GetOwner(), aOption, aRequest);
}
NS_IMETHODIMP
MobileConnection::SetCallBarringOption(JS::Handle<JS::Value> aOption,
nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->SetCallBarringOption(mClientId, GetOwner(), aOption, aRequest);
}
NS_IMETHODIMP
MobileConnection::ChangeCallBarringPassword(JS::Handle<JS::Value> aInfo,
nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->ChangeCallBarringPassword(mClientId, GetOwner(), aInfo, aRequest);
}
NS_IMETHODIMP
MobileConnection::GetCallWaitingOption(nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->GetCallWaitingOption(mClientId, GetOwner(), aRequest);
}
NS_IMETHODIMP
MobileConnection::SetCallWaitingOption(bool aEnabled,
nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->SetCallWaitingOption(mClientId, GetOwner(), aEnabled, aRequest);
}
NS_IMETHODIMP
MobileConnection::GetCallingLineIdRestriction(nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->GetCallingLineIdRestriction(mClientId, GetOwner(), aRequest);
}
NS_IMETHODIMP
MobileConnection::SetCallingLineIdRestriction(unsigned short aClirMode,
nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->SetCallingLineIdRestriction(mClientId, GetOwner(), aClirMode, aRequest);
}
NS_IMETHODIMP
MobileConnection::ExitEmergencyCbMode(nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->ExitEmergencyCbMode(mClientId, GetOwner(), aRequest);
}
NS_IMETHODIMP
MobileConnection::SetRadioEnabled(bool aEnabled,
nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->SetRadioEnabled(mClientId, GetOwner(), aEnabled, aRequest);
}
// nsIMobileConnectionListener
NS_IMETHODIMP
MobileConnection::NotifyVoiceChanged()
{
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
return DispatchTrustedEvent(NS_LITERAL_STRING("voicechange"));
}
NS_IMETHODIMP
MobileConnection::NotifyDataChanged()
{
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
return DispatchTrustedEvent(NS_LITERAL_STRING("datachange"));
}
NS_IMETHODIMP
MobileConnection::NotifyUssdReceived(const nsAString& aMessage,
bool aSessionEnded)
{
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
USSDReceivedEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mMessage = aMessage;
init.mSessionEnded = aSessionEnded;
nsRefPtr<USSDReceivedEvent> event =
USSDReceivedEvent::Constructor(this, NS_LITERAL_STRING("ussdreceived"), init);
return DispatchTrustedEvent(event);
}
NS_IMETHODIMP
MobileConnection::NotifyDataError(const nsAString& aMessage)
{
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
DataErrorEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mMessage = aMessage;
nsRefPtr<DataErrorEvent> event =
DataErrorEvent::Constructor(this, NS_LITERAL_STRING("dataerror"), init);
return DispatchTrustedEvent(event);
}
NS_IMETHODIMP
MobileConnection::NotifyCFStateChange(bool aSuccess,
unsigned short aAction,
unsigned short aReason,
const nsAString& aNumber,
unsigned short aSeconds,
unsigned short aServiceClass)
{
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
CFStateChangeEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mSuccess = aSuccess;
init.mAction = aAction;
init.mReason = aReason;
init.mNumber = aNumber;
init.mTimeSeconds = aSeconds;
init.mServiceClass = aServiceClass;
nsRefPtr<CFStateChangeEvent> event =
CFStateChangeEvent::Constructor(this, NS_LITERAL_STRING("cfstatechange"), init);
return DispatchTrustedEvent(event);
}
NS_IMETHODIMP
MobileConnection::NotifyEmergencyCbModeChanged(bool aActive,
uint32_t aTimeoutMs)
{
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
MozEmergencyCbModeEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mActive = aActive;
init.mTimeoutMs = aTimeoutMs;
nsRefPtr<MozEmergencyCbModeEvent> event =
MozEmergencyCbModeEvent::Constructor(this, NS_LITERAL_STRING("emergencycbmodechange"), init);
return DispatchTrustedEvent(event);
}
NS_IMETHODIMP
MobileConnection::NotifyOtaStatusChanged(const nsAString& aStatus)
{
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
MozOtaStatusEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mStatus = aStatus;
nsRefPtr<MozOtaStatusEvent> event =
MozOtaStatusEvent::Constructor(this, NS_LITERAL_STRING("otastatuschange"), init);
return DispatchTrustedEvent(event);
}
NS_IMETHODIMP
MobileConnection::NotifyIccChanged()
{
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
return DispatchTrustedEvent(NS_LITERAL_STRING("iccchange"));
}
NS_IMETHODIMP
MobileConnection::NotifyRadioStateChanged()
{
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
return DispatchTrustedEvent(NS_LITERAL_STRING("radiostatechange"));
}

View File

@ -0,0 +1,58 @@
/* 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_network_MobileConnection_h
#define mozilla_dom_network_MobileConnection_h
#include "nsIDOMMobileConnection.h"
#include "nsIMobileConnectionProvider.h"
#include "nsDOMEventTargetHelper.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWeakPtr.h"
namespace mozilla {
namespace dom {
class MobileConnection : public nsDOMEventTargetHelper
, public nsIDOMMozMobileConnection
{
/**
* Class MobileConnection doesn't actually inherit
* nsIMobileConnectionListener. Instead, it owns an
* nsIMobileConnectionListener derived instance mListener and passes it to
* nsIMobileConnectionProvider. The onreceived events are first delivered to
* mListener and then forwarded to its owner, MobileConnection. See also bug
* 775997 comment #51.
*/
class Listener;
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMMOZMOBILECONNECTION
NS_DECL_NSIMOBILECONNECTIONLISTENER
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
MobileConnection(uint32_t aClientId);
void Init(nsPIDOMWindow *aWindow);
void Shutdown();
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MobileConnection,
nsDOMEventTargetHelper)
private:
nsCOMPtr<nsIMobileConnectionProvider> mProvider;
nsRefPtr<Listener> mListener;
nsWeakPtr mWindow;
uint32_t mClientId;
bool CheckPermission(const char* aType);
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_network_MobileConnection_h

View File

@ -0,0 +1,113 @@
/* -*- 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 "MobileConnectionArray.h"
#include "mozilla/dom/MozMobileConnectionArrayBinding.h"
#include "mozilla/Preferences.h"
using namespace mozilla::dom;
NS_IMPL_CYCLE_COLLECTION_CLASS(MobileConnectionArray)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(MobileConnectionArray)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindow)
// Notify our mobile connections that we're going away.
tmp->DropConnections();
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(MobileConnectionArray)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMobileConnections)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(MobileConnectionArray)
NS_IMPL_CYCLE_COLLECTING_ADDREF(MobileConnectionArray)
NS_IMPL_CYCLE_COLLECTING_RELEASE(MobileConnectionArray)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MobileConnectionArray)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
MobileConnectionArray::MobileConnectionArray(nsPIDOMWindow* aWindow)
: mWindow(aWindow), mInitialized(false)
{
uint32_t numRil = mozilla::Preferences::GetUint("ril.numRadioInterfaces", 1);
MOZ_ASSERT(numRil > 0);
bool ret = mMobileConnections.SetLength(numRil);
MOZ_ASSERT(ret);
SetIsDOMBinding();
}
MobileConnectionArray::~MobileConnectionArray()
{
DropConnections();
}
void
MobileConnectionArray::Init()
{
mInitialized = true;
for (uint32_t id = 0; id < mMobileConnections.Length(); id++) {
nsRefPtr<MobileConnection> mobileConnection = new MobileConnection(id);
mobileConnection->Init(mWindow);
mMobileConnections[id] = mobileConnection;
}
}
void
MobileConnectionArray::DropConnections()
{
if (mInitialized) {
for (uint32_t i = 0; i < mMobileConnections.Length(); i++) {
mMobileConnections[i]->Shutdown();
}
}
mMobileConnections.Clear();
}
nsPIDOMWindow*
MobileConnectionArray::GetParentObject() const
{
MOZ_ASSERT(mWindow);
return mWindow;
}
JSObject*
MobileConnectionArray::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
{
return MozMobileConnectionArrayBinding::Wrap(aCx, aScope, this);
}
nsIDOMMozMobileConnection*
MobileConnectionArray::Item(uint32_t aIndex)
{
bool unused;
return IndexedGetter(aIndex, unused);
}
uint32_t
MobileConnectionArray::Length() const
{
return mMobileConnections.Length();
}
nsIDOMMozMobileConnection*
MobileConnectionArray::IndexedGetter(uint32_t aIndex, bool& aFound)
{
if (!mInitialized) {
Init();
}
aFound = false;
aFound = aIndex < mMobileConnections.Length();
return aFound ? mMobileConnections[aIndex] : nullptr;
}

View File

@ -0,0 +1,62 @@
/* -*- 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_network_MobileConnectionArray_h__
#define mozilla_dom_network_MobileConnectionArray_h__
#include "nsWrapperCache.h"
#include "mozilla/dom/MobileConnection.h"
class nsIDOMMozMobileConnection;
namespace mozilla {
namespace dom {
class MobileConnectionArray MOZ_FINAL : public nsISupports,
public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MobileConnectionArray)
MobileConnectionArray(nsPIDOMWindow* aWindow);
nsPIDOMWindow*
GetParentObject() const;
// WrapperCache
virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
// WebIDL
nsIDOMMozMobileConnection*
Item(uint32_t aIndex);
uint32_t
Length() const;
nsIDOMMozMobileConnection*
IndexedGetter(uint32_t aIndex, bool& aFound);
private:
~MobileConnectionArray();
void
Init();
void
DropConnections();
bool mInitialized;
nsCOMPtr<nsPIDOMWindow> mWindow;
nsTArray<nsRefPtr<MobileConnection>> mMobileConnections;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_network_MobileConnectionArray_h__

View File

@ -0,0 +1,25 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXPORTS.mozilla.dom += [
'MobileConnection.h',
'MobileConnectionArray.h',
]
SOURCES += [
'MobileConnection.cpp',
'MobileConnectionArray.cpp',
]
FAIL_ON_WARNINGS = True
include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'gklayout'
LOCAL_INCLUDES += [
'/dom/events',
]

View File

@ -20,4 +20,5 @@ disabled = Bug 808783
[test_call_barring_change_password.js]
[test_mobile_set_radio.js]
[test_mobile_last_known_network.js]
[test_mobile_icc_change.js]
[test_mobile_connections_array_uninitialized.js]

View File

@ -0,0 +1,84 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 30000;
SpecialPowers.addPermission("mobileconnection", true, document);
// Permission changes can't change existing Navigator.prototype
// objects, so grab our objects from a new Navigator
let ifr = document.createElement("iframe");
let connection;
ifr.onload = function() {
connection = ifr.contentWindow.navigator.mozMobileConnections[0];
ok(connection instanceof ifr.contentWindow.MozMobileConnection,
"connection is instanceof " + connection.constructor);
// The emulator's hard coded iccid value.
// See it here {B2G_HOME}/external/qemu/telephony/sim_card.c.
is(connection.iccId, 89014103211118510720);
runNextTest();
};
document.body.appendChild(ifr);
function waitForIccChange(callback) {
connection.addEventListener("iccchange", function handler() {
connection.removeEventListener("iccchange", handler);
callback();
});
}
function setRadioEnabled(enabled) {
let request = connection.setRadioEnabled(enabled);
request.onsuccess = function onsuccess() {
log('setRadioEnabled: ' + enabled);
};
request.onerror = function onerror() {
ok(false, "setRadioEnabled should be ok");
};
}
function testIccChangeOnRadioPowerOff() {
// Turn off radio
setRadioEnabled(false);
waitForIccChange(function() {
is(connection.iccId, null);
runNextTest();
});
}
function testIccChangeOnRadioPowerOn() {
// Turn on radio
setRadioEnabled(true);
waitForIccChange(function() {
// The emulator's hard coded iccid value.
is(connection.iccId, 89014103211118510720);
runNextTest();
});
}
let tests = [
testIccChangeOnRadioPowerOff,
testIccChangeOnRadioPowerOn
];
function runNextTest() {
let test = tests.shift();
if (!test) {
cleanUp();
return;
}
test();
}
function cleanUp() {
SpecialPowers.removePermission("mobileconnection", document);
finish();
}

View File

@ -95,6 +95,7 @@ if CONFIG['MOZ_B2G_RIL']:
PARALLEL_DIRS += [
'icc',
'cellbroadcast',
'mobileconnection',
'voicemail',
'wappush',
]

View File

@ -15,12 +15,6 @@ XPIDL_SOURCES += [
'nsIUDPSocketChild.idl',
]
if CONFIG['MOZ_B2G_RIL']:
XPIDL_SOURCES += [
'nsIDOMMobileConnection.idl',
'nsIMobileConnectionProvider.idl',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
XPIDL_SOURCES += [
'nsIDOMNetworkStats.idl',

View File

@ -26,16 +26,6 @@ UNIFIED_SOURCES += [
'UDPSocketParent.cpp',
]
if CONFIG['MOZ_B2G_RIL']:
EXPORTS.mozilla.dom.network += [
'MobileConnection.h',
'MobileConnectionArray.h',
]
UNIFIED_SOURCES += [
'MobileConnection.cpp',
'MobileConnectionArray.cpp',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
EXTRA_JS_MODULES = [
'NetworkStatsDB.jsm',
@ -71,7 +61,7 @@ FAIL_ON_WARNINGS = True
include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'gklayout'
LOCAL_INCLUDES += [
'/dom/events',
]

View File

@ -20,7 +20,7 @@ skip = false
[include:../../../../../dom/voicemail/test/marionette/manifest.ini]
[include:../../../../../dom/battery/test/marionette/manifest.ini]
[include:../../../../../dom/mobilemessage/tests/marionette/manifest.ini]
[include:../../../../../dom/network/tests/marionette/manifest.ini]
[include:../../../../../dom/mobileconnection/tests/marionette/manifest.ini]
[include:../../../../../dom/system/gonk/tests/marionette/manifest.ini]
[include:../../../../../dom/icc/tests/marionette/manifest.ini]
[include:../../../../../dom/system/tests/marionette/manifest.ini]

View File

@ -68,6 +68,7 @@ static nsIntRect sVirtualBounds;
static nsRefPtr<GLContext> sGLContext;
static nsTArray<nsWindow *> sTopWindows;
static nsWindow *gWindowToRedraw = nullptr;
static nsWindow *gFocusedWindow = nullptr;
static bool sFramebufferOpen;
static bool sUsingOMTC;
@ -184,24 +185,20 @@ nsWindow::DoDraw(void)
return;
}
if (sTopWindows.IsEmpty()) {
if (!gWindowToRedraw) {
LOG(" no window to draw, bailing");
return;
}
nsWindow *targetWindow = (nsWindow *)sTopWindows[0];
while (targetWindow->GetLastChild())
targetWindow = (nsWindow *)targetWindow->GetLastChild();
nsIntRegion region = gWindowToRedraw->mDirtyRegion;
gWindowToRedraw->mDirtyRegion.SetEmpty();
nsIntRegion region = sTopWindows[0]->mDirtyRegion;
sTopWindows[0]->mDirtyRegion.SetEmpty();
nsIWidgetListener* listener = targetWindow->GetWidgetListener();
nsIWidgetListener* listener = gWindowToRedraw->GetWidgetListener();
if (listener) {
listener->WillPaintWindow(targetWindow);
listener->WillPaintWindow(gWindowToRedraw);
}
LayerManager* lm = targetWindow->GetLayerManager();
LayerManager* lm = gWindowToRedraw->GetLayerManager();
if (mozilla::layers::LAYERS_CLIENT == lm->GetBackendType()) {
// No need to do anything, the compositor will handle drawing
} else if (mozilla::layers::LAYERS_BASIC == lm->GetBackendType()) {
@ -220,12 +217,12 @@ nsWindow::DoDraw(void)
// No double-buffering needed.
AutoLayerManagerSetup setupLayerManager(
targetWindow, ctx, mozilla::layers::BUFFER_NONE,
gWindowToRedraw, ctx, mozilla::layers::BUFFER_NONE,
ScreenRotation(EffectiveScreenRotation()));
listener = targetWindow->GetWidgetListener();
listener = gWindowToRedraw->GetWidgetListener();
if (listener) {
listener->PaintWindow(targetWindow, region);
listener->PaintWindow(gWindowToRedraw, region);
}
}
@ -237,7 +234,7 @@ nsWindow::DoDraw(void)
NS_RUNTIMEABORT("Unexpected layer manager type");
}
listener = targetWindow->GetWidgetListener();
listener = gWindowToRedraw->GetWidgetListener();
if (listener) {
listener->DidPaintWindow();
}
@ -284,10 +281,11 @@ nsWindow::Create(nsIWidget *aParent,
mBounds = aRect;
mParent = (nsWindow *)aParent;
nsWindow *parent = (nsWindow *)aNativeParent;
mParent = parent;
mVisible = false;
if (!aParent) {
if (!aNativeParent) {
mBounds = sVirtualBounds;
}
@ -305,6 +303,8 @@ nsWindow::Destroy(void)
{
mOnDestroyCalled = true;
sTopWindows.RemoveElement(this);
if (this == gWindowToRedraw)
gWindowToRedraw = nullptr;
if (this == gFocusedWindow)
gFocusedWindow = nullptr;
nsBaseWidget::OnDestroy();
@ -381,8 +381,8 @@ nsWindow::Resize(double aX,
if (mWidgetListener)
mWidgetListener->WindowResized(this, mBounds.width, mBounds.height);
if (aRepaint)
Invalidate(sVirtualBounds);
if (aRepaint && gWindowToRedraw)
gWindowToRedraw->Invalidate(sVirtualBounds);
return NS_OK;
}
@ -418,13 +418,14 @@ nsWindow::ConfigureChildren(const nsTArray<nsIWidget::Configuration>&)
NS_IMETHODIMP
nsWindow::Invalidate(const nsIntRect &aRect)
{
nsWindow *top = mParent;
while (top && top->mParent)
top = top->mParent;
if (top != sTopWindows[0] && this != sTopWindows[0])
nsWindow *parent = mParent;
while (parent && parent != sTopWindows[0])
parent = parent->mParent;
if (parent != sTopWindows[0])
return NS_OK;
mDirtyRegion.Or(mDirtyRegion, aRect);
gWindowToRedraw = this;
gDrawRequest = true;
mozilla::NotifyEvent();
return NS_OK;
@ -452,6 +453,8 @@ nsWindow::GetNativeData(uint32_t aDataType)
switch (aDataType) {
case NS_NATIVE_WINDOW:
return GetGonkDisplay()->GetNativeWindow();
case NS_NATIVE_WIDGET:
return this;
}
return nullptr;
}
@ -763,12 +766,12 @@ nsScreenGonk::SetRotation(uint32_t aRotation)
sVirtualBounds = gScreenBounds;
}
nsAppShell::NotifyScreenRotation();
for (unsigned int i = 0; i < sTopWindows.Length(); i++)
sTopWindows[i]->Resize(sVirtualBounds.width,
sVirtualBounds.height,
true);
!i);
nsAppShell::NotifyScreenRotation();
return NS_OK;
}