Bug 1159591 - Part 6: Move MMI logic from ril_worker to telephonyService (CLIR). r=aknow

This commit is contained in:
Edgar Chen 2015-04-30 12:20:40 +08:00
Родитель 589822ee96
Коммит 44e620874c
3 изменённых файлов: 124 добавлений и 102 удалений

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

@ -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_OUTGOING_SERVICE] = ICC_CB_FACILITY_BA_MO;
CALL_BARRING_PROGRAM_TO_FACILITY[CALL_BARRING_PROGRAM_INCOMING_SERVICE] = ICC_CB_FACILITY_BA_MT; 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 // MMI procedure as defined in TS.22.030 6.5.2
this.MMI_PROCEDURE_ACTIVATION = "*"; this.MMI_PROCEDURE_ACTIVATION = "*";
this.MMI_PROCEDURE_DEACTIVATION = "#"; this.MMI_PROCEDURE_DEACTIVATION = "#";

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

@ -1955,30 +1955,6 @@ RilObject.prototype = {
// trigger the appropriate RIL request if possible. // trigger the appropriate RIL request if possible.
let sc = mmi.serviceCode; let sc = mmi.serviceCode;
switch (sc) { 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 // Change call barring password
case MMI_SC_CHANGE_PASSWORD: case MMI_SC_CHANGE_PASSWORD:
if (!_isRadioAvailable() || !_isValidChangePasswordRequest()) { 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.n = Buf.readInt32(); // Will be TS 27.007 +CLIR parameter 'n'.
options.m = Buf.readInt32(); // Will be TS 27.007 +CLIR parameter 'm'. 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); this.sendChromeMessage(options);
}; };
RilObject.prototype[REQUEST_SET_CLIR] = function REQUEST_SET_CLIR(length, 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; 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); this.sendChromeMessage(options);
}; };

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

@ -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_PUK] = Ci.nsIIcc.CARD_LOCK_TYPE_PUK;
MMI_SC_TO_LOCK_TYPE[RIL.MMI_SC_PUK2] = Ci.nsIIcc.CARD_LOCK_TYPE_PUK2; 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 = {}; 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_ENABLE] = RIL.MMI_SM_KS_SERVICE_ENABLED;
CF_ACTION_TO_STATUS_MESSAGE[Ci.nsIMobileConnection.CALL_FORWARD_ACTION_DISABLE] = RIL.MMI_SM_KS_SERVICE_DISABLED; 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_PUK] = RIL.MMI_SM_KS_PIN_UNBLOCKED;
LOCK_TYPE_TO_STATUS_MESSAGE[Ci.nsIIcc.CARD_LOCK_TYPE_PUK2] = RIL.MMI_SM_KS_PIN2_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; let DEBUG;
function debug(s) { function debug(s) {
dump("TelephonyService: " + s + "\n"); dump("TelephonyService: " + s + "\n");
@ -460,11 +468,11 @@ TelephonyService.prototype = {
// presentation, i.e. CLIR_SUPPRESSION. See TS 22.030, Annex B. // presentation, i.e. CLIR_SUPPRESSION. See TS 22.030, Annex B.
switch (aProcedure) { switch (aProcedure) {
case RIL.MMI_PROCEDURE_ACTIVATION: case RIL.MMI_PROCEDURE_ACTIVATION:
return RIL.CLIR_SUPPRESSION; return Ci.nsIMobileConnection.CLIR_SUPPRESSION;
case RIL.MMI_PROCEDURE_DEACTIVATION: case RIL.MMI_PROCEDURE_DEACTIVATION:
return RIL.CLIR_INVOCATION; return Ci.nsIMobileConnection.CLIR_INVOCATION;
default: default:
return RIL.CLIR_DEFAULT; return Ci.nsIMobileConnection.CLIR_DEFAULT;
} }
}, },
@ -878,6 +886,11 @@ TelephonyService.prototype = {
this._clipMMI(aClientId, aMmi, aCallback); this._clipMMI(aClientId, aMmi, aCallback);
break; break;
// CLIR (non-temporary ones)
case RIL.MMI_KS_SC_CLIR:
this._clirMMI(aClientId, aMmi, aCallback);
break;
// Fall back to "sendMMI". // Fall back to "sendMMI".
default: default:
this._sendMMI(aClientId, aMmi, aCallback); 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) { _serviceCodeToKeyString: function(aServiceCode) {
switch (aServiceCode) { switch (aServiceCode) {
case RIL.MMI_SC_CFU: case RIL.MMI_SC_CFU: