Program: 142214
Project: 142214
Buggy source:
private void dispatchHomeScreen(){
  try {
    if (CommCareApplication._().getAppResourceState() == CommCareApplication.STATE_CORRUPTED || CommCareApplication._().getDatabaseState() == CommCareApplication.STATE_CORRUPTED) {
      if (!CommCareApplication._().isStorageAvailable()) {
        createNoStorageDialog();
      }
 else {
        try {
          CommCareApplication._().getSession();
          showDialog(DIALOG_CORRUPTED);
        }
 catch (        SessionUnavailableException sue) {
          returnToLogin();
        }
      }
    }
 else     if (CommCareApplication._().getAppResourceState() != CommCareApplication.STATE_READY || CommCareApplication._().getDatabaseState() != CommCareApplication.STATE_READY) {
      Intent i=new Intent(getApplicationContext(),CommCareSetupActivity.class);
      this.startActivityForResult(i,INIT_APP);
    }
 else     if (!CommCareApplication._().getCurrentApp().areResourcesValidated() && !DeveloperPreferences.isSuperuserEnabled()) {
      Intent i=new Intent(this,CommCareVerificationActivity.class);
      this.startActivityForResult(i,MISSING_MEDIA_ACTIVITY);
    }
 else     if (!CommCareApplication._().getSession().isActive()) {
      returnToLogin();
    }
 else     if (this.getIntent().hasExtra(SESSION_REQUEST)) {
      wasExternal=true;
      String sessionRequest=this.getIntent().getStringExtra(SESSION_REQUEST);
      SessionStateDescriptor ssd=new SessionStateDescriptor();
      ssd.fromBundle(sessionRequest);
      CommCareApplication._().getCurrentSessionWrapper().loadFromStateDescription(ssd);
      this.startNextFetch();
      return;
    }
 else     if (this.getIntent().hasExtra(AndroidShortcuts.EXTRA_KEY_SHORTCUT)) {
      CommCareApplication._().getCurrentSession().setCommand(this.getIntent().getStringExtra(AndroidShortcuts.EXTRA_KEY_SHORTCUT));
      startNextFetch();
      this.getIntent().removeExtra(AndroidShortcuts.EXTRA_KEY_SHORTCUT);
    }
 else     if (CommCareApplication._().isUpdatePending()) {
      Logger.log(AndroidLogger.TYPE_MAINTENANCE,"String_Node_Str");
      Intent i=new Intent(getApplicationContext(),CommCareSetupActivity.class);
      SharedPreferences prefs=CommCareApplication._().getCurrentApp().getAppPreferences();
      String ref=prefs.getString("String_Node_Str",null);
      i.putExtra(CommCareSetupActivity.KEY_PROFILE_REF,ref);
      i.putExtra(CommCareSetupActivity.KEY_UPGRADE_MODE,true);
      i.putExtra(CommCareSetupActivity.KEY_AUTO,true);
      startActivityForResult(i,UPGRADE_APP);
      return;
    }
 else     if (CommCareApplication._().isSyncPending(false)) {
      long lastSync=CommCareApplication._().getCurrentApp().getAppPreferences().getLong("String_Node_Str",0);
      String footer=lastSync == 0 ? "String_Node_Str" : SimpleDateFormat.getDateTimeInstance().format(lastSync);
      Logger.log(AndroidLogger.TYPE_USER,"String_Node_Str" + footer);
      refreshView();
      this.syncData(false);
    }
 else {
      refreshView();
    }
  }
 catch (  SessionUnavailableException sue) {
    returnToLogin();
  }
}

Fixed version (ground truth):
private void dispatchHomeScreen(){
  try {
    if (CommCareApplication._().getAppResourceState() == CommCareApplication.STATE_CORRUPTED || CommCareApplication._().getDatabaseState() == CommCareApplication.STATE_CORRUPTED) {
      if (!CommCareApplication._().isStorageAvailable()) {
        createNoStorageDialog();
      }
 else {
        try {
          CommCareApplication._().getSession();
          showDialog(DIALOG_CORRUPTED);
        }
 catch (        SessionUnavailableException sue) {
          returnToLogin();
        }
      }
    }
 else     if (CommCareApplication._().getAppResourceState() != CommCareApplication.STATE_READY || CommCareApplication._().getDatabaseState() != CommCareApplication.STATE_READY) {
      Intent i=new Intent(getApplicationContext(),CommCareSetupActivity.class);
      this.startActivityForResult(i,INIT_APP);
    }
 else     if (!CommCareApplication._().getCurrentApp().areResourcesValidated() && !DeveloperPreferences.isSuperuserEnabled()) {
      Intent i=new Intent(this,CommCareVerificationActivity.class);
      this.startActivityForResult(i,MISSING_MEDIA_ACTIVITY);
    }
 else     if (!CommCareApplication._().getSession().isActive()) {
      returnToLogin();
    }
 else     if (this.getIntent().hasExtra(SESSION_REQUEST)) {
      wasExternal=true;
      String sessionRequest=this.getIntent().getStringExtra(SESSION_REQUEST);
      SessionStateDescriptor ssd=new SessionStateDescriptor();
      ssd.fromBundle(sessionRequest);
      CommCareApplication._().getCurrentSessionWrapper().loadFromStateDescription(ssd);
      this.startNextFetch();
      return;
    }
 else     if (this.getIntent().hasExtra(AndroidShortcuts.EXTRA_KEY_SHORTCUT)) {
      CommCareApplication._().getCurrentSession().setCommand(this.getIntent().getStringExtra(AndroidShortcuts.EXTRA_KEY_SHORTCUT));
      startNextFetch();
      this.getIntent().removeExtra(AndroidShortcuts.EXTRA_KEY_SHORTCUT);
    }
 else     if (CommCareApplication._().isUpdatePending()) {
      Logger.log(AndroidLogger.TYPE_MAINTENANCE,"String_Node_Str");
      Intent i=new Intent(getApplicationContext(),CommCareSetupActivity.class);
      SharedPreferences prefs=CommCareApplication._().getCurrentApp().getAppPreferences();
      String ref=prefs.getString("String_Node_Str",null);
      i.putExtra(CommCareSetupActivity.KEY_PROFILE_REF,ref);
      i.putExtra(CommCareSetupActivity.KEY_UPGRADE_MODE,true);
      i.putExtra(CommCareSetupActivity.KEY_AUTO,true);
      startActivityForResult(i,UPGRADE_APP);
      return;
    }
 else     if (CommCareApplication._().isSyncPending(false)) {
      long lastSync=CommCareApplication._().getCurrentApp().getAppPreferences().getLong("String_Node_Str",0);
      String footer=lastSync == 0 ? "String_Node_Str" : SimpleDateFormat.getDateTimeInstance().format(lastSync);
      Logger.log(AndroidLogger.TYPE_USER,"String_Node_Str" + footer);
      refreshView();
      if (!this.checkAndStartUnsentTask(true)) {
        this.syncData(false);
      }
    }
 else {
      refreshView();
    }
  }
 catch (  SessionUnavailableException sue) {
    returnToLogin();
  }
}