Bug 874000 - (mmi-result-pin) [MMI] Use MMIResult for PIN/PIN2/PUK related functionality. r=vicamo

This commit is contained in:
Fernando Jiménez 2013-07-01 01:01:02 +08:00
Родитель 382cd761d5
Коммит 1b88241c2b
3 изменённых файлов: 84 добавлений и 40 удалений

Просмотреть файл

@ -1566,43 +1566,29 @@ RILContentHelper.prototype = {
let success = message.success;
let result = {
serviceCode: message.mmiServiceCode
};
switch (message.mmiServiceCode) {
case RIL.MMI_KS_SC_IMEI:
// We expect to have an IMEI at this point, so getting a successful
// reply from the RIL without containing an actual IMEI number is
// considered an error.
if (success && message.result) {
result.statusMessage = message.result;
} else {
result.name = message.errorMsg ?
message.errorMsg : RIL.GECKO_ERROR_GENERIC_FAILURE;
success = false;
}
break;
case RIL.MMI_KS_SC_PIN:
case RIL.MMI_KS_SC_PIN2:
case RIL.MMI_KS_SC_PUK:
case RIL.MMI_KS_SC_PUK2:
// TODO: Bug 874000: Use MMIResult for PIN/PIN2/PUK related
// functionality.
break;
case RIL.MMI_KS_SC_CALL_FORWARDING:
// TODO: Bug 884343 - Use MMIResult for Call Forwarding related
// functionality.
break;
// We expect to have an IMEI at this point if the request was supposed
// to query for the IMEI, so getting a successful reply from the RIL
// without containing an actual IMEI number is considered an error.
if (message.mmiServiceCode === RIL.MMI_KS_SC_IMEI &&
!message.statusMessage) {
message.errorMsg = message.errorMsg ?
message.errorMsg : RIL.GECKO_ERROR_GENERIC_FAILURE;
success = false;
}
let result = {
serviceCode: message.mmiServiceCode,
additionalInformation: message.additionalInformation
};
if (success) {
result.statusMessage = message.statusMessage;
let mmiResult = new DOMMMIResult(result);
Services.DOMRequest.fireSuccess(request, mmiResult);
} else {
let mmiError = new this._window.DOMMMIError(result.serviceCode,
result.name,
result.message,
message.errorMsg,
null,
result.additionalInformation);
Services.DOMRequest.fireDetailedError(request, mmiError);
}

Просмотреть файл

@ -2555,6 +2555,17 @@ this.MMI_ERROR_KS_ERROR = "emMmiError";
this.MMI_ERROR_KS_NOT_SUPPORTED = "emMmiErrorNotSupported";
this.MMI_ERROR_KS_INVALID_ACTION = "emMmiErrorInvalidAction";
this.MMI_ERROR_KS_MISMATCH_PIN = "emMmiErrorMismatchPin";
this.MMI_ERROR_KS_BAD_PIN = "emMmiErrorBadPin";
this.MMI_ERROR_KS_BAD_PUK = "emMmiErrorBadPuk";
this.MMI_ERROR_KS_INVALID_PIN = "emMmiErrorInvalidPin";
this.MMI_ERROR_KS_NEEDS_PUK = "emMmiErrorNeedsPuk";
this.MMI_ERROR_KS_SIM_BLOCKED = "emMmiErrorSimBlocked";
// MMI status message.
this.MMI_SM_KS_PIN_CHANGED = "smPinChanged";
this.MMI_SM_KS_PIN2_CHANGED = "smPin2Changed";
this.MMI_SM_KS_PIN_UNBLOCKED = "smPinUnblocked";
this.MMI_SM_KS_PIN2_UNBLOCKED = "smPin2Unblocked";
/**
* CDMA PDU constants

Просмотреть файл

@ -2184,6 +2184,7 @@ let RIL = {
let mmi = this._parseMMI(mmiString);
let _sendMMIError = (function _sendMMIError(errorMsg, mmiServiceCode) {
options.success = false;
options.rilMessageType = "sendMMI";
options.errorMsg = errorMsg;
if (mmiServiceCode) {
@ -2211,6 +2212,13 @@ let RIL = {
return;
}
if (mmi.sia.length < 4 || mmi.sia.length > 8 ||
mmi.sib.length < 4 || mmi.sib.length > 8 ||
mmi.sic.length < 4 || mmi.sic.length > 8) {
_sendMMIError(MMI_ERROR_KS_INVALID_PIN, mmiServiceCode);
return;
}
return true;
}
@ -2228,10 +2236,11 @@ let RIL = {
debug("MMI " + JSON.stringify(mmi));
}
options.rilMessageType = "sendMMI";
// We check if the MMI service code is supported and in that case we
// trigger the appropriate RIL request if possible.
let sc = mmi.serviceCode;
switch (sc) {
// Call forwarding
case MMI_SC_CFU:
@ -2246,7 +2255,6 @@ let RIL = {
// code.
options.mmiServiceCode = MMI_KS_SC_CALL_FORWARDING;
options.action = MMI_PROC_TO_CF_ACTION[mmi.procedure];
options.rilMessageType = "sendMMI";
options.reason = MMI_SC_TO_CF_REASON[sc];
options.number = mmi.sia;
options.serviceClass = this._siToServiceClass(mmi.sib);
@ -2272,7 +2280,6 @@ let RIL = {
}
options.mmiServiceCode = MMI_KS_SC_PIN;
options.rilRequestType = "sendMMI";
options.pin = mmi.sia;
options.newPin = mmi.sib;
this.changeICCPIN(options);
@ -2289,7 +2296,6 @@ let RIL = {
}
options.mmiServiceCode = MMI_KS_SC_PIN2;
options.rilRequestType = "sendMMI";
options.pin = mmi.sia;
options.newPin = mmi.sib;
this.changeICCPIN2(options);
@ -2306,7 +2312,6 @@ let RIL = {
}
options.mmiServiceCode = MMI_KS_SC_PUK;
options.rilRequestType = "sendMMI";
options.puk = mmi.sia;
options.newPin = mmi.sib;
this.enterICCPUK(options);
@ -2323,7 +2328,6 @@ let RIL = {
}
options.mmiServiceCode = MMI_KS_SC_PUK2;
options.rilRequestType = "sendMMI";
options.puk = mmi.sia;
options.newPin = mmi.sib;
this.enterICCPUK2(options);
@ -2338,9 +2342,8 @@ let RIL = {
}
// If we already had the device's IMEI, we just send it to the DOM.
options.mmiServiceCode = MMI_KS_SC_IMEI;
options.rilMessageType = "sendMMI";
options.success = true;
options.result = this.IMEI;
options.statusMessage = this.IMEI;
this.sendDOMMessage(options);
return;
@ -3028,12 +3031,56 @@ let RIL = {
/**
* Helper for processing responses of functions such as enterICC* and changeICC*.
*/
_processEnterAndChangeICCResponses: function _processEnterAndChangeICCResponses(length, options) {
_processEnterAndChangeICCResponses:
function _processEnterAndChangeICCResponses(length, options) {
options.success = (options.rilRequestError === 0);
if (!options.success) {
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
}
options.retryCount = length ? Buf.readUint32List()[0] : -1;
if (options.rilMessageType != "sendMMI") {
this.sendDOMMessage(options);
return;
}
let mmiServiceCode = options.mmiServiceCode;
if (options.success) {
switch (mmiServiceCode) {
case MMI_KS_SC_PIN:
options.statusMessage = MMI_SM_KS_PIN_CHANGED;
break;
case MMI_KS_SC_PIN2:
options.statusMessage = MMI_SM_KS_PIN2_CHANGED;
break;
case MMI_KS_SC_PUK:
options.statusMessage = MMI_SM_KS_PIN_UNBLOCKED;
break;
case MMI_KS_SC_PUK2:
options.statusMessage = MMI_SM_KS_PIN2_UNBLOCKED;
break;
}
} else {
if (options.retryCount <= 0) {
if (mmiServiceCode === MMI_KS_SC_PUK) {
options.errorMsg = MMI_ERROR_KS_SIM_BLOCKED;
} else if (mmiServiceCode === MMI_KS_SC_PIN) {
options.errorMsg = MMI_ERROR_KS_NEEDS_PUK;
}
} else {
if (mmiServiceCode === MMI_KS_SC_PIN ||
mmiServiceCode === MMI_KS_SC_PIN2) {
options.errorMsg = MMI_ERROR_KS_BAD_PIN;
} else if (mmiServiceCode === MMI_KS_SC_PUK ||
mmiServiceCode === MMI_KS_SC_PUK2) {
options.errorMsg = MMI_ERROR_KS_BAD_PUK;
}
if (options.retryCount != undefined) {
options.additionalInformation = options.retryCount;
}
}
}
this.sendDOMMessage(options);
},
@ -4866,7 +4913,7 @@ RIL[REQUEST_GET_IMEI] = function REQUEST_GET_IMEI(length, options) {
if ((!options.success || this.IMEI == null) && !options.errorMsg) {
options.errorMsg = GECKO_ERROR_GENERIC_FAILURE;
}
options.result = this.IMEI;
options.statusMessage = this.IMEI;
this.sendDOMMessage(options);
};
RIL[REQUEST_GET_IMEISV] = function REQUEST_GET_IMEISV(length, options) {