nus-yam/ex-repair huggingface dataset:
Program: 1566
Project: 1566
Buggy source:
private void handleOnLayoutFinished(PrintDocumentInfo info,boolean layoutChanged,int sequence){
  if (mRequestCounter.get() != sequence) {
    return;
  }
  if (isCancelled()) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  mControllerState=CONTROLLER_STATE_LAYOUT_COMPLETED;
  final boolean infoChanged=!info.equals(mDocument.info);
  if (infoChanged) {
    mDocument.info=info;
    PrintSpoolerService.peekInstance().setPrintJobPrintDocumentInfoNoPersistence(mPrintJobId,info);
  }
  if (infoChanged || layoutChanged) {
    mDocument.pages=null;
    PrintSpoolerService.peekInstance().setPrintJobPagesNoPersistence(mPrintJobId,null);
  }
  mRequestedPages=mEditor.getRequestedPages();
  if (mRequestedPages == null) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  if (!infoChanged && !layoutChanged && PageRangeUtils.contains(mDocument.pages,mRequestedPages)) {
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  if (!LIVE_PREVIEW_SUPPORTED && !mEditor.isPreviewConfirmed() && mMetadata.getBoolean(PrintDocumentAdapter.METADATA_KEY_PRINT_PREVIEW)) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  mEditor.updateUi();
  mControllerState=CONTROLLER_STATE_WRITE_STARTED;
  mRemotePrintAdapter.write(mRequestedPages,mWriteResultCallback,mRequestCounter.incrementAndGet());
}

Fixed version (ground truth):
private void handleOnLayoutFinished(PrintDocumentInfo info,boolean layoutChanged,int sequence){
  if (mRequestCounter.get() != sequence) {
    return;
  }
  if (isCancelled()) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  mControllerState=CONTROLLER_STATE_LAYOUT_COMPLETED;
  final boolean infoChanged=!info.equals(mDocument.info);
  if (infoChanged) {
    mDocument.info=info;
    PrintSpoolerService.peekInstance().setPrintJobPrintDocumentInfoNoPersistence(mPrintJobId,info);
  }
  if (infoChanged || layoutChanged) {
    mDocument.pages=null;
    PrintSpoolerService.peekInstance().setPrintJobPagesNoPersistence(mPrintJobId,null);
  }
  mRequestedPages=mEditor.getRequestedPages();
  if (mRequestedPages == null) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  if (!infoChanged && !layoutChanged && PageRangeUtils.contains(mDocument.pages,mRequestedPages)) {
    if (mEditor.isDone()) {
      requestCreatePdfFileOrFinish();
    }
    return;
  }
  mEditor.updateUi();
  mControllerState=CONTROLLER_STATE_WRITE_STARTED;
  mRemotePrintAdapter.write(mRequestedPages,mWriteResultCallback,mRequestCounter.incrementAndGet());
}
Program: 1568
Project: 1568
Buggy source:
public boolean isDone(){
  return isPrintConfirmed() || isPreviewConfirmed() || isCancelled();
}

Fixed version (ground truth):
public boolean isDone(){
  return isPrintConfirmed() || isCancelled();
}
Program: 1569
Project: 1569
Buggy source:
@Override public SharedPreferences getSharedPreferences(String name,int mode){
  SharedPreferencesImpl sp;
synchronized (mSync) {
    if (sSharedPrefs == null) {
      sSharedPrefs=new ArrayMap<String,ArrayMap<String,SharedPreferencesImpl>>();
    }
    final String packageName=getPackageName();
    ArrayMap<String,SharedPreferencesImpl> packagePrefs=sSharedPrefs.get(packageName);
    if (packagePrefs == null) {
      packagePrefs=new ArrayMap<String,SharedPreferencesImpl>();
      sSharedPrefs.put(packageName,packagePrefs);
    }
    if (mPackageInfo.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.KITKAT) {
      if (name == null) {
        name="String_Node_Str";
      }
    }
    sp=packagePrefs.get(name);
    if (sp == null) {
      File prefsFile=getSharedPrefsFile(name);
      sp=new SharedPreferencesImpl(prefsFile,mode);
      packagePrefs.put(name,sp);
      return sp;
    }
  }
  if ((mode & Context.MODE_MULTI_PROCESS) != 0 || getApplicationInfo().targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB) {
    sp.startReloadIfChangedUnexpectedly();
  }
  return sp;
}

Fixed version (ground truth):
@Override public SharedPreferences getSharedPreferences(String name,int mode){
  SharedPreferencesImpl sp;
synchronized (ContextImpl.class) {
    if (sSharedPrefs == null) {
      sSharedPrefs=new ArrayMap<String,ArrayMap<String,SharedPreferencesImpl>>();
    }
    final String packageName=getPackageName();
    ArrayMap<String,SharedPreferencesImpl> packagePrefs=sSharedPrefs.get(packageName);
    if (packagePrefs == null) {
      packagePrefs=new ArrayMap<String,SharedPreferencesImpl>();
      sSharedPrefs.put(packageName,packagePrefs);
    }
    if (mPackageInfo.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.KITKAT) {
      if (name == null) {
        name="String_Node_Str";
      }
    }
    sp=packagePrefs.get(name);
    if (sp == null) {
      File prefsFile=getSharedPrefsFile(name);
      sp=new SharedPreferencesImpl(prefsFile,mode);
      packagePrefs.put(name,sp);
      return sp;
    }
  }
  if ((mode & Context.MODE_MULTI_PROCESS) != 0 || getApplicationInfo().targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB) {
    sp.startReloadIfChangedUnexpectedly();
  }
  return sp;
}
Program: 1570
Project: 1570
Buggy source:
/** 
 * Returns a new media size in a portrait orientation which is the height is the greater dimension.
 * @return New instance in landscape orientation.
 */
public MediaSize asPortrait(){
  return new MediaSize(mId,mPackageName,mLabel,Math.min(mWidthMils,mHeightMils),Math.max(mWidthMils,mHeightMils),mLabelResId);
}

Fixed version (ground truth):
/** 
 * Returns a new media size in a portrait orientation which is the height is the greater dimension.
 * @return New instance in landscape orientation.
 */
public MediaSize asPortrait(){
  return new MediaSize(mId,mLabel,mPackageName,Math.min(mWidthMils,mHeightMils),Math.max(mWidthMils,mHeightMils),mLabelResId);
}
Program: 1571
Project: 1571
Buggy source:
/** 
 * Returns a new media size in a landscape orientation which is the height is the lesser dimension.
 * @return New instance in landscape orientation.
 */
public MediaSize asLandscape(){
  return new MediaSize(mId,mLabel,Math.max(mWidthMils,mHeightMils),Math.min(mWidthMils,mHeightMils),mLabelResId);
}

Fixed version (ground truth):
/** 
 * Returns a new media size in a landscape orientation which is the height is the lesser dimension.
 * @return New instance in landscape orientation.
 */
public MediaSize asLandscape(){
  return new MediaSize(mId,mLabel,mPackageName,Math.max(mWidthMils,mHeightMils),Math.min(mWidthMils,mHeightMils),mLabelResId);
}
Program: 1572
Project: 1572
Buggy source:
@SuppressWarnings("String_Node_Str") public void addPrinterAndWritePrinterHistory(PrinterInfo printer){
  if (mHistoricalPrinters.size() >= MAX_HISTORY_LENGTH) {
    mHistoricalPrinters.remove(0);
  }
  mHistoricalPrinters.add(printer);
  mWriteTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,new ArrayList<PrinterInfo>(mHistoricalPrinters));
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void addPrinterAndWritePrinterHistory(PrinterInfo printer){
  if (mHistoricalPrinters.size() >= MAX_HISTORY_LENGTH) {
    mHistoricalPrinters.remove(0);
  }
  mHistoricalPrinters.add(printer);
  new WriteTask().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,new ArrayList<PrinterInfo>(mHistoricalPrinters));
}
Program: 1573
Project: 1573
Buggy source:
public boolean stopReadPrinterHistory(){
  return mReadTask.cancel(true);
}

