nus-yam/ex-repair huggingface dataset:
Program: 142156
Project: 142156
Buggy source:
@Override public void deliverResult(List<Entity<TreeReference>> entities,List<TreeReference> references,NodeEntityFactory factory){
  loader=null;
  Detail detail=session.getDetail(selectDatum.getShortDetail());
  int[] order=detail.getSortOrder();
  for (int i=0; i < detail.getFields().length; ++i) {
    String header=detail.getFields()[i].getHeader().evaluate();
    if (order.length == 0 && !"String_Node_Str".equals(header)) {
      order=new int[]{i};
    }
  }
  ListView view=((ListView)this.findViewById(R.id.screen_entity_select_list));
  setupDivider(view);
  adapter=new EntityListAdapter(EntitySelectActivity.this,detail,references,entities,order,tts,factory);
  view.setAdapter(adapter);
  adapter.registerDataSetObserver(this.mListStateObserver);
  findViewById(R.id.entity_select_loading).setVisibility(View.GONE);
  if (adapter != null && filterString != null && !"String_Node_Str".equals(filterString)) {
    adapter.applyFilter(filterString);
  }
  if (inAwesomeMode) {
    updateSelectedItem(true);
  }
  rebuildMenus();
  this.startTimer();
}

Fixed version (ground truth):
@Override public void deliverResult(List<Entity<TreeReference>> entities,List<TreeReference> references,NodeEntityFactory factory){
  loader=null;
  Detail detail=session.getDetail(selectDatum.getShortDetail());
  int[] order=detail.getSortOrder();
  for (int i=0; i < detail.getFields().length; ++i) {
    String header=detail.getFields()[i].getHeader().evaluate();
    if (order.length == 0 && !"String_Node_Str".equals(header)) {
      order=new int[]{i};
    }
  }
  ListView view=((ListView)this.findViewById(R.id.screen_entity_select_list));
  setupDivider(view);
  adapter=new EntityListAdapter(EntitySelectActivity.this,detail,references,entities,order,tts,factory);
  view.setAdapter(adapter);
  adapter.registerDataSetObserver(this.mListStateObserver);
  findViewById(R.id.entity_select_loading).setVisibility(View.GONE);
  if (adapter != null && filterString != null && !"String_Node_Str".equals(filterString)) {
    adapter.applyFilter(filterString);
  }
  if (inAwesomeMode) {
    updateSelectedItem(true);
  }
  this.startTimer();
}
Program: 142157
Project: 142157
Buggy source:
@Override public boolean onQueryTextChange(String newText){
  lastQueryString=newText;
  if (adapter != null) {
    adapter.applyFilter(newText);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean onQueryTextChange(String newText){
  lastQueryString=newText;
  filterString=newText;
  if (adapter != null) {
    adapter.applyFilter(newText);
  }
  return false;
}
Program: 142160
Project: 142160
Buggy source:
private void setupUI(){
  setContentView(R.layout.screen_form_entry);
  ImageButton nextButton=(ImageButton)this.findViewById(R.id.nav_btn_next);
  ImageButton prevButton=(ImageButton)this.findViewById(R.id.nav_btn_prev);
  nextButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      if (!"String_Node_Str".equals(v.getTag())) {
        FormEntryActivity.this.showNextView();
      }
 else {
        triggerUserFormComplete();
      }
    }
  }
);
  prevButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      if (!"String_Node_Str".equals(v.getTag())) {
        FormEntryActivity.this.showPreviousView(true);
      }
 else {
        FormEntryActivity.this.triggerUserQuitInput();
      }
    }
  }
);
  mViewPane=(ViewGroup)findViewById(R.id.form_entry_pane);
  isAnimatingSwipe=false;
  isDialogShowing=false;
  mCurrentView=null;
  mInAnimation=null;
  mOutAnimation=null;
  mGestureDetector=new GestureDetector(this);
}

Fixed version (ground truth):
private void setupUI(){
  setContentView(R.layout.screen_form_entry);
  ImageButton nextButton=(ImageButton)this.findViewById(R.id.nav_btn_next);
  ImageButton prevButton=(ImageButton)this.findViewById(R.id.nav_btn_prev);
  nextButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      if (!"String_Node_Str".equals(v.getTag())) {
        FormEntryActivity.this.showNextView();
      }
 else {
        triggerUserFormComplete();
      }
    }
  }
);
  prevButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      if (!"String_Node_Str".equals(v.getTag())) {
        FormEntryActivity.this.showPreviousView(true);
      }
 else {
        FormEntryActivity.this.triggerUserQuitInput();
      }
    }
  }
);
  mViewPane=(ViewGroup)findViewById(R.id.form_entry_pane);
  requestMajorLayoutUpdates();
  isAnimatingSwipe=false;
  isDialogShowing=false;
  mCurrentView=null;
  mInAnimation=null;
  mOutAnimation=null;
  mGestureDetector=new GestureDetector(this);
}
Program: 142161
Project: 142161
Buggy source:
protected void setTextInputType(EditText mAnswer){
  if (secret) {
    mAnswer.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    mAnswer.setTransformationMethod(PasswordTransformationMethod.getInstance());
  }
}

Fixed version (ground truth):
protected void setTextInputType(EditText mAnswer){
  if (secret) {
    mAnswer.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    mAnswer.setTransformationMethod(PasswordTransformationMethod.getInstance());
  }
 else {
    mAnswer.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER);
  }
}
Program: 142162
Project: 142162
Buggy source:
public static boolean imageAboveTextEnabled(){
}

Fixed version (ground truth):
public static boolean imageAboveTextEnabled(){
  return doesPropertyMatch(ALTERNATE_QUESTION_LAYOUT_ENABLED,CommCarePreferences.NO,CommCarePreferences.YES);
}
Program: 142163
Project: 142163
Buggy source:
public static boolean isHomeReportEnabled(){
  SharedPreferences properties=CommCareApplication._().getCurrentApp().getAppPreferences();
  return properties.getString(HOME_REPORT_ENABLED,CommCarePreferences.NO).equals(CommCarePreferences.YES);
}

Fixed version (ground truth):
public static boolean isHomeReportEnabled(){
  return doesPropertyMatch(HOME_REPORT_ENABLED,CommCarePreferences.NO,CommCarePreferences.YES);
}
Program: 142164
Project: 142164
Buggy source:
/** 
 * Attempts to inflate an image from a CommCare UI definition source.
 * @param jrUri The image to inflate
 * @param boundingWidth the width of the container this image is being inflated into, to serveas a max width. If passed in as -1, gets set to screen width
 * @param boundingHeight the height fo the container this image is being inflated into, toserve as a max height. If passed in as -1, gets set to screen height
 * @return A bitmap if one could be created. Null if error occurs or the image is unavailable.
 */
