Program: 23971
Project: 23971
Buggy source:
/** 
 * Handle the result of one of the pollState()-related requests
 */
@Override protected void handlePollStateResult(int what,AsyncResult ar){
  int ints[];
  String states[];
  if (ar.userObj != pollingContext)   return;
  if (ar.exception != null) {
    CommandException.Error err=null;
    if (ar.exception instanceof CommandException) {
      err=((CommandException)(ar.exception)).getCommandError();
    }
    if (err == CommandException.Error.RADIO_NOT_AVAILABLE) {
      cancelPollState();
      return;
    }
    if (!cm.getRadioState().isOn()) {
      cancelPollState();
      return;
    }
    if (err != CommandException.Error.OP_NOT_ALLOWED_BEFORE_REG_NW && err != CommandException.Error.OP_NOT_ALLOWED_BEFORE_REG_NW) {
      Log.e(LOG_TAG,"String_Node_Str",ar.exception);
    }
  }
 else   try {
switch (what) {
case EVENT_POLL_STATE_REGISTRATION_CDMA:
      states=(String[])ar.result;
    int registrationState=4;
  int radioTechnology=-1;
int baseStationId=-1;
int baseStationLatitude=-1;
int baseStationLongitude=-1;
int cssIndicator=0;
int systemId=0;
int networkId=0;
int roamingIndicator=-1;
int systemIsInPrl=0;
int defaultRoamingIndicator=0;
int reasonForDenial=0;
if (states.length == 14) {
try {
registrationState=Integer.parseInt(states[0]);
radioTechnology=Integer.parseInt(states[3]);
baseStationId=Integer.parseInt(states[4]);
baseStationLatitude=Integer.parseInt(states[5],16);
baseStationLongitude=Integer.parseInt(states[6],16);
cssIndicator=Integer.parseInt(states[7]);
systemId=Integer.parseInt(states[8]);
networkId=Integer.parseInt(states[9]);
roamingIndicator=Integer.parseInt(states[10]);
systemIsInPrl=Integer.parseInt(states[11]);
defaultRoamingIndicator=Integer.parseInt(states[12]);
reasonForDenial=Integer.parseInt(states[13]);
}
 catch (NumberFormatException ex) {
Log.w(LOG_TAG,"String_Node_Str" + ex);
}
}
 else {
throw new RuntimeException("String_Node_Str" + "String_Node_Str" + states.length);
}
mRegistrationState=registrationState;
mCdmaRoaming=regCodeIsRoaming(registrationState) && !isRoamIndForHomeSystem(states[10]);
newSS.setState(regCodeToServiceState(registrationState));
this.newCdmaDataConnectionState=radioTechnologyToDataServiceState(radioTechnology);
newSS.setRadioTechnology(radioTechnology);
newNetworkType=radioTechnology;
newSS.setCssIndicator(cssIndicator);
newSS.setSystemAndNetworkId(systemId,networkId);
mRoamingIndicator=roamingIndicator;
mIsInPrl=(systemIsInPrl == 0) ? false : true;
mDefaultRoamingIndicator=defaultRoamingIndicator;
newCellLoc.setCellLocationData(baseStationId,baseStationLatitude,baseStationLongitude,systemId,networkId);
if (reasonForDenial == 0) {
mRegistrationDeniedReason=ServiceStateTracker.REGISTRATION_DENIED_GEN;
}
 else if (reasonForDenial == 1) {
mRegistrationDeniedReason=ServiceStateTracker.REGISTRATION_DENIED_AUTH;
}
 else {
mRegistrationDeniedReason="String_Node_Str";
}
if (mRegistrationState == 3) {
if (DBG) log("String_Node_Str" + mRegistrationDeniedReason);
}
break;
case EVENT_POLL_STATE_OPERATOR_CDMA:
String opNames[]=(String[])ar.result;
if (opNames != null && opNames.length >= 3) {
if (cm.getRadioState().isNVReady()) {
newSS.setOperatorName(null,opNames[1],opNames[2]);
}
 else {
newSS.setOperatorName(opNames[0],opNames[1],opNames[2]);
}
}
 else {
Log.w(LOG_TAG,"String_Node_Str");
}
break;
default :
Log.e(LOG_TAG,"String_Node_Str" + "String_Node_Str");
break;
}
}
 catch (RuntimeException ex) {
Log.e(LOG_TAG,"String_Node_Str" + "String_Node_Str",ex);
}
pollingContext[0]--;
if (pollingContext[0] == 0) {
boolean namMatch=false;
if ((mHomeSystemId != 0) && (mHomeSystemId == newSS.getSystemId())) {
namMatch=true;
}
if (isSubscriptionFromRuim) {
newSS.setRoaming(isRoamingBetweenOperators(mCdmaRoaming,newSS));
}
 else {
newSS.setRoaming(mCdmaRoaming);
}
if (mIsInPrl) {
if (namMatch && (mRoamingIndicator <= 2)) {
newSS.setCdmaRoamingIndicator(EriInfo.ROAMING_INDICATOR_OFF);
}
 else {
newSS.setCdmaRoamingIndicator(mRoamingIndicator);
}
}
 else {
if (mRegistrationState == 5) {
newSS.setCdmaRoamingIndicator(EriInfo.ROAMING_INDICATOR_FLASH);
}
 else {
}
}
newSS.setCdmaDefaultRoamingIndicator(mDefaultRoamingIndicator);
if (DBG) {
log("String_Node_Str" + newSS.getCdmaRoamingIndicator() + "String_Node_Str"+ mCdmaRoaming+ "String_Node_Str"+ namMatch+ "String_Node_Str"+ mIsInPrl+ "String_Node_Str"+ mRoamingIndicator+ "String_Node_Str"+ mDefaultRoamingIndicator);
}
pollStateDone();
}
}

