Merge b2g-inbound to m-c.

This commit is contained in:
Ryan VanderMeulen 2013-10-18 15:00:58 -04:00
commit a2a3934897
13 changed files with 437 additions and 287 deletions

View File

@ -1259,23 +1259,62 @@ window.addEventListener('ContentStart', function update_onContentStart() {
(function recordingStatusTracker() {
let gRecordingActiveCount = 0;
let gRecordingActiveProcesses = {};
Services.obs.addObserver(function(aSubject, aTopic, aData) {
let recordingHandler = function(aSubject, aTopic, aData) {
let oldCount = gRecordingActiveCount;
if (aData == "starting") {
gRecordingActiveCount += 1;
} else if (aData == "shutdown") {
gRecordingActiveCount -= 1;
let processId = (!aSubject) ? 'main'
: aSubject.QueryInterface(Ci.nsIPropertyBag2).get('childID');
if (processId && !gRecordingActiveProcesses.hasOwnProperty(processId)) {
gRecordingActiveProcesses[processId] = 0;
}
// We need to track changes from 1 <-> 0
if (gRecordingActiveCount + oldCount == 1) {
let currentActive = gRecordingActiveProcesses[processId];
switch (aData) {
case 'starting':
gRecordingActiveCount++;
currentActive++;
break;
case 'shutdown':
// Bug 928206 will make shutdown be sent even if no starting.
if (currentActive > 0) {
gRecordingActiveCount--;
currentActive--;
}
break;
case 'content-shutdown':
gRecordingActiveCount -= currentActive;
currentActive = 0;
break;
}
if (currentActive > 0) {
gRecordingActiveProcesses[processId] = currentActive;
} else {
delete gRecordingActiveProcesses[processId];
}
// We need to track changes from N <-> 0
if ((oldCount === 0 && gRecordingActiveCount > 0) ||
(gRecordingActiveCount === 0 && oldCount > 0)) {
shell.sendChromeEvent({
type: 'recording-status',
active: (gRecordingActiveCount == 1)
active: (gRecordingActiveCount > 0)
});
}
}, "recording-device-events", false);
};
Services.obs.addObserver(recordingHandler, 'recording-device-events', false);
Services.obs.addObserver(recordingHandler, 'recording-device-ipc-events', false);
Services.obs.addObserver(function(aSubject, aTopic, aData) {
// send additional recording events if content process is being killed
let props = aSubject.QueryInterface(Ci.nsIPropertyBag2);
let childId = aSubject.get('childID');
if (gRecordingActiveProcesses.hasOwnProperty(childId) >= 0) {
Services.obs.notifyObservers(aSubject, 'recording-device-ipc-events', 'content-shutdown');
}
}, 'ipc:content-shutdown', false);
})();
(function volumeStateTracker() {

View File

@ -1,4 +1,4 @@
{
"revision": "154bb18c48ff06e41fb7ba24d8f72d520919646f",
"revision": "723401621af1bfabb671ec53ac7cafd62b700cb9",
"repo_path": "/integration/gaia-central"
}

View File

@ -561,7 +561,8 @@ BluetoothHfpManager::HandleVoiceConnectionChanged()
NS_ENSURE_TRUE_VOID(connection);
nsCOMPtr<nsIDOMMozMobileConnectionInfo> voiceInfo;
connection->GetVoiceConnectionInfo(getter_AddRefs(voiceInfo));
// TODO: Bug 921991 - B2G BT: support multiple sim cards
connection->GetVoiceConnectionInfo(0, getter_AddRefs(voiceInfo));
NS_ENSURE_TRUE_VOID(voiceInfo);
nsString type;
@ -597,7 +598,8 @@ BluetoothHfpManager::HandleVoiceConnectionChanged()
* - manual: set mNetworkSelectionMode to 1 (manual)
*/
nsString mode;
connection->GetNetworkSelectionMode(mode);
// TODO: Bug 921991 - B2G BT: support multiple sim cards
connection->GetNetworkSelectionMode(0, mode);
if (mode.EqualsLiteral("manual")) {
mNetworkSelectionMode = 1;
} else {

View File

@ -292,8 +292,9 @@ BluetoothRilListener::StartMobileConnectionListening()
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
NS_ENSURE_TRUE(provider, false);
// TODO: Bug 921991 - B2G BT: support multiple sim cards
nsresult rv = provider->
RegisterMobileConnectionMsg(mMobileConnectionListener);
RegisterMobileConnectionMsg(0, mMobileConnectionListener);
return NS_SUCCEEDED(rv);
}
@ -304,8 +305,9 @@ BluetoothRilListener::StopMobileConnectionListening()
do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
NS_ENSURE_TRUE(provider, false);
// TODO: Bug 921991 - B2G BT: support multiple sim cards
nsresult rv = provider->
UnregisterMobileConnectionMsg(mMobileConnectionListener);
UnregisterMobileConnectionMsg(0, mMobileConnectionListener);
return NS_SUCCEEDED(rv);
}

View File

@ -1940,7 +1940,12 @@ ContentParent::RecvRecordingDeviceEvents(const nsString& aRecordingStatus)
{
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->NotifyObservers(nullptr, "recording-device-events", aRecordingStatus.get());
// recording-device-ipc-events needs to gather more information from content process
nsRefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
props->SetPropertyAsUint64(NS_LITERAL_STRING("childID"), mChildID);
obs->NotifyObservers((nsIPropertyBag2*) props,
"recording-device-ipc-events",
aRecordingStatus.get());
} else {
NS_WARNING("Could not get the Observer service for ContentParent::RecvRecordingDeviceEvents.");
}

View File

@ -56,6 +56,7 @@ this.SystemMessagePermissionsTable = {
"bluetooth": []
},
"connection": { },
"dummy-system-message": { }, // for system message testing framework
"headset-button": { },
"icc-stkcommand": {
"settings": ["read", "write"]

View File

@ -33,7 +33,7 @@ interface nsIMobileConnectionListener : nsISupports
* XPCOM component (in the content process) that provides the mobile
* network information.
*/
[scriptable, uuid(c66652e0-0628-11e3-8ffd-0800200c9a66)]
[scriptable, uuid(84278a49-0f05-4585-b3f4-c74882ae5719)]
interface nsIMobileConnectionProvider : nsISupports
{
/**
@ -41,47 +41,71 @@ interface nsIMobileConnectionProvider : nsISupports
* RadioInterfaceLayer in the chrome process. Only a content process that has
* the 'mobileconnection' permission is allowed to register.
*/
void registerMobileConnectionMsg(in nsIMobileConnectionListener listener);
void unregisterMobileConnectionMsg(in nsIMobileConnectionListener listener);
void registerMobileConnectionMsg(in unsigned long clientId,
in nsIMobileConnectionListener listener);
void unregisterMobileConnectionMsg(in unsigned long clientId,
in nsIMobileConnectionListener listener);
readonly attribute nsIDOMMozMobileConnectionInfo voiceConnectionInfo;
readonly attribute nsIDOMMozMobileConnectionInfo dataConnectionInfo;
readonly attribute DOMString networkSelectionMode;
nsIDOMMozMobileConnectionInfo getVoiceConnectionInfo(in unsigned long clientId);
nsIDOMMozMobileConnectionInfo getDataConnectionInfo(in unsigned long clientId);
DOMString getIccId(in unsigned long clientId);
DOMString getNetworkSelectionMode(in unsigned long clientId);
nsIDOMDOMRequest getNetworks(in nsIDOMWindow window);
nsIDOMDOMRequest selectNetwork(in nsIDOMWindow window, in nsIDOMMozMobileNetworkInfo network);
nsIDOMDOMRequest selectNetworkAutomatically(in nsIDOMWindow window);
nsIDOMDOMRequest getNetworks(in unsigned long clientId,
in nsIDOMWindow window);
nsIDOMDOMRequest selectNetwork(in unsigned long clientId,
in nsIDOMWindow window,
in nsIDOMMozMobileNetworkInfo network);
nsIDOMDOMRequest selectNetworkAutomatically(in unsigned long clientId,
in nsIDOMWindow window);
nsIDOMDOMRequest setRoamingPreference(in nsIDOMWindow window,
nsIDOMDOMRequest setRoamingPreference(in unsigned long clientId,
in nsIDOMWindow window,
in DOMString mode);
nsIDOMDOMRequest getRoamingPreference(in nsIDOMWindow window);
nsIDOMDOMRequest getRoamingPreference(in unsigned long clientId,
in nsIDOMWindow window);
nsIDOMDOMRequest setVoicePrivacyMode(in nsIDOMWindow window,
nsIDOMDOMRequest setVoicePrivacyMode(in unsigned long clientId,
in nsIDOMWindow window,
in bool enabled);
nsIDOMDOMRequest getVoicePrivacyMode(in nsIDOMWindow window);
nsIDOMDOMRequest getVoicePrivacyMode(in unsigned long clientId,
in nsIDOMWindow window);
nsIDOMDOMRequest sendMMI(in nsIDOMWindow window, in DOMString mmi);
nsIDOMDOMRequest cancelMMI(in nsIDOMWindow window);
nsIDOMDOMRequest sendMMI(in unsigned long clientId,
in nsIDOMWindow window,
in DOMString mmi);
nsIDOMDOMRequest cancelMMI(in unsigned long clientId,
in nsIDOMWindow window);
nsIDOMDOMRequest getCallForwardingOption(in nsIDOMWindow window,
nsIDOMDOMRequest getCallForwardingOption(in unsigned long clientId,
in nsIDOMWindow window,
in unsigned short reason);
nsIDOMDOMRequest setCallForwardingOption(in nsIDOMWindow window,
nsIDOMDOMRequest setCallForwardingOption(in unsigned long clientId,
in nsIDOMWindow window,
in nsIDOMMozMobileCFInfo CFInfo);
nsIDOMDOMRequest getCallBarringOption(in nsIDOMWindow window,
in jsval option);
nsIDOMDOMRequest setCallBarringOption(in nsIDOMWindow window,
in jsval option);
nsIDOMDOMRequest changeCallBarringPassword(in nsIDOMWindow window,
nsIDOMDOMRequest getCallBarringOption(in unsigned long clientId,
in nsIDOMWindow window,
in jsval option);
nsIDOMDOMRequest setCallBarringOption(in unsigned long clientId,
in nsIDOMWindow window,
in jsval option);
nsIDOMDOMRequest changeCallBarringPassword(in unsigned long clientId,
in nsIDOMWindow window,
in jsval info);
nsIDOMDOMRequest setCallWaitingOption(in nsIDOMWindow window,
nsIDOMDOMRequest setCallWaitingOption(in unsigned long clientId,
in nsIDOMWindow window,
in bool enabled);
nsIDOMDOMRequest getCallWaitingOption(in nsIDOMWindow window);
nsIDOMDOMRequest getCallWaitingOption(in unsigned long clientId,
in nsIDOMWindow window);
nsIDOMDOMRequest setCallingLineIdRestriction(in nsIDOMWindow window,
nsIDOMDOMRequest setCallingLineIdRestriction(in unsigned long clientId,
in nsIDOMWindow window,
in unsigned short clirMode);
nsIDOMDOMRequest getCallingLineIdRestriction(in nsIDOMWindow window);
nsIDOMDOMRequest getCallingLineIdRestriction(in unsigned long clientId,
in nsIDOMWindow window);
nsIDOMDOMRequest exitEmergencyCbMode(in nsIDOMWindow window);
nsIDOMDOMRequest exitEmergencyCbMode(in unsigned long clientId,
in nsIDOMWindow window);
};

View File

@ -83,6 +83,9 @@ MobileConnection::MobileConnection()
mProvider = do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
mWindow = nullptr;
// TODO: Bug 814629 - WebMobileConnection API: support multiple sim cards
mClientId = 0;
// Not being able to acquire the provider isn't fatal since we check
// for it explicitly below.
if (!mProvider) {
@ -101,7 +104,7 @@ MobileConnection::Init(nsPIDOMWindow* aWindow)
if (!CheckPermission("mobilenetwork") &&
CheckPermission("mobileconnection")) {
DebugOnly<nsresult> rv = mProvider->RegisterMobileConnectionMsg(mListener);
DebugOnly<nsresult> rv = mProvider->RegisterMobileConnectionMsg(mClientId, mListener);
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"Failed registering mobile connection messages with provider");
@ -114,7 +117,7 @@ MobileConnection::Shutdown()
{
if (mProvider && mListener) {
mListener->Disconnect();
mProvider->UnregisterMobileConnectionMsg(mListener);
mProvider->UnregisterMobileConnectionMsg(mClientId, mListener);
mProvider = nullptr;
mListener = nullptr;
}
@ -173,7 +176,7 @@ MobileConnection::GetVoice(nsIDOMMozMobileConnectionInfo** voice)
if (!mProvider || !CheckPermission("mobileconnection")) {
return NS_OK;
}
return mProvider->GetVoiceConnectionInfo(voice);
return mProvider->GetVoiceConnectionInfo(mClientId, voice);
}
NS_IMETHODIMP
@ -184,7 +187,7 @@ MobileConnection::GetData(nsIDOMMozMobileConnectionInfo** data)
if (!mProvider || !CheckPermission("mobileconnection")) {
return NS_OK;
}
return mProvider->GetDataConnectionInfo(data);
return mProvider->GetDataConnectionInfo(mClientId, data);
}
NS_IMETHODIMP
@ -195,7 +198,7 @@ MobileConnection::GetNetworkSelectionMode(nsAString& networkSelectionMode)
if (!mProvider || !CheckPermission("mobileconnection")) {
return NS_OK;
}
return mProvider->GetNetworkSelectionMode(networkSelectionMode);
return mProvider->GetNetworkSelectionMode(mClientId, networkSelectionMode);
}
NS_IMETHODIMP
@ -211,7 +214,7 @@ MobileConnection::GetNetworks(nsIDOMDOMRequest** request)
return NS_ERROR_FAILURE;
}
return mProvider->GetNetworks(GetOwner(), request);
return mProvider->GetNetworks(mClientId, GetOwner(), request);
}
NS_IMETHODIMP
@ -227,7 +230,7 @@ MobileConnection::SelectNetwork(nsIDOMMozMobileNetworkInfo* network, nsIDOMDOMRe
return NS_ERROR_FAILURE;
}
return mProvider->SelectNetwork(GetOwner(), network, request);
return mProvider->SelectNetwork(mClientId, GetOwner(), network, request);
}
NS_IMETHODIMP
@ -243,7 +246,7 @@ MobileConnection::SelectNetworkAutomatically(nsIDOMDOMRequest** request)
return NS_ERROR_FAILURE;
}
return mProvider->SelectNetworkAutomatically(GetOwner(), request);
return mProvider->SelectNetworkAutomatically(mClientId, GetOwner(), request);
}
NS_IMETHODIMP
@ -259,7 +262,7 @@ MobileConnection::SetRoamingPreference(const nsAString& aMode, nsIDOMDOMRequest*
return NS_ERROR_FAILURE;
}
return mProvider->SetRoamingPreference(GetOwner(), aMode, aDomRequest);
return mProvider->SetRoamingPreference(mClientId, GetOwner(), aMode, aDomRequest);
}
NS_IMETHODIMP
@ -275,7 +278,7 @@ MobileConnection::GetRoamingPreference(nsIDOMDOMRequest** aDomRequest)
return NS_ERROR_FAILURE;
}
return mProvider->GetRoamingPreference(GetOwner(), aDomRequest);
return mProvider->GetRoamingPreference(mClientId, GetOwner(), aDomRequest);
}
NS_IMETHODIMP
@ -291,7 +294,7 @@ MobileConnection::SetVoicePrivacyMode(bool aEnabled, nsIDOMDOMRequest** aDomRequ
return NS_ERROR_FAILURE;
}
return mProvider->SetVoicePrivacyMode(GetOwner(), aEnabled, aDomRequest);
return mProvider->SetVoicePrivacyMode(mClientId, GetOwner(), aEnabled, aDomRequest);
}
NS_IMETHODIMP
@ -307,7 +310,7 @@ MobileConnection::GetVoicePrivacyMode(nsIDOMDOMRequest** aDomRequest)
return NS_ERROR_FAILURE;
}
return mProvider->GetVoicePrivacyMode(GetOwner(), aDomRequest);
return mProvider->GetVoicePrivacyMode(mClientId, GetOwner(), aDomRequest);
}
NS_IMETHODIMP
@ -322,7 +325,7 @@ MobileConnection::SendMMI(const nsAString& aMMIString,
return NS_ERROR_FAILURE;
}
return mProvider->SendMMI(GetOwner(), aMMIString, aRequest);
return mProvider->SendMMI(mClientId, GetOwner(), aMMIString, aRequest);
}
NS_IMETHODIMP
@ -336,7 +339,7 @@ MobileConnection::CancelMMI(nsIDOMDOMRequest** aRequest)
return NS_ERROR_FAILURE;
}
return mProvider->CancelMMI(GetOwner(), aRequest);
return mProvider->CancelMMI(mClientId, GetOwner(),aRequest);
}
NS_IMETHODIMP
@ -353,7 +356,7 @@ MobileConnection::GetCallForwardingOption(uint16_t aReason,
return NS_ERROR_FAILURE;
}
return mProvider->GetCallForwardingOption(GetOwner(), aReason, aRequest);
return mProvider->GetCallForwardingOption(mClientId, GetOwner(), aReason, aRequest);
}
NS_IMETHODIMP
@ -370,7 +373,7 @@ MobileConnection::SetCallForwardingOption(nsIDOMMozMobileCFInfo* aCFInfo,
return NS_ERROR_FAILURE;
}
return mProvider->SetCallForwardingOption(GetOwner(), aCFInfo, aRequest);
return mProvider->SetCallForwardingOption(mClientId, GetOwner(), aCFInfo, aRequest);
}
NS_IMETHODIMP
@ -387,7 +390,7 @@ MobileConnection::GetCallBarringOption(const JS::Value& aOption,
return NS_ERROR_FAILURE;
}
return mProvider->GetCallBarringOption(GetOwner(), aOption, aRequest);
return mProvider->GetCallBarringOption(mClientId, GetOwner(), aOption, aRequest);
}
NS_IMETHODIMP
@ -404,7 +407,7 @@ MobileConnection::SetCallBarringOption(const JS::Value& aOption,
return NS_ERROR_FAILURE;
}
return mProvider->SetCallBarringOption(GetOwner(), aOption, aRequest);
return mProvider->SetCallBarringOption(mClientId, GetOwner(), aOption, aRequest);
}
NS_IMETHODIMP
@ -421,7 +424,7 @@ MobileConnection::ChangeCallBarringPassword(const JS::Value& aInfo,
return NS_ERROR_FAILURE;
}
return mProvider->ChangeCallBarringPassword(GetOwner(), aInfo, aRequest);
return mProvider->ChangeCallBarringPassword(mClientId, GetOwner(), aInfo, aRequest);
}
NS_IMETHODIMP
@ -437,7 +440,7 @@ MobileConnection::GetCallWaitingOption(nsIDOMDOMRequest** aRequest)
return NS_ERROR_FAILURE;
}
return mProvider->GetCallWaitingOption(GetOwner(), aRequest);
return mProvider->GetCallWaitingOption(mClientId, GetOwner(), aRequest);
}
NS_IMETHODIMP
@ -454,7 +457,7 @@ MobileConnection::SetCallWaitingOption(bool aEnabled,
return NS_ERROR_FAILURE;
}
return mProvider->SetCallWaitingOption(GetOwner(), aEnabled, aRequest);
return mProvider->SetCallWaitingOption(mClientId, GetOwner(), aEnabled, aRequest);
}
NS_IMETHODIMP
@ -470,7 +473,7 @@ MobileConnection::GetCallingLineIdRestriction(nsIDOMDOMRequest** aRequest)
return NS_ERROR_FAILURE;
}
return mProvider->GetCallingLineIdRestriction(GetOwner(), aRequest);
return mProvider->GetCallingLineIdRestriction(mClientId, GetOwner(), aRequest);
}
NS_IMETHODIMP
@ -487,7 +490,7 @@ MobileConnection::SetCallingLineIdRestriction(unsigned short aClirMode,
return NS_ERROR_FAILURE;
}
return mProvider->SetCallingLineIdRestriction(GetOwner(), aClirMode, aRequest);
return mProvider->SetCallingLineIdRestriction(mClientId, GetOwner(), aClirMode, aRequest);
}
NS_IMETHODIMP
@ -503,7 +506,7 @@ MobileConnection::ExitEmergencyCbMode(nsIDOMDOMRequest** aRequest)
return NS_ERROR_FAILURE;
}
return mProvider->ExitEmergencyCbMode(GetOwner(), aRequest);
return mProvider->ExitEmergencyCbMode(mClientId, GetOwner(), aRequest);
}
// nsIMobileConnectionListener