public static Bitmap inflateDisplayImage(Context context,String jrUri,int boundingWidth,int boundingHeight){
  if (jrUri == null || jrUri.equals("String_Node_Str")) {
    return null;
  }
  try {
    String imageFilename=ReferenceManager._().DeriveReference(jrUri).getLocalURI();
    final File imageFile=new File(imageFilename);
    if (!imageFile.exists()) {
      return null;
    }
    Display display=((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    if (boundingHeight == -1) {
      boundingHeight=display.getHeight();
    }
    if (boundingWidth == -1) {
      boundingWidth=display.getWidth();
    }
    Log.i("String_Node_Str","String_Node_Str" + boundingHeight + "String_Node_Str"+ boundingWidth);
    if (DeveloperPreferences.isSmartInflationEnabled()) {
      return getBitmapScaledForNativeDensity(context.getResources().getDisplayMetrics(),imageFile.getAbsolutePath(),boundingHeight,boundingWidth,DeveloperPreferences.getTargetInflationDensity());
    }
 else {
      return getBitmapScaledToContainer(imageFile.getAbsolutePath(),boundingHeight,boundingWidth);
    }
  }
 catch (  InvalidReferenceException e) {
    Log.e("String_Node_Str","String_Node_Str" + e.getReferenceString());
    e.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
public static Bitmap inflateDisplayImage(Context context,String jrUri){
  return inflateDisplayImage(context,jrUri,-1,-1);
}
Program: 142166
Project: 142166
Buggy source:
public static void setupPrototypeFactory(){
  LivePrototypeFactory prototypeFactory=new LivePrototypeFactory();
  PrototypeFactory.setStaticHasher(prototypeFactory);
  DbUtil.setDBUtilsPrototypeFactory(prototypeFactory);
}

Fixed version (ground truth):
public static void setupPrototypeFactory(){
  LivePrototypeFactory prototypeFactory=new LivePrototypeFactory();
  PrototypeFactory.setStaticHasher(prototypeFactory.getLiveHasher());
  DbUtil.setDBUtilsPrototypeFactory(prototypeFactory);
}
Program: 142168
Project: 142168
Buggy source:
private String readInput(InputStream stream,CommCareTransactionParserFactory factory) throws InvalidStructureException, IOException, XmlPullParserException, UnfullfilledRequirementsException, SessionUnavailableException {
  DataModelPullParser parser;
  factory.initCaseParser();
  factory.initStockParser();
  Hashtable<String,String> formNamespaces=new Hashtable<String,String>();
  for (  String xmlns : CommCareApplication._().getCommCarePlatform().getInstalledForms()) {
    Cursor cur=c.getContentResolver().query(CommCareApplication._().getCommCarePlatform().getFormContentUri(xmlns),new String[]{FormsColumns.FORM_FILE_PATH},null,null,null);
    if (cur.moveToFirst()) {
      String path=cur.getString(cur.getColumnIndex(FormsColumns.FORM_FILE_PATH));
      formNamespaces.put(xmlns,path);
    }
 else {
      throw new RuntimeException("String_Node_Str" + CommCareApplication._().getCommCarePlatform().getFormContentUri(xmlns));
    }
    cur.close();
  }
  factory.initFormInstanceParser(formNamespaces);
  SQLiteDatabase db=CommCareApplication._().getUserDbHandle();
  try {
    db.beginTransaction();
    parser=new DataModelPullParser(stream,factory,this);
    parser.parse();
    db.setTransactionSuccessful();
  }
  finally {
    db.endTransaction();
  }
  return factory.getSyncToken();
}

Fixed version (ground truth):
private String readInput(InputStream stream,CommCareTransactionParserFactory factory) throws InvalidStructureException, IOException, XmlPullParserException, UnfullfilledRequirementsException, SessionUnavailableException {
  DataModelPullParser parser;
  factory.initCaseParser();
  factory.initStockParser();
  Hashtable<String,String> formNamespaces=new Hashtable<String,String>();
  for (  String xmlns : CommCareApplication._().getCommCarePlatform().getInstalledForms()) {
    Cursor cur=c.getContentResolver().query(CommCareApplication._().getCommCarePlatform().getFormContentUri(xmlns),new String[]{FormsColumns.FORM_FILE_PATH},null,null,null);
    if (cur.moveToFirst()) {
      String path=cur.getString(cur.getColumnIndex(FormsColumns.FORM_FILE_PATH));
      formNamespaces.put(xmlns,path);
    }
 else {
      throw new RuntimeException("String_Node_Str" + CommCareApplication._().getCommCarePlatform().getFormContentUri(xmlns));
    }
    cur.close();
  }
  factory.initFormInstanceParser(formNamespaces);
  SQLiteDatabase db=CommCareApplication._().getUserDbHandle();
  try {
    db.beginTransaction();
    parser=new DataModelPullParser(stream,factory,true,false,this);
    parser.parse();
    db.setTransactionSuccessful();
  }
  finally {
    db.endTransaction();
  }
  return factory.getSyncToken();
}
Program: 142169
Project: 142169
Buggy source:
@Override protected boolean onForwardSwipe(){
  int event=mFormController.getEvent(mFormController.getNextFormIndex(mFormController.getFormIndex(),true));
  if (event != FormEntryController.EVENT_END_OF_FORM) {
    showNextView();
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override protected boolean onForwardSwipe(){
  ImageButton nextButton=(ImageButton)this.findViewById(R.id.nav_btn_next);
  if (nextButton.getTag().equals(NAV_STATE_NEXT)) {
    showNextView();
    return true;
  }
  return false;
}
Program: 142172
Project: 142172
Buggy source:
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void setColor(int backgroundColor){
  ColorDrawable colorDrawable=new ColorDrawable(backgroundColor);
  ColorDrawable disabledColor=new ColorDrawable(getResources().getColor(R.color.grey));
  int color=ViewUtil.getColorDrawableColor(colorDrawable);
  float[] hsvOutput=new float[3];
  Color.colorToHSV(color,hsvOutput);
  hsvOutput[2]=(float)(hsvOutput[2] / 1.5);
  int selectedColor=Color.HSVToColor(hsvOutput);
  ColorDrawable pressedBackground=new ColorDrawable(selectedColor);
  StateListDrawable sld=new StateListDrawable();
  sld.addState(new int[]{android.R.attr.state_enabled},colorDrawable);
  sld.addState(new int[]{android.R.attr.state_pressed},pressedBackground);
  sld.addState(StateSet.WILD_CARD,disabledColor);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    this.setBackground(sld);
  }
 else {
    this.setBackgroundDrawable(sld);
  }
}

Fixed version (ground truth):
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void setColor(int backgroundColor){
  ColorDrawable colorDrawable=new ColorDrawable(backgroundColor);
  ColorDrawable disabledColor=new ColorDrawable(getResources().getColor(R.color.grey));
  int color=ViewUtil.getColorDrawableColor(colorDrawable);
  float[] hsvOutput=new float[3];
  Color.colorToHSV(color,hsvOutput);
  hsvOutput[2]=(float)(hsvOutput[2] / 1.5);
  int selectedColor=Color.HSVToColor(hsvOutput);
  ColorDrawable pressedBackground=new ColorDrawable(selectedColor);
  StateListDrawable sld=new StateListDrawable();
  sld.addState(new int[]{-android.R.attr.state_enabled},disabledColor);
  sld.addState(new int[]{android.R.attr.state_pressed},pressedBackground);
  sld.addState(StateSet.WILD_CARD,colorDrawable);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    this.setBackground(sld);
  }
 else {
    this.setBackgroundDrawable(sld);
  }
}
Program: 142173
Project: 142173
Buggy source:
@Override public void onCreate(){
  super.onCreate();
  StethoInitializer.initStetho(this);
  Collect.setStaticApplicationContext(this);
  AndroidClassHasher.registerAndroidClassHashStrategy();
  AndroidUtil.initializeStaticHandlers();
  CommCareApplication.app=this;
  PreInitLogger pil=new PreInitLogger();
  Logger.registerLogger(pil);
  System.setProperty("String_Node_Str","String_Node_Str");
  Thread.setDefaultUncaughtExceptionHandler(new CommCareExceptionHandler(Thread.getDefaultUncaughtExceptionHandler()));
  PropertyManager.setPropertyManager(new ODKPropertyManager());
  SQLiteDatabase.loadLibs(this);
  setRoots();
  prepareTemporaryStorage();
  dbState=initGlobalDb();
  try {
    LegacyInstallUtils.checkForLegacyInstall(this,this.getGlobalStorage(ApplicationRecord.class));
  }
 catch (  SessionUnavailableException|StorageFullException sfe) {
    throw new RuntimeException(sfe);
  }
 finally {
    Logger.registerLogger(new AndroidLogger(this.getGlobalStorage(AndroidLogEntry.STORAGE_KEY,AndroidLogEntry.class)));
    pil.dumpToNewLogger();
  }
  intializeDefaultLocalizerData();
  if (dbState != STATE_MIGRATION_FAILED && dbState != STATE_MIGRATION_QUESTIONABLE) {
    initializeAppResourcesOnStartup();
  }
  ACRAUtil.initACRA(this);
}

Fixed version (ground truth):
@Override public void onCreate(){
  super.onCreate();
  StethoInitializer.initStetho(this);
  Collect.setStaticApplicationContext(this);
  AndroidClassHasher.registerAndroidClassHashStrategy();
  AndroidUtil.initializeStaticHandlers();
  CommCareApplication.app=this;
  PreInitLogger pil=new PreInitLogger();
  Logger.registerLogger(pil);
  System.setProperty("String_Node_Str","String_Node_Str");
  Thread.setDefaultUncaughtExceptionHandler(new CommCareExceptionHandler(Thread.getDefaultUncaughtExceptionHandler()));
  PropertyManager.setPropertyManager(new ODKPropertyManager());
  SQLiteDatabase.loadLibs(this);
  setRoots();
  prepareTemporaryStorage();
  dbState=initGlobalDb();
  try {
    LegacyInstallUtils.checkForLegacyInstall(this,this.getGlobalStorage(ApplicationRecord.class));
  }
 catch (  SessionUnavailableException|StorageFullException sfe) {
    throw new RuntimeException(sfe);
  }
 finally {
    Logger.registerLogger(new AndroidLogger(this.getGlobalStorage(AndroidLogEntry.STORAGE_KEY,AndroidLogEntry.class)));
    pil.dumpToNewLogger();
  }
  intializeDefaultLocalizerData();
  if (dbState != STATE_MIGRATION_FAILED && dbState != STATE_MIGRATION_QUESTIONABLE) {
    initializeAnAppOnStartup();
  }
  ACRAUtil.initACRA(this);
}
Program: 142174
Project: 142174
Buggy source:
public static Bitmap getBitmapScaledToDisplay(File f,int screenHeight,int screenWidth){
  BitmapFactory.Options o=new BitmapFactory.Options();
  o.inJustDecodeBounds=true;
  BitmapFactory.decodeFile(f.getAbsolutePath(),o);
  int heightScale=o.outHeight / screenHeight;
  int widthScale=o.outWidth / screenWidth;
  int scale=Math.max(widthScale,heightScale);
  BitmapFactory.Options options=new BitmapFactory.Options();
  options.inSampleSize=scale;
  Bitmap b=BitmapFactory.decodeFile(f.getAbsolutePath(),options);
  if (b != null) {
    Log.i(t,"String_Node_Str" + screenHeight + "String_Node_Str"+ screenWidth+ "String_Node_Str"+ scale+ "String_Node_Str"+ b.getHeight()+ "String_Node_Str"+ b.getWidth());
  }
  return b;
}

Fixed version (ground truth):
public static Bitmap getBitmapScaledToDisplay(File f,int screenHeight,int screenWidth){
  BitmapFactory.Options o=new BitmapFactory.Options();
  o.inJustDecodeBounds=true;
  BitmapFactory.decodeFile(f.getAbsolutePath(),o);
  int imageHeight=o.outHeight;
  int imageWidth=o.outWidth;
  int heightScale=Math.round((float)imageHeight / screenHeight);
  int widthScale=Math.round((float)imageWidth / screenWidth);
  int scale=Math.max(widthScale,heightScale);
  if (scale == 0) {
    scale=1;
  }
  return performSafeScaleDown(f,scale);
}
Program: 142176
Project: 142176
Buggy source:
@Override public IAnswerData getAnswer(){
  mDatePicker.clearFocus();
  DateTime ldt=new DateTime(mDatePicker.getYear(),mDatePicker.getMonth() + 1,mDatePicker.getDayOfMonth(),0,0);
  return new DateData(ldt.toDate());
}

Fixed version (ground truth):
@Override public IAnswerData getAnswer(){
  mDatePicker.clearFocus();
  LocalDate ldt=new LocalDate(mDatePicker.getYear(),mDatePicker.getMonth() + 1,mDatePicker.getDayOfMonth());
  return new DateData(ldt.toDate());
}
Program: 142179
Project: 142179
Buggy source:
@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
switch (requestCode) {
case SEAT_APP_ACTIVITY:
    if (resultCode == RESULT_OK) {
      loadFields(false);
      welcomeMessage.setText(Localization.get("String_Node_Str"));
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        refreshActionBar();
      }
    }
}
}

Fixed version (ground truth):
@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
switch (requestCode) {
case SEAT_APP_ACTIVITY:
    if (resultCode == RESULT_OK) {
      refreshForNewApp();
    }
}
}
Program: 142180
Project: 142180
Buggy source:
private void refreshView(){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    refreshActionBar();
  }
  ArrayList<ApplicationRecord> readyApps=CommCareApplication._().getUsableAppRecords();
  if (readyApps.size() == 1) {
    spinner.setVisibility(View.GONE);
    welcomeMessage.setText(Localization.get("String_Node_Str"));
    ApplicationRecord r=readyApps.get(0);
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
    prefs.edit().putString(KEY_LAST_APP,r.getUniqueId()).commit();
  }
 else {
    welcomeMessage.setText(Localization.get("String_Node_Str"));
    ArrayList<String> appNames=new ArrayList<>();
    for (    ApplicationRecord r : readyApps) {
      appNames.add(r.getDisplayName());
      appIdDropdownList.add(r.getUniqueId());
    }
    ArrayAdapter<String> adapter=new ArrayAdapter<>(this,R.layout.spinner_text_view,appNames);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);
    String currAppId=CommCareApplication._().getCurrentApp().getUniqueId();
    int position=appIdDropdownList.indexOf(currAppId);
    spinner.setSelection(position);
    spinner.setVisibility(View.VISIBLE);
  }
}

