Program: 184061
Project: 184061
Buggy source:
/** 
 * Build up the entries to display on the screen.
 * @param personCursor the URI for the contact being displayed
 */
private final void buildEntries(){
  final int numSections=mSections.size();
  for (int i=0; i < numSections; i++) {
    mSections.get(i).clear();
  }
  mRawContactIds.clear();
  Sources sources=Sources.getInstance(this);
  if (mUri != null) {
    for (    Entity entity : mEntities) {
      final ContentValues entValues=entity.getEntityValues();
      final String accountType=entValues.getAsString(RawContacts.ACCOUNT_TYPE);
      final long rawContactId=entValues.getAsLong(RawContacts._ID);
      for (      NamedContentValues subValue : entity.getSubValues()) {
        ViewEntry entry=new ViewEntry();
        final ContentValues entryValues=subValue.values;
        entryValues.put(Data.RAW_CONTACT_ID,rawContactId);
        final String mimetype=entryValues.getAsString(Data.MIMETYPE);
        if (mimetype == null)         continue;
        final DataKind kind=sources.getKindOrFallback(accountType,mimetype,this,ContactsSource.LEVEL_MIMETYPES);
        if (kind == null)         continue;
        final long id=entryValues.getAsLong(Data._ID);
        final Uri uri=ContentUris.withAppendedId(Data.CONTENT_URI,id);
        entry.contactId=rawContactId;
        entry.id=id;
        entry.uri=uri;
        entry.mimetype=mimetype;
        entry.label=buildActionString(kind,entryValues,false);
        entry.data=buildDataString(kind,entryValues);
        if (kind.typeColumn != null && entryValues.containsKey(kind.typeColumn)) {
          entry.type=entryValues.getAsInteger(kind.typeColumn);
        }
        if (kind.iconRes > 0) {
          entry.resPackageName=kind.resPackageName;
          entry.actionIcon=kind.iconRes;
        }
        if (TextUtils.isEmpty(entry.data)) {
          continue;
        }
        if (!mRawContactIds.contains(entry.contactId)) {
          mRawContactIds.add(entry.contactId);
        }
        if (CommonDataKinds.Phone.CONTENT_ITEM_TYPE.equals(mimetype) || CommonDataKinds.Email.CONTENT_ITEM_TYPE.equals(mimetype) || CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE.equals(mimetype)|| CommonDataKinds.Im.CONTENT_ITEM_TYPE.equals(mimetype)) {
          final boolean isSuperPrimary=entryValues.getAsInteger(Data.IS_SUPER_PRIMARY) != 0;
          if (CommonDataKinds.Phone.CONTENT_ITEM_TYPE.equals(mimetype)) {
            mNumPhoneNumbers++;
            entry.intent=new Intent(Intent.ACTION_CALL_PRIVILEGED,Uri.fromParts("String_Node_Str",entry.data,null));
            entry.secondaryIntent=new Intent(Intent.ACTION_SENDTO,Uri.fromParts("String_Node_Str",entry.data,null));
            entry.data=PhoneNumberUtils.stripSeparators(entry.data);
            if (TextUtils.isEmpty(entry.data)) {
              Log.w(TAG,"String_Node_Str" + id);
              continue;
            }
            entry.isPrimary=isSuperPrimary;
            mPhoneEntries.add(entry);
            if (entry.type == CommonDataKinds.Phone.TYPE_MOBILE || mShowSmsLinksForAllPhones) {
              if (kind.iconAltRes > 0) {
                entry.secondaryActionIcon=kind.iconAltRes;
              }
            }
          }
 else           if (CommonDataKinds.Email.CONTENT_ITEM_TYPE.equals(mimetype)) {
            entry.intent=new Intent(Intent.ACTION_SENDTO,Uri.fromParts("String_Node_Str",entry.data,null));
            entry.isPrimary=isSuperPrimary;
            mEmailEntries.add(entry);
          }
 else           if (CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE.equals(mimetype)) {
            entry.maxLines=4;
            entry.intent=new Intent(Intent.ACTION_VIEW,uri);
            mPostalEntries.add(entry);
          }
 else           if (CommonDataKinds.Im.CONTENT_ITEM_TYPE.equals(mimetype)) {
            Object protocolObj=entryValues.getAsInteger(Data.DATA5);
            String host=null;
            if (TextUtils.isEmpty(entry.label)) {
              entry.label=getString(R.string.chat).toLowerCase();
            }
            if (protocolObj instanceof Number) {
              int protocol=((Number)protocolObj).intValue();
              host=ContactsUtils.lookupProviderNameFromId(protocol);
              if (protocol == CommonDataKinds.Im.PROTOCOL_GOOGLE_TALK || protocol == CommonDataKinds.Im.PROTOCOL_MSN) {
                entry.maxLabelLines=2;
              }
            }
 else             if (protocolObj != null) {
              String providerName=(String)protocolObj;
              host=providerName.toLowerCase();
            }
            if (!TextUtils.isEmpty(host)) {
              entry.intent=new Intent(Intent.ACTION_SENDTO,constructImToUrl(host.toLowerCase(),entry.data));
            }
            mImEntries.add(entry);
          }
        }
 else         if (CommonDataKinds.Organization.CONTENT_ITEM_TYPE.equals(mimetype)) {
          mOrganizationEntries.add(entry);
        }
 else         if (CommonDataKinds.Note.CONTENT_ITEM_TYPE.equals(mimetype)) {
          entry.id=0;
          entry.uri=null;
          entry.intent=null;
          entry.maxLines=10;
          mOtherEntries.add(entry);
        }
 else {
          entry.intent=new Intent(Intent.ACTION_VIEW,uri);
          mOtherEntries.add(entry);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Build up the entries to display on the screen.
 * @param personCursor the URI for the contact being displayed
 */
private final void buildEntries(){
  final int numSections=mSections.size();
  for (int i=0; i < numSections; i++) {
    mSections.get(i).clear();
  }
  mRawContactIds.clear();
  Sources sources=Sources.getInstance(this);
  if (mUri != null) {
    for (    Entity entity : mEntities) {
      final ContentValues entValues=entity.getEntityValues();
      final String accountType=entValues.getAsString(RawContacts.ACCOUNT_TYPE);
      final long rawContactId=entValues.getAsLong(RawContacts._ID);
      if (!mRawContactIds.contains(rawContactId)) {
        mRawContactIds.add(rawContactId);
      }
      for (      NamedContentValues subValue : entity.getSubValues()) {
        ViewEntry entry=new ViewEntry();
        final ContentValues entryValues=subValue.values;
        entryValues.put(Data.RAW_CONTACT_ID,rawContactId);
        final String mimetype=entryValues.getAsString(Data.MIMETYPE);
        if (mimetype == null)         continue;
        final DataKind kind=sources.getKindOrFallback(accountType,mimetype,this,ContactsSource.LEVEL_MIMETYPES);
        if (kind == null)         continue;
        final long id=entryValues.getAsLong(Data._ID);
        final Uri uri=ContentUris.withAppendedId(Data.CONTENT_URI,id);
        entry.contactId=rawContactId;
        entry.id=id;
        entry.uri=uri;
        entry.mimetype=mimetype;
        entry.label=buildActionString(kind,entryValues,false);
        entry.data=buildDataString(kind,entryValues);
        if (kind.typeColumn != null && entryValues.containsKey(kind.typeColumn)) {
          entry.type=entryValues.getAsInteger(kind.typeColumn);
        }
        if (kind.iconRes > 0) {
          entry.resPackageName=kind.resPackageName;
          entry.actionIcon=kind.iconRes;
        }
        if (TextUtils.isEmpty(entry.data)) {
          continue;
        }
        if (CommonDataKinds.Phone.CONTENT_ITEM_TYPE.equals(mimetype) || CommonDataKinds.Email.CONTENT_ITEM_TYPE.equals(mimetype) || CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE.equals(mimetype)|| CommonDataKinds.Im.CONTENT_ITEM_TYPE.equals(mimetype)) {
          final boolean isSuperPrimary=entryValues.getAsInteger(Data.IS_SUPER_PRIMARY) != 0;
          if (CommonDataKinds.Phone.CONTENT_ITEM_TYPE.equals(mimetype)) {
            mNumPhoneNumbers++;
            entry.intent=new Intent(Intent.ACTION_CALL_PRIVILEGED,Uri.fromParts("String_Node_Str",entry.data,null));
            entry.secondaryIntent=new Intent(Intent.ACTION_SENDTO,Uri.fromParts("String_Node_Str",entry.data,null));
            entry.data=PhoneNumberUtils.stripSeparators(entry.data);
            if (TextUtils.isEmpty(entry.data)) {
              Log.w(TAG,"String_Node_Str" + id);
              continue;
            }
            entry.isPrimary=isSuperPrimary;
            mPhoneEntries.add(entry);
            if (entry.type == CommonDataKinds.Phone.TYPE_MOBILE || mShowSmsLinksForAllPhones) {
              if (kind.iconAltRes > 0) {
                entry.secondaryActionIcon=kind.iconAltRes;
              }
            }
          }
 else           if (CommonDataKinds.Email.CONTENT_ITEM_TYPE.equals(mimetype)) {
            entry.intent=new Intent(Intent.ACTION_SENDTO,Uri.fromParts("String_Node_Str",entry.data,null));
            entry.isPrimary=isSuperPrimary;
            mEmailEntries.add(entry);
          }
 else           if (CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE.equals(mimetype)) {
            entry.maxLines=4;
            entry.intent=new Intent(Intent.ACTION_VIEW,uri);
            mPostalEntries.add(entry);
          }
 else           if (CommonDataKinds.Im.CONTENT_ITEM_TYPE.equals(mimetype)) {
            Object protocolObj=entryValues.getAsInteger(Data.DATA5);
            String host=null;
            if (TextUtils.isEmpty(entry.label)) {
              entry.label=getString(R.string.chat).toLowerCase();
            }
            if (protocolObj instanceof Number) {
              int protocol=((Number)protocolObj).intValue();
              host=ContactsUtils.lookupProviderNameFromId(protocol);
              if (protocol == CommonDataKinds.Im.PROTOCOL_GOOGLE_TALK || protocol == CommonDataKinds.Im.PROTOCOL_MSN) {
                entry.maxLabelLines=2;
              }
            }
 else             if (protocolObj != null) {
              String providerName=(String)protocolObj;
              host=providerName.toLowerCase();
            }
            if (!TextUtils.isEmpty(host)) {
              entry.intent=new Intent(Intent.ACTION_SENDTO,constructImToUrl(host.toLowerCase(),entry.data));
            }
            mImEntries.add(entry);
          }
        }
 else         if (CommonDataKinds.Organization.CONTENT_ITEM_TYPE.equals(mimetype)) {
          mOrganizationEntries.add(entry);
        }
 else         if (CommonDataKinds.Note.CONTENT_ITEM_TYPE.equals(mimetype)) {
          entry.id=0;
          entry.uri=null;
          entry.intent=null;
          entry.maxLines=10;
          mOtherEntries.add(entry);
        }
 else {
          entry.intent=new Intent(Intent.ACTION_VIEW,uri);
          mOtherEntries.add(entry);
        }
      }
    }
  }
}