Use names also for main contact

This commit is contained in:
Dominik Schürmann 2015-03-14 14:07:45 +01:00
parent cd7f631221
commit 12734127a7
2 changed files with 4 additions and 4 deletions

View File

@ -29,7 +29,7 @@ public final class Constants {
public static final boolean DEBUG = BuildConfig.DEBUG;
public static final boolean DEBUG_LOG_DB_QUERIES = false;
public static final boolean DEBUG_SYNC_REMOVE_CONTACTS = false;
public static final boolean DEBUG_SYNC_REMOVE_CONTACTS = true;
public static final String TAG = "Keychain";

View File

@ -519,20 +519,20 @@ public class ContactHelper {
long masterKeyId = cursor.getLong(INDEX_MASTER_KEY_ID);
boolean isExpired = cursor.getInt(INDEX_IS_EXPIRED) != 0;
boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;
String[] userIdSplit = KeyRing.splitUserId(cursor.getString(INDEX_USER_ID));
if (!isExpired && !isRevoked) {
if (!isExpired && !isRevoked && userIdSplit[0] != null) {
// if expired or revoked will not be removed from keysToDelete or inserted
// into main profile ("me" contact)
boolean existsInMainProfile = keysToDelete.remove(masterKeyId);
if (!existsInMainProfile) {
long rawContactId = -1;//new raw contact
String keyIdShort = KeyFormattingUtils.convertKeyIdToHexShort(masterKeyId);
Log.d(Constants.TAG, "masterKeyId with secret " + masterKeyId);
ArrayList<ContentProviderOperation> ops = new ArrayList<>();
insertMainProfileRawContact(ops, masterKeyId);
writeContactKey(ops, context, rawContactId, masterKeyId, keyIdShort);
writeContactKey(ops, context, rawContactId, masterKeyId, userIdSplit[0]);
try {
resolver.applyBatch(ContactsContract.AUTHORITY, ops);