Program: 141981
Project: 141981
Buggy source:
@Override protected void onActivityResult(int requestCode,int resultCode,Intent intent){
  if (resultCode == RESULT_RESTART) {
    sessionNavigator.startNextSessionStep();
  }
 else {
switch (requestCode) {
case PREFERENCES_ACTIVITY:
      if (resultCode == AdvancedActionsPreferences.RESULT_DATA_RESET) {
        finish();
      }
 else       if (resultCode == DeveloperPreferences.RESULT_SYNC_CUSTOM) {
        try {
          Uri uri=intent.getData();
          String filePath=UriToFilePath.getPathFromUri(CommCareApplication.instance(),uri);
          if (filePath != null) {
            File f=new File(filePath);
            if (f != null && f.exists()) {
              formAndDataSyncer.performCustomRestoreFromFile(this,f);
            }
          }
        }
 catch (        Exception e) {
          Toast.makeText(this,"String_Node_Str",Toast.LENGTH_LONG).show();
        }
      }
    return;
case ADVANCED_ACTIONS_ACTIVITY:
  handleAdvancedActionResult(resultCode,intent);
return;
case GET_INCOMPLETE_FORM:
if (resultCode == RESULT_CANCELED) {
refreshUI();
return;
}
 else if (resultCode == RESULT_OK) {
int record=intent.getIntExtra("String_Node_Str",-1);
if (record == -1) {
  break;
}
FormRecord r=CommCareApplication.instance().getUserStorage(FormRecord.class).read(record);
SqlStorage<SessionStateDescriptor> ssdStorage=CommCareApplication.instance().getUserStorage(SessionStateDescriptor.class);
Vector<Integer> ssds=ssdStorage.getIDsForValue(SessionStateDescriptor.META_FORM_RECORD_ID,r.getID());
AndroidSessionWrapper currentState=CommCareApplication.instance().getCurrentSessionWrapper();
if (ssds.size() == 1) {
  currentState.loadFromStateDescription(ssdStorage.read(ssds.firstElement()));
}
 else {
  currentState.setFormRecordId(r.getID());
}
AndroidCommCarePlatform platform=CommCareApplication.instance().getCommCarePlatform();
formEntry(platform.getFormContentUri(r.getFormNamespace()),r);
return;
}
break;
case GET_COMMAND:
boolean fetchNext=processReturnFromGetCommand(resultCode,intent);
if (!fetchNext) {
return;
}
break;
case GET_CASE:
fetchNext=processReturnFromGetCase(resultCode,intent);
if (!fetchNext) {
return;
}
break;
case MODEL_RESULT:
fetchNext=processReturnFromFormEntry(resultCode,intent);
if (!fetchNext) {
return;
}
break;
case AUTHENTICATION_FOR_PIN:
if (resultCode == RESULT_OK) {
launchPinCreateScreen(LoginMode.PASSWORD);
}
return;
case CREATE_PIN:
boolean choseRememberPassword=intent != null && intent.getBooleanExtra(CreatePinActivity.CHOSE_REMEMBER_PASSWORD,false);
if (choseRememberPassword) {
CommCareApplication.instance().closeUserSession();
}
 else if (resultCode == RESULT_OK) {
Toast.makeText(this,Localization.get("String_Node_Str"),Toast.LENGTH_SHORT).show();
}
 else {
Toast.makeText(this,Localization.get("String_Node_Str"),Toast.LENGTH_SHORT).show();
}
return;
case MAKE_REMOTE_POST:
stepBackIfCancelled(resultCode);
if (resultCode == RESULT_OK) {
CommCareApplication.instance().getCurrentSessionWrapper().terminateSession();
}
break;
case GET_REMOTE_DATA:
stepBackIfCancelled(resultCode);
break;
case PROMPT_FOR_UPDATE:
UpdatePromptHelper.promptForUpdateIfNeeded(this,PROMPT_FOR_UPDATE);
return;
}
sessionNavigationProceedingAfterOnResume=true;
startNextSessionStepSafe();
}
super.onActivityResult(requestCode,resultCode,intent);
}