Fixed version (ground truth):
public boolean stopReadPrinterHistory(){
  final boolean cancelled=mReadTask.cancel(true);
  mReadTask=null;
  return cancelled;
}
Program: 1574
Project: 1574
Buggy source:
public void readPrinterHistory(){
  if (DEBUG) {
    Log.i(LOG_TAG,"String_Node_Str");
  }
  mReadHistoryInProgress=true;
  mReadTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,(Void[])null);
}

Fixed version (ground truth):
public void readPrinterHistory(){
  if (DEBUG) {
    Log.i(LOG_TAG,"String_Node_Str");
  }
  mReadHistoryInProgress=true;
  mReadTask=new ReadTask();
  mReadTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,(Void[])null);
}
Program: 1575
Project: 1575
Buggy source:
@Override protected void onPostExecute(List<PrinterInfo> printers){
  if (DEBUG) {
    Log.i(LOG_TAG,"String_Node_Str" + FusedPrintersProvider.this.hashCode());
  }
  mHistoricalPrinters=printers;
  mFavoritePrinters.addAll(computeFavoritePrinters(printers));
  mReadHistoryInProgress=false;
  mReadHistoryCompleted=true;
  computeAndDeliverResult();
  loadInternal();
}

Fixed version (ground truth):
@Override protected void onPostExecute(List<PrinterInfo> printers){
  if (DEBUG) {
    Log.i(LOG_TAG,"String_Node_Str" + FusedPrintersProvider.this.hashCode());
  }
  mHistoricalPrinters=printers;
  mFavoritePrinters.addAll(computeFavoritePrinters(printers));
  mReadHistoryInProgress=false;
  mReadHistoryCompleted=true;
  computeAndDeliverResult();
  loadInternal();
  mReadTask=null;
}
Program: 1576
Project: 1576
Buggy source:
private void updateUiForNewPrinterCapabilities(){
  if (!mMediaSizeSpinnerAdapter.isEmpty()) {
    mIgnoreNextMediaSizeChange=true;
    mMediaSizeSpinnerAdapter.clear();
  }
  if (!mColorModeSpinnerAdapter.isEmpty()) {
    mIgnoreNextColorModeChange=true;
    mColorModeSpinnerAdapter.clear();
  }
  if (!mOrientationSpinnerAdapter.isEmpty()) {
    mIgnoreNextOrientationChange=true;
    mOrientationSpinner.setSelection(0);
  }
  if (mRangeOptionsSpinner.getSelectedItemPosition() != 0) {
    mIgnoreNextRangeOptionChange=true;
    mRangeOptionsSpinner.setSelection(0);
  }
  if (!TextUtils.isEmpty(mCopiesEditText.getText())) {
    mIgnoreNextCopiesChange=true;
    mCopiesEditText.setText(MIN_COPIES_STRING);
  }
  updateUi();
}

Fixed version (ground truth):
private void updateUiForNewPrinterCapabilities(){
  if (!mMediaSizeSpinnerAdapter.isEmpty()) {
    mIgnoreNextMediaSizeChange=true;
    mMediaSizeSpinnerAdapter.clear();
  }
  if (!mColorModeSpinnerAdapter.isEmpty()) {
    mIgnoreNextColorModeChange=true;
    mColorModeSpinnerAdapter.clear();
  }
  if (mOrientationSpinner.getSelectedItemPosition() != 0) {
    mIgnoreNextOrientationChange=true;
    mOrientationSpinner.setSelection(0);
  }
  if (mRangeOptionsSpinner.getSelectedItemPosition() != 0) {
    mIgnoreNextRangeOptionChange=true;
    mRangeOptionsSpinner.setSelection(0);
  }
  if (!TextUtils.isEmpty(mCopiesEditText.getText())) {
    mIgnoreNextCopiesChange=true;
    mCopiesEditText.setText(MIN_COPIES_STRING);
  }
  updateUi();
}
Program: 1577
Project: 1577
Buggy source:
public boolean onTouchEvent(MotionEvent event){
  if (!mEditor.isPrintConfirmed() && !mEditor.isPreviewConfirmed() && mEditor.shouldCloseOnTouch(event)) {
    if (!mController.isWorking()) {
      PrintJobConfigActivity.this.finish();
    }
    mEditor.cancel();
    return true;
  }
  return super.onTouchEvent(event);
}

Fixed version (ground truth):
public boolean onTouchEvent(MotionEvent event){
  if (!mEditor.isPrintConfirmed() && mEditor.shouldCloseOnTouch(event)) {
    if (!mController.isWorking()) {
      PrintJobConfigActivity.this.finish();
    }
    mEditor.cancel();
    return true;
  }
  return super.onTouchEvent(event);
}
Program: 1579
Project: 1579
Buggy source:
public void addCurrentPrinterToHistory(){
  PrinterInfo printer=(PrinterInfo)mDestinationSpinner.getSelectedItem();
  if (printer != null) {
    FusedPrintersProvider printersLoader=(FusedPrintersProvider)(Loader<?>)getLoaderManager().getLoader(LOADER_ID_PRINTERS_LOADER);
    if (printersLoader != null) {
      printersLoader.addHistoricalPrinter(printer);
    }
  }
}

Fixed version (ground truth):
public void addCurrentPrinterToHistory(){
  PrinterInfo printer=(PrinterInfo)mDestinationSpinner.getSelectedItem();
  PrinterId fakePdfPritnerId=mDestinationSpinnerAdapter.mFakePdfPrinter.getId();
  if (printer != null && !printer.getId().equals(fakePdfPritnerId)) {
    FusedPrintersProvider printersLoader=(FusedPrintersProvider)(Loader<?>)getLoaderManager().getLoader(LOADER_ID_PRINTERS_LOADER);
    if (printersLoader != null) {
      printersLoader.addHistoricalPrinter(printer);
    }
  }
}
Program: 1580
Project: 1580
Buggy source:
private void handleOnLayoutFinished(PrintDocumentInfo info,boolean layoutChanged,int sequence){
  if (mRequestCounter.get() != sequence) {
    return;
  }
  if (isCancelled()) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  mControllerState=CONTROLLER_STATE_LAYOUT_COMPLETED;
  final boolean infoChanged=!info.equals(mDocument.info);
  if (infoChanged) {
    mDocument.info=info;
    PrintSpoolerService.peekInstance().setPrintJobPrintDocumentInfoNoPersistence(mPrintJobId,info);
  }
  if (infoChanged || layoutChanged) {
    mDocument.pages=null;
    PrintSpoolerService.peekInstance().setPrintJobPagesNoPersistence(mPrintJobId,null);
  }
  mRequestedPages=mEditor.getRequestedPages();
  if (mRequestedPages == null) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  if (!infoChanged && !layoutChanged && PageRangeUtils.contains(mDocument.pages,mRequestedPages)) {
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  if (!LIVE_PREVIEW_SUPPORTED && !mEditor.isPreviewConfirmed() && mMetadata.getBoolean(PrintDocumentAdapter.METADATA_KEY_PRINT_PREVIEW)) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  mEditor.updateUi();
  mControllerState=CONTROLLER_STATE_WRITE_STARTED;
  mRemotePrintAdapter.write(mRequestedPages,mWriteResultCallback,mRequestCounter.incrementAndGet());
}

Fixed version (ground truth):
private void handleOnLayoutFinished(PrintDocumentInfo info,boolean layoutChanged,int sequence){
  if (mRequestCounter.get() != sequence) {
    return;
  }
  if (isCancelled()) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  mControllerState=CONTROLLER_STATE_LAYOUT_COMPLETED;
  final boolean infoChanged=!info.equals(mDocument.info);
  if (infoChanged) {
    mDocument.info=info;
    PrintSpoolerService.peekInstance().setPrintJobPrintDocumentInfoNoPersistence(mPrintJobId,info);
  }
  if (infoChanged || layoutChanged) {
    mDocument.pages=null;
    PrintSpoolerService.peekInstance().setPrintJobPagesNoPersistence(mPrintJobId,null);
  }
  mRequestedPages=mEditor.getRequestedPages();
  if (mRequestedPages == null) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  if (!infoChanged && !layoutChanged && PageRangeUtils.contains(mDocument.pages,mRequestedPages)) {
    if (mEditor.isDone()) {
      requestCreatePdfFileOrFinish();
    }
    return;
  }
  mEditor.updateUi();
  mControllerState=CONTROLLER_STATE_WRITE_STARTED;
  mRemotePrintAdapter.write(mRequestedPages,mWriteResultCallback,mRequestCounter.incrementAndGet());
}
Program: 1582
Project: 1582
Buggy source:
public boolean isDone(){
  return isPrintConfirmed() || isPreviewConfirmed() || isCancelled();
}

Fixed version (ground truth):
public boolean isDone(){
  return isPrintConfirmed() || isCancelled();
}
Program: 1583
Project: 1583
Buggy source:
@Override public SharedPreferences getSharedPreferences(String name,int mode){
  SharedPreferencesImpl sp;
synchronized (mSync) {
    if (sSharedPrefs == null) {
      sSharedPrefs=new ArrayMap<String,ArrayMap<String,SharedPreferencesImpl>>();
    }
    final String packageName=getPackageName();
    ArrayMap<String,SharedPreferencesImpl> packagePrefs=sSharedPrefs.get(packageName);
    if (packagePrefs == null) {
      packagePrefs=new ArrayMap<String,SharedPreferencesImpl>();
      sSharedPrefs.put(packageName,packagePrefs);
    }
    if (mPackageInfo.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.KITKAT) {
      if (name == null) {
        name="String_Node_Str";
      }
    }
    sp=packagePrefs.get(name);
    if (sp == null) {
      File prefsFile=getSharedPrefsFile(name);
      sp=new SharedPreferencesImpl(prefsFile,mode);
      packagePrefs.put(name,sp);
      return sp;
    }
  }
  if ((mode & Context.MODE_MULTI_PROCESS) != 0 || getApplicationInfo().targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB) {
    sp.startReloadIfChangedUnexpectedly();
  }
  return sp;
}

Fixed version (ground truth):
@Override public SharedPreferences getSharedPreferences(String name,int mode){
  SharedPreferencesImpl sp;
synchronized (ContextImpl.class) {
    if (sSharedPrefs == null) {
      sSharedPrefs=new ArrayMap<String,ArrayMap<String,SharedPreferencesImpl>>();
    }
    final String packageName=getPackageName();
    ArrayMap<String,SharedPreferencesImpl> packagePrefs=sSharedPrefs.get(packageName);
    if (packagePrefs == null) {
      packagePrefs=new ArrayMap<String,SharedPreferencesImpl>();
      sSharedPrefs.put(packageName,packagePrefs);
    }
    if (mPackageInfo.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.KITKAT) {
      if (name == null) {
        name="String_Node_Str";
      }
    }
    sp=packagePrefs.get(name);
    if (sp == null) {
      File prefsFile=getSharedPrefsFile(name);
      sp=new SharedPreferencesImpl(prefsFile,mode);
      packagePrefs.put(name,sp);
      return sp;
    }
  }
  if ((mode & Context.MODE_MULTI_PROCESS) != 0 || getApplicationInfo().targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB) {
    sp.startReloadIfChangedUnexpectedly();
  }
  return sp;
}
Program: 1584
Project: 1584
Buggy source:
@Override public SharedPreferences getSharedPreferences(String name,int mode){
  SharedPreferencesImpl sp;
synchronized (mSync) {
    if (sSharedPrefs == null) {
      sSharedPrefs=new ArrayMap<String,ArrayMap<String,SharedPreferencesImpl>>();
    }
    final String packageName=getPackageName();
    ArrayMap<String,SharedPreferencesImpl> packagePrefs=sSharedPrefs.get(packageName);
    if (packagePrefs == null) {
      packagePrefs=new ArrayMap<String,SharedPreferencesImpl>();
      sSharedPrefs.put(packageName,packagePrefs);
    }
    if (mPackageInfo.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.KITKAT) {
      if (name == null) {
        name="String_Node_Str";
      }
    }
    sp=packagePrefs.get(name);
    if (sp == null) {
      File prefsFile=getSharedPrefsFile(name);
      sp=new SharedPreferencesImpl(prefsFile,mode);
      packagePrefs.put(name,sp);
      return sp;
    }
  }
  if ((mode & Context.MODE_MULTI_PROCESS) != 0 || getApplicationInfo().targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB) {
    sp.startReloadIfChangedUnexpectedly();
  }
  return sp;
}

Fixed version (ground truth):
@Override public SharedPreferences getSharedPreferences(String name,int mode){
  SharedPreferencesImpl sp;
synchronized (ContextImpl.class) {
    if (sSharedPrefs == null) {
      sSharedPrefs=new ArrayMap<String,ArrayMap<String,SharedPreferencesImpl>>();
    }
    final String packageName=getPackageName();
    ArrayMap<String,SharedPreferencesImpl> packagePrefs=sSharedPrefs.get(packageName);
    if (packagePrefs == null) {
      packagePrefs=new ArrayMap<String,SharedPreferencesImpl>();
      sSharedPrefs.put(packageName,packagePrefs);
    }
    if (mPackageInfo.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.KITKAT) {
      if (name == null) {
        name="String_Node_Str";
      }
    }
    sp=packagePrefs.get(name);
    if (sp == null) {
      File prefsFile=getSharedPrefsFile(name);
      sp=new SharedPreferencesImpl(prefsFile,mode);
      packagePrefs.put(name,sp);
      return sp;
    }
  }
  if ((mode & Context.MODE_MULTI_PROCESS) != 0 || getApplicationInfo().targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB) {
    sp.startReloadIfChangedUnexpectedly();
  }
  return sp;
}
Program: 1585
Project: 1585
Buggy source:
/** 
 * Returns a new media size in a portrait orientation which is the height is the greater dimension.
 * @return New instance in landscape orientation.
 */
public MediaSize asPortrait(){
  return new MediaSize(mId,mPackageName,mLabel,Math.min(mWidthMils,mHeightMils),Math.max(mWidthMils,mHeightMils),mLabelResId);
}

Fixed version (ground truth):
/** 
 * Returns a new media size in a portrait orientation which is the height is the greater dimension.
 * @return New instance in landscape orientation.
 */
public MediaSize asPortrait(){
  return new MediaSize(mId,mLabel,mPackageName,Math.min(mWidthMils,mHeightMils),Math.max(mWidthMils,mHeightMils),mLabelResId);
}
Program: 1586
Project: 1586
Buggy source:
/** 
 * Returns a new media size in a landscape orientation which is the height is the lesser dimension.
 * @return New instance in landscape orientation.
 */
public MediaSize asLandscape(){
  return new MediaSize(mId,mLabel,Math.max(mWidthMils,mHeightMils),Math.min(mWidthMils,mHeightMils),mLabelResId);
}

Fixed version (ground truth):
/** 
 * Returns a new media size in a landscape orientation which is the height is the lesser dimension.
 * @return New instance in landscape orientation.
 */
public MediaSize asLandscape(){
  return new MediaSize(mId,mLabel,mPackageName,Math.max(mWidthMils,mHeightMils),Math.min(mWidthMils,mHeightMils),mLabelResId);
}
Program: 1587
Project: 1587
Buggy source:
@SuppressWarnings("String_Node_Str") public void addPrinterAndWritePrinterHistory(PrinterInfo printer){
  if (mHistoricalPrinters.size() >= MAX_HISTORY_LENGTH) {
    mHistoricalPrinters.remove(0);
  }
  mHistoricalPrinters.add(printer);
  mWriteTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,new ArrayList<PrinterInfo>(mHistoricalPrinters));
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void addPrinterAndWritePrinterHistory(PrinterInfo printer){
  if (mHistoricalPrinters.size() >= MAX_HISTORY_LENGTH) {
    mHistoricalPrinters.remove(0);
  }
  mHistoricalPrinters.add(printer);
  new WriteTask().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,new ArrayList<PrinterInfo>(mHistoricalPrinters));
}
Program: 1588
Project: 1588
Buggy source:
public boolean stopReadPrinterHistory(){
  return mReadTask.cancel(true);
}

Fixed version (ground truth):
public boolean stopReadPrinterHistory(){
  final boolean cancelled=mReadTask.cancel(true);
  mReadTask=null;
  return cancelled;
}
Program: 1589
Project: 1589
Buggy source:
public void readPrinterHistory(){
  if (DEBUG) {
    Log.i(LOG_TAG,"String_Node_Str");
  }
  mReadHistoryInProgress=true;
  mReadTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,(Void[])null);
}

Fixed version (ground truth):
public void readPrinterHistory(){
  if (DEBUG) {
    Log.i(LOG_TAG,"String_Node_Str");
  }
  mReadHistoryInProgress=true;
  mReadTask=new ReadTask();
  mReadTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,(Void[])null);
}
Program: 1590
Project: 1590
Buggy source:
@Override protected void onPostExecute(List<PrinterInfo> printers){
  if (DEBUG) {
    Log.i(LOG_TAG,"String_Node_Str" + FusedPrintersProvider.this.hashCode());
  }
  mHistoricalPrinters=printers;
  mFavoritePrinters.addAll(computeFavoritePrinters(printers));
  mReadHistoryInProgress=false;
  mReadHistoryCompleted=true;
  computeAndDeliverResult();
  loadInternal();
}

Fixed version (ground truth):
@Override protected void onPostExecute(List<PrinterInfo> printers){
  if (DEBUG) {
    Log.i(LOG_TAG,"String_Node_Str" + FusedPrintersProvider.this.hashCode());
  }
  mHistoricalPrinters=printers;
  mFavoritePrinters.addAll(computeFavoritePrinters(printers));
  mReadHistoryInProgress=false;
  mReadHistoryCompleted=true;
  computeAndDeliverResult();
  loadInternal();
  mReadTask=null;
}
Program: 1591
Project: 1591
Buggy source:
private void updateUiForNewPrinterCapabilities(){
  if (!mMediaSizeSpinnerAdapter.isEmpty()) {
    mIgnoreNextMediaSizeChange=true;
    mMediaSizeSpinnerAdapter.clear();
  }
  if (!mColorModeSpinnerAdapter.isEmpty()) {
    mIgnoreNextColorModeChange=true;
    mColorModeSpinnerAdapter.clear();
  }
  if (!mOrientationSpinnerAdapter.isEmpty()) {
    mIgnoreNextOrientationChange=true;
    mOrientationSpinner.setSelection(0);
  }
  if (mRangeOptionsSpinner.getSelectedItemPosition() != 0) {
    mIgnoreNextRangeOptionChange=true;
    mRangeOptionsSpinner.setSelection(0);
  }
  if (!TextUtils.isEmpty(mCopiesEditText.getText())) {
    mIgnoreNextCopiesChange=true;
    mCopiesEditText.setText(MIN_COPIES_STRING);
  }
  updateUi();
}

