Program: 23894
Project: 23894
Buggy source:
/** 
 * This function should be called from checkAndProcessPlusCode only And it is used for test purpose also. It checks the dial string by looping through the network portion, post dial portion 1, post dial porting 2, etc. If there is any plus sign, then process the plus sign. Currently, this function supports the plus sign conversion within NANP only. Specifically, it handles the plus sign in the following ways: 1)+NANP or +1NANP,remove +, e.g. +8475797000 is converted to 8475797000, +18475797000 is converted to 18475797000, 2)+non-NANP Numbers,replace + with the current NANP IDP, e.g, +11875767800 is converted to 01111875767800 3)+NANP in post dial string(s), e.g. 8475797000;+8475231753 is converted to 8475797000;8475231753 This function returns the original dial string if locale/numbering plan aren't supported.
 * @hide
 */
public static String cdmaCheckAndProcessPlusCodeByNumberFormat(String dialStr,int numFormat){
  String retStr=dialStr;
  if (dialStr != null && dialStr.lastIndexOf(PLUS_SIGN_STRING) != -1) {
    String postDialStr=null;
    String tempDialStr=dialStr;
    retStr=null;
    if (DBG)     log("String_Node_Str" + dialStr);
    do {
      String networkDialStr;
      if (numFormat != FORMAT_NANP) {
        Log.e("String_Node_Str",dialStr);
        return dialStr;
      }
 else {
        networkDialStr=extractNetworkPortion(tempDialStr);
        networkDialStr=processPlusCodeWithinNanp(networkDialStr);
      }
      if (!TextUtils.isEmpty(networkDialStr)) {
        if (retStr == null) {
          retStr=networkDialStr;
        }
 else {
          retStr=retStr.concat(networkDialStr);
        }
      }
 else {
        Log.e("String_Node_Str",networkDialStr);
        return dialStr;
      }
      postDialStr=extractPostDialPortion(tempDialStr);
      if (!TextUtils.isEmpty(postDialStr)) {
        int dialableIndex=findDialableIndexFromPostDialStr(postDialStr);
        if (dialableIndex >= 1) {
          retStr=appendPwCharBackToOrigDialStr(dialableIndex,retStr,postDialStr);
          tempDialStr=postDialStr.substring(dialableIndex);
        }
 else {
          if (dialableIndex < 0) {
            postDialStr="String_Node_Str";
          }
          Log.e("String_Node_Str",postDialStr);
        }
      }
      if (DBG)       log("String_Node_Str" + postDialStr);
    }
 while (!TextUtils.isEmpty(postDialStr) && !TextUtils.isEmpty(tempDialStr));
  }
  return retStr;
}

Fixed version (ground truth):
/** 
 * This function should be called from checkAndProcessPlusCode only And it is used for test purpose also. It checks the dial string by looping through the network portion, post dial portion 1, post dial porting 2, etc. If there is any plus sign, then process the plus sign. Currently, this function supports the plus sign conversion within NANP only. Specifically, it handles the plus sign in the following ways: 1)+1NANP,remove +, e.g. +18475797000 is converted to 18475797000, 2)+NANP or +non-NANP Numbers,replace + with the current NANP IDP, e.g, +8475797000 is converted to 0118475797000, +11875767800 is converted to 01111875767800 3)+1NANP in post dial string(s), e.g. 8475797000;+18475231753 is converted to 8475797000;18475231753
 * @param dialStr the original dial string
 * @param currFormat the numbering system of the current country that the phone is camped on
 * @param defaultFormat the numbering system of the country that the phone is activated on
 * @return the converted dial string if the current/default countries belong to NANP,and if there is the "+" in the original dial string. Otherwise, the original dial string returns.
 * @hide
 */
public static String cdmaCheckAndProcessPlusCodeByNumberFormat(String dialStr,int currFormat,int defaultFormt){
  String retStr=dialStr;
  if (dialStr != null && dialStr.lastIndexOf(PLUS_SIGN_STRING) != -1) {
    if ((currFormat == defaultFormt) && (currFormat == FORMAT_NANP)) {
      String postDialStr=null;
      String tempDialStr=dialStr;
      retStr=null;
      if (DBG)       log("String_Node_Str" + dialStr);
      do {
        String networkDialStr;
        networkDialStr=extractNetworkPortion(tempDialStr);
        networkDialStr=processPlusCodeWithinNanp(networkDialStr);
        if (!TextUtils.isEmpty(networkDialStr)) {
          if (retStr == null) {
            retStr=networkDialStr;
          }
 else {
            retStr=retStr.concat(networkDialStr);
          }
        }
 else {
          Log.e("String_Node_Str",networkDialStr);
          return dialStr;
        }
        postDialStr=extractPostDialPortion(tempDialStr);
        if (!TextUtils.isEmpty(postDialStr)) {
          int dialableIndex=findDialableIndexFromPostDialStr(postDialStr);
          if (dialableIndex >= 1) {
            retStr=appendPwCharBackToOrigDialStr(dialableIndex,retStr,postDialStr);
            tempDialStr=postDialStr.substring(dialableIndex);
          }
 else {
            if (dialableIndex < 0) {
              postDialStr="String_Node_Str";
            }
            Log.e("String_Node_Str",postDialStr);
          }
        }
        if (DBG)         log("String_Node_Str" + postDialStr);
      }
 while (!TextUtils.isEmpty(postDialStr) && !TextUtils.isEmpty(tempDialStr));
    }
 else {
      Log.e("String_Node_Str",dialStr);
    }
  }
  return retStr;
}