Program: 182927
Project: 182927
Buggy source:
private void appendStructuredNamesInternal(final StringBuilder builder,final List<ContentValues> contentValuesList){
  ContentValues primaryContentValues=null;
  ContentValues subprimaryContentValues=null;
  for (  ContentValues contentValues : contentValuesList) {
    if (contentValues == null) {
      continue;
    }
    Integer isSuperPrimary=contentValues.getAsInteger(StructuredName.IS_SUPER_PRIMARY);
    if (isSuperPrimary != null && isSuperPrimary > 0) {
      primaryContentValues=contentValues;
      break;
    }
 else     if (primaryContentValues == null) {
      Integer isPrimary=contentValues.getAsInteger(StructuredName.IS_PRIMARY);
      if (isPrimary != null && isPrimary > 0 && containsNonEmptyName(contentValues)) {
        primaryContentValues=contentValues;
      }
 else       if (subprimaryContentValues == null && containsNonEmptyName(contentValues)) {
        subprimaryContentValues=contentValues;
      }
    }
  }
  if (primaryContentValues == null) {
    if (subprimaryContentValues != null) {
      primaryContentValues=subprimaryContentValues;
    }
 else {
      Log.e(LOG_TAG,"String_Node_Str");
      primaryContentValues=new ContentValues();
    }
  }
  final String familyName=primaryContentValues.getAsString(StructuredName.FAMILY_NAME);
  final String middleName=primaryContentValues.getAsString(StructuredName.MIDDLE_NAME);
  final String givenName=primaryContentValues.getAsString(StructuredName.GIVEN_NAME);
  final String prefix=primaryContentValues.getAsString(StructuredName.PREFIX);
  final String suffix=primaryContentValues.getAsString(StructuredName.SUFFIX);
  final String displayName=primaryContentValues.getAsString(StructuredName.DISPLAY_NAME);
  if (!TextUtils.isEmpty(familyName) || !TextUtils.isEmpty(givenName)) {
    final boolean shouldAppendCharsetParameterToName=!(mIsV30 && UTF_8.equalsIgnoreCase(mCharsetString)) && shouldAppendCharsetParameters(Arrays.asList(familyName,givenName,middleName,prefix,suffix));
    final boolean reallyUseQuotedPrintableToName=(!mRefrainsQPToPrimaryProperties && !(VCardUtils.containsOnlyNonCrLfPrintableAscii(familyName) && VCardUtils.containsOnlyNonCrLfPrintableAscii(givenName) && VCardUtils.containsOnlyNonCrLfPrintableAscii(middleName)&& VCardUtils.containsOnlyNonCrLfPrintableAscii(prefix)&& VCardUtils.containsOnlyNonCrLfPrintableAscii(suffix)));
    final String formattedName;
    if (!TextUtils.isEmpty(displayName)) {
      formattedName=displayName;
    }
 else {
      formattedName=VCardUtils.constructNameFromElements(VCardConfig.getNameOrderType(mVCardType),familyName,middleName,givenName,prefix,suffix);
    }
    final boolean shouldAppendCharsetParameterToFN=!(mIsV30 && UTF_8.equalsIgnoreCase(mCharsetString)) && shouldAppendCharsetParameter(formattedName);
    final boolean reallyUseQuotedPrintableToFN=!mRefrainsQPToPrimaryProperties && !VCardUtils.containsOnlyNonCrLfPrintableAscii(formattedName);
    final String encodedFamily;
    final String encodedGiven;
    final String encodedMiddle;
    final String encodedPrefix;
    final String encodedSuffix;
    if (reallyUseQuotedPrintableToName) {
      encodedFamily=encodeQuotedPrintable(familyName);
      encodedGiven=encodeQuotedPrintable(givenName);
      encodedMiddle=encodeQuotedPrintable(middleName);
      encodedPrefix=encodeQuotedPrintable(prefix);
      encodedSuffix=encodeQuotedPrintable(suffix);
    }
 else {
      encodedFamily=escapeCharacters(familyName);
      encodedGiven=escapeCharacters(givenName);
      encodedMiddle=escapeCharacters(middleName);
      encodedPrefix=escapeCharacters(prefix);
      encodedSuffix=escapeCharacters(suffix);
    }
    final String encodedFormattedname=(reallyUseQuotedPrintableToFN ? encodeQuotedPrintable(formattedName) : escapeCharacters(formattedName));
    builder.append(Constants.PROPERTY_N);
    if (mIsDoCoMo) {
      if (shouldAppendCharsetParameterToName) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(mVCardCharsetParameter);
      }
      if (reallyUseQuotedPrintableToName) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(VCARD_PARAM_ENCODING_QP);
      }
      builder.append(VCARD_DATA_SEPARATOR);
      builder.append(formattedName);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(VCARD_ITEM_SEPARATOR);
    }
 else {
      if (shouldAppendCharsetParameterToName) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(mVCardCharsetParameter);
      }
      if (reallyUseQuotedPrintableToName) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(VCARD_PARAM_ENCODING_QP);
      }
      builder.append(VCARD_DATA_SEPARATOR);
      builder.append(encodedFamily);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(encodedGiven);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(encodedMiddle);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(encodedPrefix);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(encodedSuffix);
    }
    builder.append(VCARD_END_OF_LINE);
    builder.append(Constants.PROPERTY_FN);
    if (shouldAppendCharsetParameterToFN) {
      builder.append(VCARD_PARAM_SEPARATOR);
      builder.append(mVCardCharsetParameter);
    }
    if (reallyUseQuotedPrintableToFN) {
      builder.append(VCARD_PARAM_SEPARATOR);
      builder.append(VCARD_PARAM_ENCODING_QP);
    }
    builder.append(VCARD_DATA_SEPARATOR);
    builder.append(encodedFormattedname);
    builder.append(VCARD_END_OF_LINE);
  }
 else   if (!TextUtils.isEmpty(displayName)) {
    final boolean reallyUseQuotedPrintableToDisplayName=(!mRefrainsQPToPrimaryProperties && !VCardUtils.containsOnlyNonCrLfPrintableAscii(displayName));
    final String encodedDisplayName=reallyUseQuotedPrintableToDisplayName ? encodeQuotedPrintable(displayName) : escapeCharacters(displayName);
    builder.append(Constants.PROPERTY_N);
    if (shouldAppendCharsetParameter(displayName)) {
      builder.append(VCARD_PARAM_SEPARATOR);
      builder.append(mVCardCharsetParameter);
    }
    if (reallyUseQuotedPrintableToDisplayName) {
      builder.append(VCARD_PARAM_SEPARATOR);
      builder.append(VCARD_PARAM_ENCODING_QP);
    }
    builder.append(VCARD_DATA_SEPARATOR);
    builder.append(encodedDisplayName);
    builder.append(VCARD_ITEM_SEPARATOR);
    builder.append(VCARD_ITEM_SEPARATOR);
    builder.append(VCARD_ITEM_SEPARATOR);
    builder.append(VCARD_ITEM_SEPARATOR);
    builder.append(VCARD_END_OF_LINE);
    if (mIsV30) {
      builder.append(Constants.PROPERTY_FN);
      if (shouldAppendCharsetParameter(displayName)) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(mVCardCharsetParameter);
      }
      builder.append(VCARD_DATA_SEPARATOR);
      builder.append(encodedDisplayName);
      builder.append(VCARD_END_OF_LINE);
    }
  }
 else   if (mIsV30) {
    appendVCardLine(builder,Constants.PROPERTY_N,"String_Node_Str");
    appendVCardLine(builder,Constants.PROPERTY_FN,"String_Node_Str");
  }
 else   if (mIsDoCoMo) {
    appendVCardLine(builder,Constants.PROPERTY_N,"String_Node_Str");
  }
  final String phoneticFamilyName;
  final String phoneticMiddleName;
  final String phoneticGivenName;
{
    String tmpPhoneticFamilyName=primaryContentValues.getAsString(StructuredName.PHONETIC_FAMILY_NAME);
    String tmpPhoneticMiddleName=primaryContentValues.getAsString(StructuredName.PHONETIC_MIDDLE_NAME);
    String tmpPhoneticGivenName=primaryContentValues.getAsString(StructuredName.PHONETIC_GIVEN_NAME);
    if (mNeedsToConvertPhoneticString) {
      phoneticFamilyName=VCardUtils.toHalfWidthString(tmpPhoneticFamilyName);
      phoneticMiddleName=VCardUtils.toHalfWidthString(tmpPhoneticMiddleName);
      phoneticGivenName=VCardUtils.toHalfWidthString(tmpPhoneticGivenName);
    }
 else {
      phoneticFamilyName=tmpPhoneticFamilyName;
      phoneticMiddleName=tmpPhoneticMiddleName;
      phoneticGivenName=tmpPhoneticGivenName;
    }
  }
  if (!(TextUtils.isEmpty(phoneticFamilyName) && TextUtils.isEmpty(phoneticMiddleName) && TextUtils.isEmpty(phoneticGivenName))) {
    if (mIsV30) {
      final String sortString=VCardUtils.constructNameFromElements(mVCardType,phoneticFamilyName,phoneticMiddleName,phoneticGivenName);
      builder.append(Constants.PROPERTY_SORT_STRING);
      final String encodedSortString=escapeCharacters(sortString);
      if (shouldAppendCharsetParameter(encodedSortString)) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(mVCardCharsetParameter);
      }
      builder.append(VCARD_DATA_SEPARATOR);
      builder.append(encodedSortString);
      builder.append(VCARD_END_OF_LINE);
    }
 else     if (mIsJapaneseMobilePhone) {
      builder.append(Constants.PROPERTY_SOUND);
      builder.append(VCARD_PARAM_SEPARATOR);
      builder.append(Constants.PARAM_TYPE_X_IRMC_N);
      boolean reallyUseQuotedPrintable=(!mRefrainsQPToPrimaryProperties && !(VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticFamilyName) && VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticMiddleName) && VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticGivenName)));
      final String encodedPhoneticFamilyName;
      final String encodedPhoneticMiddleName;
      final String encodedPhoneticGivenName;
      if (reallyUseQuotedPrintable) {
        encodedPhoneticFamilyName=encodeQuotedPrintable(phoneticFamilyName);
        encodedPhoneticMiddleName=encodeQuotedPrintable(phoneticMiddleName);
        encodedPhoneticGivenName=encodeQuotedPrintable(phoneticGivenName);
      }
 else {
        encodedPhoneticFamilyName=escapeCharacters(phoneticFamilyName);
        encodedPhoneticMiddleName=escapeCharacters(phoneticMiddleName);
        encodedPhoneticGivenName=escapeCharacters(phoneticGivenName);
      }
      if (shouldAppendCharsetParameters(Arrays.asList(encodedPhoneticFamilyName,encodedPhoneticMiddleName,encodedPhoneticGivenName))) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(mVCardCharsetParameter);
      }
      builder.append(VCARD_DATA_SEPARATOR);
      builder.append(encodedPhoneticFamilyName);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(encodedPhoneticGivenName);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(encodedPhoneticMiddleName);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(VCARD_END_OF_LINE);
    }
  }
 else   if (mIsDoCoMo) {
    builder.append(Constants.PROPERTY_SOUND);
    builder.append(VCARD_PARAM_SEPARATOR);
    builder.append(Constants.PARAM_TYPE_X_IRMC_N);
    builder.append(VCARD_DATA_SEPARATOR);
    builder.append(VCARD_ITEM_SEPARATOR);
    builder.append(VCARD_ITEM_SEPARATOR);
    builder.append(VCARD_ITEM_SEPARATOR);
    builder.append(VCARD_ITEM_SEPARATOR);
    builder.append(VCARD_END_OF_LINE);
  }
  if (mUsesDefactProperty) {
    if (!TextUtils.isEmpty(phoneticGivenName)) {
      final boolean reallyUseQuotedPrintable=!VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticGivenName);
      final String encodedPhoneticGivenName;
      if (reallyUseQuotedPrintable) {
        encodedPhoneticGivenName=encodeQuotedPrintable(phoneticGivenName);
      }
 else {
        encodedPhoneticGivenName=escapeCharacters(phoneticGivenName);
      }
      builder.append(Constants.PROPERTY_X_PHONETIC_FIRST_NAME);
      if (shouldAppendCharsetParameter(encodedPhoneticGivenName)) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(mVCardCharsetParameter);
      }
      if (reallyUseQuotedPrintable) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(VCARD_PARAM_ENCODING_QP);
      }
      builder.append(VCARD_DATA_SEPARATOR);
      builder.append(encodedPhoneticGivenName);
      builder.append(VCARD_END_OF_LINE);
    }
    if (!TextUtils.isEmpty(phoneticMiddleName)) {
      final boolean reallyUseQuotedPrintable=!VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticMiddleName);
      final String encodedPhoneticMiddleName;
      if (reallyUseQuotedPrintable) {
        encodedPhoneticMiddleName=encodeQuotedPrintable(phoneticMiddleName);
      }
 else {
        encodedPhoneticMiddleName=escapeCharacters(phoneticMiddleName);
      }
      builder.append(Constants.PROPERTY_X_PHONETIC_MIDDLE_NAME);
      if (shouldAppendCharsetParameter(encodedPhoneticMiddleName)) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(mVCardCharsetParameter);
      }
      if (reallyUseQuotedPrintable) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(VCARD_PARAM_ENCODING_QP);
      }
      builder.append(VCARD_DATA_SEPARATOR);
      builder.append(encodedPhoneticMiddleName);
      builder.append(VCARD_END_OF_LINE);
    }
    if (!TextUtils.isEmpty(phoneticFamilyName)) {
      final boolean reallyUseQuotedPrintable=!VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticFamilyName);
      final String encodedPhoneticFamilyName;
      if (reallyUseQuotedPrintable) {
        encodedPhoneticFamilyName=encodeQuotedPrintable(phoneticFamilyName);
      }
 else {
        encodedPhoneticFamilyName=escapeCharacters(phoneticFamilyName);
      }
      builder.append(Constants.PROPERTY_X_PHONETIC_LAST_NAME);
      if (shouldAppendCharsetParameter(encodedPhoneticFamilyName)) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(mVCardCharsetParameter);
      }
      if (reallyUseQuotedPrintable) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(VCARD_PARAM_ENCODING_QP);
      }
      builder.append(VCARD_DATA_SEPARATOR);
      builder.append(encodedPhoneticFamilyName);
      builder.append(VCARD_END_OF_LINE);
    }
  }
}

