Bug 840780 3/3 - B2G RIL: Add support to manage and access logical channels to UICC. r=vicamo

This commit is contained in:
Siddartha Pothapragada 2013-02-25 17:27:26 +08:00
Родитель 71525c8deb
Коммит cbfe3f7459
4 изменённых файлов: 257 добавлений и 1 удалений

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

@ -78,7 +78,10 @@ const RIL_IPC_MSG_NAMES = [
"RIL:SetCallForwardingOption",
"RIL:GetCallForwardingOption",
"RIL:CellBroadcastReceived",
"RIL:CfStateChanged"
"RIL:CfStateChanged",
"RIL:IccOpenChannel",
"RIL:IccCloseChannel",
"RIL:IccExchangeAPDU"
];
const kVoiceChangedTopic = "mobile-connection-voice-changed";
@ -611,6 +614,54 @@ RILContentHelper.prototype = {
cpmm.sendAsyncMessage("RIL:SendStkEventDownload", {event: event});
},
iccOpenChannel: function iccOpenChannel(window,
aid) {
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:IccOpenChannel", {requestId: requestId,
aid: aid});
return request;
},
iccExchangeAPDU: function iccExchangeAPDU(window,
channel,
apdu) {
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);
//Potentially you need serialization here and can't pass the jsval through
cpmm.sendAsyncMessage("RIL:IccExchangeAPDU", {requestId: requestId,
channel: channel,
apdu: apdu});
return request;
},
iccCloseChannel: function iccCloseChannel(window,
channel) {
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:IccCloseChannel", {requestId: requestId,
channel: channel});
return request;
},
getCallForwardingOption: function getCallForwardingOption(window, reason) {
if (window == null) {
throw Components.Exception("Can't get window object",
@ -988,6 +1039,15 @@ RILContentHelper.prototype = {
case "RIL:StkSessionEnd":
Services.obs.notifyObservers(null, kStkSessionEndTopic, null);
break;
case "RIL:IccOpenChannel":
this.handleIccOpenChannel(msg.json);
break;
case "RIL:IccCloseChannel":
this.handleIccCloseChannel(msg.json);
break;
case "RIL:IccExchangeAPDU":
this.handleIccExchangeAPDU(msg.json);
break;
case "RIL:DataError":
this.updateConnectionInfo(msg.json, this.rilContext.dataConnectionInfo);
Services.obs.notifyObservers(null, kDataErrorTopic, msg.json.error);
@ -1075,6 +1135,31 @@ RILContentHelper.prototype = {
}
},
handleIccOpenChannel: function handleIccOpenChannel(message) {
if (message.error) {
this.fireRequestError(message.requestId, message.error);
} else {
this.fireRequestSuccess(message.requestId, message.channel);
}
},
handleIccCloseChannel: function handleIccCloseChannel(message) {
if (message.error) {
this.fireRequestError(message.requestId, message.error);
} else {
this.fireRequestSuccess(message.requestId, null);
}
},
handleIccExchangeAPDU: function handleIccExchangeAPDU(message) {
if (message.error) {
this.fireRequestError(message.requestId, message.error);
} else {
var result = [message.sw1, message.sw2, message.simResponse];
this.fireRequestSuccess(message.requestId, result);
}
},
handleVoicemailNotification: function handleVoicemailNotification(message) {
let changed = false;
if (!this.voicemailStatus) {

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

@ -96,6 +96,9 @@ const RIL_IPC_MOBILECONNECTION_MSG_NAMES = [
"RIL:SendStkMenuSelection",
"RIL:SendStkTimerExpiration",
"RIL:SendStkEventDownload",
"RIL:IccOpenChannel",
"RIL:IccExchangeAPDU",
"RIL:IccCloseChannel",
"RIL:RegisterMobileConnectionMsg",
"RIL:SetCallForwardingOption",
"RIL:GetCallForwardingOption"
@ -493,6 +496,18 @@ RadioInterfaceLayer.prototype = {
case "RIL:SendStkEventDownload":
this.sendStkEventDownload(msg.json);
break;
case "RIL:IccOpenChannel":
this.saveRequestTarget(msg);
this.iccOpenChannel(msg.json);
break;
case "RIL:IccCloseChannel":
this.saveRequestTarget(msg);
this.iccCloseChannel(msg.json);
break;
case "RIL:IccExchangeAPDU":
this.saveRequestTarget(msg);
this.iccExchangeAPDU(msg.json);
break;
case "RIL:RegisterMobileConnectionMsg":
this.registerMessageTarget("mobileconnection", msg.target);
break;
@ -551,6 +566,15 @@ RadioInterfaceLayer.prototype = {
case "callError":
this.handleCallError(message);
break;
case "iccOpenChannel":
this.handleIccOpenChannel(message);
break;
case "iccCloseChannel":
this.handleIccCloseChannel(message);
break;
case "iccExchangeAPDU":
this.handleIccExchangeAPDU(message);
break;
case "getAvailableNetworks":
this.handleGetAvailableNetworks(message);
break;
@ -1364,6 +1388,30 @@ RadioInterfaceLayer.prototype = {
this._sendRequestResults("RIL:EnumerateCalls", options);
},
/**
* Open Logical UICC channel (aid) for Secure Element access
*/
handleIccOpenChannel: function handleIccOpenChannel(message) {
debug("handleIccOpenChannel: " + JSON.stringify(message));
this._sendRequestResults("RIL:IccOpenChannel", message);
},
/**
* Close Logical UICC channel
*/
handleIccCloseChannel: function handleIccCloseChannel(message) {
debug("handleIccCloseChannel: " + JSON.stringify(message));
this._sendRequestResults("RIL:IccCloseChannel", message);
},
/**
* Exchange APDU data on an open Logical UICC channel
*/
handleIccExchangeAPDU: function handleIccExchangeAPDU(message) {
debug("handleIccExchangeAPDU: " + JSON.stringify(message));
this._sendRequestResults("RIL:IccExchangeAPDU", message);
},
/**
* Handle available networks returned by the 'getAvailableNetworks' request.
*/
@ -2098,6 +2146,24 @@ RadioInterfaceLayer.prototype = {
this.worker.postMessage(message);
},
iccOpenChannel: function iccOpenChannel(message) {
debug("ICC Open Channel");
message.rilMessageType = "iccOpenChannel";
this.worker.postMessage(message);
},
iccCloseChannel: function iccCloseChannel(message) {
debug("ICC Close Channel");
message.rilMessageType = "iccCloseChannel";
this.worker.postMessage(message);
},
iccExchangeAPDU: function iccExchangeAPDU(message) {
debug("ICC Exchange APDU");
message.rilMessageType = "iccExchangeAPDU";
this.worker.postMessage(message);
},
setCallForwardingOption: function setCallForwardingOption(message) {
debug("setCallForwardingOption: " + JSON.stringify(message));
message.rilMessageType = "setCallForward";

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

@ -149,6 +149,11 @@ this.REQUEST_MODIFY_QOS = 118;
this.REQUEST_SUSPEND_QOS = 119;
this.REQUEST_RESUME_QOS = 120;
// UICC Secure Access
this.REQUEST_SIM_OPEN_CHANNEL = 121;
this.REQUEST_SIM_CLOSE_CHANNEL = 122;
this.REQUEST_SIM_ACCESS_CHANNEL = 123;
this.RESPONSE_TYPE_SOLICITED = 0;
this.RESPONSE_TYPE_UNSOLICITED = 1;

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

@ -1470,6 +1470,70 @@ let RIL = {
Buf.simpleRequest(REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, options);
},
/**
* Open Logical UICC channel (aid) for Secure Element access
*/
iccOpenChannel: function iccOpenChannel(options) {
if (DEBUG) {
debug("iccOpenChannel: " + JSON.stringify(options));
}
let token = Buf.newParcel(REQUEST_SIM_OPEN_CHANNEL, options);
Buf.writeString(options.aid);
Buf.sendParcel();
},
/**
* Exchange APDU data on an open Logical UICC channel
*/
iccExchangeAPDU: function iccExchangeAPDU(options) {
if (DEBUG) debug("iccExchangeAPDU: " + JSON.stringify(options));
var cla = options.apdu.cla;
var command = options.apdu.command;
var channel = options.channel;
var path = options.apdu.path;
var data = options.apdu.data;
var data2 = options.apdu.data2;
if (path == null || path === undefined) {
var path = "";
}
if (data == null || data === undefined) {
var data = "";
}
if (data2 == null || data2 === undefined) {
var data2 = "";
}
var p1 = options.apdu.p1;
var p2 = options.apdu.p2;
var p3 = options.apdu.p3; // Extra
Buf.newParcel(REQUEST_SIM_ACCESS_CHANNEL, options);
Buf.writeUint32(cla);
Buf.writeUint32(command);
Buf.writeUint32(channel);
Buf.writeString(path); // path
Buf.writeUint32(p1);
Buf.writeUint32(p2);
Buf.writeUint32(p3);
Buf.writeString(data); // generic data field.
Buf.writeString(data2);
Buf.sendParcel();
},
/**
* Close Logical UICC channel
*/
iccCloseChannel: function iccCloseChannel(options) {
if (DEBUG) debug("iccCloseChannel: " + JSON.stringify(options));
Buf.newParcel(REQUEST_SIM_CLOSE_CHANNEL, options);
Buf.writeUint32(1);
Buf.writeUint32(options.channel);
Buf.sendParcel();
},
/**
* Tell the radio to choose a specific voice/data network
*/
@ -4690,6 +4754,42 @@ RIL[REQUEST_SET_FACILITY_LOCK] = function REQUEST_SET_FACILITY_LOCK(length, opti
this.sendDOMMessage(options);
};
RIL[REQUEST_CHANGE_BARRING_PASSWORD] = null;
RIL[REQUEST_SIM_OPEN_CHANNEL] = function REQUEST_SIM_OPEN_CHANNEL(length, options) {
if (options.rilRequestError) {
options.error = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
return;
}
options.channel = Buf.readUint32();
if (DEBUG) debug("Setting channel number in options: " + options.channel);
this.sendDOMMessage(options);
};
RIL[REQUEST_SIM_CLOSE_CHANNEL] = function REQUEST_SIM_CLOSE_CHANNEL(length, options) {
if (options.rilRequestError) {
options.error = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
return;
}
// No return value
this.sendDOMMessage(options);
};
RIL[REQUEST_SIM_ACCESS_CHANNEL] = function REQUEST_SIM_ACCESS_CHANNEL(length, options) {
if (options.rilRequestError) {
options.error = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
}
options.sw1 = Buf.readUint32();
options.sw2 = Buf.readUint32();
options.simResponse = Buf.readString();
if (DEBUG) {
debug("Setting return values for RIL[REQUEST_SIM_ACCESS_CHANNEL]: ["
+ options.sw1 + "," + options.sw2 + ", " + options.simResponse + "]");
}
this.sendDOMMessage(options);
};
RIL[REQUEST_QUERY_NETWORK_SELECTION_MODE] = function REQUEST_QUERY_NETWORK_SELECTION_MODE(length, options) {
this._receivedNetworkInfo(NETWORK_INFO_NETWORK_SELECTION_MODE);