From 44e620874cc31d04cd107b108b7be1203c8c058f Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Thu, 30 Apr 2015 12:20:40 +0800 Subject: [PATCH] Bug 1159591 - Part 6: Move MMI logic from ril_worker to telephonyService (CLIR). r=aknow --- dom/system/gonk/ril_consts.js | 5 - dom/system/gonk/ril_worker.js | 94 ------------------ dom/telephony/gonk/TelephonyService.js | 127 ++++++++++++++++++++++++- 3 files changed, 124 insertions(+), 102 deletions(-) diff --git a/dom/system/gonk/ril_consts.js b/dom/system/gonk/ril_consts.js index 7c2f5f082f93..93453eb30442 100644 --- a/dom/system/gonk/ril_consts.js +++ b/dom/system/gonk/ril_consts.js @@ -2976,11 +2976,6 @@ CALL_BARRING_PROGRAM_TO_FACILITY[CALL_BARRING_PROGRAM_ALL_SERVICE] = ICC_CB_FACI CALL_BARRING_PROGRAM_TO_FACILITY[CALL_BARRING_PROGRAM_OUTGOING_SERVICE] = ICC_CB_FACILITY_BA_MO; CALL_BARRING_PROGRAM_TO_FACILITY[CALL_BARRING_PROGRAM_INCOMING_SERVICE] = ICC_CB_FACILITY_BA_MT; -// CLIR constants. Must be in sync with nsIMobileConnectionService interface -this.CLIR_DEFAULT = 0; -this.CLIR_INVOCATION = 1; -this.CLIR_SUPPRESSION = 2; - // MMI procedure as defined in TS.22.030 6.5.2 this.MMI_PROCEDURE_ACTIVATION = "*"; this.MMI_PROCEDURE_DEACTIVATION = "#"; diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index c8e223d2dbbc..964b23af9022 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -1955,30 +1955,6 @@ RilObject.prototype = { // trigger the appropriate RIL request if possible. let sc = mmi.serviceCode; switch (sc) { - // CLIR (non-temporary ones) - // TODO: Both dial() and sendMMI() functions should be unified at some - // point in the future. In the mean time we handle temporary CLIR MMI - // commands through the dial() function. Please see bug 889737. - case MMI_SC_CLIR: - options.procedure = mmi.procedure; - switch (options.procedure) { - case MMI_PROCEDURE_INTERROGATION: - this.getCLIR(options); - return; - case MMI_PROCEDURE_ACTIVATION: - options.clirMode = CLIR_INVOCATION; - break; - case MMI_PROCEDURE_DEACTIVATION: - options.clirMode = CLIR_SUPPRESSION; - break; - default: - _sendMMIError(MMI_ERROR_KS_NOT_SUPPORTED); - return; - } - options.isSetCLIR = true; - this.setCLIR(options); - return; - // Change call barring password case MMI_SC_CHANGE_PASSWORD: if (!_isRadioAvailable() || !_isValidChangePasswordRequest()) { @@ -4608,66 +4584,6 @@ RilObject.prototype[REQUEST_GET_CLIR] = function REQUEST_GET_CLIR(length, option options.n = Buf.readInt32(); // Will be TS 27.007 +CLIR parameter 'n'. options.m = Buf.readInt32(); // Will be TS 27.007 +CLIR parameter 'm'. - - if (options.rilMessageType === "sendMMI") { - // TS 27.007 +CLIR parameter 'm'. - switch (options.m) { - // CLIR not provisioned. - case 0: - options.statusMessage = MMI_SM_KS_SERVICE_NOT_PROVISIONED; - break; - // CLIR provisioned in permanent mode. - case 1: - options.statusMessage = MMI_SM_KS_CLIR_PERMANENT; - break; - // Unknown (e.g. no network, etc.). - case 2: - options.errorMsg = MMI_ERROR_KS_ERROR; - break; - // CLIR temporary mode presentation restricted. - case 3: - // TS 27.007 +CLIR parameter 'n'. - switch (options.n) { - // Default. - case 0: - // CLIR invocation. - case 1: - options.statusMessage = MMI_SM_KS_CLIR_DEFAULT_ON_NEXT_CALL_ON; - break; - // CLIR suppression. - case 2: - options.statusMessage = MMI_SM_KS_CLIR_DEFAULT_ON_NEXT_CALL_OFF; - break; - default: - options.errorMsg = GECKO_ERROR_GENERIC_FAILURE; - break; - } - break; - // CLIR temporary mode presentation allowed. - case 4: - // TS 27.007 +CLIR parameter 'n'. - switch (options.n) { - // Default. - case 0: - // CLIR suppression. - case 2: - options.statusMessage = MMI_SM_KS_CLIR_DEFAULT_OFF_NEXT_CALL_OFF; - break; - // CLIR invocation. - case 1: - options.statusMessage = MMI_SM_KS_CLIR_DEFAULT_OFF_NEXT_CALL_ON; - break; - default: - options.errorMsg = GECKO_ERROR_GENERIC_FAILURE; - break; - } - break; - default: - options.errorMsg = GECKO_ERROR_GENERIC_FAILURE; - break; - } - } - this.sendChromeMessage(options); }; RilObject.prototype[REQUEST_SET_CLIR] = function REQUEST_SET_CLIR(length, options) { @@ -4676,16 +4592,6 @@ RilObject.prototype[REQUEST_SET_CLIR] = function REQUEST_SET_CLIR(length, option return; } - if (!options.errorMsg && options.rilMessageType === "sendMMI") { - switch (options.procedure) { - case MMI_PROCEDURE_ACTIVATION: - options.statusMessage = MMI_SM_KS_SERVICE_ENABLED; - break; - case MMI_PROCEDURE_DEACTIVATION: - options.statusMessage = MMI_SM_KS_SERVICE_DISABLED; - break; - } - } this.sendChromeMessage(options); }; diff --git a/dom/telephony/gonk/TelephonyService.js b/dom/telephony/gonk/TelephonyService.js index b9fb0a06bc0e..e13753766188 100644 --- a/dom/telephony/gonk/TelephonyService.js +++ b/dom/telephony/gonk/TelephonyService.js @@ -59,6 +59,10 @@ MMI_SC_TO_LOCK_TYPE[RIL.MMI_SC_PIN2] = Ci.nsIIcc.CARD_LOCK_TYPE_PIN2; MMI_SC_TO_LOCK_TYPE[RIL.MMI_SC_PUK] = Ci.nsIIcc.CARD_LOCK_TYPE_PUK; MMI_SC_TO_LOCK_TYPE[RIL.MMI_SC_PUK2] = Ci.nsIIcc.CARD_LOCK_TYPE_PUK2; +const MMI_PROC_TO_CLIR_ACTION = {}; +MMI_PROC_TO_CLIR_ACTION[RIL.MMI_PROCEDURE_ACTIVATION] = Ci.nsIMobileConnection.CLIR_INVOCATION; +MMI_PROC_TO_CLIR_ACTION[RIL.MMI_PROCEDURE_DEACTIVATION] = Ci.nsIMobileConnection.CLIR_SUPPRESSION; + const CF_ACTION_TO_STATUS_MESSAGE = {}; CF_ACTION_TO_STATUS_MESSAGE[Ci.nsIMobileConnection.CALL_FORWARD_ACTION_ENABLE] = RIL.MMI_SM_KS_SERVICE_ENABLED; CF_ACTION_TO_STATUS_MESSAGE[Ci.nsIMobileConnection.CALL_FORWARD_ACTION_DISABLE] = RIL.MMI_SM_KS_SERVICE_DISABLED; @@ -71,6 +75,10 @@ LOCK_TYPE_TO_STATUS_MESSAGE[Ci.nsIIcc.CARD_LOCK_TYPE_PIN2] = RIL.MMI_SM_KS_PIN2_ LOCK_TYPE_TO_STATUS_MESSAGE[Ci.nsIIcc.CARD_LOCK_TYPE_PUK] = RIL.MMI_SM_KS_PIN_UNBLOCKED; LOCK_TYPE_TO_STATUS_MESSAGE[Ci.nsIIcc.CARD_LOCK_TYPE_PUK2] = RIL.MMI_SM_KS_PIN2_UNBLOCKED; +const CLIR_ACTION_TO_STATUS_MESSAGE = {}; +CLIR_ACTION_TO_STATUS_MESSAGE[Ci.nsIMobileConnection.CLIR_INVOCATION] = RIL.MMI_SM_KS_SERVICE_ENABLED; +CLIR_ACTION_TO_STATUS_MESSAGE[Ci.nsIMobileConnection.CLIR_SUPPRESSION] = RIL.MMI_SM_KS_SERVICE_DISABLED; + let DEBUG; function debug(s) { dump("TelephonyService: " + s + "\n"); @@ -460,11 +468,11 @@ TelephonyService.prototype = { // presentation, i.e. CLIR_SUPPRESSION. See TS 22.030, Annex B. switch (aProcedure) { case RIL.MMI_PROCEDURE_ACTIVATION: - return RIL.CLIR_SUPPRESSION; + return Ci.nsIMobileConnection.CLIR_SUPPRESSION; case RIL.MMI_PROCEDURE_DEACTIVATION: - return RIL.CLIR_INVOCATION; + return Ci.nsIMobileConnection.CLIR_INVOCATION; default: - return RIL.CLIR_DEFAULT; + return Ci.nsIMobileConnection.CLIR_DEFAULT; } }, @@ -878,6 +886,11 @@ TelephonyService.prototype = { this._clipMMI(aClientId, aMmi, aCallback); break; + // CLIR (non-temporary ones) + case RIL.MMI_KS_SC_CLIR: + this._clirMMI(aClientId, aMmi, aCallback); + break; + // Fall back to "sendMMI". default: this._sendMMI(aClientId, aMmi, aCallback); @@ -1135,6 +1148,114 @@ TelephonyService.prototype = { }); }, + /** + * Handle CLIR MMI code. + * + * @param aClientId + * Client id. + * @param aMmi + * Parsed MMI structure. + * @param aCallback + * A nsITelephonyDialCallback object. + */ + _clirMMI: function(aClientId, aMmi, aCallback) { + let connection = gGonkMobileConnectionService.getItemByServiceId(aClientId); + switch (aMmi.procedure) { + case RIL.MMI_PROCEDURE_INTERROGATION: + connection.getCallingLineIdRestriction({ + QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionCallback]), + notifyGetClirStatusSuccess: function(aN, aM) { + let errorMsg; + let statusMessage; + // TS 27.007 +CLIR parameter 'm'. + switch (aM) { + // CLIR not provisioned. + case 0: + statusMessage = RIL.MMI_SM_KS_SERVICE_NOT_PROVISIONED; + break; + // CLIR provisioned in permanent mode. + case 1: + statusMessage = RIL.MMI_SM_KS_CLIR_PERMANENT; + break; + // Unknown (e.g. no network, etc.). + case 2: + errorMsg = RIL.MMI_ERROR_KS_ERROR; + break; + // CLIR temporary mode presentation restricted. + case 3: + // TS 27.007 +CLIR parameter 'n'. + switch (aN) { + // Default. + case 0: + // CLIR invocation. + case 1: + statusMessage = RIL.MMI_SM_KS_CLIR_DEFAULT_ON_NEXT_CALL_ON; + break; + // CLIR suppression. + case 2: + statusMessage = RIL.MMI_SM_KS_CLIR_DEFAULT_ON_NEXT_CALL_OFF; + break; + default: + errorMsg = RIL.GECKO_ERROR_GENERIC_FAILURE; + break; + } + break; + // CLIR temporary mode presentation allowed. + case 4: + // TS 27.007 +CLIR parameter 'n'. + switch (aN) { + // Default. + case 0: + // CLIR suppression. + case 2: + statusMessage = RIL.MMI_SM_KS_CLIR_DEFAULT_OFF_NEXT_CALL_OFF; + break; + // CLIR invocation. + case 1: + statusMessage = RIL.MMI_SM_KS_CLIR_DEFAULT_OFF_NEXT_CALL_ON; + break; + default: + errorMsg = RIL.GECKO_ERROR_GENERIC_FAILURE; + break; + } + break; + default: + errorMsg = RIL.GECKO_ERROR_GENERIC_FAILURE; + break; + } + + if (errorMsg) { + aCallback.notifyDialMMIError(errorMsg); + return; + } + + aCallback.notifyDialMMISuccess(statusMessage); + }, + notifyError: function(aErrorMsg) { + aCallback.notifyDialMMIError(aErrorMsg); + }, + }); + break; + case RIL.MMI_PROCEDURE_ACTIVATION: + case RIL.MMI_PROCEDURE_DEACTIVATION: { + let clirMode = MMI_PROC_TO_CLIR_ACTION[aMmi.procedure]; + connection.setCallingLineIdRestriction(clirMode, { + QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionCallback]), + notifySuccess: function() { + aCallback.notifyDialMMISuccess(CLIR_ACTION_TO_STATUS_MESSAGE[clirMode]); + }, + notifyError: function(aErrorMsg) { + aCallback.notifyDialMMIError(aErrorMsg); + }, + }); + break; + } + default: + aCallback.notifyDialMMIError(RIL.MMI_ERROR_KS_NOT_SUPPORTED); + break; + } + }, + _serviceCodeToKeyString: function(aServiceCode) { switch (aServiceCode) { case RIL.MMI_SC_CFU: