Bug 951177 - Part 1: removal of anr and email. r=vicamo

This commit is contained in:
"allstars.chh" 2014-01-18 17:20:26 +01:00
parent 43fc73200d
commit 85f4ae17a4
2 changed files with 17 additions and 14 deletions

View File

@ -13735,15 +13735,6 @@ let ICCContactHelper = {
return;
}
// Check if contact has additional properties (email, anr, ...etc) that
// need to be updated as well.
if ((field === USIM_PBR_EMAIL && !contact.email) ||
(field === USIM_PBR_ANR0 && (!Array.isArray(contact.anr) ||
!contact.anr[0]))) {
updateField();
return;
}
ICCContactHelper.updateContactField(pbr, contact, field, updateField, onerror);
})();
},
@ -13783,7 +13774,8 @@ let ICCContactHelper = {
if (field === USIM_PBR_EMAIL) {
ICCRecordHelper.updateEmail(pbr, contact.recordId, contact.email, null, onsuccess, onerror);
} else if (field === USIM_PBR_ANR0) {
ICCRecordHelper.updateANR(pbr, contact.recordId, contact.anr[0], null, onsuccess, onerror);
let anr = Array.isArray(contact.anr) ? contact.anr[0] : null;
ICCRecordHelper.updateANR(pbr, contact.recordId, anr, null, onsuccess, onerror);
} else {
if (DEBUG) {
debug("Unsupported field :" + field);
@ -13813,8 +13805,16 @@ let ICCContactHelper = {
let gotIapCb = function gotIapCb(iap) {
let recordId = iap[pbr[field].indexInIAP];
if (recordId === 0xff) {
// Case 1.
this.addContactFieldType2(pbr, contact, field, onsuccess, onerror);
// If the value in IAP[index] is 0xff, which means the contact stored on
// the SIM doesn't have the additional attribute (email or anr).
// So if the contact to be updated doesn't have the attribute either,
// we don't have to update it.
if ((field === USIM_PBR_EMAIL && contact.email) ||
(field === USIM_PBR_ANR0 &&
(Array.isArray(contact.anr) && contact.anr[0]))) {
// Case 1.
this.addContactFieldType2(pbr, contact, field, onsuccess, onerror);
}
return;
}
@ -13822,7 +13822,8 @@ let ICCContactHelper = {
if (field === USIM_PBR_EMAIL) {
ICCRecordHelper.updateEmail(pbr, recordId, contact.email, contact.recordId, onsuccess, onerror);
} else if (field === USIM_PBR_ANR0) {
ICCRecordHelper.updateANR(pbr, recordId, contact.anr[0], contact.recordId, onsuccess, onerror);
let anr = Array.isArray(contact.anr) ? contact.anr[0] : null;
ICCRecordHelper.updateANR(pbr, recordId, anr, contact.recordId, onsuccess, onerror);
} else {
if (DEBUG) {
debug("Unsupported field :" + field);

View File

@ -1702,7 +1702,9 @@ add_test(function test_update_icc_contact() {
} else if (pbr.anr0.fileType === ICC_USIM_TYPE2_TAG) {
do_check_eq(recordNumber, ANR0_RECORD_ID);
}
do_check_eq(number, aContact.anr[0]);
if (Array.isArray(aContact.anr)) {
do_check_eq(number, aContact.anr[0]);
}
onsuccess();
};