Bug 943234 - Part 1: return mozContact in updateContact. r=vicamo

From 237b1d77da6e1470979dfc422e3f2e2f30066b43 Mon Sep 17 00:00:00 2001
---
 dom/system/gonk/RILContentHelper.js |   29 ++++++++++++++++++++++++++++-
 dom/system/gonk/ril_worker.js       |    7 +++++--
 2 files changed, 33 insertions(+), 3 deletions(-)
This commit is contained in:
Yoshi Huang 2013-11-28 17:50:01 +08:00
parent 8a45591906
commit 1fdf1012ee
2 changed files with 33 additions and 3 deletions

View File

@ -1102,6 +1102,7 @@ RILContentHelper.prototype = {
let request = Services.DOMRequest.createRequest(window);
let requestId = this.getRequestId(request);
this._windowsMap[requestId] = window;
// Parsing nsDOMContact to Icc Contact format
let iccContact = {};
@ -1728,7 +1729,7 @@ RILContentHelper.prototype = {
this.handleReadIccContacts(data);
break;
case "RIL:UpdateIccContact":
this.handleSimpleRequest(data.requestId, data.errorMsg, null);
this.handleUpdateIccContact(data);
break;
case "RIL:DataError":
this.updateConnectionInfo(data, this.rilContexts[clientId].dataConnectionInfo);
@ -1894,6 +1895,32 @@ RILContentHelper.prototype = {
this.fireRequestSuccess(message.requestId, result);
},
handleUpdateIccContact: function handleUpdateIccContact(message) {
if (message.errorMsg) {
this.fireRequestError(message.requestId, message.errorMsg);
return;
}
let window = this._windowsMap[message.requestId];
delete this._windowsMap[message.requestId];
let iccContact = message.contact;
let prop = {name: [iccContact.alphaId], tel: [{value: iccContact.number}]};
if (iccContact.email) {
prop.email = [{value: iccContact.email}];
}
// ANR - Additional Number
let anrLen = iccContact.anr ? iccContact.anr.length : 0;
for (let i = 0; i < anrLen; i++) {
prop.tel.push({value: iccContact.anr[i]});
}
let contact = new window.mozContact(prop);
contact.id = iccContact.contactId;
this.fireRequestSuccess(message.requestId, contact);
},
handleVoicemailNotification: function handleVoicemailNotification(clientId,
message) {
let changed = false;

View File

@ -903,6 +903,9 @@ let RIL = {
*/
updateICCContact: function updateICCContact(options) {
let onsuccess = function onsuccess() {
let recordIndex =
contact.pbrIndex * ICC_MAX_LINEAR_FIXED_RECORDS + contact.recordId;
contact.contactId = this.iccInfo.iccid + recordIndex;
// Reuse 'options' to get 'requestId' and 'contactType'.
RIL.sendChromeMessage(options);
}.bind(this);
@ -919,15 +922,15 @@ let RIL = {
let contact = options.contact;
let iccid = RIL.iccInfo.iccid;
let isValidRecordId = false;
if (typeof contact.contactId === "string" &&
contact.contactId.startsWith(iccid)) {
let recordIndex = contact.contactId.substring(iccid.length);
contact.pbrIndex = Math.floor(recordIndex / ICC_MAX_LINEAR_FIXED_RECORDS);
contact.recordId = recordIndex % ICC_MAX_LINEAR_FIXED_RECORDS;
isValidRecordId = contact.recordId > 0 && contact.recordId < 0xff;
}
let isValidRecordId = contact.recordId > 0 && contact.recordId < 0xff;
if (DEBUG) {
debug("Update ICC Contact " + JSON.stringify(contact));
}