Fixed version (ground truth):
private void refreshView(){
  refreshForNewApp();
  ArrayList<ApplicationRecord> readyApps=CommCareApplication._().getUsableAppRecords();
  if (readyApps.size() == 1) {
    spinner.setVisibility(View.GONE);
    welcomeMessage.setText(Localization.get("String_Node_Str"));
    ApplicationRecord r=readyApps.get(0);
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
    prefs.edit().putString(KEY_LAST_APP,r.getUniqueId()).commit();
  }
 else {
    welcomeMessage.setText(Localization.get("String_Node_Str"));
    ArrayList<String> appNames=new ArrayList<>();
    appIdDropdownList.clear();
    for (    ApplicationRecord r : readyApps) {
      appNames.add(r.getDisplayName());
      appIdDropdownList.add(r.getUniqueId());
    }
    ArrayAdapter<String> adapter=new ArrayAdapter<>(this,R.layout.spinner_text_view,appNames);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);
    String currAppId=CommCareApplication._().getCurrentApp().getUniqueId();
    int position=appIdDropdownList.indexOf(currAppId);
    spinner.setSelection(position);
    spinner.setVisibility(View.VISIBLE);
  }
}
Program: 142181
Project: 142181
Buggy source:
private void startValidationActivity(){
  Intent i=new Intent(this,CommCareVerificationActivity.class);
  CommCareHomeActivity.this.startActivityForResult(i,MEDIA_VALIDATOR_ACTIVITY);
}

