Bug 818393 - Part 3: Call barring RIL implementation. r=htsai.

---
 dom/system/gonk/RILContentHelper.js    |  112 +++++++++++++++++++++++++++++++-
 dom/system/gonk/RadioInterfaceLayer.js |   38 +++++++++++
 dom/system/gonk/ril_consts.js          |   19 ++++++
 dom/system/gonk/ril_worker.js          |   31 +++++++++
 4 files changed, 199 insertions(+), 1 deletion(-)
This commit is contained in:
Szu-Yu Chen [:aknow] 2013-05-21 13:13:37 +08:00
parent d404b99597
commit 0b34baff3e
4 changed files with 199 additions and 1 deletions

View File

@ -78,6 +78,8 @@ const RIL_IPC_MSG_NAMES = [
"RIL:DataError",
"RIL:SetCallForwardingOption",
"RIL:GetCallForwardingOption",
"RIL:SetCallBarringOption",
"RIL:GetCallBarringOption",
"RIL:SetCallWaitingOption",
"RIL:GetCallWaitingOption",
"RIL:CellBroadcastReceived",
@ -311,6 +313,19 @@ CellBroadcastEtwsInfo.prototype = {
popup: null
};
function CallBarringOption(option) {
this.program = option.program;
this.enabled = option.enabled;
this.password = option.password;
this.serviceClass = option.serviceClass;
}
CallBarringOption.prototype = {
__exposedProps__ : {program: 'r',
enabled: 'r',
password: 'r',
serviceClass: 'r'}
};
function RILContentHelper() {
this.rilContext = {
cardState: RIL.GECKO_CARDSTATE_UNKNOWN,
@ -778,6 +793,53 @@ RILContentHelper.prototype = {
return request;
},
getCallBarringOption: function getCallBarringOption(window, option) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
}
let request = Services.DOMRequest.createRequest(window);
let requestId = this.getRequestId(request);
if (DEBUG) debug("getCallBarringOption: " + JSON.stringify(option));
if (!this._isValidCallBarringOption(option)) {
this.dispatchFireRequestError(requestId, "InvalidCallBarringOption");
return request;
}
cpmm.sendAsyncMessage("RIL:GetCallBarringOption", {
requestId: requestId,
program: option.program,
password: option.password,
serviceClass: option.serviceClass
});
return request;
},
setCallBarringOption: function setCallBarringOption(window, option) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
}
let request = Services.DOMRequest.createRequest(window);
let requestId = this.getRequestId(request);
if (DEBUG) debug("setCallBarringOption: " + JSON.stringify(option));
if (!this._isValidCallBarringOption(option)) {
this.dispatchFireRequestError(requestId, "InvalidCallBarringOption");
return request;
}
cpmm.sendAsyncMessage("RIL:SetCallBarringOption", {
requestId: requestId,
program: option.program,
enabled: option.enabled,
password: option.password,
serviceClass: option.serviceClass
});
return request;
},
getCallWaitingOption: function getCallWaitingOption(window) {
if (window == null) {
throw Components.Exception("Can't get window object",
@ -1181,6 +1243,12 @@ RILContentHelper.prototype = {
case "RIL:SetCallForwardingOption":
this.handleSetCallForwardingOption(msg.json);
break;
case "RIL:GetCallBarringOption":
this.handleGetCallBarringOption(msg.json);
break;
case "RIL:SetCallBarringOption":
this.handleSetCallBarringOption(msg.json);
break;
case "RIL:GetCallWaitingOption":
this.handleGetCallWaitingOption(msg.json);
break;
@ -1403,6 +1471,23 @@ RILContentHelper.prototype = {
Services.DOMRequest.fireSuccess(request, null);
},
handleGetCallBarringOption: function handleGetCallBarringOption(message) {
if (!message.success) {
this.fireRequestError(message.requestId, message.errorMsg);
} else {
let option = new CallBarringOption(message);
this.fireRequestSuccess(message.requestId, option);
}
},
handleSetCallBarringOption: function handleSetCallBarringOption(message) {
if (!message.success) {
this.fireRequestError(message.requestId, message.errorMsg);
} else {
this.fireRequestSuccess(message.requestId, null);
}
},
handleGetCallWaitingOption: function handleGetCallWaitingOption(message) {
let requestId = message.requestId;
let request = this.takeRequest(requestId);
@ -1505,6 +1590,31 @@ RILContentHelper.prototype = {
default:
return false;
}
},
/**
* Helper for guarding us against invalid program values for call barring.
*/
_isValidCallBarringProgram: function _isValidCallBarringProgram(program) {
switch (program) {
case Ci.nsIDOMMozMobileConnection.CALL_BARRING_PROGRAM_ALL_OUTGOING:
case Ci.nsIDOMMozMobileConnection.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL:
case Ci.nsIDOMMozMobileConnection.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL_EXCEPT_HOME:
case Ci.nsIDOMMozMobileConnection.CALL_BARRING_PROGRAM_ALL_INCOMING:
case Ci.nsIDOMMozMobileConnection.CALL_BARRING_PROGRAM_INCOMING_ROAMING:
return true;
default:
return false;
}
},
/**
* Helper for guarding us against invalid option for call barring.
*/
_isValidCallBarringOption: function _isValidCallBarringOption(option) {
return (option
&& option.serviceClass != null
&& this._isValidCallBarringProgram(option.program));
}
};

View File

@ -95,6 +95,8 @@ const RIL_IPC_MOBILECONNECTION_MSG_NAMES = [
"RIL:RegisterMobileConnectionMsg",
"RIL:SetCallForwardingOption",
"RIL:GetCallForwardingOption",
"RIL:SetCallBarringOption",
"RIL:GetCallBarringOption",
"RIL:SetCallWaitingOption",
"RIL:GetCallWaitingOption"
];
@ -552,6 +554,14 @@ RadioInterfaceLayer.prototype = {
this.saveRequestTarget(msg);
this.getCallForwardingOption(msg.json);
break;
case "RIL:SetCallBarringOption":
this.saveRequestTarget(msg);
this.setCallBarringOption(msg.json);
break;
case "RIL:GetCallBarringOption":
this.saveRequestTarget(msg);
this.getCallBarringOption(msg.json);
break;
case "RIL:SetCallWaitingOption":
this.saveRequestTarget(msg);
this.setCallWaitingOption(msg.json);
@ -728,6 +738,12 @@ RadioInterfaceLayer.prototype = {
case "setCallForward":
this.handleSetCallForward(message);
break;
case "queryCallBarringStatus":
this.handleQueryCallBarringStatus(message);
break;
case "setCallBarring":
this.handleSetCallBarring(message);
break;
case "queryCallWaiting":
this.handleQueryCallWaiting(message);
break;
@ -1886,6 +1902,16 @@ RadioInterfaceLayer.prototype = {
this._sendRequestResults(messageType, message);
},
handleQueryCallBarringStatus: function handleQueryCallBarringStatus(message) {
debug("handleQueryCallBarringStatus: " + JSON.stringify(message));
this._sendRequestResults("RIL:GetCallBarringOption", message);
},
handleSetCallBarring: function handleSetCallBarring(message) {
debug("handleSetCallBarring: " + JSON.stringify(message));
this._sendRequestResults("RIL:SetCallBarringOption", message);
},
handleQueryCallWaiting: function handleQueryCallWaiting(message) {
debug("handleQueryCallWaiting: " + JSON.stringify(message));
this._sendRequestResults("RIL:GetCallWaitingOption", message);
@ -2244,6 +2270,18 @@ RadioInterfaceLayer.prototype = {
this.worker.postMessage(message);
},
setCallBarringOption: function setCallBarringingOption(message) {
debug("setCallBarringOption: " + JSON.stringify(message));
message.rilMessageType = "setCallBarring";
this.worker.postMessage(message);
},
getCallBarringOption: function getCallBarringOption(message) {
debug("getCallBarringOption: " + JSON.stringify(message));
message.rilMessageType = "queryCallBarringStatus";
this.worker.postMessage(message);
},
setCallWaitingOption: function setCallWaitingOption(message) {
debug("setCallWaitingOption: " + JSON.stringify(message));
message.rilMessageType = "setCallWaiting";

View File

@ -526,6 +526,11 @@ this.ICC_STATUS_ERROR_WRONG_PARAMETERS = 0x6a;
// TS 27.007, clause 7.4, +CLCK
this.ICC_CB_FACILITY_SIM = "SC";
this.ICC_CB_FACILITY_FDN = "FD";
this.ICC_CB_FACILITY_BAOC = "AO";
this.ICC_CB_FACILITY_BOIC = "OI";
this.ICC_CB_FACILITY_BOIC_EX_HC = "OX";
this.ICC_CB_FACILITY_BAIC = "AI";
this.ICC_CB_FACILITY_BIC_ROAM = "IR";
// ICC service class
// TS 27.007, clause 7.4, +CLCK
@ -2399,6 +2404,20 @@ this.CALL_FORWARD_REASON_NOT_REACHABLE = 3;
this.CALL_FORWARD_REASON_ALL_CALL_FORWARDING = 4;
this.CALL_FORWARD_REASON_ALL_CONDITIONAL_CALL_FORWARDING = 5;
// Call barring program. Must be in sync with nsIDOMMozMobileConnection interface
this.CALL_BARRING_PROGRAM_ALL_OUTGOING = 0;
this.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL = 1;
this.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL_EXCEPT_HOME = 2;
this.CALL_BARRING_PROGRAM_ALL_INCOMING = 3;
this.CALL_BARRING_PROGRAM_INCOMING_ROAMING = 4;
this.CALL_BARRING_PROGRAM_TO_FACILITY = {};
CALL_BARRING_PROGRAM_TO_FACILITY[CALL_BARRING_PROGRAM_ALL_OUTGOING] = ICC_CB_FACILITY_BAOC;
CALL_BARRING_PROGRAM_TO_FACILITY[CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL] = ICC_CB_FACILITY_BOIC;
CALL_BARRING_PROGRAM_TO_FACILITY[CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL_EXCEPT_HOME] = ICC_CB_FACILITY_BOIC_EX_HC;
CALL_BARRING_PROGRAM_TO_FACILITY[CALL_BARRING_PROGRAM_ALL_INCOMING] = ICC_CB_FACILITY_BAIC;
CALL_BARRING_PROGRAM_TO_FACILITY[CALL_BARRING_PROGRAM_INCOMING_ROAMING] = ICC_CB_FACILITY_BIC_ROAM;
// MMI procedure as defined in TS.22.030 6.5.2
this.MMI_PROCEDURE_ACTIVATION = "*";
this.MMI_PROCEDURE_DEACTIVATION = "#";

View File

@ -2411,6 +2411,37 @@ let RIL = {
Buf.sendParcel();
},
/**
* Queries current call barring rules.
*
* @param program
* One of nsIDOMMozMobileConnection.CALL_BARRING_PROGRAM_* constants.
* @param serviceClass
* One of ICC_SERVICE_CLASS_* constants.
*/
queryCallBarringStatus: function queryCallBarringStatus(options) {
options.facility = CALL_BARRING_PROGRAM_TO_FACILITY[options.program];
options.password = ""; // For query no need to provide it.
this.queryICCFacilityLock(options);
},
/**
* Configures call barring rule.
*
* @param program
* One of nsIDOMMozMobileConnection.CALL_BARRING_PROGRAM_* constants.
* @param enabled
* Enable or disable the call barring.
* @param password
* Barring password.
* @param serviceClass
* One of ICC_SERVICE_CLASS_* constants.
*/
setCallBarring: function setCallBarring(options) {
options.facility = CALL_BARRING_PROGRAM_TO_FACILITY[options.program];
this.setICCFacilityLock(options);
},
/**
* Handle STK CALL_SET_UP request.
*