Fixed version (ground truth):
private void updateUiForNewPrinterCapabilities(){
  if (!mMediaSizeSpinnerAdapter.isEmpty()) {
    mIgnoreNextMediaSizeChange=true;
    mMediaSizeSpinnerAdapter.clear();
  }
  if (!mColorModeSpinnerAdapter.isEmpty()) {
    mIgnoreNextColorModeChange=true;
    mColorModeSpinnerAdapter.clear();
  }
  if (mOrientationSpinner.getSelectedItemPosition() != 0) {
    mIgnoreNextOrientationChange=true;
    mOrientationSpinner.setSelection(0);
  }
  if (mRangeOptionsSpinner.getSelectedItemPosition() != 0) {
    mIgnoreNextRangeOptionChange=true;
    mRangeOptionsSpinner.setSelection(0);
  }
  if (!TextUtils.isEmpty(mCopiesEditText.getText())) {
    mIgnoreNextCopiesChange=true;
    mCopiesEditText.setText(MIN_COPIES_STRING);
  }
  updateUi();
}
Program: 1592
Project: 1592
Buggy source:
public boolean onTouchEvent(MotionEvent event){
  if (!mEditor.isPrintConfirmed() && !mEditor.isPreviewConfirmed() && mEditor.shouldCloseOnTouch(event)) {
    if (!mController.isWorking()) {
      PrintJobConfigActivity.this.finish();
    }
    mEditor.cancel();
    return true;
  }
  return super.onTouchEvent(event);
}

Fixed version (ground truth):
public boolean onTouchEvent(MotionEvent event){
  if (!mEditor.isPrintConfirmed() && mEditor.shouldCloseOnTouch(event)) {
    if (!mController.isWorking()) {
      PrintJobConfigActivity.this.finish();
    }
    mEditor.cancel();
    return true;
  }
  return super.onTouchEvent(event);
}
Program: 1594
Project: 1594
Buggy source:
public void addCurrentPrinterToHistory(){
  PrinterInfo printer=(PrinterInfo)mDestinationSpinner.getSelectedItem();
  if (printer != null) {
    FusedPrintersProvider printersLoader=(FusedPrintersProvider)(Loader<?>)getLoaderManager().getLoader(LOADER_ID_PRINTERS_LOADER);
    if (printersLoader != null) {
      printersLoader.addHistoricalPrinter(printer);
    }
  }
}

Fixed version (ground truth):
public void addCurrentPrinterToHistory(){
  PrinterInfo printer=(PrinterInfo)mDestinationSpinner.getSelectedItem();
  PrinterId fakePdfPritnerId=mDestinationSpinnerAdapter.mFakePdfPrinter.getId();
  if (printer != null && !printer.getId().equals(fakePdfPritnerId)) {
    FusedPrintersProvider printersLoader=(FusedPrintersProvider)(Loader<?>)getLoaderManager().getLoader(LOADER_ID_PRINTERS_LOADER);
    if (printersLoader != null) {
      printersLoader.addHistoricalPrinter(printer);
    }
  }
}
Program: 1595
Project: 1595
Buggy source:
private void handleOnLayoutFinished(PrintDocumentInfo info,boolean layoutChanged,int sequence){
  if (mRequestCounter.get() != sequence) {
    return;
  }
  if (isCancelled()) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  mControllerState=CONTROLLER_STATE_LAYOUT_COMPLETED;
  final boolean infoChanged=!info.equals(mDocument.info);
  if (infoChanged) {
    mDocument.info=info;
    PrintSpoolerService.peekInstance().setPrintJobPrintDocumentInfoNoPersistence(mPrintJobId,info);
  }
  if (infoChanged || layoutChanged) {
    mDocument.pages=null;
    PrintSpoolerService.peekInstance().setPrintJobPagesNoPersistence(mPrintJobId,null);
  }
  mRequestedPages=mEditor.getRequestedPages();
  if (mRequestedPages == null) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  if (!infoChanged && !layoutChanged && PageRangeUtils.contains(mDocument.pages,mRequestedPages)) {
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  if (!LIVE_PREVIEW_SUPPORTED && !mEditor.isPreviewConfirmed() && mMetadata.getBoolean(PrintDocumentAdapter.METADATA_KEY_PRINT_PREVIEW)) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  mEditor.updateUi();
  mControllerState=CONTROLLER_STATE_WRITE_STARTED;
  mRemotePrintAdapter.write(mRequestedPages,mWriteResultCallback,mRequestCounter.incrementAndGet());
}

Fixed version (ground truth):
private void handleOnLayoutFinished(PrintDocumentInfo info,boolean layoutChanged,int sequence){
  if (mRequestCounter.get() != sequence) {
    return;
  }
  if (isCancelled()) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  mControllerState=CONTROLLER_STATE_LAYOUT_COMPLETED;
  final boolean infoChanged=!info.equals(mDocument.info);
  if (infoChanged) {
    mDocument.info=info;
    PrintSpoolerService.peekInstance().setPrintJobPrintDocumentInfoNoPersistence(mPrintJobId,info);
  }
  if (infoChanged || layoutChanged) {
    mDocument.pages=null;
    PrintSpoolerService.peekInstance().setPrintJobPagesNoPersistence(mPrintJobId,null);
  }
  mRequestedPages=mEditor.getRequestedPages();
  if (mRequestedPages == null) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  if (!infoChanged && !layoutChanged && PageRangeUtils.contains(mDocument.pages,mRequestedPages)) {
    if (mEditor.isDone()) {
      requestCreatePdfFileOrFinish();
    }
    return;
  }
  mEditor.updateUi();
  mControllerState=CONTROLLER_STATE_WRITE_STARTED;
  mRemotePrintAdapter.write(mRequestedPages,mWriteResultCallback,mRequestCounter.incrementAndGet());
}
Program: 1597
Project: 1597
Buggy source:
public boolean isDone(){
  return isPrintConfirmed() || isPreviewConfirmed() || isCancelled();
}

Fixed version (ground truth):
public boolean isDone(){
  return isPrintConfirmed() || isCancelled();
}
Program: 1598
Project: 1598
Buggy source:
@Override public SharedPreferences getSharedPreferences(String name,int mode){
  SharedPreferencesImpl sp;
synchronized (mSync) {
    if (sSharedPrefs == null) {
      sSharedPrefs=new ArrayMap<String,ArrayMap<String,SharedPreferencesImpl>>();
    }
    final String packageName=getPackageName();
    ArrayMap<String,SharedPreferencesImpl> packagePrefs=sSharedPrefs.get(packageName);
    if (packagePrefs == null) {
      packagePrefs=new ArrayMap<String,SharedPreferencesImpl>();
      sSharedPrefs.put(packageName,packagePrefs);
    }
    if (mPackageInfo.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.KITKAT) {
      if (name == null) {
        name="String_Node_Str";
      }
    }
    sp=packagePrefs.get(name);
    if (sp == null) {
      File prefsFile=getSharedPrefsFile(name);
      sp=new SharedPreferencesImpl(prefsFile,mode);
      packagePrefs.put(name,sp);
      return sp;
    }
  }
  if ((mode & Context.MODE_MULTI_PROCESS) != 0 || getApplicationInfo().targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB) {
    sp.startReloadIfChangedUnexpectedly();
  }
  return sp;
}

Fixed version (ground truth):
@Override public SharedPreferences getSharedPreferences(String name,int mode){
  SharedPreferencesImpl sp;
synchronized (ContextImpl.class) {
    if (sSharedPrefs == null) {
      sSharedPrefs=new ArrayMap<String,ArrayMap<String,SharedPreferencesImpl>>();
    }
    final String packageName=getPackageName();
    ArrayMap<String,SharedPreferencesImpl> packagePrefs=sSharedPrefs.get(packageName);
    if (packagePrefs == null) {
      packagePrefs=new ArrayMap<String,SharedPreferencesImpl>();
      sSharedPrefs.put(packageName,packagePrefs);
    }
    if (mPackageInfo.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.KITKAT) {
      if (name == null) {
        name="String_Node_Str";
      }
    }
    sp=packagePrefs.get(name);
    if (sp == null) {
      File prefsFile=getSharedPrefsFile(name);
      sp=new SharedPreferencesImpl(prefsFile,mode);
      packagePrefs.put(name,sp);
      return sp;
    }
  }
  if ((mode & Context.MODE_MULTI_PROCESS) != 0 || getApplicationInfo().targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB) {
    sp.startReloadIfChangedUnexpectedly();
  }
  return sp;
}
Program: 1599
Project: 1599
Buggy source:
@Override public SharedPreferences getSharedPreferences(String name,int mode){
  SharedPreferencesImpl sp;
synchronized (mSync) {
    if (sSharedPrefs == null) {
      sSharedPrefs=new ArrayMap<String,ArrayMap<String,SharedPreferencesImpl>>();
    }
    final String packageName=getPackageName();
    ArrayMap<String,SharedPreferencesImpl> packagePrefs=sSharedPrefs.get(packageName);
    if (packagePrefs == null) {
      packagePrefs=new ArrayMap<String,SharedPreferencesImpl>();
      sSharedPrefs.put(packageName,packagePrefs);
    }
    if (mPackageInfo.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.KITKAT) {
      if (name == null) {
        name="String_Node_Str";
      }
    }
    sp=packagePrefs.get(name);
    if (sp == null) {
      File prefsFile=getSharedPrefsFile(name);
      sp=new SharedPreferencesImpl(prefsFile,mode);
      packagePrefs.put(name,sp);
      return sp;
    }
  }
  if ((mode & Context.MODE_MULTI_PROCESS) != 0 || getApplicationInfo().targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB) {
    sp.startReloadIfChangedUnexpectedly();
  }
  return sp;
}

Fixed version (ground truth):
@Override public SharedPreferences getSharedPreferences(String name,int mode){
  SharedPreferencesImpl sp;
synchronized (ContextImpl.class) {
    if (sSharedPrefs == null) {
      sSharedPrefs=new ArrayMap<String,ArrayMap<String,SharedPreferencesImpl>>();
    }
    final String packageName=getPackageName();
    ArrayMap<String,SharedPreferencesImpl> packagePrefs=sSharedPrefs.get(packageName);
    if (packagePrefs == null) {
      packagePrefs=new ArrayMap<String,SharedPreferencesImpl>();
      sSharedPrefs.put(packageName,packagePrefs);
    }
    if (mPackageInfo.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.KITKAT) {
      if (name == null) {
        name="String_Node_Str";
      }
    }
    sp=packagePrefs.get(name);
    if (sp == null) {
      File prefsFile=getSharedPrefsFile(name);
      sp=new SharedPreferencesImpl(prefsFile,mode);
      packagePrefs.put(name,sp);
      return sp;
    }
  }
  if ((mode & Context.MODE_MULTI_PROCESS) != 0 || getApplicationInfo().targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB) {
    sp.startReloadIfChangedUnexpectedly();
  }
  return sp;
}
Program: 1600
Project: 1600
Buggy source:
/** 
 * Returns a new media size in a portrait orientation which is the height is the greater dimension.
 * @return New instance in landscape orientation.
 */
public MediaSize asPortrait(){
  return new MediaSize(mId,mPackageName,mLabel,Math.min(mWidthMils,mHeightMils),Math.max(mWidthMils,mHeightMils),mLabelResId);
}

Fixed version (ground truth):
/** 
 * Returns a new media size in a portrait orientation which is the height is the greater dimension.
 * @return New instance in landscape orientation.
 */
public MediaSize asPortrait(){
  return new MediaSize(mId,mLabel,mPackageName,Math.min(mWidthMils,mHeightMils),Math.max(mWidthMils,mHeightMils),mLabelResId);
}
Program: 1601
Project: 1601
Buggy source:
/** 
 * Returns a new media size in a landscape orientation which is the height is the lesser dimension.
 * @return New instance in landscape orientation.
 */
public MediaSize asLandscape(){
  return new MediaSize(mId,mLabel,Math.max(mWidthMils,mHeightMils),Math.min(mWidthMils,mHeightMils),mLabelResId);
}

Fixed version (ground truth):
/** 
 * Returns a new media size in a landscape orientation which is the height is the lesser dimension.
 * @return New instance in landscape orientation.
 */
public MediaSize asLandscape(){
  return new MediaSize(mId,mLabel,mPackageName,Math.max(mWidthMils,mHeightMils),Math.min(mWidthMils,mHeightMils),mLabelResId);
}
Program: 1602
Project: 1602
Buggy source:
@SuppressWarnings("String_Node_Str") public void addPrinterAndWritePrinterHistory(PrinterInfo printer){
  if (mHistoricalPrinters.size() >= MAX_HISTORY_LENGTH) {
    mHistoricalPrinters.remove(0);
  }
  mHistoricalPrinters.add(printer);
  mWriteTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,new ArrayList<PrinterInfo>(mHistoricalPrinters));
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void addPrinterAndWritePrinterHistory(PrinterInfo printer){
  if (mHistoricalPrinters.size() >= MAX_HISTORY_LENGTH) {
    mHistoricalPrinters.remove(0);
  }
  mHistoricalPrinters.add(printer);
  new WriteTask().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,new ArrayList<PrinterInfo>(mHistoricalPrinters));
}
Program: 1603
Project: 1603
Buggy source:
public boolean stopReadPrinterHistory(){
  return mReadTask.cancel(true);
}

Fixed version (ground truth):
public boolean stopReadPrinterHistory(){
  final boolean cancelled=mReadTask.cancel(true);
  mReadTask=null;
  return cancelled;
}
Program: 1604
Project: 1604
Buggy source:
public void readPrinterHistory(){
  if (DEBUG) {
    Log.i(LOG_TAG,"String_Node_Str");
  }
  mReadHistoryInProgress=true;
  mReadTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,(Void[])null);
}

Fixed version (ground truth):
public void readPrinterHistory(){
  if (DEBUG) {
    Log.i(LOG_TAG,"String_Node_Str");
  }
  mReadHistoryInProgress=true;
  mReadTask=new ReadTask();
  mReadTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,(Void[])null);
}
Program: 1605
Project: 1605
Buggy source:
@Override protected void onPostExecute(List<PrinterInfo> printers){
  if (DEBUG) {
    Log.i(LOG_TAG,"String_Node_Str" + FusedPrintersProvider.this.hashCode());
  }
  mHistoricalPrinters=printers;
  mFavoritePrinters.addAll(computeFavoritePrinters(printers));
  mReadHistoryInProgress=false;
  mReadHistoryCompleted=true;
  computeAndDeliverResult();
  loadInternal();
}

Fixed version (ground truth):
@Override protected void onPostExecute(List<PrinterInfo> printers){
  if (DEBUG) {
    Log.i(LOG_TAG,"String_Node_Str" + FusedPrintersProvider.this.hashCode());
  }
  mHistoricalPrinters=printers;
  mFavoritePrinters.addAll(computeFavoritePrinters(printers));
  mReadHistoryInProgress=false;
  mReadHistoryCompleted=true;
  computeAndDeliverResult();
  loadInternal();
  mReadTask=null;
}
Program: 1606
Project: 1606
Buggy source:
private void updateUiForNewPrinterCapabilities(){
  if (!mMediaSizeSpinnerAdapter.isEmpty()) {
    mIgnoreNextMediaSizeChange=true;
    mMediaSizeSpinnerAdapter.clear();
  }
  if (!mColorModeSpinnerAdapter.isEmpty()) {
    mIgnoreNextColorModeChange=true;
    mColorModeSpinnerAdapter.clear();
  }
  if (!mOrientationSpinnerAdapter.isEmpty()) {
    mIgnoreNextOrientationChange=true;
    mOrientationSpinner.setSelection(0);
  }
  if (mRangeOptionsSpinner.getSelectedItemPosition() != 0) {
    mIgnoreNextRangeOptionChange=true;
    mRangeOptionsSpinner.setSelection(0);
  }
  if (!TextUtils.isEmpty(mCopiesEditText.getText())) {
    mIgnoreNextCopiesChange=true;
    mCopiesEditText.setText(MIN_COPIES_STRING);
  }
  updateUi();
}

Fixed version (ground truth):
private void updateUiForNewPrinterCapabilities(){
  if (!mMediaSizeSpinnerAdapter.isEmpty()) {
    mIgnoreNextMediaSizeChange=true;
    mMediaSizeSpinnerAdapter.clear();
  }
  if (!mColorModeSpinnerAdapter.isEmpty()) {
    mIgnoreNextColorModeChange=true;
    mColorModeSpinnerAdapter.clear();
  }
  if (mOrientationSpinner.getSelectedItemPosition() != 0) {
    mIgnoreNextOrientationChange=true;
    mOrientationSpinner.setSelection(0);
  }
  if (mRangeOptionsSpinner.getSelectedItemPosition() != 0) {
    mIgnoreNextRangeOptionChange=true;
    mRangeOptionsSpinner.setSelection(0);
  }
  if (!TextUtils.isEmpty(mCopiesEditText.getText())) {
    mIgnoreNextCopiesChange=true;
    mCopiesEditText.setText(MIN_COPIES_STRING);
  }
  updateUi();
}
Program: 1607
Project: 1607
Buggy source:
public boolean onTouchEvent(MotionEvent event){
  if (!mEditor.isPrintConfirmed() && !mEditor.isPreviewConfirmed() && mEditor.shouldCloseOnTouch(event)) {
    if (!mController.isWorking()) {
      PrintJobConfigActivity.this.finish();
    }
    mEditor.cancel();
    return true;
  }
  return super.onTouchEvent(event);
}

Fixed version (ground truth):
public boolean onTouchEvent(MotionEvent event){
  if (!mEditor.isPrintConfirmed() && mEditor.shouldCloseOnTouch(event)) {
    if (!mController.isWorking()) {
      PrintJobConfigActivity.this.finish();
    }
    mEditor.cancel();
    return true;
  }
  return super.onTouchEvent(event);
}
Program: 1609
Project: 1609
Buggy source:
public void addCurrentPrinterToHistory(){
  PrinterInfo printer=(PrinterInfo)mDestinationSpinner.getSelectedItem();
  if (printer != null) {
    FusedPrintersProvider printersLoader=(FusedPrintersProvider)(Loader<?>)getLoaderManager().getLoader(LOADER_ID_PRINTERS_LOADER);
    if (printersLoader != null) {
      printersLoader.addHistoricalPrinter(printer);
    }
  }
}

