Bug 883178 - [MMI] Implement DOMMMIResult and DOMMMIError. Part 2: DOMMMIResult and DOMMMIError. r=vicamo, sr=sicking

This commit is contained in:
Fernando Jiménez 2013-06-30 20:21:32 +08:00
Родитель 068bfbaf11
Коммит 83c78dfd70
9 изменённых файлов: 181 добавлений и 36 удалений

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

@ -531,3 +531,27 @@ dictionary MozCallBarringOption
*/ */
unsigned short serviceClass; unsigned short serviceClass;
}; };
dictionary DOMMMIResult
{
/**
* String key that identifies the service associated with the MMI code
* request. The UI is supposed to handle the localization of the strings
* associated with this string key.
*/
DOMString serviceCode;
/**
* String key containing the status message of the associated MMI request.
* The UI is supposed to handle the localization of the strings associated
* with this string key.
*/
DOMString statusMessage;
/**
* Some MMI requests like call forwarding or PIN/PIN2/PUK/PUK2 related
* requests provide extra information along with the status message, this
* information can be a number, a string key or an array of string keys.
*/
jsval additionalInformation;
};

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

@ -278,7 +278,7 @@ MobileConnection::SelectNetworkAutomatically(nsIDOMDOMRequest** request)
NS_IMETHODIMP NS_IMETHODIMP
MobileConnection::SendMMI(const nsAString& aMMIString, MobileConnection::SendMMI(const nsAString& aMMIString,
nsIDOMDOMRequest** request) nsIDOMDOMRequest** aRequest)
{ {
if (!CheckPermission("mobileconnection")) { if (!CheckPermission("mobileconnection")) {
return NS_OK; return NS_OK;
@ -288,11 +288,11 @@ MobileConnection::SendMMI(const nsAString& aMMIString,
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
return mProvider->SendMMI(GetOwner(), aMMIString, request); return mProvider->SendMMI(GetOwner(), aMMIString, aRequest);
} }
NS_IMETHODIMP NS_IMETHODIMP
MobileConnection::CancelMMI(nsIDOMDOMRequest** request) MobileConnection::CancelMMI(nsIDOMDOMRequest** aRequest)
{ {
if (!CheckPermission("mobileconnection")) { if (!CheckPermission("mobileconnection")) {
return NS_OK; return NS_OK;
@ -302,7 +302,7 @@ MobileConnection::CancelMMI(nsIDOMDOMRequest** request)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
return mProvider->CancelMMI(GetOwner(), request); return mProvider->CancelMMI(GetOwner(), aRequest);
} }
NS_IMETHODIMP NS_IMETHODIMP

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

@ -58,7 +58,12 @@ tasks.push(function testGettingIMEI() {
request.onsuccess = function onsuccess(event) { request.onsuccess = function onsuccess(event) {
ok(true, "request success"); ok(true, "request success");
is(event.target.result, "000000000000000", "Emulator IMEI"); is(typeof event.target.result, "object", "typeof result object");
ok(event.target.result instanceof Object, "result instanceof Object");
is(event.target.result.statusMessage, "000000000000000", "Emulator IMEI");
is(event.target.result.serviceCode, "scImei", "Service code IMEI");
is(event.target.result.additionalInformation, undefined,
"No additional information");
tasks.next(); tasks.next();
} }
request.onerror = function onerror() { request.onerror = function onerror() {

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

@ -61,6 +61,8 @@ const CELLBROADCASTMESSAGE_CID =
Components.ID("{29474c96-3099-486f-bb4a-3c9a1da834e4}"); Components.ID("{29474c96-3099-486f-bb4a-3c9a1da834e4}");
const CELLBROADCASTETWSINFO_CID = const CELLBROADCASTETWSINFO_CID =
Components.ID("{59f176ee-9dcd-4005-9d47-f6be0cd08e17}"); Components.ID("{59f176ee-9dcd-4005-9d47-f6be0cd08e17}");
const DOMMMIERROR_CID =
Components.ID("{6b204c42-7928-4e71-89ad-f90cd82aff96}");
const RIL_IPC_MSG_NAMES = [ const RIL_IPC_MSG_NAMES = [
"RIL:CardStateChanged", "RIL:CardStateChanged",
@ -334,6 +336,34 @@ CallBarringOption.prototype = {
serviceClass: 'r'} serviceClass: 'r'}
}; };
function DOMMMIResult(result) {
this.serviceCode = result.serviceCode;
this.statusMessage = result.statusMessage;
this.additionalInformation = result.additionalInformation;
};
DOMMMIResult.prototype = {
__exposedProps__: {serviceCode: 'r',
statusMessage: 'r',
additionalInformation: 'r'}
};
function DOMMMIError() {
};
DOMMMIError.prototype = {
classDescription: "DOMMMIError",
classID: DOMMMIERROR_CID,
contractID: "@mozilla.org/dom/mmi-error;1",
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]),
__init: function(serviceCode,
name,
message,
additionalInformation) {
this.__DOM_IMPL__.init(name, message);
this.serviceCode = serviceCode;
this.additionalInformation = additionalInformation;
},
};
function RILContentHelper() { function RILContentHelper() {
this.rilContext = { this.rilContext = {
cardState: RIL.GECKO_CARDSTATE_UNKNOWN, cardState: RIL.GECKO_CARDSTATE_UNKNOWN,
@ -593,10 +623,14 @@ RILContentHelper.prototype = {
}, },
sendMMI: function sendMMI(window, mmi) { sendMMI: function sendMMI(window, mmi) {
// We need to save the global window to get the proper MMIError
// constructor once we get the reply from the parent process.
this._window = window;
debug("Sending MMI " + mmi); debug("Sending MMI " + mmi);
if (!window) { if (!window) {
throw Components.Exception("Can't get window object", throw Components.Exception("Can't get window object",
Cr.NS_ERROR_EXPECTED); Cr.NS_ERROR_UNEXPECTED);
} }
let request = Services.DOMRequest.createRequest(window); let request = Services.DOMRequest.createRequest(window);
let requestId = this.getRequestId(request); let requestId = this.getRequestId(request);
@ -1207,14 +1241,9 @@ RILContentHelper.prototype = {
break; break;
case "RIL:SendMMI:Return:OK": case "RIL:SendMMI:Return:OK":
case "RIL:CancelMMI:Return:OK": case "RIL:CancelMMI:Return:OK":
this.handleSendCancelMMIOK(msg.json);
break;
case "RIL:SendMMI:Return:KO": case "RIL:SendMMI:Return:KO":
case "RIL:CancelMMI:Return:KO": case "RIL:CancelMMI:Return:KO":
request = this.takeRequest(msg.json.requestId); this.handleSendCancelMMI(msg.json);
if (request) {
Services.DOMRequest.fireError(request, msg.json.errorMsg);
}
break; break;
case "RIL:StkCommand": case "RIL:StkCommand":
this._deliverEvent("_iccListeners", "notifyStkCommand", this._deliverEvent("_iccListeners", "notifyStkCommand",
@ -1528,21 +1557,55 @@ RILContentHelper.prototype = {
Services.DOMRequest.fireSuccess(request, null); Services.DOMRequest.fireSuccess(request, null);
}, },
handleSendCancelMMIOK: function handleSendCancelMMIOK(message) { handleSendCancelMMI: function handleSendCancelMMI(message) {
debug("handleSendCancelMMI " + JSON.stringify(message));
let request = this.takeRequest(message.requestId); let request = this.takeRequest(message.requestId);
if (!request) { if (!request) {
return; return;
} }
// MMI query call forwarding options request returns a set of rules that let success = message.success;
// will be exposed in the form of an array of nsIDOMMozMobileCFInfo
// instances. let result = {
if (message.success && message.rules) { serviceCode: message.mmiServiceCode
this._cfRulesToMobileCfInfo(message.rules); };
message.result = message.rules;
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;
} }
Services.DOMRequest.fireSuccess(request, message.result); if (success) {
let mmiResult = new DOMMMIResult(result);
Services.DOMRequest.fireSuccess(request, mmiResult);
} else {
let mmiError = new this._window.DOMMMIError(result.serviceCode,
result.name,
result.message,
result.additionalInformation);
Services.DOMRequest.fireDetailedError(request, mmiError);
}
}, },
_getRandomId: function _getRandomId() { _getRandomId: function _getRandomId() {
@ -1630,5 +1693,6 @@ RILContentHelper.prototype = {
} }
}; };
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RILContentHelper]); this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RILContentHelper,
DOMMMIError]);

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

@ -19,5 +19,7 @@ category profile-after-change RadioInterfaceLayer @mozilla.org/ril;1
# RILContentHelper.js # RILContentHelper.js
component {472816e1-1fd6-4405-996c-806f9ea68174} RILContentHelper.js component {472816e1-1fd6-4405-996c-806f9ea68174} RILContentHelper.js
component {6b204c42-7928-4e71-89ad-f90cd82aff96} RILContentHelper.js
contract @mozilla.org/ril/content-helper;1 {472816e1-1fd6-4405-996c-806f9ea68174} contract @mozilla.org/ril/content-helper;1 {472816e1-1fd6-4405-996c-806f9ea68174}
contract @mozilla.org/dom/mmi-error;1 {6b204c42-7928-4e71-89ad-f90cd82aff96}
category profile-after-change RILContentHelper @mozilla.org/ril/content-helper;1 category profile-after-change RILContentHelper @mozilla.org/ril/content-helper;1

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

@ -2536,6 +2536,26 @@ this.MMI_SC_BA_ALL = "330";
this.MMI_SC_BA_MO = "333"; this.MMI_SC_BA_MO = "333";
this.MMI_SC_BA_MT = "353"; this.MMI_SC_BA_MT = "353";
// MMI service code key strings.
this.MMI_KS_SC_CALL_BARRING = "scCallBarring";
this.MMI_KS_SC_CALL_FORWARDING = "scCallForwarding";
this.MMI_KS_SC_CLIP = "scClip";
this.MMI_KS_SC_CLIR = "scClir";
this.MMI_KS_SC_PWD = "scPwd";
this.MMI_KS_SC_CALL_WAITING = "scCallWaiting";
this.MMI_KS_SC_PIN = "scPin";
this.MMI_KS_SC_PIN2 = "scPin2";
this.MMI_KS_SC_PUK = "scPuk";
this.MMI_KS_SC_PUK2 = "scPuk2";
this.MMI_KS_SC_IMEI = "scImei";
this.MMI_KS_SC_USSD = "scUssd";
// MMI error messages key strings.
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";
/** /**
* CDMA PDU constants * CDMA PDU constants
*/ */

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

@ -2183,28 +2183,31 @@ let RIL = {
let mmiString = options.mmi; let mmiString = options.mmi;
let mmi = this._parseMMI(mmiString); let mmi = this._parseMMI(mmiString);
let _sendMMIError = (function _sendMMIError(errorMsg) { let _sendMMIError = (function _sendMMIError(errorMsg, mmiServiceCode) {
options.rilMessageType = "sendMMI"; options.rilMessageType = "sendMMI";
options.errorMsg = errorMsg; options.errorMsg = errorMsg;
if (mmiServiceCode) {
options.mmiServiceCode = mmiServiceCode;
}
this.sendDOMMessage(options); this.sendDOMMessage(options);
}).bind(this); }).bind(this);
function _isValidPINPUKRequest() { function _isValidPINPUKRequest(mmiServiceCode) {
// The only allowed MMI procedure for ICC PIN, PIN2, PUK and PUK2 handling // The only allowed MMI procedure for ICC PIN, PIN2, PUK and PUK2 handling
// is "Registration" (**). // is "Registration" (**).
if (!mmi.procedure || mmi.procedure != MMI_PROCEDURE_REGISTRATION ) { if (!mmi.procedure || mmi.procedure != MMI_PROCEDURE_REGISTRATION ) {
_sendMMIError("WRONG_MMI_PROCEDURE"); _sendMMIError(MMI_ERROR_KS_INVALID_ACTION, mmiServiceCode);
return; return;
} }
if (!mmi.sia || !mmi.sia.length || !mmi.sib || !mmi.sib.length || if (!mmi.sia || !mmi.sia.length || !mmi.sib || !mmi.sib.length ||
!mmi.sic || !mmi.sic.length) { !mmi.sic || !mmi.sic.length) {
_sendMMIError("MISSING_SUPPLEMENTARY_INFORMATION"); _sendMMIError(MMI_ERROR_KS_ERROR, mmiServiceCode);
return; return;
} }
if (mmi.sib != mmi.sic) { if (mmi.sib != mmi.sic) {
_sendMMIError("NEW_PIN_MISMATCH"); _sendMMIError(MMI_ERROR_KS_MISMATCH_PIN, mmiServiceCode);
return; return;
} }
@ -2217,7 +2220,7 @@ let RIL = {
this.sendUSSD(options); this.sendUSSD(options);
return; return;
} }
_sendMMIError("NO_VALID_MMI_STRING"); _sendMMIError(MMI_ERROR_KS_ERROR);
return; return;
} }
@ -2241,6 +2244,7 @@ let RIL = {
// procedure, and a reason, given by the MMI service code, but there // procedure, and a reason, given by the MMI service code, but there
// is no way that we get this far without a valid procedure or service // is no way that we get this far without a valid procedure or service
// code. // code.
options.mmiServiceCode = MMI_KS_SC_CALL_FORWARDING;
options.action = MMI_PROC_TO_CF_ACTION[mmi.procedure]; options.action = MMI_PROC_TO_CF_ACTION[mmi.procedure];
options.rilMessageType = "sendMMI"; options.rilMessageType = "sendMMI";
options.reason = MMI_SC_TO_CF_REASON[sc]; options.reason = MMI_SC_TO_CF_REASON[sc];
@ -2263,10 +2267,11 @@ let RIL = {
// an MMI code of the form **04*OLD_PIN*NEW_PIN*NEW_PIN#, where old PIN // an MMI code of the form **04*OLD_PIN*NEW_PIN*NEW_PIN#, where old PIN
// should be entered as the SIA parameter and the new PIN as SIB and // should be entered as the SIA parameter and the new PIN as SIB and
// SIC. // SIC.
if (!_isValidPINPUKRequest()) { if (!_isValidPINPUKRequest(MMI_KS_SC_PIN)) {
return; return;
} }
options.mmiServiceCode = MMI_KS_SC_PIN;
options.rilRequestType = "sendMMI"; options.rilRequestType = "sendMMI";
options.pin = mmi.sia; options.pin = mmi.sia;
options.newPin = mmi.sib; options.newPin = mmi.sib;
@ -2279,10 +2284,11 @@ let RIL = {
// enter and MMI code of the form **042*OLD_PIN2*NEW_PIN2*NEW_PIN2#, // enter and MMI code of the form **042*OLD_PIN2*NEW_PIN2*NEW_PIN2#,
// where the old PIN2 should be entered as the SIA parameter and the // where the old PIN2 should be entered as the SIA parameter and the
// new PIN2 as SIB and SIC. // new PIN2 as SIB and SIC.
if (!_isValidPINPUKRequest()) { if (!_isValidPINPUKRequest(MMI_KS_SC_PIN2)) {
return; return;
} }
options.mmiServiceCode = MMI_KS_SC_PIN2;
options.rilRequestType = "sendMMI"; options.rilRequestType = "sendMMI";
options.pin = mmi.sia; options.pin = mmi.sia;
options.newPin = mmi.sib; options.newPin = mmi.sib;
@ -2295,10 +2301,11 @@ let RIL = {
// enter an MMI code of the form **05*PUK*NEW_PIN*NEW_PIN#, where PUK // enter an MMI code of the form **05*PUK*NEW_PIN*NEW_PIN#, where PUK
// should be entered as the SIA parameter and the new PIN as SIB and // should be entered as the SIA parameter and the new PIN as SIB and
// SIC. // SIC.
if (!_isValidPINPUKRequest()) { if (!_isValidPINPUKRequest(MMI_KS_SC_PUK)) {
return; return;
} }
options.mmiServiceCode = MMI_KS_SC_PUK;
options.rilRequestType = "sendMMI"; options.rilRequestType = "sendMMI";
options.puk = mmi.sia; options.puk = mmi.sia;
options.newPin = mmi.sib; options.newPin = mmi.sib;
@ -2311,10 +2318,11 @@ let RIL = {
// enter an MMI code of the form **052*PUK2*NEW_PIN2*NEW_PIN2#, where // enter an MMI code of the form **052*PUK2*NEW_PIN2*NEW_PIN2#, where
// PUK2 should be entered as the SIA parameter and the new PIN2 as SIB // PUK2 should be entered as the SIA parameter and the new PIN2 as SIB
// and SIC. // and SIC.
if (!_isValidPINPUKRequest()) { if (!_isValidPINPUKRequest(MMI_KS_SC_PUK2)) {
return; return;
} }
options.mmiServiceCode = MMI_KS_SC_PUK2;
options.rilRequestType = "sendMMI"; options.rilRequestType = "sendMMI";
options.puk = mmi.sia; options.puk = mmi.sia;
options.newPin = mmi.sib; options.newPin = mmi.sib;
@ -2329,6 +2337,7 @@ let RIL = {
return; return;
} }
// If we already had the device's IMEI, we just send it to the DOM. // 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.rilMessageType = "sendMMI";
options.success = true; options.success = true;
options.result = this.IMEI; options.result = this.IMEI;
@ -2344,12 +2353,13 @@ let RIL = {
case MMI_SC_BA_ALL: case MMI_SC_BA_ALL:
case MMI_SC_BA_MO: case MMI_SC_BA_MO:
case MMI_SC_BA_MT: case MMI_SC_BA_MT:
_sendMMIError("CALL_BARRING_NOT_SUPPORTED_VIA_MMI");
return;
// Call waiting // Call waiting
case MMI_SC_CALL_WAITING: case MMI_SC_CALL_WAITING:
_sendMMIError("CALL_WAITING_NOT_SUPPORTED_VIA_MMI"); // CLIP
case MMI_SC_CLIP:
// CLIR
case MMI_SC_CLIR:
_sendMMIError(MMI_ERROR_KS_NOT_SUPPORTED);
return; return;
} }
@ -2358,13 +2368,14 @@ let RIL = {
if (mmi.fullMMI && if (mmi.fullMMI &&
(mmiString.charAt(mmiString.length - 1) == MMI_END_OF_USSD)) { (mmiString.charAt(mmiString.length - 1) == MMI_END_OF_USSD)) {
options.ussd = mmi.fullMMI; options.ussd = mmi.fullMMI;
options.mmiServiceCode = MMI_KS_SC_USSD;
this.sendUSSD(options); this.sendUSSD(options);
return; return;
} }
// At this point, the MMI string is considered as not valid MMI code and // At this point, the MMI string is considered as not valid MMI code and
// not valid USSD code. // not valid USSD code.
_sendMMIError("NOT_VALID_MMI_STRING"); _sendMMIError(MMI_ERROR_KS_ERROR);
}, },
/** /**
@ -2384,6 +2395,7 @@ let RIL = {
* Cancel pending USSD. * Cancel pending USSD.
*/ */
cancelUSSD: function cancelUSSD(options) { cancelUSSD: function cancelUSSD(options) {
options.mmiServiceCode = MMI_KS_SC_USSD;
Buf.simpleRequest(REQUEST_CANCEL_USSD, options); Buf.simpleRequest(REQUEST_CANCEL_USSD, options);
}, },
@ -4847,6 +4859,7 @@ RIL[REQUEST_GET_IMEI] = function REQUEST_GET_IMEI(length, options) {
return; return;
} }
options.mmiServiceCode = MMI_KS_SC_IMEI;
options.rilMessageType = "sendMMI"; options.rilMessageType = "sendMMI";
options.success = (options.rilRequestError === 0); options.success = (options.rilRequestError === 0);
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError]; options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];

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

@ -0,0 +1,16 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[JSImplementation="@mozilla.org/dom/mmi-error;1",
Constructor(DOMString serviceCode,
DOMString name,
optional DOMString message = "",
optional DOMString additionalInformation = "")]
interface DOMMMIError : DOMError {
readonly attribute DOMString serviceCode;
readonly attribute any additionalInformation;
};

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

@ -61,6 +61,7 @@ webidl_files = \
DOMCursor.webidl \ DOMCursor.webidl \
DOMError.webidl \ DOMError.webidl \
DOMImplementation.webidl \ DOMImplementation.webidl \
DOMMMIError.webidl \
DOMParser.webidl \ DOMParser.webidl \
DOMRequest.webidl \ DOMRequest.webidl \
DOMSettableTokenList.webidl \ DOMSettableTokenList.webidl \