merge b2g-inbound to mozilla-central

This commit is contained in:
Carsten "Tomcat" Book 2013-11-11 12:03:04 +01:00
commit 54656e2880
8 changed files with 282 additions and 154 deletions

View File

@ -1,4 +1,4 @@
{
"revision": "cc492bd8ccdfb6f02734b7e13d970c605c8a4f87",
"revision": "4a3f02dbc339012f5f595b8180f54adf5cb08713",
"repo_path": "/integration/gaia-central"
}

View File

@ -415,7 +415,7 @@ BluetoothHfpManager::Init()
#ifdef MOZ_B2G_RIL
mListener = new BluetoothRilListener();
if (!mListener->StartListening()) {
if (!mListener->Listen(true)) {
BT_WARNING("Failed to start listening RIL");
return false;
}
@ -447,7 +447,7 @@ BluetoothHfpManager::Init()
BluetoothHfpManager::~BluetoothHfpManager()
{
#ifdef MOZ_B2G_RIL
if (!mListener->StopListening()) {
if (!mListener->Listen(false)) {
BT_WARNING("Failed to stop listening RIL");
}
mListener = nullptr;
@ -586,15 +586,14 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
#ifdef MOZ_B2G_RIL
void
BluetoothHfpManager::HandleVoiceConnectionChanged()
BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
{
nsCOMPtr<nsIMobileConnectionProvider> connection =
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
NS_ENSURE_TRUE_VOID(connection);
nsCOMPtr<nsIDOMMozMobileConnectionInfo> voiceInfo;
// TODO: Bug 921991 - B2G BT: support multiple sim cards
connection->GetVoiceConnectionInfo(0, getter_AddRefs(voiceInfo));
connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
NS_ENSURE_TRUE_VOID(voiceInfo);
nsString type;
@ -605,11 +604,12 @@ BluetoothHfpManager::HandleVoiceConnectionChanged()
voiceInfo->GetRoaming(&roaming);
UpdateCIND(CINDType::ROAM, roaming);
bool service = false;
nsString regState;
voiceInfo->GetState(regState);
if (regState.EqualsLiteral("registered")) {
service = true;
bool service = regState.EqualsLiteral("registered");
if (service != sCINDItems[CINDType::SERVICE].value) {
// Notify BluetoothRilListener of service change
mListener->ServiceChanged(aClientId, service);
}
UpdateCIND(CINDType::SERVICE, service);
@ -630,8 +630,7 @@ BluetoothHfpManager::HandleVoiceConnectionChanged()
* - manual: set mNetworkSelectionMode to 1 (manual)
*/
nsString mode;
// TODO: Bug 921991 - B2G BT: support multiple sim cards
connection->GetNetworkSelectionMode(0, mode);
connection->GetNetworkSelectionMode(aClientId, mode);
if (mode.EqualsLiteral("manual")) {
mNetworkSelectionMode = 1;
} else {
@ -658,15 +657,14 @@ BluetoothHfpManager::HandleVoiceConnectionChanged()
}
void
BluetoothHfpManager::HandleIccInfoChanged()
BluetoothHfpManager::HandleIccInfoChanged(uint32_t aClientId)
{
nsCOMPtr<nsIIccProvider> icc =
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
NS_ENSURE_TRUE_VOID(icc);
nsCOMPtr<nsIDOMMozIccInfo> iccInfo;
// TODO: Bug 921991 - B2G BT: support multiple sim cards
icc->GetIccInfo(0, getter_AddRefs(iccInfo));
icc->GetIccInfo(aClientId, getter_AddRefs(iccInfo));
NS_ENSURE_TRUE_VOID(iccInfo);
nsCOMPtr<nsIDOMMozGsmIccInfo> gsmIccInfo = do_QueryInterface(iccInfo);

View File

@ -121,8 +121,8 @@ public:
void HandleCallStateChanged(uint32_t aCallIndex, uint16_t aCallState,
const nsAString& aError, const nsAString& aNumber,
const bool aIsOutgoing, bool aSend);
void HandleIccInfoChanged();
void HandleVoiceConnectionChanged();
void HandleIccInfoChanged(uint32_t aClientId);
void HandleVoiceConnectionChanged(uint32_t aClientId);
#endif
bool IsConnected();

View File

@ -7,36 +7,24 @@
#include "BluetoothRilListener.h"
#include "BluetoothHfpManager.h"
#include "nsIIccProvider.h"
#include "nsIMobileConnectionProvider.h"
#include "nsITelephonyProvider.h"
#include "nsIDOMMobileConnection.h"
#include "nsIRadioInterfaceLayer.h"
#include "nsRadioInterfaceLayer.h"
#include "nsServiceManagerUtils.h"
#include "nsString.h"
USING_BLUETOOTH_NAMESPACE
namespace {
/**
* IccListener
*/
class IccListener : public nsIIccListener
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIICCLISTENER
IccListener() { }
};
NS_IMPL_ISUPPORTS1(IccListener, nsIIccListener)
NS_IMETHODIMP
IccListener::NotifyIccInfoChanged()
{
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
hfp->HandleIccInfoChanged();
hfp->HandleIccInfoChanged(mOwner->mClientId);
return NS_OK;
}
@ -59,25 +47,39 @@ IccListener::NotifyCardStateChanged()
return NS_OK;
}
bool
IccListener::Listen(bool aStart)
{
nsCOMPtr<nsIIccProvider> provider =
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
NS_ENSURE_TRUE(provider, false);
nsresult rv;
if (aStart) {
rv = provider->RegisterIccMsg(mOwner->mClientId, this);
} else {
rv = provider->UnregisterIccMsg(mOwner->mClientId, this);
}
return NS_SUCCEEDED(rv);
}
void
IccListener::SetOwner(BluetoothRilListener *aOwner)
{
mOwner = aOwner;
}
/**
* MobileConnectionListener
*/
class MobileConnectionListener : public nsIMobileConnectionListener
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMOBILECONNECTIONLISTENER
MobileConnectionListener() { }
};
NS_IMPL_ISUPPORTS1(MobileConnectionListener, nsIMobileConnectionListener)
NS_IMETHODIMP
MobileConnectionListener::NotifyVoiceChanged()
{
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
hfp->HandleVoiceConnectionChanged();
hfp->HandleVoiceConnectionChanged(mClientId);
return NS_OK;
}
@ -131,20 +133,26 @@ MobileConnectionListener::NotifyIccChanged()
return NS_OK;
}
bool
MobileConnectionListener::Listen(bool aStart)
{
nsCOMPtr<nsIMobileConnectionProvider> provider =
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
NS_ENSURE_TRUE(provider, false);
nsresult rv;
if (aStart) {
rv = provider->RegisterMobileConnectionMsg(mClientId, this);
} else {
rv = provider->UnregisterMobileConnectionMsg(mClientId, this);
}
return NS_SUCCEEDED(rv);
}
/**
* TelephonyListener Implementation
*
* TODO: Bug 921991 - B2G BT: support multiple sim cards
*/
class TelephonyListener : public nsITelephonyListener
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSITELEPHONYLISTENER
TelephonyListener() { }
};
NS_IMPL_ISUPPORTS1(TelephonyListener, nsITelephonyListener)
NS_IMETHODIMP
@ -243,36 +251,109 @@ TelephonyListener::NotifyCdmaCallWaiting(uint32_t aServiceId,
return NS_OK;
}
} // anonymous namespace
bool
TelephonyListener::Listen(bool aStart)
{
nsCOMPtr<nsITelephonyProvider> provider =
do_GetService(TELEPHONY_PROVIDER_CONTRACTID);
NS_ENSURE_TRUE(provider, false);
nsresult rv;
if (aStart) {
rv = provider->RegisterListener(this);
} else {
rv = provider->UnregisterListener(this);
}
return NS_SUCCEEDED(rv);
}
/**
* BluetoothRilListener
*/
BluetoothRilListener::BluetoothRilListener()
{
mIccListener = new IccListener();
mMobileConnectionListener = new MobileConnectionListener();
mTelephonyListener = new TelephonyListener();
// Query number of total clients (sim slots)
uint32_t numOfClients;
nsCOMPtr<nsIRadioInterfaceLayer> radioInterfaceLayer =
do_GetService(NS_RADIOINTERFACELAYER_CONTRACTID);
NS_ENSURE_TRUE_VOID(radioInterfaceLayer);
radioInterfaceLayer->GetNumRadioInterfaces(&numOfClients);
// Init MobileConnectionListener array and IccInfoListener
for (uint32_t i = 0; i < numOfClients; i++) {
MobileConnectionListener listener(i);
mMobileConnListeners.AppendElement(listener);
}
mIccListener.SetOwner(this);
// Probe for available client
SelectClient();
}
bool
BluetoothRilListener::StartListening()
BluetoothRilListener::Listen(bool aStart)
{
NS_ENSURE_TRUE(StartIccListening(), false);
NS_ENSURE_TRUE(StartMobileConnectionListening(), false);
NS_ENSURE_TRUE(StartTelephonyListening(), false);
NS_ENSURE_TRUE(ListenMobileConnAndIccInfo(aStart), false);
NS_ENSURE_TRUE(mTelephonyListener.Listen(aStart), false);
return true;
}
bool
BluetoothRilListener::StopListening()
void
BluetoothRilListener::SelectClient()
{
NS_ENSURE_TRUE(StopIccListening(), false);
NS_ENSURE_TRUE(StopMobileConnectionListening(), false);
NS_ENSURE_TRUE(StopTelephonyListening(), false);
// Reset mClientId
mClientId = mMobileConnListeners.Length();
return true;
nsCOMPtr<nsIMobileConnectionProvider> connection =
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
NS_ENSURE_TRUE_VOID(connection);
uint32_t i;
for (i = 0; i < mMobileConnListeners.Length(); i++) {
nsCOMPtr<nsIDOMMozMobileConnectionInfo> voiceInfo;
connection->GetVoiceConnectionInfo(i, getter_AddRefs(voiceInfo));
if (!voiceInfo) {
BT_WARNING("%s: Failed to get voice connection info", __FUNCTION__);
continue;
}
nsString regState;
voiceInfo->GetState(regState);
if (regState.EqualsLiteral("registered")) {
// Found available client
mClientId = i;
return;
}
}
}
void
BluetoothRilListener::ServiceChanged(uint32_t aClientId, bool aRegistered)
{
// Stop listening
ListenMobileConnAndIccInfo(false);
/**
* aRegistered:
* - TRUE: service becomes registered. We were listening to all clients
* and one of them becomes available. Select it to listen.
* - FALSE: service becomes un-registered. The client we were listening
* becomes unavailable. Select another registered one to listen.
*/
if (aRegistered) {
mClientId = aClientId;
} else {
SelectClient();
}
// Restart listening
ListenMobileConnAndIccInfo(true);
BT_LOGR("%s: %d client %d. new mClientId %d", __FUNCTION__, aRegistered, aClientId,
(mClientId < mMobileConnListeners.Length()) ? mClientId : -1);
}
void
@ -282,78 +363,32 @@ BluetoothRilListener::EnumerateCalls()
do_GetService(TELEPHONY_PROVIDER_CONTRACTID);
NS_ENSURE_TRUE_VOID(provider);
provider->EnumerateCalls(mTelephonyListener);
}
nsCOMPtr<nsITelephonyListener> listener(
do_QueryInterface(&mTelephonyListener));
// private
bool
BluetoothRilListener::StartIccListening()
{
nsCOMPtr<nsIIccProvider> provider =
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
NS_ENSURE_TRUE(provider, false);
// TODO: Bug 921991 - B2G BT: support multiple sim cards
nsresult rv = provider->RegisterIccMsg(0, mIccListener);
return NS_SUCCEEDED(rv);
provider->EnumerateCalls(listener);
}
bool
BluetoothRilListener::StopIccListening()
BluetoothRilListener::ListenMobileConnAndIccInfo(bool aStart)
{
nsCOMPtr<nsIIccProvider> provider =
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
NS_ENSURE_TRUE(provider, false);
/**
* mClientId < number of total clients:
* The client with mClientId is available. Start/Stop listening
* mobile connection and icc info of this client only.
*
* mClientId >= number of total clients:
* All clients are unavailable. Start/Stop listening mobile
* connections of all clients.
*/
if (mClientId < mMobileConnListeners.Length()) {
NS_ENSURE_TRUE(mMobileConnListeners[mClientId].Listen(aStart), false);
NS_ENSURE_TRUE(mIccListener.Listen(aStart), false);
} else {
for (uint32_t i = 0; i < mMobileConnListeners.Length(); i++) {
NS_ENSURE_TRUE(mMobileConnListeners[i].Listen(aStart), false);
}
}
// TODO: Bug 921991 - B2G BT: support multiple sim cards
nsresult rv = provider->UnregisterIccMsg(0, mIccListener);
return NS_SUCCEEDED(rv);
}
bool
BluetoothRilListener::StartMobileConnectionListening()
{
nsCOMPtr<nsIMobileConnectionProvider> provider =
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
NS_ENSURE_TRUE(provider, false);
// TODO: Bug 921991 - B2G BT: support multiple sim cards
nsresult rv = provider->
RegisterMobileConnectionMsg(0, mMobileConnectionListener);
return NS_SUCCEEDED(rv);
}
bool
BluetoothRilListener::StopMobileConnectionListening()
{
nsCOMPtr<nsIMobileConnectionProvider> provider =
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
NS_ENSURE_TRUE(provider, false);
// TODO: Bug 921991 - B2G BT: support multiple sim cards
nsresult rv = provider->
UnregisterMobileConnectionMsg(0, mMobileConnectionListener);
return NS_SUCCEEDED(rv);
}
bool
BluetoothRilListener::StartTelephonyListening()
{
nsCOMPtr<nsITelephonyProvider> provider =
do_GetService(TELEPHONY_PROVIDER_CONTRACTID);
NS_ENSURE_TRUE(provider, false);
nsresult rv = provider->RegisterListener(mTelephonyListener);
return NS_SUCCEEDED(rv);
}
bool
BluetoothRilListener::StopTelephonyListening()
{
nsCOMPtr<nsITelephonyProvider> provider =
do_GetService(TELEPHONY_PROVIDER_CONTRACTID);
NS_ENSURE_TRUE(provider, false);
nsresult rv = provider->UnregisterListener(mTelephonyListener);
return NS_SUCCEEDED(rv);
return true;
}

View File

@ -9,37 +9,114 @@
#include "BluetoothCommon.h"
#include "nsCOMPtr.h"
class nsIIccListener;
class nsIMobileConnectionListener;
class nsITelephonyListener;
#include "nsIIccProvider.h"
#include "nsIMobileConnectionProvider.h"
#include "nsITelephonyProvider.h"
BEGIN_BLUETOOTH_NAMESPACE
class BluetoothRilListener;
class IccListener : public nsIIccListener
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIICCLISTENER
IccListener() { }
bool Listen(bool aStart);
void SetOwner(BluetoothRilListener *aOwner);
private:
BluetoothRilListener* mOwner;
};
class MobileConnectionListener : public nsIMobileConnectionListener
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMOBILECONNECTIONLISTENER
MobileConnectionListener(uint32_t aClientId)
: mClientId(aClientId) { }
bool Listen(bool aStart);
private:
uint32_t mClientId;
};
class TelephonyListener : public nsITelephonyListener
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSITELEPHONYLISTENER
TelephonyListener() { }
bool Listen(bool aStart);
};
class BluetoothRilListener
{
public:
BluetoothRilListener();
bool StartListening();
bool StopListening();
/**
* Start/Stop listening.
*
* @param aStart [in] whether to start/stop listening
*/
bool Listen(bool aStart);
/**
* Be informed that certain client's service has changed.
*
* @param aClientId [in] the client id with service change
* @param aRegistered [in] whether changed service is registered
*/
void ServiceChanged(uint32_t aClientId, bool aRegistered);
/**
* Enumerate current calls.
*/
void EnumerateCalls();
/**
* The id of client that mobile connection and icc info listeners
* are listening to.
*
* mClientId equals to number of total clients (array length of
* mobile connection listeners) if there is no available client to listen.
*/
uint32_t mClientId;
private:
bool StartIccListening();
bool StopIccListening();
/**
* Start/Stop listening of mobile connection and icc info.
*
* @param aStart [in] whether to start/stop listening
*/
bool ListenMobileConnAndIccInfo(bool aStart);
bool StartMobileConnectionListening();
bool StopMobileConnectionListening();
/**
* Select available client to listen and assign mClientId.
*
* mClientId is assigned to number of total clients (array length of
* mobile connection listeners) if there is no available client to listen.
*/
void SelectClient();
bool StartTelephonyListening();
bool StopTelephonyListening();
/**
* Array of mobile connection listeners.
*
* The length equals to number of total clients.
*/
nsTArray<MobileConnectionListener> mMobileConnListeners;
nsCOMPtr<nsIIccListener> mIccListener;
nsCOMPtr<nsIMobileConnectionListener> mMobileConnectionListener;
nsCOMPtr<nsITelephonyListener> mTelephonyListener;
IccListener mIccListener;
TelephonyListener mTelephonyListener;
};
END_BLUETOOTH_NAMESPACE

View File

@ -407,16 +407,25 @@ MmsConnection.prototype = {
return;
}
this.connected =
// We only need to capture the state change of MMS network. Using
// |network.state| isn't reliable due to the possibilty of shared APN.
let connected =
this.radioInterface.getDataCallStateByType("mms") ==
Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
// Return if the MMS network state doesn't change, where the network
// state change can come from other non-MMS networks.
if (connected == this.connected) {
return;
}
this.connected = connected;
if (!this.connected) {
return;
}
// Set up the MMS APN setting based on the network, which is going to
// be used for the HTTP requests later.
// Set up the MMS APN setting based on the connected MMS network,
// which is going to be used for the HTTP requests later.
this.setApnSetting(network);
if (DEBUG) debug("Got the MMS network connected! Resend the buffered " +

View File

@ -11,4 +11,6 @@
#define NS_RILCONTENTHELPER_CID \
{ 0x472816e1, 0x1fd6, 0x4405, \
{ 0x99, 0x6c, 0x80, 0x6f, 0x9e, 0xa6, 0x81, 0x74 } }
#define NS_RADIOINTERFACELAYER_CONTRACTID "@mozilla.org/ril;1"
#define NS_RILCONTENTHELPER_CONTRACTID "@mozilla.org/ril/content-helper;1"

View File

@ -6,6 +6,7 @@
let Ci = Components.interfaces;
let Cu = Components.utils;
let Cr = Components.results;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
@ -88,7 +89,13 @@ this.ThirdPartyCookieProbe.prototype = {
data.addRejected(firstParty);
}
} catch (ex) {
// Errors should not remain silent
if (ex instanceof Ci.nsIXPCException) {
if (ex.result == Cr.NS_ERROR_HOST_IS_IP_ADDRESS ||
ex.result == Cr.NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS) {
return;
}
}
// Other errors should not remain silent.
Services.console.logStringMessage("ThirdPartyCookieProbe: Uncaught error " + ex + "\n" + ex.stack);
}
},