Fixed version (ground truth):
public void addCurrentPrinterToHistory(){
  PrinterInfo printer=(PrinterInfo)mDestinationSpinner.getSelectedItem();
  PrinterId fakePdfPritnerId=mDestinationSpinnerAdapter.mFakePdfPrinter.getId();
  if (printer != null && !printer.getId().equals(fakePdfPritnerId)) {
    FusedPrintersProvider printersLoader=(FusedPrintersProvider)(Loader<?>)getLoaderManager().getLoader(LOADER_ID_PRINTERS_LOADER);
    if (printersLoader != null) {
      printersLoader.addHistoricalPrinter(printer);
    }
  }
}
Program: 1610
Project: 1610
Buggy source:
private void handleOnLayoutFinished(PrintDocumentInfo info,boolean layoutChanged,int sequence){
  if (mRequestCounter.get() != sequence) {
    return;
  }
  if (isCancelled()) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  mControllerState=CONTROLLER_STATE_LAYOUT_COMPLETED;
  final boolean infoChanged=!info.equals(mDocument.info);
  if (infoChanged) {
    mDocument.info=info;
    PrintSpoolerService.peekInstance().setPrintJobPrintDocumentInfoNoPersistence(mPrintJobId,info);
  }
  if (infoChanged || layoutChanged) {
    mDocument.pages=null;
    PrintSpoolerService.peekInstance().setPrintJobPagesNoPersistence(mPrintJobId,null);
  }
  mRequestedPages=mEditor.getRequestedPages();
  if (mRequestedPages == null) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  if (!infoChanged && !layoutChanged && PageRangeUtils.contains(mDocument.pages,mRequestedPages)) {
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  if (!LIVE_PREVIEW_SUPPORTED && !mEditor.isPreviewConfirmed() && mMetadata.getBoolean(PrintDocumentAdapter.METADATA_KEY_PRINT_PREVIEW)) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  mEditor.updateUi();
  mControllerState=CONTROLLER_STATE_WRITE_STARTED;
  mRemotePrintAdapter.write(mRequestedPages,mWriteResultCallback,mRequestCounter.incrementAndGet());
}

Fixed version (ground truth):
private void handleOnLayoutFinished(PrintDocumentInfo info,boolean layoutChanged,int sequence){
  if (mRequestCounter.get() != sequence) {
    return;
  }
  if (isCancelled()) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  mControllerState=CONTROLLER_STATE_LAYOUT_COMPLETED;
  final boolean infoChanged=!info.equals(mDocument.info);
  if (infoChanged) {
    mDocument.info=info;
    PrintSpoolerService.peekInstance().setPrintJobPrintDocumentInfoNoPersistence(mPrintJobId,info);
  }
  if (infoChanged || layoutChanged) {
    mDocument.pages=null;
    PrintSpoolerService.peekInstance().setPrintJobPagesNoPersistence(mPrintJobId,null);
  }
  mRequestedPages=mEditor.getRequestedPages();
  if (mRequestedPages == null) {
    mEditor.updateUi();
    if (mEditor.isDone()) {
      PrintJobConfigActivity.this.finish();
    }
    return;
  }
  if (!infoChanged && !layoutChanged && PageRangeUtils.contains(mDocument.pages,mRequestedPages)) {
    if (mEditor.isDone()) {
      requestCreatePdfFileOrFinish();
    }
    return;
  }
  mEditor.updateUi();
  mControllerState=CONTROLLER_STATE_WRITE_STARTED;
  mRemotePrintAdapter.write(mRequestedPages,mWriteResultCallback,mRequestCounter.incrementAndGet());
}
Program: 1612
Project: 1612
Buggy source:
public boolean isDone(){
  return isPrintConfirmed() || isPreviewConfirmed() || isCancelled();
}

Fixed version (ground truth):
public boolean isDone(){
  return isPrintConfirmed() || isCancelled();
}
Program: 1613
Project: 1613
Buggy source:
/** 
 * Returns a new media size in a portrait orientation which is the height is the greater dimension.
 * @return New instance in landscape orientation.
 */
public MediaSize asPortrait(){
  return new MediaSize(mId,mPackageName,mLabel,Math.min(mWidthMils,mHeightMils),Math.max(mWidthMils,mHeightMils),mLabelResId);
}

Fixed version (ground truth):
/** 
 * Returns a new media size in a portrait orientation which is the height is the greater dimension.
 * @return New instance in landscape orientation.
 */
public MediaSize asPortrait(){
  return new MediaSize(mId,mLabel,mPackageName,Math.min(mWidthMils,mHeightMils),Math.max(mWidthMils,mHeightMils),mLabelResId);
}
Program: 1614
Project: 1614
Buggy source:
/** 
 * Returns a new media size in a landscape orientation which is the height is the lesser dimension.
 * @return New instance in landscape orientation.
 */
public MediaSize asLandscape(){
  return new MediaSize(mId,mLabel,Math.max(mWidthMils,mHeightMils),Math.min(mWidthMils,mHeightMils),mLabelResId);
}

Fixed version (ground truth):
/** 
 * Returns a new media size in a landscape orientation which is the height is the lesser dimension.
 * @return New instance in landscape orientation.
 */
public MediaSize asLandscape(){
  return new MediaSize(mId,mLabel,mPackageName,Math.max(mWidthMils,mHeightMils),Math.min(mWidthMils,mHeightMils),mLabelResId);
}
Program: 1615
Project: 1615
Buggy source:
@SuppressWarnings("String_Node_Str") public void addPrinterAndWritePrinterHistory(PrinterInfo printer){
  if (mHistoricalPrinters.size() >= MAX_HISTORY_LENGTH) {
    mHistoricalPrinters.remove(0);
  }
  mHistoricalPrinters.add(printer);
  mWriteTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,new ArrayList<PrinterInfo>(mHistoricalPrinters));
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void addPrinterAndWritePrinterHistory(PrinterInfo printer){
  if (mHistoricalPrinters.size() >= MAX_HISTORY_LENGTH) {
    mHistoricalPrinters.remove(0);
  }
  mHistoricalPrinters.add(printer);
  new WriteTask().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,new ArrayList<PrinterInfo>(mHistoricalPrinters));
}
Program: 1616
Project: 1616
Buggy source:
public boolean stopReadPrinterHistory(){
  return mReadTask.cancel(true);
}

Fixed version (ground truth):
public boolean stopReadPrinterHistory(){
  final boolean cancelled=mReadTask.cancel(true);
  mReadTask=null;
  return cancelled;
}
Program: 1617
Project: 1617
Buggy source:
public void readPrinterHistory(){
  if (DEBUG) {
    Log.i(LOG_TAG,"String_Node_Str");
  }
  mReadHistoryInProgress=true;
  mReadTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,(Void[])null);
}

Fixed version (ground truth):
public void readPrinterHistory(){
  if (DEBUG) {
    Log.i(LOG_TAG,"String_Node_Str");
  }
  mReadHistoryInProgress=true;
  mReadTask=new ReadTask();
  mReadTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR,(Void[])null);
}
Program: 1618
Project: 1618
Buggy source:
@Override protected void onPostExecute(List<PrinterInfo> printers){
  if (DEBUG) {
    Log.i(LOG_TAG,"String_Node_Str" + FusedPrintersProvider.this.hashCode());
  }
  mHistoricalPrinters=printers;
  mFavoritePrinters.addAll(computeFavoritePrinters(printers));
  mReadHistoryInProgress=false;
  mReadHistoryCompleted=true;
  computeAndDeliverResult();
  loadInternal();
}

Fixed version (ground truth):
@Override protected void onPostExecute(List<PrinterInfo> printers){
  if (DEBUG) {
    Log.i(LOG_TAG,"String_Node_Str" + FusedPrintersProvider.this.hashCode());
  }
  mHistoricalPrinters=printers;
  mFavoritePrinters.addAll(computeFavoritePrinters(printers));
  mReadHistoryInProgress=false;
  mReadHistoryCompleted=true;
  computeAndDeliverResult();
  loadInternal();
  mReadTask=null;
}