Fixed version (ground truth):
private void startValidationActivity(){
  Intent i=new Intent(this,CommCareVerificationActivity.class);
  i.putExtra(CommCareVerificationActivity.KEY_LAUNCH_FROM_SETTINGS,true);
  CommCareHomeActivity.this.startActivityForResult(i,MEDIA_VALIDATOR_ACTIVITY);
}
Program: 142182
Project: 142182
Buggy source:
public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.missing_multimedia_layout);
  retryButton=(Button)findViewById(R.id.screen_multimedia_retry);
  retryButton.setOnClickListener(this);
  this.fromManager=this.getIntent().getBooleanExtra(AppManagerActivity.KEY_LAUNCH_FROM_MANAGER,false);
  if (fromManager) {
    Button skipButton=(Button)findViewById(R.id.skip_verification_button);
    skipButton.setVisibility(View.VISIBLE);
    skipButton.setOnClickListener(this);
  }
  missingMediaPrompt=(TextView)findViewById(R.id.MissingMediaPrompt);
  fire();
}

Fixed version (ground truth):
public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.missing_multimedia_layout);
  retryButton=(Button)findViewById(R.id.screen_multimedia_retry);
  retryButton.setOnClickListener(this);
  this.fromSettings=this.getIntent().getBooleanExtra(KEY_LAUNCH_FROM_SETTINGS,false);
  this.fromManager=this.getIntent().getBooleanExtra(AppManagerActivity.KEY_LAUNCH_FROM_MANAGER,false);
  if (fromManager) {
    Button skipButton=(Button)findViewById(R.id.skip_verification_button);
    skipButton.setVisibility(View.VISIBLE);
    skipButton.setOnClickListener(this);
  }
  missingMediaPrompt=(TextView)findViewById(R.id.MissingMediaPrompt);
  fire();
}
Program: 142183
Project: 142183
Buggy source:
@Override public void onResume(){
  super.onResume();
  boolean shouldBeHere=fromManager || CommCareApplication._().shouldSeeMMVerification();
  if (!shouldBeHere) {
    Intent i=new Intent(this,CommCareHomeActivity.class);
    startActivity(i);
  }
}

Fixed version (ground truth):
@Override public void onResume(){
  super.onResume();
  boolean shouldBeHere=fromManager || fromSettings || CommCareApplication._().shouldSeeMMVerification();
  if (!shouldBeHere) {
    Intent i=new Intent(this,CommCareHomeActivity.class);
    startActivity(i);
  }
}
Program: 142184
Project: 142184
Buggy source:
private void markSenseIncompleteUnsent(final SQLiteDatabase db){
  if (inSenseMode) {
    SqlStorage<FormRecord> storage=new SqlStorage<FormRecord>(FormRecord.STORAGE_KEY,FormRecord.class,new ConcreteDbHelper(c,db));
    for (    FormRecord record : storage) {
      if (FormRecord.STATUS_INCOMPLETE.equals(record.getStatus())) {
        storage.write(record.updateStatus(record.getInstanceURI().toString(),FormRecord.STATUS_COMPLETE));
      }
    }
  }
}

