Beispiel #1
0
    /*       private Contact getContactInfoForSelf() {
                Contact entry = new Contact(true);
                entry.mContactMethodType = CONTACT_METHOD_TYPE_SELF;

                if (Log.isLoggable(LogTag.CONTACT, Log.DEBUG)) {
                    log("getContactInfoForSelf");
                }
                Cursor cursor = mContext.getContentResolver().query(
                        Profile.CONTENT_URI, SELF_PROJECTION, null, null, null);
                if (cursor == null) {
                    Log.w(TAG, "getContactInfoForSelf() returned NULL cursor!"
                            + " contact uri used " + Profile.CONTENT_URI);
                    return entry;
                }

                try {
                    if (cursor.moveToFirst()) {
                        fillSelfContact(entry, cursor);
                    }
                } finally {
                    cursor.close();
                }
                return entry;
            }
    */
    private void fillPhoneTypeContact(final Contact contact, final Cursor cursor) {
      synchronized (contact) {
        contact.mContactMethodType = CONTACT_METHOD_TYPE_PHONE;
        contact.mContactMethodId = cursor.getLong(PHONE_ID_COLUMN);
        contact.mLabel = cursor.getString(PHONE_LABEL_COLUMN);
        contact.mName = cursor.getString(CONTACT_NAME_COLUMN);
        contact.mPersonId = cursor.getLong(CONTACT_ID_COLUMN);
        contact.mPresenceResId = getPresenceIconResourceId(cursor.getInt(CONTACT_PRESENCE_COLUMN));
        contact.mPresenceText = cursor.getString(CONTACT_STATUS_COLUMN);
        contact.mNumberE164 = cursor.getString(PHONE_NORMALIZED_NUMBER);
        contact.mSendToVoicemail = cursor.getInt(SEND_TO_VOICEMAIL) == 1;
        if (Log.isLoggable(LogTag.CONTACT, Log.DEBUG)) {
          log(
              "fillPhoneTypeContact: name="
                  + contact.mName
                  + ", number="
                  + contact.mNumber
                  + ", presence="
                  + contact.mPresenceResId
                  + " SendToVoicemail: "
                  + contact.mSendToVoicemail);
        }
      }
      byte[] data = loadAvatarData(contact);

      synchronized (contact) {
        contact.mAvatarData = data;
      }
    }
Beispiel #2
0
 // Remove a contact from the ContactsCache based on the number or email address
 private void remove(Contact contact) {
   synchronized (ContactsCache.this) {
     String number = contact.getNumber();
     final boolean isNotRegularPhoneNumber =
         contact.isMe() || MessageUtils.isEmailAddress(number) || MessageUtils.isAlias(number);
     final String key = isNotRegularPhoneNumber ? number : key(number, sStaticKeyBuffer);
     ArrayList<Contact> candidates = mContactsHash.get(key);
     if (candidates != null) {
       int length = candidates.size();
       for (int i = 0; i < length; i++) {
         Contact c = candidates.get(i);
         if (isNotRegularPhoneNumber) {
           if (number.equals(c.mNumber)) {
             candidates.remove(i);
             break;
           }
         } else {
           if (PhoneNumberUtils.compare(number, c.mNumber)) {
             candidates.remove(i);
             break;
           }
         }
       }
       if (candidates.size() == 0) {
         mContactsHash.remove(key);
       }
     }
   }
 }
Beispiel #3
0
 void dump() {
   synchronized (ContactsCache.this) {
     Log.d(TAG, "**** Contact cache dump ****");
     for (String key : mContactsHash.keySet()) {
       ArrayList<Contact> alc = mContactsHash.get(key);
       for (Contact c : alc) {
         Log.d(TAG, key + " ==> " + c.toString());
       }
     }
   }
 }
Beispiel #4
0
 void invalidate() {
   // Don't remove the contacts. Just mark them stale so we'll update their
   // info, particularly their presence.
   synchronized (ContactsCache.this) {
     for (ArrayList<Contact> alc : mContactsHash.values()) {
       for (Contact c : alc) {
         synchronized (c) {
           c.mIsStale = true;
         }
       }
     }
   }
 }