View File

@ -48,6 +48,8 @@ private:
nsRefPtr<Listener> mListener;
nsWeakPtr mWindow;
uint32_t mClientId;
bool CheckPermission(const char* type);
};

View File

@ -44,7 +44,8 @@ this.PhoneNumberUtils = {
#ifdef MOZ_B2G_RIL
// Get network mcc
let voice = mobileConnection.voiceConnectionInfo;
// TODO: Bug 926740 - PhoneNumberUtils for multisim
let voice = mobileConnection.getVoiceConnectionInfo(0);
if (voice && voice.network && voice.network.mcc) {
mcc = voice.network.mcc;
}

View File

@ -88,13 +88,13 @@ const RIL_IPC_MSG_NAMES = [
"RIL:StkCommand",
"RIL:StkSessionEnd",
"RIL:DataError",
"RIL:SetCallForwardingOption",
"RIL:GetCallForwardingOption",
"RIL:SetCallBarringOption",
"RIL:GetCallBarringOption",
"RIL:SetCallForwardingOptions",
"RIL:GetCallForwardingOptions",
"RIL:SetCallBarringOptions",
"RIL:GetCallBarringOptions",
"RIL:ChangeCallBarringPassword",
"RIL:SetCallWaitingOption",
"RIL:GetCallWaitingOption",
"RIL:SetCallWaitingOptions",
"RIL:GetCallWaitingOptions",
"RIL:SetCallingLineIdRestriction",
"RIL:GetCallingLineIdRestriction",
"RIL:CellBroadcastReceived",
@ -384,13 +384,13 @@ CellBroadcastEtwsInfo.prototype = {
popup: null
};
function CallBarringOption(option) {
this.program = option.program;
this.enabled = option.enabled;
this.password = option.password;
this.serviceClass = option.serviceClass;
function CallBarringOptions(options) {
this.program = options.program;
this.enabled = options.enabled;
this.password = options.password;
this.serviceClass = options.serviceClass;
}
CallBarringOption.prototype = {
CallBarringOptions.prototype = {
__exposedProps__ : {program: 'r',
enabled: 'r',
password: 'r',
@ -449,17 +449,30 @@ IccCardLockError.prototype = {
};
function RILContentHelper() {
this.rilContext = {
cardState: RIL.GECKO_CARDSTATE_UNKNOWN,
networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN,
iccInfo: null,
voiceConnectionInfo: new MobileConnectionInfo(),
dataConnectionInfo: new MobileConnectionInfo()
};
this.numClients = gNumRadioInterfaces;
debug("Number of clients: " + this.numClients);
this.rilContexts = [];
for (let clientId = 0; clientId < this.numClients; clientId++) {
this.rilContexts[clientId] = {
cardState: RIL.GECKO_CARDSTATE_UNKNOWN,
networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN,
iccInfo: null,
voiceConnectionInfo: new MobileConnectionInfo(),
dataConnectionInfo: new MobileConnectionInfo()
};
}
this.voicemailInfo = new VoicemailInfo();
this.initDOMRequestHelper(/* aWindow */ null, RIL_IPC_MSG_NAMES);
this._windowsMap = [];
this._selectingNetworks = [];
this._mobileConnectionListeners = [];
this._cellBroadcastListeners = [];
this._voicemailListeners = [];
this._iccListeners = [];
Services.obs.addObserver(this, "xpcom-shutdown", false);
}
@ -525,88 +538,103 @@ RILContentHelper.prototype = {
* 1. Should clear iccInfo to null if there is no card detected.
* 2. Need to create corresponding object based on iccType.
*/
updateIccInfo: function updateIccInfo(newInfo) {
updateIccInfo: function updateIccInfo(clientId, newInfo) {
let rilContext = this.rilContexts[clientId];
// Card is not detected, clear iccInfo to null.
if (!newInfo || !newInfo.iccType) {
this.rilContext.iccInfo = null;
rilContext.iccInfo = null;
return;
}
// If iccInfo is null, new corresponding object based on iccType.
if (!this.rilContext.iccInfo) {
if (!rilContext.iccInfo) {
if (newInfo.iccType === "ruim" || newInfo.iccType === "csim") {
this.rilContext.iccInfo = new CdmaIccInfo();
rilContext.iccInfo = new CdmaIccInfo();
} else {
this.rilContext.iccInfo = new GsmIccInfo();
rilContext.iccInfo = new GsmIccInfo();
}
}
this.updateInfo(newInfo, this.rilContext.iccInfo);
this.updateInfo(newInfo, rilContext.iccInfo);
},
_windowsMap: null,
rilContext: null,
rilContexts: null,
getRilContext: function getRilContext() {
// Update ril context by sending IPC message to chrome only when the first
getRilContext: function getRilContext(clientId) {
// Update ril contexts by sending IPC message to chrome only when the first
// time we require it. The information will be updated by following info
// changed messages.
this.getRilContext = function getRilContext() {
return this.rilContext;
this.getRilContext = function getRilContext(clientId) {
return this.rilContexts[clientId];
};
let rilContext =
cpmm.sendSyncMessage("RIL:GetRilContext", {clientId: 0})[0];
if (!rilContext) {
debug("Received null rilContext from chrome process.");
return;
for (let cId = 0; cId < this.numClients; cId++) {
let rilContext =
cpmm.sendSyncMessage("RIL:GetRilContext", {clientId: cId})[0];
if (!rilContext) {
debug("Received null rilContext from chrome process.");
continue;
}
this.rilContexts[cId].cardState = rilContext.cardState;
this.rilContexts[cId].networkSelectionMode = rilContext.networkSelectionMode;
this.updateIccInfo(cId, rilContext.iccInfo);
this.updateConnectionInfo(rilContext.voice, this.rilContexts[cId].voiceConnectionInfo);
this.updateConnectionInfo(rilContext.data, this.rilContexts[cId].dataConnectionInfo);
}
this.rilContext.cardState = rilContext.cardState;
this.rilContext.networkSelectionMode = rilContext.networkSelectionMode;
this.updateIccInfo(rilContext.iccInfo);
this.updateConnectionInfo(rilContext.voice, this.rilContext.voiceConnectionInfo);
this.updateConnectionInfo(rilContext.data, this.rilContext.dataConnectionInfo);
return this.rilContext;
return this.rilContexts[clientId];
},
/**
* nsIIccProvider
*/
get iccInfo() {
//TODO: Bug 814637 - WebIccManager API: support multiple sim cards.
let context = this.getRilContext(0);
return context && context.iccInfo;
},
get cardState() {
//TODO: Bug 814637 - WebIccManager API: support multiple sim cards.
let context = this.getRilContext(0);
return context && context.cardState;
},
/**
* nsIMobileConnectionProvider
*/
get iccInfo() {
let context = this.getRilContext();
return context && context.iccInfo;
},
get voiceConnectionInfo() {
let context = this.getRilContext();
getVoiceConnectionInfo: function getVoiceConnectionInfo(clientId) {
let context = this.getRilContext(clientId);
return context && context.voiceConnectionInfo;
},
get dataConnectionInfo() {
let context = this.getRilContext();
getDataConnectionInfo: function getDataConnectionInfo(clientId) {
let context = this.getRilContext(clientId);
return context && context.dataConnectionInfo;
},
get cardState() {
let context = this.getRilContext();
return context && context.cardState;
getIccId: function getIccId(clientId) {
let context = this.getRilContext(clientId);
return context && context.iccInfo.iccid;
},
get networkSelectionMode() {
let context = this.getRilContext();
getNetworkSelectionMode: function getNetworkSelectionMode(clientId) {
let context = this.getRilContext(clientId);
return context && context.networkSelectionMode;
},
/**
* The network that is currently trying to be selected (or "automatic").
* This helps ensure that only one network is selected at a time.
* The networks that are currently trying to be selected (or "automatic").
* This helps ensure that only one network per client is selected at a time.
*/
_selectingNetwork: null,
_selectingNetworks: null,
getNetworks: function getNetworks(window) {
getNetworks: function getNetworks(clientId, window) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
@ -616,7 +644,7 @@ RILContentHelper.prototype = {
let requestId = this.getRequestId(request);
cpmm.sendAsyncMessage("RIL:GetAvailableNetworks", {
clientId: 0,
clientId: clientId,
data: {
requestId: requestId
}
@ -624,14 +652,14 @@ RILContentHelper.prototype = {
return request;
},
selectNetwork: function selectNetwork(window, network) {
selectNetwork: function selectNetwork(clientId, window, network) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
}
if (this._selectingNetwork) {
throw new Error("Already selecting a network: " + this._selectingNetwork);
if (this._selectingNetworks[clientId]) {
throw new Error("Already selecting a network: " + this._selectingNetworks[clientId]);
}
if (!network) {
@ -649,8 +677,8 @@ RILContentHelper.prototype = {
let request = Services.DOMRequest.createRequest(window);
let requestId = this.getRequestId(request);
if (this.rilContext.networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_MANUAL &&
this.rilContext.voiceConnectionInfo.network === network) {
if (this.rilContexts[clientId].networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_MANUAL &&
this.rilContexts[clientId].voiceConnectionInfo.network === network) {
// Already manually selected this network, so schedule
// onsuccess to be fired on the next tick
@ -658,10 +686,10 @@ RILContentHelper.prototype = {
return request;
}
this._selectingNetwork = network;
this._selectingNetworks[clientId] = network;
cpmm.sendAsyncMessage("RIL:SelectNetwork", {
clientId: 0,
clientId: clientId,
data: {
requestId: requestId,
mnc: network.mnc,
@ -672,30 +700,30 @@ RILContentHelper.prototype = {
return request;
},
selectNetworkAutomatically: function selectNetworkAutomatically(window) {
selectNetworkAutomatically: function selectNetworkAutomatically(clientId, window) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
}
if (this._selectingNetwork) {
throw new Error("Already selecting a network: " + this._selectingNetwork);
if (this._selectingNetworks[clientId]) {
throw new Error("Already selecting a network: " + this._selectingNetworks[clientId]);
}
let request = Services.DOMRequest.createRequest(window);
let requestId = this.getRequestId(request);
if (this.rilContext.networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_AUTOMATIC) {
if (this.rilContexts[clientId].networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_AUTOMATIC) {
// Already using automatic selection mode, so schedule
// onsuccess to be be fired on the next tick
this.dispatchFireRequestSuccess(requestId, null);
return request;
}
this._selectingNetwork = "automatic";
this._selectingNetworks[clientId] = "automatic";
cpmm.sendAsyncMessage("RIL:SelectNetworkAuto", {
clientId: 0,
clientId: clientId,
data: {
requestId: requestId
}
@ -703,7 +731,7 @@ RILContentHelper.prototype = {
return request;
},
setRoamingPreference: function setRoamingPreference(window, mode) {
setRoamingPreference: function setRoamingPreference(clientId, window, mode) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
@ -719,7 +747,7 @@ RILContentHelper.prototype = {
}
cpmm.sendAsyncMessage("RIL:SetRoamingPreference", {
clientId: 0,
clientId: clientId,
data: {
requestId: requestId,
mode: mode
@ -728,7 +756,7 @@ RILContentHelper.prototype = {
return request;
},
getRoamingPreference: function getRoamingPreference(window) {
getRoamingPreference: function getRoamingPreference(clientId, window) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
@ -738,7 +766,7 @@ RILContentHelper.prototype = {
let requestId = this.getRequestId(request);
cpmm.sendAsyncMessage("RIL:GetRoamingPreference", {
clientId: 0,
clientId: clientId,
data: {
requestId: requestId
}
@ -746,7 +774,7 @@ RILContentHelper.prototype = {
return request;
},
setVoicePrivacyMode: function setVoicePrivacyMode(window, enabled) {
setVoicePrivacyMode: function setVoicePrivacyMode(clientId, window, enabled) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
@ -756,7 +784,7 @@ RILContentHelper.prototype = {
let requestId = this.getRequestId(request);
cpmm.sendAsyncMessage("RIL:SetVoicePrivacyMode", {
clientId: 0,
clientId: clientId,
data: {
requestId: requestId,
enabled: enabled
@ -765,7 +793,7 @@ RILContentHelper.prototype = {
return request;
},
getVoicePrivacyMode: function getVoicePrivacyMode(window) {
getVoicePrivacyMode: function getVoicePrivacyMode(clientId, window) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
@ -775,7 +803,7 @@ RILContentHelper.prototype = {
let requestId = this.getRequestId(request);
cpmm.sendAsyncMessage("RIL:GetVoicePrivacyMode", {
clientId: 0,
clientId: clientId,
data: {
requestId: requestId
}
@ -851,7 +879,7 @@ RILContentHelper.prototype = {
return request;
},
sendMMI: function sendMMI(window, mmi) {
sendMMI: function sendMMI(clientId, window, mmi) {
debug("Sending MMI " + mmi);
if (!window) {
throw Components.Exception("Can't get window object",
@ -864,7 +892,7 @@ RILContentHelper.prototype = {
this._windowsMap[requestId] = window;
cpmm.sendAsyncMessage("RIL:SendMMI", {
clientId: 0,
clientId: clientId,
data: {
mmi: mmi,
requestId: requestId
@ -873,7 +901,7 @@ RILContentHelper.prototype = {
return request;
},
cancelMMI: function cancelMMI(window) {
cancelMMI: function cancelMMI(clientId, window) {
debug("Cancel MMI");
if (!window) {
throw Components.Exception("Can't get window object",
@ -882,7 +910,7 @@ RILContentHelper.prototype = {
let request = Services.DOMRequest.createRequest(window);
let requestId = this.getRequestId(request);
cpmm.sendAsyncMessage("RIL:CancelMMI", {
clientId: 0,
clientId: clientId,
data: {
requestId: requestId
}
@ -1076,7 +1104,7 @@ RILContentHelper.prototype = {
return request;
},
getCallForwardingOption: function getCallForwardingOption(window, reason) {
getCallForwardingOption: function getCallForwardingOption(clientId, window, reason) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
@ -1090,8 +1118,8 @@ RILContentHelper.prototype = {
return request;
}
cpmm.sendAsyncMessage("RIL:GetCallForwardingOption", {
clientId: 0,
cpmm.sendAsyncMessage("RIL:GetCallForwardingOptions", {
clientId: clientId,
data: {
requestId: requestId,
reason: reason
@ -1101,7 +1129,7 @@ RILContentHelper.prototype = {
return request;
},
setCallForwardingOption: function setCallForwardingOption(window, cfInfo) {
setCallForwardingOption: function setCallForwardingOption(clientId, window, cfInfo) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
@ -1117,8 +1145,8 @@ RILContentHelper.prototype = {
return request;
}
cpmm.sendAsyncMessage("RIL:SetCallForwardingOption", {
clientId: 0,
cpmm.sendAsyncMessage("RIL:SetCallForwardingOptions", {
clientId: clientId,
data: {
requestId: requestId,
active: cfInfo.active,
@ -1132,7 +1160,7 @@ RILContentHelper.prototype = {
return request;
},
getCallBarringOption: function getCallBarringOption(window, option) {
getCallBarringOption: function getCallBarringOption(clientId, window, option) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
@ -1141,14 +1169,14 @@ RILContentHelper.prototype = {
let requestId = this.getRequestId(request);
if (DEBUG) debug("getCallBarringOption: " + JSON.stringify(option));
if (!this._isValidCallBarringOption(option)) {
if (!this._isValidCallBarringOptions(option)) {
this.dispatchFireRequestError(requestId,
RIL.GECKO_ERROR_INVALID_PARAMETER);
return request;
}
cpmm.sendAsyncMessage("RIL:GetCallBarringOption", {
clientId: 0,
cpmm.sendAsyncMessage("RIL:GetCallBarringOptions", {
clientId: clientId,
data: {
requestId: requestId,
program: option.program,
@ -1159,7 +1187,7 @@ RILContentHelper.prototype = {
return request;
},
setCallBarringOption: function setCallBarringOption(window, option) {
setCallBarringOption: function setCallBarringOption(clientId, window, option) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
@ -1168,14 +1196,14 @@ RILContentHelper.prototype = {
let requestId = this.getRequestId(request);
if (DEBUG) debug("setCallBarringOption: " + JSON.stringify(option));
if (!this._isValidCallBarringOption(option, true)) {
if (!this._isValidCallBarringOptions(option, true)) {
this.dispatchFireRequestError(requestId,
RIL.GECKO_ERROR_INVALID_PARAMETER);
return request;
}
cpmm.sendAsyncMessage("RIL:SetCallBarringOption", {
clientId: 0,
cpmm.sendAsyncMessage("RIL:SetCallBarringOptions", {
clientId: clientId,
data: {
requestId: requestId,
program: option.program,
@ -1187,7 +1215,7 @@ RILContentHelper.prototype = {
return request;
},
changeCallBarringPassword: function changeCallBarringPassword(window, info) {
changeCallBarringPassword: function changeCallBarringPassword(clientId, window, info) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
@ -1205,14 +1233,14 @@ RILContentHelper.prototype = {
if (DEBUG) debug("changeCallBarringPassword: " + JSON.stringify(info));
info.requestId = requestId;
cpmm.sendAsyncMessage("RIL:ChangeCallBarringPassword", {
clientId: 0,
clientId: clientId,
data: info
});
return request;
},
getCallWaitingOption: function getCallWaitingOption(window) {
getCallWaitingOption: function getCallWaitingOption(clientId, window) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
@ -1220,8 +1248,8 @@ RILContentHelper.prototype = {
let request = Services.DOMRequest.createRequest(window);
let requestId = this.getRequestId(request);
cpmm.sendAsyncMessage("RIL:GetCallWaitingOption", {
clientId: 0,
cpmm.sendAsyncMessage("RIL:GetCallWaitingOptions", {
clientId: clientId,
data: {
requestId: requestId
}
@ -1230,7 +1258,7 @@ RILContentHelper.prototype = {
return request;
},
setCallWaitingOption: function setCallWaitingOption(window, enabled) {
setCallWaitingOption: function setCallWaitingOption(clientId, window, enabled) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
@ -1238,8 +1266,8 @@ RILContentHelper.prototype = {
let request = Services.DOMRequest.createRequest(window);
let requestId = this.getRequestId(request);
cpmm.sendAsyncMessage("RIL:SetCallWaitingOption", {
clientId: 0,
cpmm.sendAsyncMessage("RIL:SetCallWaitingOptions", {
clientId: clientId,
data: {
requestId: requestId,
enabled: enabled
@ -1249,7 +1277,7 @@ RILContentHelper.prototype = {
return request;
},
getCallingLineIdRestriction: function getCallingLineIdRestriction(window) {
getCallingLineIdRestriction: function getCallingLineIdRestriction(clientId, window) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
@ -1258,7 +1286,7 @@ RILContentHelper.prototype = {
let requestId = this.getRequestId(request);
cpmm.sendAsyncMessage("RIL:GetCallingLineIdRestriction", {
clientId: 0,
clientId: clientId,
data: {
requestId: requestId
}
@ -1268,7 +1296,7 @@ RILContentHelper.prototype = {
},
setCallingLineIdRestriction:
function setCallingLineIdRestriction(window, clirMode) {
function setCallingLineIdRestriction(clientId, window, clirMode) {
if (window == null) {
throw Components.Exception("Can't get window object",
@ -1278,7 +1306,7 @@ RILContentHelper.prototype = {
let requestId = this.getRequestId(request);
cpmm.sendAsyncMessage("RIL:SetCallingLineIdRestriction", {
clientId: 0,
clientId: clientId,
data: {
requestId: requestId,
clirMode: clirMode
@ -1288,7 +1316,7 @@ RILContentHelper.prototype = {
return request;
},
exitEmergencyCbMode: function exitEmergencyCbMode(window) {
exitEmergencyCbMode: function exitEmergencyCbMode(clientId, window) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
@ -1297,7 +1325,7 @@ RILContentHelper.prototype = {
let requestId = this.getRequestId(request);
cpmm.sendAsyncMessage("RIL:ExitEmergencyCbMode", {
clientId: 0,
clientId: clientId,
data: {
requestId: requestId,
}
@ -1334,10 +1362,13 @@ RILContentHelper.prototype = {
return this.getVoicemailInfo().displayName;
},
registerListener: function registerListener(listenerType, listener) {
let listeners = this[listenerType];
registerListener: function registerListener(listenerType, clientId, listener) {
if (!this[listenerType]) {
return;
}
let listeners = this[listenerType][clientId];
if (!listeners) {
listeners = this[listenerType] = [];
listeners = this[listenerType][clientId] = [];
}
if (listeners.indexOf(listener) != -1) {
@ -1348,8 +1379,11 @@ RILContentHelper.prototype = {
if (DEBUG) debug("Registered " + listenerType + " listener: " + listener);
},
unregisterListener: function unregisterListener(listenerType, listener) {
let listeners = this[listenerType];
unregisterListener: function unregisterListener(listenerType, clientId, listener) {
if (!this[listenerType]) {
return;
}
let listeners = this[listenerType][clientId];
if (!listeners) {
return;
}
@ -1361,44 +1395,50 @@ RILContentHelper.prototype = {
}
},
registerMobileConnectionMsg: function registerMobileConnectionMsg(listener) {
registerMobileConnectionMsg: function registerMobileConnectionMsg(clientId, listener) {
debug("Registering for mobile connection related messages");
this.registerListener("_mobileConnectionListeners", listener);
this.registerListener("_mobileConnectionListeners", clientId, listener);
cpmm.sendAsyncMessage("RIL:RegisterMobileConnectionMsg");
},
unregisterMobileConnectionMsg: function unregisteMobileConnectionMsg(listener) {
this.unregisterListener("_mobileConnectionListeners", listener);
unregisterMobileConnectionMsg: function unregisteMobileConnectionMsg(clientId, listener) {
this.unregisterListener("_mobileConnectionListeners", clientId, listener);
},
registerVoicemailMsg: function registerVoicemailMsg(listener) {
debug("Registering for voicemail-related messages");
this.registerListener("_voicemailListeners", listener);
//TODO: Bug 814634 - WebVoicemail API: support multiple sim cards.
this.registerListener("_voicemailListeners", 0, listener);
cpmm.sendAsyncMessage("RIL:RegisterVoicemailMsg");
},
unregisterVoicemailMsg: function unregisteVoicemailMsg(listener) {
this.unregisterListener("_voicemailListeners", listener);
//TODO: Bug 814634 - WebVoicemail API: support multiple sim cards.
this.unregisterListener("_voicemailListeners", 0, listener);
},
registerCellBroadcastMsg: function registerCellBroadcastMsg(listener) {
debug("Registering for Cell Broadcast related messages");
this.registerListener("_cellBroadcastListeners", listener);
//TODO: Bug 921326 - Cellbroadcast API: support multiple sim cards
this.registerListener("_cellBroadcastListeners", 0, listener);
cpmm.sendAsyncMessage("RIL:RegisterCellBroadcastMsg");
},
unregisterCellBroadcastMsg: function unregisterCellBroadcastMsg(listener) {
this.unregisterListener("_cellBroadcastListeners", listener);
//TODO: Bug 921326 - Cellbroadcast API: support multiple sim cards
this.unregisterListener("_cellBroadcastListeners", 0, listener);
},
registerIccMsg: function registerIccMsg(listener) {
debug("Registering for ICC related messages");
this.registerListener("_iccListeners", listener);
//TODO: Bug 814637 - WebIccManager API: support multiple sim cards.
this.registerListener("_iccListeners", 0, listener);
cpmm.sendAsyncMessage("RIL:RegisterIccMsg");
},
unregisterIccMsg: function unregisterIccMsg(listener) {
this.unregisterListener("_iccListeners", listener);
//TODO: Bug 814637 - WebIccManager API: support multiple sim cards.
this.unregisterListener("_iccListeners", 0, listener);
},
// nsIObserver
@ -1478,35 +1518,43 @@ RILContentHelper.prototype = {
debug("Received message '" + msg.name + "': " + JSON.stringify(msg.json));
let data = msg.json.data;
let clientId = msg.json.clientId;
switch (msg.name) {
case "RIL:CardStateChanged":
if (this.rilContext.cardState != data.cardState) {
this.rilContext.cardState = data.cardState;
this._deliverEvent("_iccListeners",
if (this.rilContexts[clientId].cardState != data.cardState) {
this.rilContexts[clientId].cardState = data.cardState;
this._deliverEvent(clientId,
"_iccListeners",
"notifyCardStateChanged",
null);
}
break;
case "RIL:IccInfoChanged":
this.updateIccInfo(data);
this._deliverEvent("_iccListeners", "notifyIccInfoChanged", null);
this.updateIccInfo(clientId, data);
this._deliverEvent(clientId,
"_iccListeners",
"notifyIccInfoChanged",
null);
break;
case "RIL:VoiceInfoChanged":
this.updateConnectionInfo(data,
this.rilContext.voiceConnectionInfo);
this._deliverEvent("_mobileConnectionListeners",
this.rilContexts[clientId].voiceConnectionInfo);
this._deliverEvent(clientId,
"_mobileConnectionListeners",
"notifyVoiceChanged",
null);
break;
case "RIL:DataInfoChanged":
this.updateConnectionInfo(data,
this.rilContext.dataConnectionInfo);
this._deliverEvent("_mobileConnectionListeners",
this.rilContexts[clientId].dataConnectionInfo);
this._deliverEvent(clientId,
"_mobileConnectionListeners",
"notifyDataChanged",
null);
break;
case "RIL:OtaStatusChanged":
this._deliverEvent("_mobileConnectionListeners",
this._deliverEvent(clientId,
"_mobileConnectionListeners",
"notifyOtaStatusChanged",
[data]);
break;
@ -1514,18 +1562,18 @@ RILContentHelper.prototype = {
this.handleGetAvailableNetworks(data);
break;
case "RIL:NetworkSelectionModeChanged":
this.rilContext.networkSelectionMode = data.mode;
this.rilContexts[clientId].networkSelectionMode = data.mode;
break;
case "RIL:SelectNetwork":
this.handleSelectNetwork(data,
this.handleSelectNetwork(clientId, data,
RIL.GECKO_NETWORK_SELECTION_MANUAL);
break;
case "RIL:SelectNetworkAuto":
this.handleSelectNetwork(data,
this.handleSelectNetwork(clientId, data,
RIL.GECKO_NETWORK_SELECTION_AUTOMATIC);
break;
case "RIL:VoicemailNotification":
this.handleVoicemailNotification(data);
this.handleVoicemailNotification(clientId, data);
break;
case "RIL:VoicemailInfoChanged":
this.updateInfo(data, this.voicemailInfo);
@ -1560,7 +1608,8 @@ RILContentHelper.prototype = {
}
break;
case "RIL:USSDReceived":
this._deliverEvent("_mobileConnectionListeners",
this._deliverEvent(clientId,
"_mobileConnectionListeners",
"notifyUssdReceived",
[data.message, data.sessionEnded]);
break;
@ -1569,11 +1618,11 @@ RILContentHelper.prototype = {
this.handleSendCancelMMI(data);
break;
case "RIL:StkCommand":
this._deliverEvent("_iccListeners", "notifyStkCommand",
this._deliverEvent(clientId, "_iccListeners", "notifyStkCommand",
[JSON.stringify(data)]);
break;
case "RIL:StkSessionEnd":
this._deliverEvent("_iccListeners", "notifyStkSessionEnd", null);
this._deliverEvent(clientId, "_iccListeners", "notifyStkSessionEnd", null);
break;
case "RIL:IccOpenChannel":
this.handleSimpleRequest(data.requestId, data.errorMsg,
@ -1592,34 +1641,35 @@ RILContentHelper.prototype = {
this.handleSimpleRequest(data.requestId, data.errorMsg, null);
break;
case "RIL:DataError":
this.updateConnectionInfo(data, this.rilContext.dataConnectionInfo);
this._deliverEvent("_mobileConnectionListeners", "notifyDataError",
this.updateConnectionInfo(data, this.rilContexts[clientId].dataConnectionInfo);
this._deliverEvent(clientId, "_mobileConnectionListeners", "notifyDataError",
[data.errorMsg]);
break;
case "RIL:GetCallForwardingOption":
this.handleGetCallForwardingOption(data);
case "RIL:GetCallForwardingOptions":
this.handleGetCallForwardingOptions(data);
break;
case "RIL:SetCallForwardingOption":
case "RIL:SetCallForwardingOptions":
this.handleSimpleRequest(data.requestId, data.errorMsg, null);
break;
case "RIL:GetCallBarringOption":
this.handleGetCallBarringOption(data);
case "RIL:GetCallBarringOptions":
this.handleGetCallBarringOptions(data);
break;
case "RIL:SetCallBarringOption":
case "RIL:SetCallBarringOptions":
this.handleSimpleRequest(data.requestId, data.errorMsg, null);
break;
case "RIL:ChangeCallBarringPassword":
this.handleSimpleRequest(data.requestId, data.errorMsg, null);
break;
case "RIL:GetCallWaitingOption":
case "RIL:GetCallWaitingOptions":
this.handleSimpleRequest(data.requestId, data.errorMsg,
data.enabled);
break;
case "RIL:SetCallWaitingOption":
case "RIL:SetCallWaitingOptions":
this.handleSimpleRequest(data.requestId, data.errorMsg, null);
break;
case "RIL:CfStateChanged":
this._deliverEvent("_mobileConnectionListeners",
this._deliverEvent(clientId,
"_mobileConnectionListeners",
"notifyCFStateChange",
[data.success, data.action,
data.reason, data.number,
@ -1633,7 +1683,8 @@ RILContentHelper.prototype = {
break;
case "RIL:CellBroadcastReceived": {
let message = new CellBroadcastMessage(data);
this._deliverEvent("_cellBroadcastListeners",
this._deliverEvent(clientId,
"_cellBroadcastListeners",
"notifyMessageReceived",
[message]);
break;
@ -1649,7 +1700,8 @@ RILContentHelper.prototype = {
this.handleExitEmergencyCbMode(data);
break;
case "RIL:EmergencyCbModeChanged":
this._deliverEvent("_mobileConnectionListeners",
this._deliverEvent(clientId,
"_mobileConnectionListeners",
"notifyEmergencyCbModeChanged",
[data.active, data.timeoutMs]);
break;
@ -1690,9 +1742,9 @@ RILContentHelper.prototype = {
this.fireRequestSuccess(message.requestId, networks);
},
handleSelectNetwork: function handleSelectNetwork(message, mode) {
this._selectingNetwork = null;
this.rilContext.networkSelectionMode = mode;
handleSelectNetwork: function handleSelectNetwork(clientId, message, mode) {
this._selectingNetworks[clientId] = null;
this.rilContexts[clientId].networkSelectionMode = mode;
if (message.errorMsg) {
this.fireRequestError(message.requestId, message.errorMsg);
@ -1742,7 +1794,8 @@ RILContentHelper.prototype = {
ObjectWrapper.wrap(result, window));
},
handleVoicemailNotification: function handleVoicemailNotification(message) {
handleVoicemailNotification: function handleVoicemailNotification(clientId, message) {
// TODO: Bug 818352 - B2G Multi-SIM: voicemail - add subscription id in nsIRILContentHelper
let changed = false;
if (!this.voicemailStatus) {
this.voicemailStatus = new VoicemailStatus();
@ -1772,7 +1825,8 @@ RILContentHelper.prototype = {
}
if (changed) {
this._deliverEvent("_voicemailListeners",
this._deliverEvent(clientId,
"_voicemailListeners",
"notifyStatusChanged",
[this.voicemailStatus]);
}
@ -1787,7 +1841,7 @@ RILContentHelper.prototype = {
}
},
handleGetCallForwardingOption: function handleGetCallForwardingOption(message) {
handleGetCallForwardingOptions: function handleGetCallForwardingOptions(message) {
if (message.errorMsg) {
this.fireRequestError(message.requestId, message.errorMsg);
return;
@ -1797,12 +1851,12 @@ RILContentHelper.prototype = {
this.fireRequestSuccess(message.requestId, message.rules);
},
handleGetCallBarringOption: function handleGetCallBarringOption(message) {
handleGetCallBarringOptions: function handleGetCallBarringOptions(message) {
if (!message.success) {
this.fireRequestError(message.requestId, message.errorMsg);
} else {
let option = new CallBarringOption(message);
this.fireRequestSuccess(message.requestId, option);
let options = new CallBarringOptions(message);
this.fireRequestSuccess(message.requestId, options);
}
},
@ -1878,8 +1932,11 @@ RILContentHelper.prototype = {
}
},
_deliverEvent: function _deliverEvent(listenerType, name, args) {
let thisListeners = this[listenerType];
_deliverEvent: function _deliverEvent(clientId, listenerType, name, args) {
if (!this[listenerType]) {
return;
}
let thisListeners = this[listenerType][clientId];
if (!thisListeners) {
return;
}
@ -1950,18 +2007,18 @@ RILContentHelper.prototype = {
},
/**
* Helper for guarding us against invalid option for call barring.
* Helper for guarding us against invalid options for call barring.
*/
_isValidCallBarringOption:
function _isValidCallBarringOption(option, usedForSetting) {
if (!option ||
option.serviceClass == null ||
!this._isValidCallBarringProgram(option.program)) {
_isValidCallBarringOptions:
function _isValidCallBarringOptions(options, usedForSetting) {
if (!options ||
options.serviceClass == null ||
!this._isValidCallBarringProgram(options.program)) {
return false;
}
// For setting callbarring option, |enabled| and |password| are required.
if (usedForSetting && (option.enabled == null || option.password == null)) {
// For setting callbarring options, |enabled| and |password| are required.
if (usedForSetting && (options.enabled == null || options.password == null)) {
return false;
}

View File

@ -90,13 +90,13 @@ const RIL_IPC_MOBILECONNECTION_MSG_NAMES = [
"RIL:SendMMI",
"RIL:CancelMMI",
"RIL:RegisterMobileConnectionMsg",
"RIL:SetCallForwardingOption",
"RIL:GetCallForwardingOption",
"RIL:SetCallBarringOption",
"RIL:GetCallBarringOption",
"RIL:SetCallForwardingOptions",
"RIL:GetCallForwardingOptions",
"RIL:SetCallBarringOptions",
"RIL:GetCallBarringOptions",
"RIL:ChangeCallBarringPassword",
"RIL:SetCallWaitingOption",
"RIL:GetCallWaitingOption",
"RIL:SetCallWaitingOptions",
"RIL:GetCallWaitingOptions",
"RIL:SetCallingLineIdRestriction",
"RIL:GetCallingLineIdRestriction",
"RIL:SetRoamingPreference",
@ -935,25 +935,25 @@ RadioInterface.prototype = {
case "RIL:UpdateIccContact":
this.workerMessenger.sendWithIPCMessage(msg, "updateICCContact");
break;
case "RIL:SetCallForwardingOption":
this.setCallForwardingOption(msg.target, msg.json.data);
case "RIL:SetCallForwardingOptions":
this.setCallForwardingOptions(msg.target, msg.json.data);
break;
case "RIL:GetCallForwardingOption":
case "RIL:GetCallForwardingOptions":
this.workerMessenger.sendWithIPCMessage(msg, "queryCallForwardStatus");
break;
case "RIL:SetCallBarringOption":
case "RIL:SetCallBarringOptions":
this.workerMessenger.sendWithIPCMessage(msg, "setCallBarring");
break;
case "RIL:GetCallBarringOption":
case "RIL:GetCallBarringOptions":
this.workerMessenger.sendWithIPCMessage(msg, "queryCallBarringStatus");
break;
case "RIL:ChangeCallBarringPassword":
this.workerMessenger.sendWithIPCMessage(msg, "changeCallBarringPassword");
break;
case "RIL:SetCallWaitingOption":
case "RIL:SetCallWaitingOptions":
this.workerMessenger.sendWithIPCMessage(msg, "setCallWaiting");
break;
case "RIL:GetCallWaitingOption":
case "RIL:GetCallWaitingOptions":
this.workerMessenger.sendWithIPCMessage(msg, "queryCallWaiting");
break;
case "RIL:SetCallingLineIdRestriction":
@ -2406,12 +2406,12 @@ RadioInterface.prototype = {
}).bind(this));
},
setCallForwardingOption: function setCallForwardingOption(target, message) {
if (DEBUG) this.debug("setCallForwardingOption: " + JSON.stringify(message));
setCallForwardingOptions: function setCallForwardingOptions(target, message) {
if (DEBUG) this.debug("setCallForwardingOptions: " + JSON.stringify(message));
message.serviceClass = RIL.ICC_SERVICE_CLASS_VOICE;
this.workerMessenger.send("setCallForward", message, (function(response) {
this._sendCfStateChanged(response);
target.sendAsyncMessage("RIL:SetCallForwardingOption", {
target.sendAsyncMessage("RIL:SetCallForwardingOptions", {
clientId: this.clientId,
data: response
});

View File

@ -26,6 +26,7 @@ const kMozSettingsChangedObserverTopic = "mozsettings-changed";
const MAX_RETRIES_ON_AUTHENTICATION_FAILURE = 2;
const MAX_SUPPLICANT_LOOP_ITERATIONS = 4;
const MAX_RETRIES_ON_DHCP_FAILURE = 2;
// Settings DB path for wifi
const SETTINGS_WIFI_ENABLED = "wifi.enabled";
@ -558,6 +559,21 @@ var WifiManager = (function() {
}
netUtil.runDhcp(manager.ifname, function(data) {
dhcpInfo = data.info;
if (!dhcpInfo) {
if (++manager.dhcpFailuresCount >= MAX_RETRIES_ON_DHCP_FAILURE) {
manager.dhcpFailuresCount = 0;
notify("disconnected", {ssid: manager.connectionInfo.ssid});
return;
}
// NB: We have to call disconnect first. Otherwise, we only reauth with
// the existing AP and don't retrigger DHCP.
manager.disconnect(function() {
manager.reassociate(function(){});
});
return;
}
manager.dhcpFailuresCount = 0;
notify("networkconnected", data);
});
});
@ -789,6 +805,7 @@ var WifiManager = (function() {
manager.connectionInfo = { ssid: null, bssid: null, id: -1 };
manager.authenticationFailuresCount = 0;
manager.loopDetectionCount = 0;
manager.dhcpFailuresCount = 0;
var waitForDriverReadyTimer = null;
function cancelWaitForDriverReadyTimer() {
@ -1823,34 +1840,31 @@ function WifiWorker() {
};
WifiManager.onnetworkconnected = function() {
if (this.info) {
WifiNetworkInterface.state =
Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
WifiNetworkInterface.ip = this.info.ipaddr_str;
WifiNetworkInterface.netmask = this.info.mask_str;
WifiNetworkInterface.broadcast = this.info.broadcast_str;
WifiNetworkInterface.gateway = this.info.gateway_str;
WifiNetworkInterface.dns1 = this.info.dns1_str;
WifiNetworkInterface.dns2 = this.info.dns2_str;
Services.obs.notifyObservers(WifiNetworkInterface,
kNetworkInterfaceStateChangedTopic,
null);
self.ipAddress = this.info.ipaddr_str;
// We start the connection information timer when we associate, but
// don't have our IP address until here. Make sure that we fire a new
// connectionInformation event with the IP address the next time the
// timer fires.
self._lastConnectionInfo = null;
self._fireEvent("onconnect", { network: netToDOM(self.currentNetwork) });
} else {
// NB: We have to call disconnect first. Otherwise, we only reauth with
// the existing AP and don't retrigger DHCP.
WifiManager.disconnect(function() {
WifiManager.reassociate(function(){});
});
if (!this.info) {
debug("Network information is invalid.");
return;
}
WifiNetworkInterface.state =
Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
WifiNetworkInterface.ip = this.info.ipaddr_str;
WifiNetworkInterface.netmask = this.info.mask_str;
WifiNetworkInterface.broadcast = this.info.broadcast_str;
WifiNetworkInterface.gateway = this.info.gateway_str;
WifiNetworkInterface.dns1 = this.info.dns1_str;
WifiNetworkInterface.dns2 = this.info.dns2_str;
Services.obs.notifyObservers(WifiNetworkInterface,
kNetworkInterfaceStateChangedTopic,
null);
self.ipAddress = this.info.ipaddr_str;
// We start the connection information timer when we associate, but
// don't have our IP address until here. Make sure that we fire a new
// connectionInformation event with the IP address the next time the
// timer fires.
self._lastConnectionInfo = null;
self._fireEvent("onconnect", { network: netToDOM(self.currentNetwork) });
};
WifiManager.onscanresultsavailable = function() {