Fixed version (ground truth):
private void markSenseIncompleteUnsent(final SQLiteDatabase db){
  if (inSenseMode) {
    SqlStorage<FormRecord> storage=new SqlStorage<FormRecord>(FormRecord.STORAGE_KEY,FormRecord.class,new ConcreteDbHelper(c,db));
    for (    FormRecord record : storage) {
      if (FormRecord.STATUS_INCOMPLETE.equals(record.getStatus())) {
        storage.write(record.updateInstanceAndStatus(record.getInstanceURI().toString(),FormRecord.STATUS_COMPLETE));
      }
    }
  }
}
Program: 142186
Project: 142186
Buggy source:
/** 
 * Clears out all of the elements of this wrapper which are for an individual traversal. Includes any cached info (since the casedb might have changed) and the individual id's and such.
 */
private void cleanVolatiles(){
  formRecordId=-1;
  instanceUri=null;
  instanceStatus=null;
  sessionStateRecordId=-1;
  initializer=null;
}

Fixed version (ground truth):
/** 
 * Clears out all of the elements of this wrapper which are for an individual traversal. Includes any cached info (since the casedb might have changed) and the individual id's and such.
 */
private void cleanVolatiles(){
  formRecordId=-1;
  sessionStateRecordId=-1;
  initializer=null;
}
Program: 142188
Project: 142188
Buggy source:
public FormRecord updateRecordStatus(FormRecord record,String newStatus) throws IOException, StorageFullException {
  record=record.updateStatus(record.getInstanceURI().toString(),newStatus);
  storage.write(record);
  return record;
}

Fixed version (ground truth):
public FormRecord updateRecordStatus(FormRecord record,String newStatus) throws IOException, StorageFullException {
  record=record.updateInstanceAndStatus(record.getInstanceURI().toString(),newStatus);
  storage.write(record);
  return record;
}
Program: 142191
Project: 142191
Buggy source:
@Override protected Integer doTaskBackground(Void... params){
  SqlStorage<FormRecord> storage=CommCareApplication._().getUserStorage(FormRecord.class);
  Vector<Integer> recordsToRemove=storage.getIDsForValues(new String[]{FormRecord.META_STATUS},new String[]{FormRecord.STATUS_SAVED});
  int oldrecords=recordsToRemove.size();
  Vector<Integer> unindexedRecords=storage.getIDsForValues(new String[]{FormRecord.META_STATUS},new String[]{FormRecord.STATUS_UNINDEXED});
  int count=0;
  for (  int recordID : unindexedRecords) {
    FormRecord r=storage.read(recordID);
    try {
      updateAndWriteRecord(context,platform,r,FormRecord.STATUS_SAVED,storage);
    }
 catch (    FileNotFoundException|InvalidStructureException e) {
      recordsToRemove.add(recordID);
    }
catch (    XmlPullParserException|IOException|UnfullfilledRequirementsException e) {
    }
    count++;
    this.publishProgress(count,unindexedRecords.size());
  }
  this.publishProgress(STATUS_CLEANUP);
  SqlStorage<SessionStateDescriptor> ssdStorage=CommCareApplication._().getUserStorage(SessionStateDescriptor.class);
  for (  int recordID : recordsToRemove) {
    wipeRecord(context,-1,recordID,storage,ssdStorage);
  }
  Log.d(TAG,"String_Node_Str" + unindexedRecords.size() + "String_Node_Str"+ oldrecords+ "String_Node_Str"+ (recordsToRemove.size() - oldrecords)+ "String_Node_Str");
  return SUCCESS;
}

Fixed version (ground truth):
@Override protected Integer doTaskBackground(Void... params){
  SqlStorage<FormRecord> storage=CommCareApplication._().getUserStorage(FormRecord.class);
  Vector<Integer> recordsToRemove=storage.getIDsForValues(new String[]{FormRecord.META_STATUS},new String[]{FormRecord.STATUS_SAVED});
  int oldrecords=recordsToRemove.size();
  Vector<Integer> unindexedRecords=storage.getIDsForValues(new String[]{FormRecord.META_STATUS},new String[]{FormRecord.STATUS_UNINDEXED});
  int count=0;
  for (  int recordID : unindexedRecords) {
    FormRecord r=storage.read(recordID);
    try {
      updateAndWriteUnindexedRecord(context,platform,r,storage);
    }
 catch (    FileNotFoundException|InvalidStructureException e) {
      recordsToRemove.add(recordID);
    }
catch (    XmlPullParserException|IOException|UnfullfilledRequirementsException e) {
    }
    count++;
    this.publishProgress(count,unindexedRecords.size());
  }
  this.publishProgress(STATUS_CLEANUP);
  SqlStorage<SessionStateDescriptor> ssdStorage=CommCareApplication._().getUserStorage(SessionStateDescriptor.class);
  for (  int recordID : recordsToRemove) {
    wipeRecord(context,-1,recordID,storage,ssdStorage);
  }
  Log.d(TAG,"String_Node_Str" + unindexedRecords.size() + "String_Node_Str"+ oldrecords+ "String_Node_Str"+ (recordsToRemove.size() - oldrecords)+ "String_Node_Str");
  return SUCCESS;
}
Program: 142193
Project: 142193
Buggy source:
@Override public void onResume(){
  super.onResume();
  if (!mFromManager && CommCareApplication._().usableAppsPresent()) {
    Intent i=new Intent(this,CommCareHomeActivity.class);
    startActivity(i);
  }
}

Fixed version (ground truth):
@Override public void onResume(){
  super.onResume();
  if (!mFromManager && !inUpgradeMode && CommCareApplication._().usableAppsPresent()) {
    Intent i=new Intent(this,CommCareHomeActivity.class);
    startActivity(i);
  }
}
Program: 142194
Project: 142194
Buggy source:
@Override protected void onResume(){
  super.onResume();
  if (CommCareApplication._().getCurrentApp() != null) {
    platform=CommCareApplication._().getCommCarePlatform();
  }
  refreshActionBar();
  dispatchHomeScreen();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  if (CommCareApplication._().getCurrentApp() != null) {
    platform=CommCareApplication._().getCommCarePlatform();
  }
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    refreshActionBar();
  }
  dispatchHomeScreen();
}
Program: 142195
Project: 142195
Buggy source:
/** 
 * Populate an input string with attribute keys formatted as {{ attr_key }} with attribute values.
 * @param input String input
 * @param mapping Bundle of key-value mappings with which to complete replacements
 * @return The populated String
 */
