Bug 847820 - Part 3: RIL implementation. r=allstars.chh

This commit is contained in:
Edgar Chen 2013-03-06 10:12:23 +08:00
Родитель 80ec4da562
Коммит f8d13b4176
3 изменённых файлов: 56 добавлений и 60 удалений

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

@ -81,7 +81,8 @@ const RIL_IPC_MSG_NAMES = [
"RIL:CfStateChanged",
"RIL:IccOpenChannel",
"RIL:IccCloseChannel",
"RIL:IccExchangeAPDU"
"RIL:IccExchangeAPDU",
"RIL:IccUpdateContact"
];
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
@ -655,6 +656,34 @@ RILContentHelper.prototype = {
return request;
},
updateContact: function updateContact(window, contactType, contact, pin2) {
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);
// Parsing nsDOMContact to Icc Contact format
let iccContact = {};
if (contact.name) {
iccContact.alphaId = contact.name[0];
}
if (contact.tel) {
iccContact.number = contact.tel[0].value;
}
cpmm.sendAsyncMessage("RIL:IccUpdateContact", {requestId: requestId,
contactType: contactType,
contact: iccContact,
pin2: pin2});
return request;
},
getCallForwardingOption: function getCallForwardingOption(window, reason) {
if (window == null) {
throw Components.Exception("Can't get window object",
@ -1057,6 +1086,9 @@ RILContentHelper.prototype = {
case "RIL:IccExchangeAPDU":
this.handleIccExchangeAPDU(msg.json);
break;
case "RIL:IccUpdateContact":
this.handleIccUpdateContact(msg.json);
break;
case "RIL:DataError":
this.updateConnectionInfo(msg.json, this.rilContext.dataConnectionInfo);
this._deliverEvent("_mobileConnectionListeners", "notifyDataError",
@ -1168,6 +1200,14 @@ RILContentHelper.prototype = {
}
},
handleIccUpdateContact: function handleIccUpdateContact(message) {
if (message.errorMsg) {
this.fireRequestError(message.requestId, message.errorMsg);
} else {
this.fireRequestSuccess(message.requestId, null);
}
},
handleVoicemailNotification: function handleVoicemailNotification(message) {
let changed = false;
if (!this.voicemailStatus) {

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

@ -99,6 +99,7 @@ const RIL_IPC_MOBILECONNECTION_MSG_NAMES = [
"RIL:IccOpenChannel",
"RIL:IccExchangeAPDU",
"RIL:IccCloseChannel",
"RIL:IccUpdateContact",
"RIL:RegisterMobileConnectionMsg",
"RIL:RegisterIccMsg",
"RIL:SetCallForwardingOption",
@ -510,6 +511,10 @@ RadioInterfaceLayer.prototype = {
this.saveRequestTarget(msg);
this.iccExchangeAPDU(msg.json);
break;
case "RIL:IccUpdateContact":
this.saveRequestTarget(msg);
this.updateICCContact(msg.json);
break;
case "RIL:RegisterMobileConnectionMsg":
this.registerMessageTarget("mobileconnection", msg.target);
break;
@ -675,15 +680,7 @@ RadioInterfaceLayer.prototype = {
}
break;
case "icccontactupdate":
if (!this._contactUpdateCallbacks) {
return;
}
let updateCallback = this._contactUpdateCallbacks[message.requestId];
if (updateCallback) {
delete this._contactUpdateCallbacks[message.requestId];
updateCallback.onUpdated(message.errorMsg,
message.contactType);
}
this.handleIccUpdateContact(message);
break;
case "iccmbdn":
this.handleICCMbdn(message);
@ -1397,6 +1394,11 @@ RadioInterfaceLayer.prototype = {
this._sendRequestResults("RIL:EnumerateCalls", options);
},
handleIccUpdateContact: function handleIccUpdateContact(message) {
debug("handleIccUpdateContact: " + JSON.stringify(message));
this._sendRequestResults("RIL:IccUpdateContact", message);
},
/**
* Open Logical UICC channel (aid) for Secure Element access
*/
@ -2883,18 +2885,9 @@ RadioInterfaceLayer.prototype = {
requestId: requestId});
},
_contactUpdateCallbacks: null,
updateICCContact: function updateICCContact(contactType, contact, pin2, callback) {
if (!this._contactUpdateCallbacks) {
this._contactUpdateCallbacks = {};
}
let requestId = Math.floor(Math.random() * 1000);
this._contactUpdateCallbacks[requestId] = callback;
this.worker.postMessage({rilMessageType: "updateICCContact",
contactType: contactType,
contact: contact,
pin2: pin2,
requestId: requestId});
updateICCContact: function updateICCContact(message) {
message.rilMessageType = "updateICCContact";
this.worker.postMessage(message);
},
};

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

@ -69,21 +69,6 @@ interface nsIRILContactCallback : nsISupports
in jsval contacts);
};
[scriptable, function, uuid(ab954d56-12a1-4c6b-8753-14ad5664111d)]
interface nsIRILContactUpdateCallback : nsISupports
{
/**
* Called when an ICC contact is updated.
*
* @param errorMsg
* Error message from RIL.
* @param contactType
* Type of the contact, i.e. ADN, FDN.
*/
void onUpdated(in DOMString errorMsg,
in DOMString contactType);
};
[scriptable, uuid(c0c5cb9f-6372-4b5a-b74c-baacc2da5e4f)]
interface nsIVoicemailInfo : nsISupports
{
@ -108,7 +93,7 @@ interface nsIRilContext : nsISupports
readonly attribute nsIDOMMozMobileConnectionInfo data;
};
[scriptable, uuid(8b3a1bc8-86d2-11e2-ace0-33f0ed290b90)]
[scriptable, uuid(9a914550-8f7a-11e2-9e96-0800200c9a66)]
interface nsIRadioInterfaceLayer : nsISupports
{
/**
@ -164,26 +149,4 @@ interface nsIRadioInterfaceLayer : nsISupports
*/
void getICCContacts(in DOMString contactType,
in nsIRILContactCallback callback);
/**
* Update ICC Contact.
*
* This function allows two operations: update the existing contact or
* insert a new contact.
* If the contact has 'recordId' property, the corresponding record will be
* updated. If not, the contact will be inserted.
*
* @param contactType One of the values below.
* "ADN" (Abbreviated Dialling Numbers)
* "FDN" (Fixed Dialling Numbers)
* @param contact The contact will be updated.
* If has 'recordId' property, updates corresponding record.
* If not, finds a free record and updates it.
* @param pin2 PIN2 is required for updating FDN, otherwise should be "".
* @param callback A nsIRILContactUpdateCallback object.
*/
void updateICCContact(in DOMString contactType,
in jsval contact,
in DOMString pin2,
in nsIRILContactUpdateCallback callback);
};