diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index 58292b5010b2..f5885db5d43e 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -455,18 +455,6 @@ RadioInterfaceLayer.prototype = { return this.radioInterfaces[clientId]; }, - getClientIdForEmergencyCall: function() { - // Select the client with sim card first. - for (let cid = 0; cid < this.numRadioInterfaces; ++cid) { - if (this.getRadioInterface(cid).isCardPresent()) { - return cid; - } - } - - // Use the defualt client if no card presents. - return HW_DEFAULT_CLIENT_ID; - }, - setMicrophoneMuted: function(muted) { for (let clientId = 0; clientId < this.numRadioInterfaces; clientId++) { let radioInterface = this.radioInterfaces[clientId]; diff --git a/dom/system/gonk/nsIRadioInterfaceLayer.idl b/dom/system/gonk/nsIRadioInterfaceLayer.idl index d30801429f26..168fe38940af 100644 --- a/dom/system/gonk/nsIRadioInterfaceLayer.idl +++ b/dom/system/gonk/nsIRadioInterfaceLayer.idl @@ -42,19 +42,12 @@ interface nsIRadioInterface : nsISupports #define NS_RADIOINTERFACELAYER_CONTRACTID "@mozilla.org/ril;1" %} -[scriptable, uuid(78b65e8c-68e7-4510-9a05-65bba12b283e)] +[scriptable, uuid(09730e0d-75bb-4f21-8540-062a2eadc8ff)] interface nsIRadioInterfaceLayer : nsISupports { readonly attribute unsigned long numRadioInterfaces; nsIRadioInterface getRadioInterface(in unsigned long clientId); - /** - * Select a proper client for dialing emergency call. - * - * @return clientId or -1 if none of the clients are avaialble. - */ - unsigned long getClientIdForEmergencyCall(); - void setMicrophoneMuted(in boolean muted); }; diff --git a/dom/telephony/gonk/TelephonyService.js b/dom/telephony/gonk/TelephonyService.js index c43c8535d431..caa102c64222 100644 --- a/dom/telephony/gonk/TelephonyService.js +++ b/dom/telephony/gonk/TelephonyService.js @@ -52,6 +52,8 @@ const DIAL_ERROR_RADIO_NOT_AVAILABLE = RIL.GECKO_ERROR_RADIO_NOT_AVAILABLE; const TONES_GAP_DURATION = 70; +const EMERGENCY_CALL_DEFAULT_CLIENT_ID = 0; + // Consts for MMI. // MMI procedure as defined in TS.22.030 6.5.2 const MMI_PROCEDURE_ACTIVATION = "*"; @@ -721,6 +723,26 @@ TelephonyService.prototype = { return false; }, + /** + * Select a proper client for dialing emergency call. + * + * @return clientId + */ + _getClientIdForEmergencyCall: function() { + // Select the client with sim card first. + for (let cid = 0; cid < this._numClients; ++cid) { + let icc = gIccService.getIccByServiceId(cid); + let cardState = icc ? icc.cardState : Ci.nsIIcc.CARD_STATE_UNKONWN; + if (cardState !== Ci.nsIIcc.CARD_STATE_UNDETECTED && + cardState !== Ci.nsIIcc.CARD_STATE_UNKNOWN) { + return cid; + } + } + + // Use the defualt client if no card presents. + return EMERGENCY_CALL_DEFAULT_CLIENT_ID; + }, + /** * Dial number. Perform call setup or SS procedure accordingly. * @@ -866,7 +888,7 @@ TelephonyService.prototype = { if (isEmergency) { // Automatically select a proper clientId for emergency call. - aClientId = gRadioInterfaceLayer.getClientIdForEmergencyCall() ; + aClientId = this._getClientIdForEmergencyCall() ; if (aClientId === -1) { if (DEBUG) debug("Error: No client is avaialble for emergency call."); aCallback.notifyError(DIAL_ERROR_INVALID_STATE_ERROR);