private static String replace(String input,Bundle mapping){
  String[] tokens=TemplatePrinterUtils.splitKeepDelimiter(input,"String_Node_Str","String_Node_Str");
  for (int i=0; i < tokens.length; i++) {
    String token=tokens[i];
    if (i % 2 == 1) {
      String[] tokenSplits=TemplatePrinterUtils.splitKeepDelimiter(token,"String_Node_Str","String_Node_Str");
      for (int j=1; j < tokenSplits.length - 1; j++) {
        String tokenSplit=tokenSplits[j];
        if (!tokenSplit.startsWith("String_Node_Str")) {
          String key=TemplatePrinterUtils.remove(tokenSplit,"String_Node_Str");
          if (mapping.containsKey(key) && (key=mapping.getString(key)) != null) {
            tokenSplits[j]=key;
          }
 else {
            tokenSplits[j]="String_Node_Str";
          }
        }
      }
      tokenSplits[0]="String_Node_Str";
      tokenSplits[tokenSplits.length - 1]="String_Node_Str";
      tokens[i]=TemplatePrinterUtils.join(tokenSplits);
    }
  }
  return TemplatePrinterUtils.join(tokens);
}

Fixed version (ground truth):
/** 
 * Populate an input string with attribute keys formatted as {{ attr_key }} with attribute values.
 * @param input String input
 * @param mapping Bundle of key-value mappings with which to complete replacements
 * @return The populated String
 */
private static String replace(String input,Bundle mapping){
  String[] tokens=TemplatePrinterUtils.splitKeepDelimiter(input,"String_Node_Str","String_Node_Str");
  for (int i=0; i < tokens.length; i++) {
    String token=tokens[i];
    if (i % 2 == 1) {
      String[] tokenSplits=TemplatePrinterUtils.splitKeepDelimiter(token,"String_Node_Str","String_Node_Str");
      for (int j=1; j < tokenSplits.length - 1; j++) {
        String tokenSplit=tokenSplits[j];
        if (!tokenSplit.startsWith("String_Node_Str")) {
          String key=TemplatePrinterUtils.remove(tokenSplit,"String_Node_Str");
          String value;
          if (mapping.containsKey(key) && (value=mapping.getString(key)) != null) {
            value.replaceAll("String_Node_Str","String_Node_Str");
            tokenSplits[j]=value;
          }
 else {
            tokenSplits[j]="String_Node_Str";
          }
        }
      }
      tokenSplits[0]="String_Node_Str";
      tokenSplits[tokenSplits.length - 1]="String_Node_Str";
      tokens[i]=TemplatePrinterUtils.join(tokenSplits);
    }
  }
  return TemplatePrinterUtils.join(tokens);
}
Program: 142196
Project: 142196
Buggy source:
/** 
 * Populates an html print template based on the given set of key-value pairings and save the newly-populated template to a temp location
 * @param input the html print template
 * @param mapping the mapping of keywords to case property values
 * @throws IOException , PrintValidationException
 */
private static void populateAndSaveHtml(File input,Bundle mapping,String outputPath) throws IOException, PrintValidationException {
  String fileText=TemplatePrinterUtils.docToString(input).toLowerCase();
  int startBodyIndex=fileText.indexOf("String_Node_Str");
  String beforeBodySection=fileText.substring(0,startBodyIndex);
  String bodySection=fileText.substring(startBodyIndex);
  validateString(bodySection);
  bodySection=replace(bodySection,mapping);
  TemplatePrinterUtils.writeStringToFile(beforeBodySection + bodySection,outputPath);
}

Fixed version (ground truth):
/** 
 * Populates an html print template based on the given set of key-value pairings and save the newly-populated template to a temp location
 * @param input the html print template
 * @param mapping the mapping of keywords to case property values
 * @throws IOException , PrintValidationException
 */
private static void populateAndSaveHtml(File input,Bundle mapping,String outputPath) throws IOException, PrintValidationException {
  String fileText=TemplatePrinterUtils.docToString(input);
  int startBodyIndex=fileText.toLowerCase().indexOf("String_Node_Str");
  String beforeBodySection=fileText.substring(0,startBodyIndex);
  String bodySection=fileText.substring(startBodyIndex);
  validateString(bodySection);
  bodySection=replace(bodySection,mapping);
  TemplatePrinterUtils.writeStringToFile(beforeBodySection + bodySection,outputPath);
}
Program: 142197
Project: 142197
Buggy source:
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  int w=MeasureSpec.getSize(widthMeasureSpec);
  int h=MeasureSpec.getSize(heightMeasureSpec);
  w=Math.max(w,h);
  h=w;
  setMeasuredDimension(w,w);
}

Fixed version (ground truth):
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  int w=MeasureSpec.getSize(widthMeasureSpec);
  int h=MeasureSpec.getSize(heightMeasureSpec);
  if (w == 0 || h == 0) {
    w=Math.max(w,h);
  }
 else {
    w=Math.min(w,h);
  }
  h=w;
  setMeasuredDimension(w,w);
}
Program: 142198
Project: 142198
Buggy source:
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  int w=MeasureSpec.getSize(widthMeasureSpec);
  int h=MeasureSpec.getSize(heightMeasureSpec);
  w=Math.max(w,h);
  h=w;
  setMeasuredDimension(w,w);
}

Fixed version (ground truth):
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  int canvasWidth=MeasureSpec.getSize(widthMeasureSpec);
  int canvasHeight=MeasureSpec.getSize(heightMeasureSpec);
  int squareCanvasDimension=Math.min(canvasWidth,canvasHeight);
  if (squareCanvasDimension <= 0) {
    squareCanvasDimension=Math.max(canvasWidth,canvasHeight);
  }
  setMeasuredDimension(squareCanvasDimension,squareCanvasDimension);
}
Program: 142199
Project: 142199
Buggy source:
public void setupImageLayout(View layout,final String source){
  ImageView iv=(ImageView)layout;
  Bitmap b;
  if (!source.equals("String_Node_Str")) {
    try {
      b=BitmapFactory.decodeStream(ReferenceManager._().DeriveReference(source).getStream());
      if (b == null) {
        iv.setImageDrawable(getResources().getDrawable(R.drawable.ic_menu_archive));
      }
 else {
        iv.setImageBitmap(b);
      }
    }
 catch (    IOException ex) {
      ex.printStackTrace();
      iv.setImageDrawable(getResources().getDrawable(R.drawable.ic_menu_archive));
    }
catch (    InvalidReferenceException ex) {
      ex.printStackTrace();
      iv.setImageDrawable(getResources().getDrawable(R.drawable.ic_menu_archive));
    }
  }
 else {
    iv.setImageDrawable(getResources().getDrawable(R.color.white));
  }
}

