Bug 1162464 - Part 2: Implementation Changes. r=echen

This commit is contained in:
Bevis Tseng 2015-05-08 11:23:09 +08:00
Родитель c647ff437f
Коммит 364c86e99a
4 изменённых файлов: 74 добавлений и 139 удалений

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

@ -482,6 +482,60 @@ Icc.prototype = {
aCallback.notifySuccessWithBoolean(aResponse.result);
});
},
iccOpenChannel: function(aAid, aCallback) {
this._radioInterface.sendWorkerMessage("iccOpenChannel",
{ aid: aAid },
(aResponse) => {
if (aResponse.errorMsg) {
aCallback.notifyError(aResponse.errorMsg);
return;
}
aCallback.notifyOpenChannelSuccess(aResponse.channel);
});
},
iccExchangeAPDU: function(aChannel, aCla, aIns, aP1, aP2, aP3, aData, aCallback) {
if (!aData) {
if (DEBUG) debug('data is not set , aP3 : ' + aP3);
}
let apdu = {
cla: aCla,
command: aIns,
p1: aP1,
p2: aP2,
p3: aP3,
data: aData
};
this._radioInterface.sendWorkerMessage("iccExchangeAPDU",
{ channel: aChannel, apdu: apdu },
(aResponse) => {
if (aResponse.errorMsg) {
aCallback.notifyError(aResponse.errorMsg);
return;
}
aCallback.notifyExchangeAPDUResponse(aResponse.sw1,
aResponse.sw2,
aResponse.simResponse);
});
},
iccCloseChannel: function(aChannel, aCallback) {
this._radioInterface.sendWorkerMessage("iccCloseChannel",
{ channel: aChannel },
(aResponse) => {
if (aResponse.errorMsg) {
aCallback.notifyError(aResponse.errorMsg);
return;
}
aCallback.notifyCloseChannelSuccess();
});
}
};

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

