From 1b88241c2b6ea3c22ee29b7693cf7e0376d222d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Jim=C3=A9nez?= Date: Mon, 1 Jul 2013 01:01:02 +0800 Subject: [PATCH 1/2] Bug 874000 - (mmi-result-pin) [MMI] Use MMIResult for PIN/PIN2/PUK related functionality. r=vicamo --- dom/system/gonk/RILContentHelper.js | 46 +++++++------------- dom/system/gonk/ril_consts.js | 11 +++++ dom/system/gonk/ril_worker.js | 67 ++++++++++++++++++++++++----- 3 files changed, 84 insertions(+), 40 deletions(-) diff --git a/dom/system/gonk/RILContentHelper.js b/dom/system/gonk/RILContentHelper.js index 453a46fdc32e..b6b4c4c4bb9d 100644 --- a/dom/system/gonk/RILContentHelper.js +++ b/dom/system/gonk/RILContentHelper.js @@ -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); } diff --git a/dom/system/gonk/ril_consts.js b/dom/system/gonk/ril_consts.js index 417dc42441a7..dfadd1973a66 100644 --- a/dom/system/gonk/ril_consts.js +++ b/dom/system/gonk/ril_consts.js @@ -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 diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index 45cce20e7839..c1b688950e15 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -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) { From 95ac483c0883e477ddf416cd8cffd1bf8a3cdc3b Mon Sep 17 00:00:00 2001 From: Jose Antonio Olivera Ortega Date: Mon, 1 Jul 2013 01:23:52 +0800 Subject: [PATCH 2/2] Bug 879680 - (mmi-result-cf) [MMI] Use MMIResult for Call Forwarding related functionality. r=ferjm --- dom/system/gonk/RILContentHelper.js | 8 ++++++++ dom/system/gonk/ril_consts.js | 5 +++++ dom/system/gonk/ril_worker.js | 26 ++++++++++++++++++++++++-- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/dom/system/gonk/RILContentHelper.js b/dom/system/gonk/RILContentHelper.js index b6b4c4c4bb9d..c54c13d05fe3 100644 --- a/dom/system/gonk/RILContentHelper.js +++ b/dom/system/gonk/RILContentHelper.js @@ -1576,6 +1576,14 @@ RILContentHelper.prototype = { success = false; } + // MMI query call forwarding options request returns a set of rules that + // will be exposed in the form of an array of nsIDOMMozMobileCFInfo + // instances. + if (message.mmiServiceCode === RIL.MMI_KS_SC_CALL_FORWARDING && + message.additionalInformation) { + this._cfRulesToMobileCfInfo(message.additionalInformation); + } + let result = { serviceCode: message.mmiServiceCode, additionalInformation: message.additionalInformation diff --git a/dom/system/gonk/ril_consts.js b/dom/system/gonk/ril_consts.js index dfadd1973a66..d77997f1dcbb 100644 --- a/dom/system/gonk/ril_consts.js +++ b/dom/system/gonk/ril_consts.js @@ -2566,6 +2566,11 @@ 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"; +this.MMI_SM_KS_SERVICE_ENABLED = "smServiceEnabled"; +this.MMI_SM_KS_SERVICE_DISABLED = "smServiceDisabled"; +this.MMI_SM_KS_SERVICE_REGISTERED = "smServiceRegistered"; +this.MMI_SM_KS_SERVICE_ERASED = "smServiceErased"; +this.MMI_SM_KS_SERVICE_INTERROGATED = "smServiceInterrogated"; /** * CDMA PDU constants diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index c1b688950e15..2870a28dfcc3 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -4850,8 +4850,7 @@ RIL[REQUEST_QUERY_CALL_FORWARD_STATUS] = } if (!rulesLength) { options.success = false; - options.errorMsg = - "Invalid rule length while querying call forwarding status."; + options.errorMsg = GECKO_ERROR_GENERIC_FAILURE; this.sendDOMMessage(options); return; } @@ -4867,6 +4866,13 @@ RIL[REQUEST_QUERY_CALL_FORWARD_STATUS] = rules[i] = rule; } options.rules = rules; + if (options.rilMessageType === "sendMMI") { + options.statusMessage = MMI_SM_KS_SERVICE_INTERROGATED; + // MMI query call forwarding options request returns a set of rules that + // will be exposed in the form of an array of nsIDOMMozMobileCFInfo + // instances. + options.additionalInformation = rules; + } this.sendDOMMessage(options); }; RIL[REQUEST_SET_CALL_FORWARD] = @@ -4875,6 +4881,22 @@ RIL[REQUEST_SET_CALL_FORWARD] = if (!options.success) { options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError]; } + if (options.success && options.isSendMMI) { + switch (options.action) { + case CALL_FORWARD_ACTION_ENABLE: + options.statusMessage = MMI_SM_KS_SERVICE_ENABLED; + break; + case CALL_FORWARD_ACTION_DISABLE: + options.statusMessage = MMI_SM_KS_SERVICE_DISABLED; + break; + case CALL_FORWARD_ACTION_REGISTRATION: + options.statusMessage = MMI_SM_KS_SERVICE_REGISTERED; + break; + case CALL_FORWARD_ACTION_ERASURE: + options.statusMessage = MMI_SM_KS_SERVICE_ERASED; + break; + } + } this.sendDOMMessage(options); }; RIL[REQUEST_QUERY_CALL_WAITING] =