Bug 1159591 - Part 7: Move MMI logic from ril_worker to telephonyService (Call Barring Password). r=aknow

This commit is contained in:
Edgar Chen 2015-04-30 12:35:55 +08:00
parent 7f842c4553
commit 9be23ec753
2 changed files with 56 additions and 44 deletions

View File

@ -1916,33 +1916,6 @@ RilObject.prototype = {
return;
}
function _isValidChangePasswordRequest() {
if (mmi.procedure !== MMI_PROCEDURE_REGISTRATION &&
mmi.procedure !== MMI_PROCEDURE_ACTIVATION) {
_sendMMIError(MMI_ERROR_KS_INVALID_ACTION);
return false;
}
if (mmi.sia !== "" && mmi.sia !== MMI_ZZ_BARRING_SERVICE) {
_sendMMIError(MMI_ERROR_KS_NOT_SUPPORTED);
return false;
}
let validPassword = si => /^[0-9]{4}$/.test(si);
if (!validPassword(mmi.sib) || !validPassword(mmi.sic) ||
!validPassword(mmi.pwd)) {
_sendMMIError(MMI_ERROR_KS_INVALID_PASSWORD);
return false;
}
if (mmi.sic != mmi.pwd) {
_sendMMIError(MMI_ERROR_KS_MISMATCH_PASSWORD);
return false;
}
return true;
}
let _isRadioAvailable = (function() {
if (this.radioState !== GECKO_RADIOSTATE_ENABLED) {
_sendMMIError(GECKO_ERROR_RADIO_NOT_AVAILABLE);
@ -1955,17 +1928,6 @@ RilObject.prototype = {
// trigger the appropriate RIL request if possible.
let sc = mmi.serviceCode;
switch (sc) {
// Change call barring password
case MMI_SC_CHANGE_PASSWORD:
if (!_isRadioAvailable() || !_isValidChangePasswordRequest()) {
return;
}
options.pin = mmi.sib;
options.newPin = mmi.sic;
this.changeCallBarringPassword(options);
return;
// Call barring
case MMI_SC_BAOC:
case MMI_SC_BAOIC:
@ -4759,12 +4721,6 @@ RilObject.prototype[REQUEST_SET_FACILITY_LOCK] = function REQUEST_SET_FACILITY_L
};
RilObject.prototype[REQUEST_CHANGE_BARRING_PASSWORD] =
function REQUEST_CHANGE_BARRING_PASSWORD(length, options) {
if (options.rilMessageType != "sendMMI") {
this.sendChromeMessage(options);
return;
}
options.statusMessage = MMI_SM_KS_PASSWORD_CHANGED;
this.sendChromeMessage(options);
};
RilObject.prototype[REQUEST_QUERY_NETWORK_SELECTION_MODE] = function REQUEST_QUERY_NETWORK_SELECTION_MODE(length, options) {

View File

@ -891,6 +891,11 @@ TelephonyService.prototype = {
this._clirMMI(aClientId, aMmi, aCallback);
break;
// Change call barring password
case RIL.MMI_KS_SC_CHANGE_PASSWORD:
this._callBarringPasswordMMI(aClientId, aMmi, aCallback);
break;
// Fall back to "sendMMI".
default:
this._sendMMI(aClientId, aMmi, aCallback);
@ -1256,6 +1261,57 @@ TelephonyService.prototype = {
}
},
/**
* Handle change call barring password MMI code.
*
* @param aClientId
* Client id.
* @param aMmi
* Parsed MMI structure.
* @param aCallback
* A nsITelephonyDialCallback object.
*/
_callBarringPasswordMMI: function(aClientId, aMmi, aCallback) {
if (!this._isRadioOn(aClientId)) {
aCallback.notifyDialMMIError(RIL.GECKO_ERROR_RADIO_NOT_AVAILABLE);
return;
}
if (aMmi.procedure !== RIL.MMI_PROCEDURE_REGISTRATION &&
aMmi.procedure !== RIL.MMI_PROCEDURE_ACTIVATION) {
aCallback.notifyDialMMIError(RIL.MMI_ERROR_KS_INVALID_ACTION);
return;
}
if (aMmi.sia !== "" && aMmi.sia !== RIL.MMI_ZZ_BARRING_SERVICE) {
aCallback.notifyDialMMIError(RIL.MMI_ERROR_KS_NOT_SUPPORTED);
return;
}
let validPassword = aSi => /^[0-9]{4}$/.test(aSi);
if (!validPassword(aMmi.sib) || !validPassword(aMmi.sic) ||
!validPassword(aMmi.pwd)) {
aCallback.notifyDialMMIError(RIL.MMI_ERROR_KS_INVALID_PASSWORD);
return;
}
if (aMmi.sic !== aMmi.pwd) {
aCallback.notifyDialMMIError(RIL.MMI_ERROR_KS_MISMATCH_PASSWORD);
return;
}
let connection = gGonkMobileConnectionService.getItemByServiceId(aClientId);
connection.changeCallBarringPassword(aMmi.sib, aMmi.sic, {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionCallback]),
notifySuccess: function() {
aCallback.notifyDialMMISuccess(RIL.MMI_SM_KS_PASSWORD_CHANGED);
},
notifyError: function(aErrorMsg) {
aCallback.notifyDialMMIError(aErrorMsg);
},
});
},
_serviceCodeToKeyString: function(aServiceCode) {
switch (aServiceCode) {
case RIL.MMI_SC_CFU: