Bug 1089566 - Refine the policy for selecting emergency client. r=hsinyi

This commit is contained in:
Szu-Yu Chen [:aknow] 2014-12-17 06:51:09 +08:00
parent 6c831fcc58
commit 273ba66b2d

View File

@ -494,19 +494,13 @@ XPCOMUtils.defineLazyGetter(this, "gRadioEnabledController", function() {
_getNumCards: function() {
let numCards = 0;
for (let i = 0, N = _ril.numRadioInterfaces; i < N; ++i) {
if (this._isCardPresentAtClient(i)) {
if (_ril.getRadioInterface(i).isCardPresent()) {
numCards++;
}
}
return numCards;
},
_isCardPresentAtClient: function(clientId) {
let cardState = _ril.getRadioInterface(clientId).rilContext.cardState;
return cardState !== Ci.nsIIccProvider.CARD_STATE_UNDETECTED &&
cardState !== Ci.nsIIccProvider.CARD_STATE_UNKNOWN;
},
_isRadioAbleToEnableAtClient: function(clientId, numCards) {
if (!RILQUIRKS_RADIO_OFF_WO_CARD) {
return true;
@ -516,7 +510,7 @@ XPCOMUtils.defineLazyGetter(this, "gRadioEnabledController", function() {
// 1. a SIM card is presented or
// 2. it is the default clientId and there is no any SIM card at any client.
if (this._isCardPresentAtClient(clientId)) {
if (_ril.getRadioInterface(clientId).isCardPresent()) {
return true;
}
@ -1511,12 +1505,15 @@ RadioInterfaceLayer.prototype = {
},
getClientIdForEmergencyCall: function() {
// Select the client with sim card first.
for (let cid = 0; cid < this.numRadioInterfaces; ++cid) {
if (gRadioEnabledController._isRadioAbleToEnableAtClient(cid)) {
if (this.getRadioInterface(cid).isCardPresent()) {
return cid;
}
}
return -1;
// Use the defualt client if no card presents.
return HW_DEFAULT_CLIENT_ID;
},
setMicrophoneMuted: function(muted) {
@ -1824,6 +1821,12 @@ RadioInterface.prototype = {
return false;
},
isCardPresent: function() {
let cardState = this.rilContext.cardState;
return cardState !== Ci.nsIIccProvider.CARD_STATE_UNDETECTED &&
cardState !== Ci.nsIIccProvider.CARD_STATE_UNKNOWN;
},
/**
* Process a message from the content process.
*/