Fixed version (ground truth):
@Override protected void onActivityResult(int requestCode,int resultCode,Intent intent){
  if (resultCode == RESULT_RESTART) {
    sessionNavigator.startNextSessionStep();
  }
 else {
switch (requestCode) {
case PREFERENCES_ACTIVITY:
      if (resultCode == AdvancedActionsPreferences.RESULT_DATA_RESET) {
        finish();
      }
 else       if (resultCode == DeveloperPreferences.RESULT_SYNC_CUSTOM) {
        try {
          Uri uri=intent.getData();
          String filePath=UriToFilePath.getPathFromUri(CommCareApplication.instance(),uri);
          if (filePath != null) {
            File f=new File(filePath);
            if (f != null && f.exists()) {
              formAndDataSyncer.performCustomRestoreFromFile(this,f);
            }
          }
        }
 catch (        Exception e) {
          Toast.makeText(this,"String_Node_Str",Toast.LENGTH_LONG).show();
        }
      }
    return;
case ADVANCED_ACTIONS_ACTIVITY:
  handleAdvancedActionResult(resultCode,intent);
return;
case GET_INCOMPLETE_FORM:
if (resultCode == RESULT_CANCELED) {
refreshUI();
return;
}
 else if (resultCode == RESULT_OK) {
int record=intent.getIntExtra("String_Node_Str",-1);
if (record == -1) {
  break;
}
FormRecord r=CommCareApplication.instance().getUserStorage(FormRecord.class).read(record);
SqlStorage<SessionStateDescriptor> ssdStorage=CommCareApplication.instance().getUserStorage(SessionStateDescriptor.class);
Vector<Integer> ssds=ssdStorage.getIDsForValue(SessionStateDescriptor.META_FORM_RECORD_ID,r.getID());
AndroidSessionWrapper currentState=CommCareApplication.instance().getCurrentSessionWrapper();
if (ssds.size() == 1) {
  currentState.loadFromStateDescription(ssdStorage.read(ssds.firstElement()));
}
 else {
  currentState.setFormRecordId(r.getID());
}
AndroidCommCarePlatform platform=CommCareApplication.instance().getCommCarePlatform();
formEntry(platform.getFormContentUri(r.getFormNamespace()),r);
return;
}
break;
case GET_COMMAND:
boolean fetchNext=processReturnFromGetCommand(resultCode,intent);
if (!fetchNext) {
return;
}
break;
case GET_CASE:
fetchNext=processReturnFromGetCase(resultCode,intent);
if (!fetchNext) {
return;
}
break;
case MODEL_RESULT:
fetchNext=processReturnFromFormEntry(resultCode,intent);
if (!fetchNext) {
return;
}
break;
case AUTHENTICATION_FOR_PIN:
if (resultCode == RESULT_OK) {
launchPinCreateScreen(LoginMode.PASSWORD);
}
return;
case CREATE_PIN:
boolean choseRememberPassword=intent != null && intent.getBooleanExtra(CreatePinActivity.CHOSE_REMEMBER_PASSWORD,false);
if (choseRememberPassword) {
CommCareApplication.instance().closeUserSession();
}
 else if (resultCode == RESULT_OK) {
Toast.makeText(this,Localization.get("String_Node_Str"),Toast.LENGTH_SHORT).show();
}
 else {
Toast.makeText(this,Localization.get("String_Node_Str"),Toast.LENGTH_SHORT).show();
}
return;
case MAKE_REMOTE_POST:
stepBackIfCancelled(resultCode);
if (resultCode == RESULT_OK) {
CommCareApplication.instance().getCurrentSessionWrapper().terminateSession();
}
break;
case GET_REMOTE_DATA:
stepBackIfCancelled(resultCode);
break;
}
sessionNavigationProceedingAfterOnResume=true;
startNextSessionStepSafe();
}
super.onActivityResult(requestCode,resultCode,intent);
}