Program: 7368
Project: 7368
Buggy source:
/** 
 * Set the internal state for this view, given a current  {@link EntityDelta} state and the {@link ContactsSource} thatapply to that state.
 */
public void setState(EntityDelta state,ContactsSource source){
  mGeneral.removeAllViews();
  mSecondary.removeAllViews();
  if (state == null || source == null)   return;
  EntityModifier.ensureKindExists(state,source,StructuredName.CONTENT_ITEM_TYPE);
  mHeader.setBackgroundColor(source.getHeaderColor(mContext));
  mSideBar.setBackgroundColor(source.getSideBarColor(mContext));
  ValuesDelta values=state.getValues();
  String accountName=values.getAsString(RawContacts.ACCOUNT_NAME);
  if (TextUtils.isEmpty(accountName)) {
    accountName="String_Node_Str";
  }
  mHeaderAccountName.setText(accountName);
  mHeaderAccountType.setText(source.getDisplayLabel(mContext));
  mHeaderIcon.setImageDrawable(source.getDisplayIcon(mContext));
  EntityModifier.ensureKindExists(state,source,Photo.CONTENT_ITEM_TYPE);
  mHasPhotoEditor=(source.getKindForMimetype(Photo.CONTENT_ITEM_TYPE) != null);
  mPhoto.setVisibility(mHasPhotoEditor ? View.VISIBLE : View.GONE);
  mPhoto.setEnabled(!source.readOnly);
  mName.setEnabled(!source.readOnly);
  boolean readOnly=source.readOnly;
  if (readOnly) {
    mGeneral.setVisibility(View.GONE);
    mSecondary.setVisibility(View.GONE);
    mSecondaryHeader.setVisibility(View.GONE);
  }
 else {
    mReadOnly.setVisibility(View.GONE);
  }
  for (  DataKind kind : source.getSortedDataKinds()) {
    if (!kind.editable)     continue;
    final String mimeType=kind.mimeType;
    if (StructuredName.CONTENT_ITEM_TYPE.equals(mimeType)) {
      final ValuesDelta primary=state.getPrimaryEntry(mimeType);
      mName.setValues(kind,primary,state,source.readOnly);
    }
 else     if (Photo.CONTENT_ITEM_TYPE.equals(mimeType)) {
      final ValuesDelta primary=state.getPrimaryEntry(mimeType);
      mPhoto.setValues(kind,primary,state,source.readOnly);
    }
 else     if (!readOnly) {
      if (kind.fieldList == null)       continue;
      final ViewGroup parent=kind.secondary ? mSecondary : mGeneral;
      final KindSectionView section=(KindSectionView)mInflater.inflate(R.layout.item_kind_section,parent,false);
      section.setState(kind,state,source.readOnly);
      section.setId(kind.weight);
      parent.addView(section);
    }
  }
  final int secondaryVisibility=mSecondary.getChildCount() > 0 ? View.VISIBLE : View.GONE;
  mSecondary.setVisibility(secondaryVisibility);
  mSecondaryHeader.setVisibility(secondaryVisibility);
}

Fixed version (ground truth):
/** 
 * Set the internal state for this view, given a current  {@link EntityDelta} state and the {@link ContactsSource} thatapply to that state.
 */
public void setState(EntityDelta state,ContactsSource source){
  mGeneral.removeAllViews();
  mSecondary.removeAllViews();
  if (state == null || source == null)   return;
  EntityModifier.ensureKindExists(state,source,StructuredName.CONTENT_ITEM_TYPE);
  mHeader.setBackgroundColor(source.getHeaderColor(mContext));
  mSideBar.setBackgroundColor(source.getSideBarColor(mContext));
  ValuesDelta values=state.getValues();
  String accountName=values.getAsString(RawContacts.ACCOUNT_NAME);
  if (TextUtils.isEmpty(accountName)) {
    accountName="String_Node_Str";
  }
  mHeaderAccountName.setText(accountName);
  mHeaderAccountType.setText(source.getDisplayLabel(mContext));
  mHeaderIcon.setImageDrawable(source.getDisplayIcon(mContext));
  mRawContactId=values.getAsLong(RawContacts._ID);
  EntityModifier.ensureKindExists(state,source,Photo.CONTENT_ITEM_TYPE);
  mHasPhotoEditor=(source.getKindForMimetype(Photo.CONTENT_ITEM_TYPE) != null);
  mPhoto.setVisibility(mHasPhotoEditor ? View.VISIBLE : View.GONE);
  mPhoto.setEnabled(!source.readOnly);
  mName.setEnabled(!source.readOnly);
  boolean readOnly=source.readOnly;
  if (readOnly) {
    mGeneral.setVisibility(View.GONE);
    mSecondary.setVisibility(View.GONE);
    mSecondaryHeader.setVisibility(View.GONE);
  }
 else {
    mReadOnly.setVisibility(View.GONE);
  }
  for (  DataKind kind : source.getSortedDataKinds()) {
    if (!kind.editable)     continue;
    final String mimeType=kind.mimeType;
    if (StructuredName.CONTENT_ITEM_TYPE.equals(mimeType)) {
      final ValuesDelta primary=state.getPrimaryEntry(mimeType);
      mName.setValues(kind,primary,state,source.readOnly);
    }
 else     if (Photo.CONTENT_ITEM_TYPE.equals(mimeType)) {
      final ValuesDelta primary=state.getPrimaryEntry(mimeType);
      mPhoto.setValues(kind,primary,state,source.readOnly);
    }
 else     if (!readOnly) {
      if (kind.fieldList == null)       continue;
      final ViewGroup parent=kind.secondary ? mSecondary : mGeneral;
      final KindSectionView section=(KindSectionView)mInflater.inflate(R.layout.item_kind_section,parent,false);
      section.setState(kind,state,source.readOnly);
      section.setId(kind.weight);
      parent.addView(section);
    }
  }
  final int secondaryVisibility=mSecondary.getChildCount() > 0 ? View.VISIBLE : View.GONE;
  mSecondary.setVisibility(secondaryVisibility);
  mSecondaryHeader.setVisibility(secondaryVisibility);
}