Fixed version (ground truth):
public void setupImageLayout(View layout,final String source){
  ImageView iv=(ImageView)layout;
  Bitmap b;
  if (!source.equals("String_Node_Str")) {
    try {
      b=BitmapFactory.decodeStream(ReferenceManager._().DeriveReference(source).getStream());
      if (b == null) {
        iv.setImageDrawable(getResources().getDrawable(R.drawable.ic_menu_archive));
      }
 else {
        iv.setImageBitmap(b);
      }
    }
 catch (    IOException ex) {
      ex.printStackTrace();
      iv.setImageDrawable(getResources().getDrawable(R.drawable.ic_menu_archive));
    }
catch (    InvalidReferenceException ex) {
      ex.printStackTrace();
      iv.setImageDrawable(getResources().getDrawable(R.drawable.ic_menu_archive));
    }
  }
 else {
    iv.setImageDrawable(getResources().getDrawable(R.color.transparent));
  }
}
Program: 142200
Project: 142200
Buggy source:
/** 
 * Initializes the first "usable" application from the list of globally installed app records
 */
public void initFirstUsableAppRecord(){
  for (  ApplicationRecord record : getUsableAppRecords()) {
    initializeAppResources(new CommCareApp(record));
  }
}

Fixed version (ground truth):
/** 
 * Initializes the first "usable" application from the list of globally installed app records
 */
public void initFirstUsableAppRecord(){
  for (  ApplicationRecord record : getUsableAppRecords()) {
    initializeAppResources(new CommCareApp(record));
    break;
  }
}
Program: 142201
Project: 142201
Buggy source:
protected void returnToLogin(){
  Intent i=new Intent(getApplicationContext(),LoginActivity.class);
  i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
  startActivity(i);
}

Fixed version (ground truth):
protected void returnToLogin(){
  Intent i=new Intent(getApplicationContext(),LoginActivity.class);
  i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
  i.putExtra(LoginActivity.REDIRECT_TO_HOMESCREEN,true);
  startActivity(i);
}
Program: 142202
Project: 142202
Buggy source:
@Override protected void onResume(){
  super.onResume();
  if (unredirectedSessionExpiration) {
    unredirectedSessionExpiration=false;
    returnToLogin();
  }
 else {
    registerReceiver(userSessionExpiredReceiver,new IntentFilter(SessionAwareFragmentActivity.USER_SESSION_EXPIRED));
  }
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  if (unredirectedSessionExpiration) {
    unredirectedSessionExpiration=false;
    returnToLogin();
  }
  registerReceiver(userSessionExpiredReceiver,new IntentFilter(SessionAwareFragmentActivity.USER_SESSION_EXPIRED));
}
Program: 142203
Project: 142203
Buggy source:
private void done(){
  Intent i=new Intent();
  setResult(RESULT_OK,i);
  ACRAUtil.registerUserData();
  CommCareApplication._().clearNotifications(NOTIFICATION_MESSAGE_LOGIN);
  finish();
}

Fixed version (ground truth):
private void done(){
  Intent parentIntent=getIntent();
  boolean redirectHome=parentIntent.getBooleanExtra(LoginActivity.REDIRECT_TO_HOMESCREEN,false);
  ACRAUtil.registerUserData();
  CommCareApplication._().clearNotifications(NOTIFICATION_MESSAGE_LOGIN);
  if (redirectHome) {
    Intent i=new Intent(getApplicationContext(),CommCareHomeActivity.class);
    startActivity(i);
  }
 else {
    Intent i=new Intent();
    setResult(RESULT_OK,i);
    finish();
  }
}
Program: 142204
Project: 142204
Buggy source:
@Override protected void onResume(){
  super.onResume();
  try {
    if (CommCareApplication._().getSession().isActive() && CommCareApplication._().getSession().getLoggedInUser() != null) {
      Intent i=new Intent();
      i.putExtra(ALREADY_LOGGED_IN,true);
      setResult(RESULT_OK,i);
      CommCareApplication._().clearNotifications(NOTIFICATION_MESSAGE_LOGIN);
      finish();
      return;
    }
  }
 catch (  SessionUnavailableException sue) {
  }
  refreshView();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  try {
    if (CommCareApplication._().getSession().isActive() && CommCareApplication._().getSession().getLoggedInUser() != null) {
      Intent i=new Intent();
      i.putExtra(ALREADY_LOGGED_IN,true);
      setResult(RESULT_OK,i);
      CommCareApplication._().clearNotifications(NOTIFICATION_MESSAGE_LOGIN);
      finish();
      return;
    }
  }
 catch (  SessionUnavailableException sue) {
  }
}
Program: 142205
Project: 142205
Buggy source:
@Override protected void onActivityResult(int requestCode,int resultCode,Intent intent){
switch (requestCode) {
case CommCareHomeActivity.INIT_APP:
    boolean installFailed=intent != null && intent.getBooleanExtra(CommCareSetupActivity.KEY_INSTALL_FAILED,false);
  if (resultCode == RESULT_OK && !installFailed) {
    if (!CommCareApplication._().getCurrentApp().areResourcesValidated()) {
      Intent i=new Intent(this,CommCareVerificationActivity.class);
      i.putExtra(KEY_LAUNCH_FROM_MANAGER,true);
      this.startActivityForResult(i,CommCareHomeActivity.MISSING_MEDIA_ACTIVITY);
    }
 else {
      Toast.makeText(this,"String_Node_Str",Toast.LENGTH_LONG).show();
    }
    break;
  }
case CommCareHomeActivity.MISSING_MEDIA_ACTIVITY:
if (resultCode == RESULT_CANCELED) {
  AlertDialog.Builder builder=new AlertDialog.Builder(this);
  builder.setTitle("String_Node_Str");
  builder.setMessage(R.string.skipped_verification_warning).setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      dialog.dismiss();
    }
  }
);
  AlertDialog dialog=builder.create();
  dialog.show();
}
 else if (resultCode == RESULT_OK) {
  Toast.makeText(this,"String_Node_Str",Toast.LENGTH_LONG).show();
}
break;
}
}

