Bug 963516 - Part 3: ril implementation to support matchMvno(). f=edgar r=hsinyi

This commit is contained in:
Jessica Jong 2014-01-28 02:22:00 +08:00
parent e37a31baae
commit 2e933670a8
2 changed files with 76 additions and 2 deletions

View File

@ -107,7 +107,8 @@ const RIL_IPC_MSG_NAMES = [
"RIL:RadioStateChanged",
"RIL:SetVoicePrivacyMode",
"RIL:GetVoicePrivacyMode",
"RIL:OtaStatusChanged"
"RIL:OtaStatusChanged",
"RIL:MatchMvno"
];
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
@ -636,6 +637,26 @@ RILContentHelper.prototype = {
return context && context.cardState;
},
matchMvno: function(clientId, window, mvnoType, mvnoData) {
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);
cpmm.sendAsyncMessage("RIL:MatchMvno", {
clientId: clientId,
data: {
requestId: requestId,
mvnoType: mvnoType,
mvnoData: mvnoData
}
});
return request;
},
/**
* nsIMobileConnectionProvider
*/
@ -1784,6 +1805,9 @@ RILContentHelper.prototype = {
case "RIL:UpdateIccContact":
this.handleUpdateIccContact(data);
break;
case "RIL:MatchMvno":
this.handleSimpleRequest(data.requestId, data.errorMsg, data.result);
break;
case "RIL:DataError":
this.updateConnectionInfo(data, this.rilContexts[clientId].dataConnectionInfo);
this._deliverEvent(clientId, "_mobileConnectionListeners", "notifyDataError",

View File

@ -144,7 +144,8 @@ const RIL_IPC_ICCMANAGER_MSG_NAMES = [
"RIL:IccCloseChannel",
"RIL:ReadIccContacts",
"RIL:UpdateIccContact",
"RIL:RegisterIccMsg"
"RIL:RegisterIccMsg",
"RIL:MatchMvno"
];
const RIL_IPC_VOICEMAIL_MSG_NAMES = [
@ -1398,6 +1399,9 @@ RadioInterface.prototype = {
case "RIL:UpdateIccContact":
this.workerMessenger.sendWithIPCMessage(msg, "updateICCContact");
break;
case "RIL:MatchMvno":
this.matchMvno(msg.target, msg.json.data);
break;
case "RIL:SetCallForwardingOptions":
this.setCallForwardingOptions(msg.target, msg.json.data);
break;
@ -1639,6 +1643,52 @@ RadioInterface.prototype = {
return iccId;
},
// Matches the mvnoData pattern with imsi. Characters 'x' and 'X' are skipped
// and not compared. E.g., if the mvnoData passed is '310260x10xxxxxx',
// then the function returns true only if imsi has the same first 6 digits,
// 8th and 9th digit.
isImsiMatches: function(mvnoData) {
let imsi = this.rilContext.imsi;
// This should not be an error, but a mismatch.
if (mvnoData.length > imsi.length) {
return false;
}
for (let i = 0; i < mvnoData.length; i++) {
let c = mvnoData[i];
if ((c !== 'x') && (c !== 'X') && (c !== imsi[i])) {
return false;
}
}
return true;
},
matchMvno: function(target, message) {
if (DEBUG) this.debug("matchMvno: " + JSON.stringify(message));
if (!message || !message.mvnoType || !message.mvnoData) {
message.errorMsg = RIL.GECKO_ERROR_INVALID_PARAMETER;
}
// Currently we only support imsi matching.
if (message.mvnoType != "imsi") {
message.errorMsg = RIL.GECKO_ERROR_MODE_NOT_SUPPORTED;
}
// Fire error if mvnoType is imsi but imsi is not available.
if (!this.rilContext.imsi) {
message.errorMsg = RIL.GECKO_ERROR_GENERIC_FAILURE;
}
if (!message.errorMsg) {
message.result = this.isImsiMatches(message.mvnoData);
}
target.sendAsyncMessage("RIL:MatchMvno", {
clientId: this.clientId,
data: message
});
},
updateNetworkInfo: function(message) {
let voiceMessage = message[RIL.NETWORK_INFO_VOICE_REGISTRATION_STATE];
let dataMessage = message[RIL.NETWORK_INFO_DATA_REGISTRATION_STATE];