Fixed version (ground truth):
private void appendStructuredNamesInternal(final StringBuilder builder,final List<ContentValues> contentValuesList){
  ContentValues primaryContentValues=null;
  ContentValues subprimaryContentValues=null;
  for (  ContentValues contentValues : contentValuesList) {
    if (contentValues == null) {
      continue;
    }
    Integer isSuperPrimary=contentValues.getAsInteger(StructuredName.IS_SUPER_PRIMARY);
    if (isSuperPrimary != null && isSuperPrimary > 0) {
      primaryContentValues=contentValues;
      break;
    }
 else     if (primaryContentValues == null) {
      Integer isPrimary=contentValues.getAsInteger(StructuredName.IS_PRIMARY);
      if (isPrimary != null && isPrimary > 0 && containsNonEmptyName(contentValues)) {
        primaryContentValues=contentValues;
      }
 else       if (subprimaryContentValues == null && containsNonEmptyName(contentValues)) {
        subprimaryContentValues=contentValues;
      }
    }
  }
  if (primaryContentValues == null) {
    if (subprimaryContentValues != null) {
      primaryContentValues=subprimaryContentValues;
    }
 else {
      Log.e(LOG_TAG,"String_Node_Str");
      primaryContentValues=new ContentValues();
    }
  }
  final String familyName=primaryContentValues.getAsString(StructuredName.FAMILY_NAME);
  final String middleName=primaryContentValues.getAsString(StructuredName.MIDDLE_NAME);
  final String givenName=primaryContentValues.getAsString(StructuredName.GIVEN_NAME);
  final String prefix=primaryContentValues.getAsString(StructuredName.PREFIX);
  final String suffix=primaryContentValues.getAsString(StructuredName.SUFFIX);
  final String displayName=primaryContentValues.getAsString(StructuredName.DISPLAY_NAME);
  if (!TextUtils.isEmpty(familyName) || !TextUtils.isEmpty(givenName)) {
    final boolean shouldAppendCharsetParameterToName=!(mIsV30 && UTF_8.equalsIgnoreCase(mCharsetString)) && shouldAppendCharsetParameters(Arrays.asList(familyName,givenName,middleName,prefix,suffix));
    final boolean reallyUseQuotedPrintableToName=(!mRefrainsQPToPrimaryProperties && !(VCardUtils.containsOnlyNonCrLfPrintableAscii(familyName) && VCardUtils.containsOnlyNonCrLfPrintableAscii(givenName) && VCardUtils.containsOnlyNonCrLfPrintableAscii(middleName)&& VCardUtils.containsOnlyNonCrLfPrintableAscii(prefix)&& VCardUtils.containsOnlyNonCrLfPrintableAscii(suffix)));
    final String formattedName;
    if (!TextUtils.isEmpty(displayName)) {
      formattedName=displayName;
    }
 else {
      formattedName=VCardUtils.constructNameFromElements(VCardConfig.getNameOrderType(mVCardType),familyName,middleName,givenName,prefix,suffix);
    }
    final boolean shouldAppendCharsetParameterToFN=!(mIsV30 && UTF_8.equalsIgnoreCase(mCharsetString)) && shouldAppendCharsetParameter(formattedName);
    final boolean reallyUseQuotedPrintableToFN=!mRefrainsQPToPrimaryProperties && !VCardUtils.containsOnlyNonCrLfPrintableAscii(formattedName);
    final String encodedFamily;
    final String encodedGiven;
    final String encodedMiddle;
    final String encodedPrefix;
    final String encodedSuffix;
    if (reallyUseQuotedPrintableToName) {
      encodedFamily=encodeQuotedPrintable(familyName);
      encodedGiven=encodeQuotedPrintable(givenName);
      encodedMiddle=encodeQuotedPrintable(middleName);
      encodedPrefix=encodeQuotedPrintable(prefix);
      encodedSuffix=encodeQuotedPrintable(suffix);
    }
 else {
      encodedFamily=escapeCharacters(familyName);
      encodedGiven=escapeCharacters(givenName);
      encodedMiddle=escapeCharacters(middleName);
      encodedPrefix=escapeCharacters(prefix);
      encodedSuffix=escapeCharacters(suffix);
    }
    final String encodedFormattedname=(reallyUseQuotedPrintableToFN ? encodeQuotedPrintable(formattedName) : escapeCharacters(formattedName));
    builder.append(Constants.PROPERTY_N);
    if (mIsDoCoMo) {
      if (shouldAppendCharsetParameterToName) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(mVCardCharsetParameter);
      }
      if (reallyUseQuotedPrintableToName) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(VCARD_PARAM_ENCODING_QP);
      }
      builder.append(VCARD_DATA_SEPARATOR);
      builder.append(formattedName);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(VCARD_ITEM_SEPARATOR);
    }
 else {
      if (shouldAppendCharsetParameterToName) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(mVCardCharsetParameter);
      }
      if (reallyUseQuotedPrintableToName) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(VCARD_PARAM_ENCODING_QP);
      }
      builder.append(VCARD_DATA_SEPARATOR);
      builder.append(encodedFamily);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(encodedGiven);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(encodedMiddle);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(encodedPrefix);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(encodedSuffix);
    }
    builder.append(VCARD_END_OF_LINE);
    builder.append(Constants.PROPERTY_FN);
    if (shouldAppendCharsetParameterToFN) {
      builder.append(VCARD_PARAM_SEPARATOR);
      builder.append(mVCardCharsetParameter);
    }
    if (reallyUseQuotedPrintableToFN) {
      builder.append(VCARD_PARAM_SEPARATOR);
      builder.append(VCARD_PARAM_ENCODING_QP);
    }
    builder.append(VCARD_DATA_SEPARATOR);
    builder.append(encodedFormattedname);
    builder.append(VCARD_END_OF_LINE);
  }
 else   if (!TextUtils.isEmpty(displayName)) {
    final boolean reallyUseQuotedPrintableToDisplayName=(!mRefrainsQPToPrimaryProperties && !VCardUtils.containsOnlyNonCrLfPrintableAscii(displayName));
    final String encodedDisplayName=reallyUseQuotedPrintableToDisplayName ? encodeQuotedPrintable(displayName) : escapeCharacters(displayName);
    builder.append(Constants.PROPERTY_N);
    if (shouldAppendCharsetParameter(displayName)) {
      builder.append(VCARD_PARAM_SEPARATOR);
      builder.append(mVCardCharsetParameter);
    }
    if (reallyUseQuotedPrintableToDisplayName) {
      builder.append(VCARD_PARAM_SEPARATOR);
      builder.append(VCARD_PARAM_ENCODING_QP);
    }
    builder.append(VCARD_DATA_SEPARATOR);
    builder.append(encodedDisplayName);
    builder.append(VCARD_ITEM_SEPARATOR);
    builder.append(VCARD_ITEM_SEPARATOR);
    builder.append(VCARD_ITEM_SEPARATOR);
    builder.append(VCARD_ITEM_SEPARATOR);
    builder.append(VCARD_END_OF_LINE);
    builder.append(Constants.PROPERTY_FN);
    if (shouldAppendCharsetParameter(displayName)) {
      builder.append(VCARD_PARAM_SEPARATOR);
      builder.append(mVCardCharsetParameter);
    }
    builder.append(VCARD_DATA_SEPARATOR);
    builder.append(encodedDisplayName);
    builder.append(VCARD_END_OF_LINE);
  }
 else   if (mIsV30) {
    appendVCardLine(builder,Constants.PROPERTY_N,"String_Node_Str");
    appendVCardLine(builder,Constants.PROPERTY_FN,"String_Node_Str");
  }
 else   if (mIsDoCoMo) {
    appendVCardLine(builder,Constants.PROPERTY_N,"String_Node_Str");
  }
  final String phoneticFamilyName;
  final String phoneticMiddleName;
  final String phoneticGivenName;
{
    String tmpPhoneticFamilyName=primaryContentValues.getAsString(StructuredName.PHONETIC_FAMILY_NAME);
    String tmpPhoneticMiddleName=primaryContentValues.getAsString(StructuredName.PHONETIC_MIDDLE_NAME);
    String tmpPhoneticGivenName=primaryContentValues.getAsString(StructuredName.PHONETIC_GIVEN_NAME);
    if (mNeedsToConvertPhoneticString) {
      phoneticFamilyName=VCardUtils.toHalfWidthString(tmpPhoneticFamilyName);
      phoneticMiddleName=VCardUtils.toHalfWidthString(tmpPhoneticMiddleName);
      phoneticGivenName=VCardUtils.toHalfWidthString(tmpPhoneticGivenName);
    }
 else {
      phoneticFamilyName=tmpPhoneticFamilyName;
      phoneticMiddleName=tmpPhoneticMiddleName;
      phoneticGivenName=tmpPhoneticGivenName;
    }
  }
  if (!(TextUtils.isEmpty(phoneticFamilyName) && TextUtils.isEmpty(phoneticMiddleName) && TextUtils.isEmpty(phoneticGivenName))) {
    if (mIsV30) {
      final String sortString=VCardUtils.constructNameFromElements(mVCardType,phoneticFamilyName,phoneticMiddleName,phoneticGivenName);
      builder.append(Constants.PROPERTY_SORT_STRING);
      if (shouldAppendCharsetParameter(sortString)) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(mVCardCharsetParameter);
      }
      builder.append(VCARD_DATA_SEPARATOR);
      builder.append(escapeCharacters(sortString));
      builder.append(VCARD_END_OF_LINE);
    }
 else     if (mIsJapaneseMobilePhone) {
      builder.append(Constants.PROPERTY_SOUND);
      builder.append(VCARD_PARAM_SEPARATOR);
      builder.append(Constants.PARAM_TYPE_X_IRMC_N);
      boolean reallyUseQuotedPrintable=(!mRefrainsQPToPrimaryProperties && !(VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticFamilyName) && VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticMiddleName) && VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticGivenName)));
      final String encodedPhoneticFamilyName;
      final String encodedPhoneticMiddleName;
      final String encodedPhoneticGivenName;
      if (reallyUseQuotedPrintable) {
        encodedPhoneticFamilyName=encodeQuotedPrintable(phoneticFamilyName);
        encodedPhoneticMiddleName=encodeQuotedPrintable(phoneticMiddleName);
        encodedPhoneticGivenName=encodeQuotedPrintable(phoneticGivenName);
      }
 else {
        encodedPhoneticFamilyName=escapeCharacters(phoneticFamilyName);
        encodedPhoneticMiddleName=escapeCharacters(phoneticMiddleName);
        encodedPhoneticGivenName=escapeCharacters(phoneticGivenName);
      }
      if (shouldAppendCharsetParameters(Arrays.asList(encodedPhoneticFamilyName,encodedPhoneticMiddleName,encodedPhoneticGivenName))) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(mVCardCharsetParameter);
      }
      builder.append(VCARD_DATA_SEPARATOR);
{
        boolean first=true;
        if (!TextUtils.isEmpty(encodedPhoneticFamilyName)) {
          builder.append(encodedPhoneticFamilyName);
          first=false;
        }
        if (!TextUtils.isEmpty(encodedPhoneticMiddleName)) {
          if (first) {
            first=false;
          }
 else {
            builder.append(' ');
          }
          builder.append(encodedPhoneticMiddleName);
        }
        if (!TextUtils.isEmpty(encodedPhoneticGivenName)) {
          if (!first) {
            builder.append(' ');
          }
          builder.append(encodedPhoneticGivenName);
        }
      }
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(VCARD_ITEM_SEPARATOR);
      builder.append(VCARD_END_OF_LINE);
    }
  }
 else   if (mIsDoCoMo) {
    builder.append(Constants.PROPERTY_SOUND);
    builder.append(VCARD_PARAM_SEPARATOR);
    builder.append(Constants.PARAM_TYPE_X_IRMC_N);
    builder.append(VCARD_DATA_SEPARATOR);
    builder.append(VCARD_ITEM_SEPARATOR);
    builder.append(VCARD_ITEM_SEPARATOR);
    builder.append(VCARD_ITEM_SEPARATOR);
    builder.append(VCARD_ITEM_SEPARATOR);
    builder.append(VCARD_END_OF_LINE);
  }
  if (mUsesDefactProperty) {
    if (!TextUtils.isEmpty(phoneticGivenName)) {
      final boolean reallyUseQuotedPrintable=(mUsesQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticGivenName));
      final String encodedPhoneticGivenName;
      if (reallyUseQuotedPrintable) {
        encodedPhoneticGivenName=encodeQuotedPrintable(phoneticGivenName);
      }
 else {
        encodedPhoneticGivenName=escapeCharacters(phoneticGivenName);
      }
      builder.append(Constants.PROPERTY_X_PHONETIC_FIRST_NAME);
      if (shouldAppendCharsetParameter(phoneticGivenName)) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(mVCardCharsetParameter);
      }
      if (reallyUseQuotedPrintable) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(VCARD_PARAM_ENCODING_QP);
      }
      builder.append(VCARD_DATA_SEPARATOR);
      builder.append(encodedPhoneticGivenName);
      builder.append(VCARD_END_OF_LINE);
    }
    if (!TextUtils.isEmpty(phoneticMiddleName)) {
      final boolean reallyUseQuotedPrintable=(mUsesQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticMiddleName));
      final String encodedPhoneticMiddleName;
      if (reallyUseQuotedPrintable) {
        encodedPhoneticMiddleName=encodeQuotedPrintable(phoneticMiddleName);
      }
 else {
        encodedPhoneticMiddleName=escapeCharacters(phoneticMiddleName);
      }
      builder.append(Constants.PROPERTY_X_PHONETIC_MIDDLE_NAME);
      if (shouldAppendCharsetParameter(phoneticMiddleName)) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(mVCardCharsetParameter);
      }
      if (reallyUseQuotedPrintable) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(VCARD_PARAM_ENCODING_QP);
      }
      builder.append(VCARD_DATA_SEPARATOR);
      builder.append(encodedPhoneticMiddleName);
      builder.append(VCARD_END_OF_LINE);
    }
    if (!TextUtils.isEmpty(phoneticFamilyName)) {
      final boolean reallyUseQuotedPrintable=(mUsesQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticFamilyName));
      final String encodedPhoneticFamilyName;
      if (reallyUseQuotedPrintable) {
        encodedPhoneticFamilyName=encodeQuotedPrintable(phoneticFamilyName);
      }
 else {
        encodedPhoneticFamilyName=escapeCharacters(phoneticFamilyName);
      }
      builder.append(Constants.PROPERTY_X_PHONETIC_LAST_NAME);
      if (shouldAppendCharsetParameter(phoneticFamilyName)) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(mVCardCharsetParameter);
      }
      if (reallyUseQuotedPrintable) {
        builder.append(VCARD_PARAM_SEPARATOR);
        builder.append(VCARD_PARAM_ENCODING_QP);
      }
      builder.append(VCARD_DATA_SEPARATOR);
      builder.append(encodedPhoneticFamilyName);
      builder.append(VCARD_END_OF_LINE);
    }
  }
}