Fixed version (ground truth):
@Override protected void onActivityResult(int requestCode,int resultCode,Intent intent){
switch (requestCode) {
case CommCareHomeActivity.INIT_APP:
    boolean installFailed=intent != null && intent.getBooleanExtra(CommCareSetupActivity.KEY_INSTALL_FAILED,false);
  if (resultCode == RESULT_OK && !installFailed) {
    if (!CommCareApplication._().getCurrentApp().areResourcesValidated()) {
      Intent i=new Intent(this,CommCareVerificationActivity.class);
      i.putExtra(KEY_LAUNCH_FROM_MANAGER,true);
      this.startActivityForResult(i,CommCareHomeActivity.MISSING_MEDIA_ACTIVITY);
    }
  }
 else {
    Toast.makeText(this,"String_Node_Str",Toast.LENGTH_LONG).show();
  }
break;
case CommCareHomeActivity.MISSING_MEDIA_ACTIVITY:
if (resultCode == RESULT_CANCELED) {
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setTitle("String_Node_Str");
builder.setMessage(R.string.skipped_verification_warning).setPositiveButton("String_Node_Str",new DialogInterface.OnClickListener(){
  @Override public void onClick(  DialogInterface dialog,  int which){
    dialog.dismiss();
  }
}
);
AlertDialog dialog=builder.create();
dialog.show();
}
 else if (resultCode == RESULT_OK) {
Toast.makeText(this,"String_Node_Str",Toast.LENGTH_LONG).show();
}
break;
}
}
Program: 142206
Project: 142206
Buggy source:
@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  super.onActivityResult(requestCode,resultCode,data);
  String result=null;
switch (requestCode) {
case BARCODE_CAPTURE:
    if (resultCode == Activity.RESULT_OK) {
      result=data.getStringExtra("String_Node_Str");
      String dbg="String_Node_Str" + result;
      Log.i(TAG,dbg);
    }
  break;
case ARCHIVE_INSTALL:
if (resultCode == Activity.RESULT_OK) {
  result=data.getStringExtra(InstallArchiveActivity.ARCHIVE_REFERENCE);
}
break;
}
if (result == null) return;
incomingRef=result;
this.uiState=UiState.ready;
try {
ReferenceManager._().DeriveReference(incomingRef);
}
 catch (InvalidReferenceException ire) {
incomingRef=null;
Toast.makeText(getApplicationContext(),Localization.get("String_Node_Str"),Toast.LENGTH_LONG).show();
this.uiState=UiState.basic;
uiStateScreenTransition();
}
}

Fixed version (ground truth):
@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  super.onActivityResult(requestCode,resultCode,data);
  String result=null;
switch (requestCode) {
case BARCODE_CAPTURE:
    if (resultCode == Activity.RESULT_OK) {
      result=data.getStringExtra("String_Node_Str");
      String dbg="String_Node_Str" + result;
      Log.i(TAG,dbg);
    }
  break;
case ARCHIVE_INSTALL:
if (resultCode == Activity.RESULT_OK) {
  result=data.getStringExtra(InstallArchiveActivity.ARCHIVE_REFERENCE);
}
break;
}
if (result == null) return;
incomingRef=result;
this.uiState=UiState.ready;
try {
ReferenceManager._().DeriveReference(incomingRef);
}
 catch (InvalidReferenceException ire) {
incomingRef=null;
Toast.makeText(getApplicationContext(),Localization.get("String_Node_Str"),Toast.LENGTH_LONG).show();
this.uiState=UiState.basic;
}
uiStateScreenTransition();
}
Program: 142207
Project: 142207
Buggy source:
/** 
 * Returns the chosen URL in the UI, prefixing it with http:// if not set.
 * @return The current URL
 */
public String getURL(){
  int selectedPrefix=prefixURLSpinner.getSelectedItemPosition();
  String url=profileLocation.getText().toString();
  if (url == null || url.length() == 0) {
    return url;
  }
  if (selectedPrefix < prefixURLSpinner.getCount() - 1) {
    url=prefixURLSpinner.getSelectedItem() + "String_Node_Str" + url;
    if (!url.startsWith("String_Node_Str")) {
      url="String_Node_Str" + url;
    }
  }
  return url;
}

Fixed version (ground truth):
/** 
 * Returns the chosen URL in the UI, prefixing it with http:// if not set.
 * @return The current URL
 */
public String getURL(){
  int selectedPrefix=prefixURLSpinner.getSelectedItemPosition();
  String url=profileLocation.getText().toString();
  if (url == null || url.length() == 0) {
    return url;
  }
  if (BuildConfig.DEBUG) {
    Log.v(TAG,"String_Node_Str" + selectedPrefix + "String_Node_Str"+ prefixURLSpinner.getSelectedItem());
  }
  if (selectedPrefix < prefixURLSpinner.getCount() - 1) {
    url=prefixURLSpinner.getSelectedItem() + "String_Node_Str" + url;
  }
 else {
    if (BuildConfig.DEBUG) {
      if (!(prefixURLSpinner.getSelectedItem().toString().equalsIgnoreCase("String_Node_Str"))) {
        throw new AssertionError("String_Node_Str");
      }
    }
    if (url.indexOf("String_Node_Str") == -1) {
      url="String_Node_Str" + url;
    }
  }
  return url;
}
Program: 142208
Project: 142208
Buggy source:
public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.missing_multimedia_layout);
  retryButton=(Button)findViewById(R.id.screen_multimedia_retry);
  retryButton.setOnClickListener(this);
  boolean fromManager=this.getIntent().getBooleanExtra(AppManagerActivity.KEY_LAUNCH_FROM_MANAGER,false);
  Log.i("String_Node_Str","String_Node_Str" + fromManager);
  if (fromManager) {
    skipButton=(Button)findViewById(R.id.skip_verification_button);
    skipButton.setVisibility(View.VISIBLE);
    skipButton.setOnClickListener(this);
  }
  missingMediaPrompt=(TextView)findViewById(R.id.MissingMediaPrompt);
  fire();
}

Fixed version (ground truth):
public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.missing_multimedia_layout);
  retryButton=(Button)findViewById(R.id.screen_multimedia_retry);
  retryButton.setOnClickListener(this);
  this.fromManager=this.getIntent().getBooleanExtra(AppManagerActivity.KEY_LAUNCH_FROM_MANAGER,false);
  if (fromManager) {
    skipButton=(Button)findViewById(R.id.skip_verification_button);
    skipButton.setVisibility(View.VISIBLE);
    skipButton.setOnClickListener(this);
  }
  missingMediaPrompt=(TextView)findViewById(R.id.MissingMediaPrompt);
  fire();
}