/** * Update an ADN-like EF record by record index * * <p>This is useful for iteration the whole ADN file, such as write the whole phone book or * erase/format the whole phonebook. Currently the email field if set in the ADN record is * ignored. throws SecurityException if no WRITE_CONTACTS permission * * @param efid must be one among EF_ADN, EF_FDN, and EF_SDN * @param newTag adn tag to be stored * @param newPhoneNumber adn number to be stored Set both newTag and newPhoneNubmer to "" means to * replace the old record with empty one, aka, delete old record * @param index is 1-based adn record index to be updated * @param pin2 required to update EF_FDN, otherwise must be null * @return true for success */ public boolean updateAdnRecordsInEfByIndex( int efid, String newTag, String newPhoneNumber, int index, String pin2) { if (phone.getContext().checkCallingOrSelfPermission(android.Manifest.permission.WRITE_CONTACTS) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires android.permission.WRITE_CONTACTS permission"); } if (DBG) logd( "updateAdnRecordsInEfByIndex: efid=" + efid + " Index=" + index + " ==> " + "(" + newTag + "," + newPhoneNumber + ")" + " pin2=" + pin2); synchronized (mLock) { checkThread(); success = false; Message response = mBaseHandler.obtainMessage(EVENT_UPDATE_DONE); AdnRecord newAdn = new AdnRecord(newTag, newPhoneNumber); adnCache.updateAdnByIndex(efid, newAdn, index, pin2, response); try { mLock.wait(); } catch (InterruptedException e) { logd("interrupted while trying to update by index"); } } return success; }