Fixed version (ground truth):
/** 
 * Handle the result of one of the pollState()-related requests
 */
@Override protected void handlePollStateResult(int what,AsyncResult ar){
  int ints[];
  String states[];
  if (ar.userObj != pollingContext)   return;
  if (ar.exception != null) {
    CommandException.Error err=null;
    if (ar.exception instanceof CommandException) {
      err=((CommandException)(ar.exception)).getCommandError();
    }
    if (err == CommandException.Error.RADIO_NOT_AVAILABLE) {
      cancelPollState();
      return;
    }
    if (!cm.getRadioState().isOn()) {
      cancelPollState();
      return;
    }
    if (err != CommandException.Error.OP_NOT_ALLOWED_BEFORE_REG_NW && err != CommandException.Error.OP_NOT_ALLOWED_BEFORE_REG_NW) {
      Log.e(LOG_TAG,"String_Node_Str",ar.exception);
    }
  }
 else   try {
switch (what) {
case EVENT_POLL_STATE_REGISTRATION_CDMA:
      states=(String[])ar.result;
    int registrationState=4;
  int radioTechnology=-1;
int baseStationId=-1;
int baseStationLatitude=-1;
int baseStationLongitude=-1;
int cssIndicator=0;
int systemId=0;
int networkId=0;
int roamingIndicator=-1;
int systemIsInPrl=0;
int defaultRoamingIndicator=0;
int reasonForDenial=0;
if (states.length == 14) {
try {
registrationState=Integer.parseInt(states[0]);
radioTechnology=Integer.parseInt(states[3]);
baseStationId=Integer.parseInt(states[4]);
baseStationLatitude=Integer.parseInt(states[5],16);
baseStationLongitude=Integer.parseInt(states[6],16);
cssIndicator=Integer.parseInt(states[7]);
systemId=Integer.parseInt(states[8]);
networkId=Integer.parseInt(states[9]);
roamingIndicator=Integer.parseInt(states[10]);
systemIsInPrl=Integer.parseInt(states[11]);
defaultRoamingIndicator=Integer.parseInt(states[12]);
reasonForDenial=Integer.parseInt(states[13]);
}
 catch (NumberFormatException ex) {
Log.w(LOG_TAG,"String_Node_Str" + ex);
}
}
 else {
throw new RuntimeException("String_Node_Str" + "String_Node_Str" + states.length);
}
mRegistrationState=registrationState;
mCdmaRoaming=regCodeIsRoaming(registrationState) && !isRoamIndForHomeSystem(states[10]);
newSS.setState(regCodeToServiceState(registrationState));
this.newCdmaDataConnectionState=radioTechnologyToDataServiceState(radioTechnology);
newSS.setRadioTechnology(radioTechnology);
newNetworkType=radioTechnology;
newSS.setCssIndicator(cssIndicator);
newSS.setSystemAndNetworkId(systemId,networkId);
mRoamingIndicator=roamingIndicator;
mIsInPrl=(systemIsInPrl == 0) ? false : true;
mDefaultRoamingIndicator=defaultRoamingIndicator;
newCellLoc.setCellLocationData(baseStationId,baseStationLatitude,baseStationLongitude,systemId,networkId);
if (reasonForDenial == 0) {
mRegistrationDeniedReason=ServiceStateTracker.REGISTRATION_DENIED_GEN;
}
 else if (reasonForDenial == 1) {
mRegistrationDeniedReason=ServiceStateTracker.REGISTRATION_DENIED_AUTH;
}
 else {
mRegistrationDeniedReason="String_Node_Str";
}
if (mRegistrationState == 3) {
if (DBG) log("String_Node_Str" + mRegistrationDeniedReason);
}
break;
case EVENT_POLL_STATE_OPERATOR_CDMA:
String opNames[]=(String[])ar.result;
if (opNames != null && opNames.length >= 3) {
if (cm.getRadioState().isNVReady()) {
newSS.setOperatorName(null,opNames[1],opNames[2]);
}
 else {
newSS.setOperatorName(opNames[0],opNames[1],opNames[2]);
}
}
 else {
Log.w(LOG_TAG,"String_Node_Str");
}
break;
default :
Log.e(LOG_TAG,"String_Node_Str" + "String_Node_Str");
break;
}
}
 catch (RuntimeException ex) {
Log.e(LOG_TAG,"String_Node_Str" + "String_Node_Str",ex);
}
pollingContext[0]--;
if (pollingContext[0] == 0) {
boolean namMatch=false;
if (!isSidsAllZeros() && isHomeSid(newSS.getSystemId())) {
namMatch=true;
}
if (isSubscriptionFromRuim) {
newSS.setRoaming(isRoamingBetweenOperators(mCdmaRoaming,newSS));
}
 else {
newSS.setRoaming(mCdmaRoaming);
}
newSS.setCdmaDefaultRoamingIndicator(mDefaultRoamingIndicator);
newSS.setCdmaRoamingIndicator(mRoamingIndicator);
boolean isPrlLoaded=true;
if (TextUtils.isEmpty(mPrlVersion)) {
isPrlLoaded=false;
}
if (!isPrlLoaded) {
newSS.setCdmaRoamingIndicator(EriInfo.ROAMING_INDICATOR_FLASH);
}
 else if (!isSidsAllZeros()) {
if (!namMatch && !mIsInPrl) {
newSS.setCdmaRoamingIndicator(mDefaultRoamingIndicator);
}
 else if (namMatch && !mIsInPrl) {
newSS.setCdmaRoamingIndicator(EriInfo.ROAMING_INDICATOR_FLASH);
}
 else if (!namMatch && mIsInPrl) {
newSS.setCdmaRoamingIndicator(mRoamingIndicator);
}
 else {
if ((mRoamingIndicator <= 2)) {
newSS.setCdmaRoamingIndicator(EriInfo.ROAMING_INDICATOR_OFF);
}
 else {
newSS.setCdmaRoamingIndicator(mRoamingIndicator);
}
}
}
if (DBG) {
log("String_Node_Str" + newSS.getCdmaRoamingIndicator() + "String_Node_Str"+ mCdmaRoaming+ "String_Node_Str"+ isPrlLoaded+ "String_Node_Str"+ namMatch+ "String_Node_Str"+ mIsInPrl+ "String_Node_Str"+ mRoamingIndicator+ "String_Node_Str"+ mDefaultRoamingIndicator);
}
pollStateDone();
}
}