@ -265,6 +265,26 @@ IccChild::GetServiceStateEnabled(uint32_t aService,
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
IccChild::IccOpenChannel(const nsAString& aAid, nsIIccChannelCallback* aCallback)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
IccChild::IccExchangeAPDU(int32_t aChannel, uint8_t aCla, uint8_t aIns, uint8_t aP1,
uint8_t aP2, int16_t aP3, const nsAString & aData,
nsIIccChannelCallback* aCallback)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
IccChild::IccCloseChannel(int32_t aChannel, nsIIccChannelCallback* aCallback)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/**
* PIccRequestChild Implementation.
*/

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

@ -46,9 +46,6 @@ const RILCONTENTHELPER_CID =
const RIL_IPC_MSG_NAMES = [
"RIL:StkCommand",
"RIL:StkSessionEnd",
"RIL:IccOpenChannel",
"RIL:IccCloseChannel",
"RIL:IccExchangeAPDU",
"RIL:ReadIccContacts",
"RIL:UpdateIccContact",
];
@ -89,7 +86,6 @@ function RILContentHelper() {
this.initDOMRequestHelper(/* aWindow */ null, RIL_IPC_MSG_NAMES);
this._windowsMap = [];
this._iccListeners = [];
this._iccChannelCallback = [];
Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
@ -173,60 +169,6 @@ RILContentHelper.prototype = {
});
},
iccOpenChannel: function(clientId, aid, callback) {
let requestId = UUIDGenerator.generateUUID().toString();
this._addIccChannelCallback(requestId, callback);
cpmm.sendAsyncMessage("RIL:IccOpenChannel", {
clientId: clientId,
data: {
requestId: requestId,
aid: aid
}
});
},
iccExchangeAPDU: function(clientId, channel, cla, ins, p1, p2, p3, data, callback) {
let requestId = UUIDGenerator.generateUUID().toString();
this._addIccChannelCallback(requestId, callback);
if (!data) {
if (DEBUG) debug('data is not set , p3 : ' + p3);
}
let apdu = {
cla: cla,
command: ins,
p1: p1,
p2: p2,
p3: p3,
data: data
};
//Potentially you need serialization here and can't pass the jsval through
cpmm.sendAsyncMessage("RIL:IccExchangeAPDU", {
clientId: clientId,
data: {
requestId: requestId,
channel: channel,
apdu: apdu
}
});
},
iccCloseChannel: function(clientId, channel, callback) {
let requestId = UUIDGenerator.generateUUID().toString();
this._addIccChannelCallback(requestId, callback);
cpmm.sendAsyncMessage("RIL:IccCloseChannel", {
clientId: clientId,
data: {
requestId: requestId,
channel: channel
}
});
},
readContacts: function(clientId, window, contactType) {
if (window == null) {
throw Components.Exception("Can't get window object",
@ -330,24 +272,6 @@ RILContentHelper.prototype = {
}
},
_iccChannelCallback: null,
_addIccChannelCallback: function(requestId, channelCb) {
let cbInterfaces = this._iccChannelCallback;
if (!cbInterfaces[requestId] && channelCb) {
cbInterfaces[requestId] = channelCb;
return;
}
if (DEBUG) debug("Unable to add channelCbInterface for requestId : " + requestId);
},
_getIccChannelCallback: function(requestId) {
let cb = this._iccChannelCallback[requestId];
delete this._iccChannelCallback[requestId];
return cb;
},
registerIccMsg: function(clientId, listener) {
if (DEBUG) debug("Registering for ICC related messages");
this.registerListener("_iccListeners", clientId, listener);
@ -454,15 +378,6 @@ RILContentHelper.prototype = {
case "RIL:StkSessionEnd":
this._deliverEvent(clientId, "_iccListeners", "notifyStkSessionEnd", null);
break;
case "RIL:IccOpenChannel":
this.handleIccOpenChannel(data);
break;
case "RIL:IccCloseChannel":
this.handleIccCloseChannel(data);
break;
case "RIL:IccExchangeAPDU":
this.handleIccExchangeAPDU(data);
break;
case "RIL:ReadIccContacts":
this.handleReadIccContacts(data);
break;
@ -472,48 +387,6 @@ RILContentHelper.prototype = {
}
},
handleSimpleRequest: function(requestId, errorMsg, result) {
if (errorMsg) {
this.fireRequestError(requestId, errorMsg);
} else {
this.fireRequestSuccess(requestId, result);
}
},
handleIccOpenChannel: function(message) {
let requestId = message.requestId;
let callback = this._getIccChannelCallback(requestId);
if (!callback) {
return;
}
return !message.errorMsg ? callback.notifyOpenChannelSuccess(message.channel) :
callback.notifyError(message.errorMsg);
},
handleIccCloseChannel: function(message) {
let requestId = message.requestId;
let callback = this._getIccChannelCallback(requestId);
if (!callback) {
return;
}
return !message.errorMsg ? callback.notifyCloseChannelSuccess() :
callback.notifyError(message.errorMsg);
},
handleIccExchangeAPDU: function(message) {
let requestId = message.requestId;
let callback = this._getIccChannelCallback(requestId);
if (!callback) {
return;
}
return !message.errorMsg ?
callback.notifyExchangeAPDUResponse(message.sw1, message.sw2, message.simResponse) :
callback.notifyError(message.errorMsg);
},
handleReadIccContacts: function(message) {
if (message.errorMsg) {
this.fireRequestError(message.requestId, message.errorMsg);

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

@ -93,9 +93,6 @@ const RIL_IPC_ICCMANAGER_MSG_NAMES = [
"RIL:SendStkMenuSelection",
"RIL:SendStkTimerExpiration",
"RIL:SendStkEventDownload",
"RIL:IccOpenChannel",
"RIL:IccExchangeAPDU",
"RIL:IccCloseChannel",
"RIL:ReadIccContacts",
"RIL:UpdateIccContact",
"RIL:RegisterIccMsg",
@ -1732,15 +1729,6 @@ RadioInterface.prototype = {
case "RIL:SendStkEventDownload":
this.workerMessenger.send("sendStkEventDownload", msg.json.data);
break;
case "RIL:IccOpenChannel":
this.workerMessenger.sendWithIPCMessage(msg, "iccOpenChannel");
break;
case "RIL:IccCloseChannel":
this.workerMessenger.sendWithIPCMessage(msg, "iccCloseChannel");
break;
case "RIL:IccExchangeAPDU":
this.workerMessenger.sendWithIPCMessage(msg, "iccExchangeAPDU");
break;
case "RIL:ReadIccContacts":
this.workerMessenger.sendWithIPCMessage(msg, "readICCContacts");
break;