nus-yam/ex-repair huggingface dataset:
Program: 45432
Project: 45432
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.m_dragmode:
    if (!dragPlot) {
      dragPlot=true;
      mode_drag.setText("String_Node_Str");
    }
 else {
      dragPlot=false;
      mockGarden.refreshBounds();
      mode_drag.setText("String_Node_Str");
    }
  break;
case R.id.m_rotatemode:
if (!rotateMode) {
  sb_rotation.setVisibility(View.VISIBLE);
  rotateMode=true;
  mode_rotate.setText("String_Node_Str");
}
 else {
  sb_rotation.setVisibility(View.INVISIBLE);
  rotateMode=false;
  mode_rotate.setText("String_Node_Str");
}
break;
case R.id.m_change_color:
int color=PreferenceManager.getDefaultSharedPreferences(EditScreen.this).getInt("String_Node_Str",Color.WHITE);
new ColorPickerDialog(EditScreen.this,EditScreen.this,color).show();
break;
case R.id.m_save:
newPlot.getShape().getPaint().setStrokeWidth(3);
finish();
}
return super.onOptionsItemSelected(item);
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.m_dragmode:
    if (!dragPlot) {
      dragPlot=true;
      mode_drag.setText("String_Node_Str");
    }
 else {
      dragPlot=false;
      mockGarden.refreshBounds();
      mode_drag.setText("String_Node_Str");
    }
  break;
case R.id.m_rotatemode:
if (!rotateMode) {
  sb_rotation.setVisibility(View.VISIBLE);
  rotateMode=true;
  mode_rotate.setText("String_Node_Str");
}
 else {
  sb_rotation.setVisibility(View.INVISIBLE);
  rotateMode=false;
  mode_rotate.setText("String_Node_Str");
}
break;
case R.id.m_change_color:
int color=PreferenceManager.getDefaultSharedPreferences(EditScreen.this).getInt("String_Node_Str",Color.WHITE);
new ColorPickerDialog(EditScreen.this,EditScreen.this,color).show();
break;
case R.id.m_save:
newPlot.getShape().getPaint().setStrokeWidth(3);
mockGarden.refreshBounds();
finish();
}
return super.onOptionsItemSelected(item);
}
Program: 45433
Project: 45433
Buggy source:
public void onBackPressed(){
  Bundle extras=getIntent().getExtras();
  if (extras.containsKey("String_Node_Str"))   mockGarden.getPlots().remove(mockGarden.getPlots().size() - 1);
 else {
    float[] d={EditView.X,EditView.Y};
    Matrix inverse=new Matrix();
    EditView.m.invert(inverse);
    inverse.mapPoints(d);
    if (EditView.X != 0 && EditView.Y != 0) {
      newPlot.getShape().getBounds().offset((int)(oldPlot.getShape().getBounds().exactCenterX() - d[0]),(int)(oldPlot.getShape().getBounds().exactCenterY() - d[1]));
      EditView.X=0;
      EditView.Y=0;
    }
    newPlot.getShape().getPaint().setStrokeWidth(3);
    newPlot.setColor(newPlot.getColor());
    newPlot.getShape().getPaint().setColor(oldPlot.getColor());
    newPlot.setAngle(oldPlot.getAngle());
  }
  finish();
}

Fixed version (ground truth):
public void onBackPressed(){
  Bundle extras=getIntent().getExtras();
  if (extras.containsKey("String_Node_Str"))   mockGarden.getPlots().remove(mockGarden.getPlots().size() - 1);
 else {
    newPlot.getShape().setBounds(oldPlot.getShape().getBounds());
    newPlot.getShape().getPaint().setStrokeWidth(3);
    newPlot.setColor(newPlot.getColor());
    newPlot.getShape().getPaint().setColor(oldPlot.getColor());
    newPlot.setAngle(oldPlot.getAngle());
  }
  mockGarden.refreshBounds();
  finish();
}
Program: 45436
Project: 45436
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  showFullScreen=getSharedPreferences("String_Node_Str",Context.MODE_PRIVATE).getBoolean("String_Node_Str",false);
  if (showFullScreen)   setTheme(android.R.style.Theme_Light_NoTitleBar_Fullscreen);
  super.onCreate(savedInstanceState);
  Bundle extras=getIntent().getExtras();
  if (extras != null && extras.containsKey("String_Node_Str")) {
    mockGarden=StartScreen.gardens.get(extras.getInt("String_Node_Str"));
    setTitle(mockGarden.getName());
  }
 else {
    mockGarden=new Garden("String_Node_Str");
    showDialog(0);
  }
  setContentView(R.layout.garden);
  gardenView=(GardenView)findViewById(R.id.garden_view);
  zoom=(ZoomControls)findViewById(R.id.zoom_controls);
  zoomAutoHidden=getSharedPreferences("String_Node_Str",Context.MODE_PRIVATE).getBoolean("String_Node_Str",false);
  if (zoomAutoHidden)   zoom.setVisibility(View.GONE);
  zoom.setOnZoomInClickListener(zoomIn);
  zoom.setOnZoomOutClickListener(zoomOut);
  boolean hintsOn=getSharedPreferences("String_Node_Str",Context.MODE_PRIVATE).getBoolean("String_Node_Str",true);
  if (hintsOn) {
    ((TextView)findViewById(R.id.garden_hint)).setText(R.string.hint_gardenscreen);
    ((TextView)findViewById(R.id.garden_hint)).setVisibility(View.VISIBLE);
  }
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  showFullScreen=getSharedPreferences("String_Node_Str",Context.MODE_PRIVATE).getBoolean("String_Node_Str",false);
  if (showFullScreen)   setTheme(android.R.style.Theme_Light_NoTitleBar_Fullscreen);
  super.onCreate(savedInstanceState);
  Bundle extras=getIntent().getExtras();
  if (extras != null && extras.containsKey("String_Node_Str")) {
    mockGarden=StartScreen.gardens.get(extras.getInt("String_Node_Str"));
    setTitle(mockGarden.getName());
  }
 else {
    mockGarden=new Garden(R.drawable.preview,"String_Node_Str");
    showDialog(0);
  }
  setContentView(R.layout.garden);
  gardenView=(GardenView)findViewById(R.id.garden_view);
  zoom=(ZoomControls)findViewById(R.id.zoom_controls);
  zoomAutoHidden=getSharedPreferences("String_Node_Str",Context.MODE_PRIVATE).getBoolean("String_Node_Str",false);
  if (zoomAutoHidden)   zoom.setVisibility(View.GONE);
  zoom.setOnZoomInClickListener(zoomIn);
  zoom.setOnZoomOutClickListener(zoomOut);
  boolean hintsOn=getSharedPreferences("String_Node_Str",Context.MODE_PRIVATE).getBoolean("String_Node_Str",true);
  if (hintsOn) {
    ((TextView)findViewById(R.id.garden_hint)).setText(R.string.hint_gardenscreen);
    ((TextView)findViewById(R.id.garden_hint)).setVisibility(View.VISIBLE);
  }
}
Program: 45437
Project: 45437
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  LauncherApplication app=((LauncherApplication)getApplication());
  mModel=app.setLauncher(this);
  mIconCache=app.getIconCache();
  mDragController=new DragController(this);
  mInflater=getLayoutInflater();
  mAppWidgetManager=AppWidgetManager.getInstance(this);
  mAppWidgetHost=new LauncherAppWidgetHost(this,APPWIDGET_HOST_ID);
  mAppWidgetHost.startListening();
  if (PROFILE_STARTUP) {
    android.os.Debug.startMethodTracing(Environment.getExternalStorageDirectory() + "String_Node_Str");
  }
  loadHotseats();
  checkForLocaleChange();
  setWallpaperDimension();
  setContentView(R.layout.launcher);
  setupViews();
  registerContentObservers();
  lockAllApps();
  mSavedState=savedInstanceState;
  restoreState(mSavedState);
  if (PROFILE_STARTUP) {
    android.os.Debug.stopMethodTracing();
  }
  if (!mRestoring) {
    mModel.startLoader(this,true);
  }
  mDefaultKeySsb=new SpannableStringBuilder();
  Selection.setSelection(mDefaultKeySsb,0);
  IntentFilter filter=new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
  registerReceiver(mCloseSystemDialogsReceiver,filter);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  LauncherApplication app=((LauncherApplication)getApplication());
  mModel=app.setLauncher(this);
  mIconCache=app.getIconCache();
  mDragController=new DragController(this);
  mInflater=getLayoutInflater();
  mAppWidgetManager=AppWidgetManager.getInstance(this);
  mAppWidgetHost=new LauncherAppWidgetHost(this,APPWIDGET_HOST_ID);
  mAppWidgetHost.startListening();
  if (PROFILE_STARTUP) {
    android.os.Debug.startMethodTracing(Environment.getExternalStorageDirectory() + "String_Node_Str");
  }
  loadHotseats();
  checkForLocaleChange();
  setWallpaperDimension();
  setNumScreens();
  setupViews();
  registerContentObservers();
  lockAllApps();
  mSavedState=savedInstanceState;
  restoreState(mSavedState);
  if (PROFILE_STARTUP) {
    android.os.Debug.stopMethodTracing();
  }
  if (!mRestoring) {
    mModel.startLoader(this,true);
  }
  mDefaultKeySsb=new SpannableStringBuilder();
  Selection.setSelection(mDefaultKeySsb,0);
  IntentFilter filter=new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
  registerReceiver(mCloseSystemDialogsReceiver,filter);
}
Program: 45439
Project: 45439
Buggy source:
private boolean checkItemPlacement(ItemInfo occupied[][][],ItemInfo item){
  for (int x=item.cellX; x < (item.cellX + item.spanX); x++) {
    for (int y=item.cellY; y < (item.cellY + item.spanY); y++) {
      if (occupied[item.screen][x][y] != null) {
        Log.e(TAG,"String_Node_Str" + item + "String_Node_Str"+ item.screen+ "String_Node_Str"+ x+ "String_Node_Str"+ y+ "String_Node_Str"+ occupied[item.screen][x][y]);
        return false;
      }
    }
  }
  for (int x=item.cellX; x < (item.cellX + item.spanX); x++) {
    for (int y=item.cellY; y < (item.cellY + item.spanY); y++) {
      occupied[item.screen][x][y]=item;
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean checkItemPlacement(ItemInfo occupied[][][],ItemInfo item){
  if (item.container != LauncherSettings.Favorites.CONTAINER_DESKTOP) {
    return true;
  }
  for (int x=item.cellX; x < (item.cellX + item.spanX); x++) {
    for (int y=item.cellY; y < (item.cellY + item.spanY); y++) {
      if (occupied[item.screen][x][y] != null) {
        Log.e(TAG,"String_Node_Str" + item + "String_Node_Str"+ item.screen+ "String_Node_Str"+ x+ "String_Node_Str"+ y+ "String_Node_Str"+ occupied[item.screen][x][y]);
        return false;
      }
    }
  }
  for (int x=item.cellX; x < (item.cellX + item.spanX); x++) {
    for (int y=item.cellY; y < (item.cellY + item.spanY); y++) {
      occupied[item.screen][x][y]=item;
    }
  }
  return true;
}
Program: 45440
Project: 45440
Buggy source:
@Override protected void setChildrenDrawingCacheEnabled(boolean enabled){
  final int count=getChildCount();
  for (int i=0; i < count; i++) {
    final View view=getChildAt(i);
    view.setDrawingCacheEnabled(enabled);
    view.buildDrawingCache(false);
  }
}

Fixed version (ground truth):
@Override protected void setChildrenDrawingCacheEnabled(boolean enabled){
  final int count=getChildCount();
  for (int i=0; i < count; i++) {
    final View view=getChildAt(i);
    view.setDrawingCacheEnabled(enabled);
    view.buildDrawingCache(true);
  }
}
Program: 45443
Project: 45443
Buggy source:
/** 
 * Initializes various states for this workspace.
 */
private void initWorkspace(){
  Context context=getContext();
  mScroller=new Scroller(context,new OvershootInterpolator());
  mCurrentScreen=mDefaultScreen;
  Launcher.setScreen(mCurrentScreen);
  LauncherApplication app=(LauncherApplication)context.getApplicationContext();
  mIconCache=app.getIconCache();
  final ViewConfiguration configuration=ViewConfiguration.get(getContext());
  mTouchSlop=configuration.getScaledTouchSlop();
  mPagingTouchSlop=configuration.getScaledPagingTouchSlop();
  mMaximumVelocity=configuration.getScaledMaximumFlingVelocity();
}

Fixed version (ground truth):
/** 
 * Initializes various states for this workspace.
 */
private void initWorkspace(){
  Context context=getContext();
  mScrollInterpolator=new WorkspaceOvershootInterpolator();
  mScroller=new Scroller(context,mScrollInterpolator);
  mCurrentScreen=mDefaultScreen;
  Launcher.setScreen(mCurrentScreen);
  LauncherApplication app=(LauncherApplication)context.getApplicationContext();
  mIconCache=app.getIconCache();
  final ViewConfiguration configuration=ViewConfiguration.get(getContext());
  mTouchSlop=configuration.getScaledTouchSlop();
  mPagingTouchSlop=configuration.getScaledPagingTouchSlop();
  mMaximumVelocity=configuration.getScaledMaximumFlingVelocity();
}
Program: 45444
Project: 45444
Buggy source:
void snapToScreen(int whichScreen){
  whichScreen=Math.max(0,Math.min(whichScreen,getChildCount() - 1));
  clearVacantCache();
  enableChildrenCache(mCurrentScreen,whichScreen);
  final int screenDelta=Math.abs(whichScreen - mCurrentScreen);
  mNextScreen=whichScreen;
  mPreviousIndicator.setLevel(mNextScreen);
  mNextIndicator.setLevel(mNextScreen);
  View focusedChild=getFocusedChild();
  if (focusedChild != null && screenDelta != 0 && focusedChild == getChildAt(mCurrentScreen)) {
    focusedChild.clearFocus();
  }
  final int newX=whichScreen * getWidth();
  final int delta=newX - mScrollX;
  final int duration=screenDelta != 0 ? screenDelta * 300 : 300;
  awakenScrollBars(duration);
  if (!mScroller.isFinished())   mScroller.abortAnimation();
  mScroller.startScroll(mScrollX,0,delta,0,duration);
  invalidate();
}

Fixed version (ground truth):
void snapToScreen(int whichScreen){
  whichScreen=Math.max(0,Math.min(whichScreen,getChildCount() - 1));
  clearVacantCache();
  enableChildrenCache(mCurrentScreen,whichScreen);
  final int screenDelta=Math.abs(whichScreen - mCurrentScreen);
  mNextScreen=whichScreen;
  mPreviousIndicator.setLevel(mNextScreen);
  mNextIndicator.setLevel(mNextScreen);
  View focusedChild=getFocusedChild();
  if (focusedChild != null && screenDelta != 0 && focusedChild == getChildAt(mCurrentScreen)) {
    focusedChild.clearFocus();
  }
  final int newX=whichScreen * getWidth();
  final int delta=newX - mScrollX;
  final int duration=screenDelta != 0 ? 200 + screenDelta * 100 : 300;
  awakenScrollBars(duration);
  if (!mScroller.isFinished())   mScroller.abortAnimation();
  mScrollInterpolator.setDistance(screenDelta);
  mScroller.startScroll(mScrollX,0,delta,0,duration);
  invalidate();
}
Program: 45445
Project: 45445
Buggy source:
public void run(){
  mPosX=((float)mData[0]) / (1 << 16);
  mVelocity=((float)mData[1]) / (1 << 16);
  mZoom=((float)mData[2]) / (1 << 16);
  mZoomDirty=false;
}

Fixed version (ground truth):
public void run(){
  mRollo.mScrollPos=((float)mData[0]) / (1 << 16);
  mVelocity=((float)mData[1]) / (1 << 16);
  mZoom=((float)mData[2]) / (1 << 16);
  mZoomDirty=false;
}
Program: 45446
Project: 45446
Buggy source:
private boolean checkClickOK(){
  return (Math.abs(mAllApps.mVelocity) < 0.4f) && (Math.abs(mAllApps.mPosX - Math.round(mAllApps.mPosX)) < 0.4f);
}

Fixed version (ground truth):
private boolean checkClickOK(){
  return (Math.abs(mAllApps.mVelocity) < 0.4f) && (Math.abs(mScrollPos - Math.round(mScrollPos)) < 0.4f);
}
Program: 45447
Project: 45447
Buggy source:
private void gainFocus(){
  if (!mArrowNavigation && mRollo.mState.iconCount > 0) {
    mArrowNavigation=true;
    mRollo.selectIcon(Math.round(mPosX) * mColumnsPerPage,SELECTED_FOCUSED);
    mRollo.mState.save();
  }
}

Fixed version (ground truth):
private void gainFocus(){
  if (!mArrowNavigation && mRollo.mState.iconCount > 0) {
    mArrowNavigation=true;
    mRollo.selectIcon(Math.round(mRollo.mScrollPos) * mColumnsPerPage,SELECTED_FOCUSED);
    mRollo.mState.save();
  }
}
Program: 45450
Project: 45450
Buggy source:
int chooseTappedIcon(int x,int y,float pos){
  y+=(pos - ((int)pos)) * (mTouchYBorders[1] - mTouchYBorders[0]);
  int col=-1;
  int row=-1;
  final int columnsCount=mAllApps.mColumnsPerPage;
  for (int i=0; i < columnsCount; i++) {
    if (x >= mTouchXBorders[i] && x < mTouchXBorders[i + 1]) {
      col=i;
      break;
    }
  }
  final int rowsCount=mAllApps.mRowsPerPage;
  for (int i=0; i < rowsCount; i++) {
    if (y >= mTouchYBorders[i] && y < mTouchYBorders[i + 1]) {
      row=i;
      break;
    }
  }
  if (row < 0 || col < 0) {
    return -1;
  }
  int index=(((int)pos) * columnsCount) + (row * columnsCount) + col;
  if (index >= mState.iconCount) {
    return -1;
  }
 else {
    return index;
  }
}

Fixed version (ground truth):
int chooseTappedIcon(int x,int y){
  float pos=mScrollPos;
  y+=(pos - ((int)pos)) * (mTouchYBorders[1] - mTouchYBorders[0]);
  int col=-1;
  int row=-1;
  final int columnsCount=mAllApps.mColumnsPerPage;
  for (int i=0; i < columnsCount; i++) {
    if (x >= mTouchXBorders[i] && x < mTouchXBorders[i + 1]) {
      col=i;
      break;
    }
  }
  final int rowsCount=mAllApps.mRowsPerPage;
  for (int i=0; i < rowsCount; i++) {
    if (y >= mTouchYBorders[i] && y < mTouchYBorders[i + 1]) {
      row=i;
      break;
    }
  }
  if (row < 0 || col < 0) {
    return -1;
  }
  int index=(((int)pos) * columnsCount) + (row * columnsCount) + col;
  if (index >= mState.iconCount) {
    return -1;
  }
 else {
    return index;
  }
}
Program: 45451
Project: 45451
Buggy source:
@Override public void onWindowFocusChanged(boolean hasWindowFocus){
  super.onWindowFocusChanged(hasWindowFocus);
  if (mSurrendered)   return;
  if (mArrowNavigation) {
    if (!hasWindowFocus) {
      mLastSelectedIcon=mRollo.mState.selectedIconIndex;
      mRollo.setHomeSelected(SELECTED_NONE);
      mRollo.clearSelectedIcon();
      mRollo.mState.save();
    }
 else {
      if (mRollo.mState.iconCount > 0) {
        if (mLastSelection == SELECTION_ICONS) {
          int selection=mLastSelectedIcon;
          final int firstIcon=Math.round(mPosX) * mColumnsPerPage;
          if (selection < 0 || selection < firstIcon || selection >= mRollo.mState.iconCount || selection >= firstIcon + (mColumnsPerPage * mRowsPerPage)) {
            selection=firstIcon;
          }
          mRollo.selectIcon(selection,SELECTED_FOCUSED);
          mRollo.mState.save();
        }
 else         if (mLastSelection == SELECTION_HOME) {
          mRollo.setHomeSelected(SELECTED_FOCUSED);
          mRollo.mState.save();
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onWindowFocusChanged(boolean hasWindowFocus){
  super.onWindowFocusChanged(hasWindowFocus);
  if (mSurrendered)   return;
  if (mArrowNavigation) {
    if (!hasWindowFocus) {
      mLastSelectedIcon=mRollo.mState.selectedIconIndex;
      mRollo.setHomeSelected(SELECTED_NONE);
      mRollo.clearSelectedIcon();
      mRollo.mState.save();
    }
 else {
      if (mRollo.mState.iconCount > 0) {
        if (mLastSelection == SELECTION_ICONS) {
          int selection=mLastSelectedIcon;
          final int firstIcon=Math.round(mRollo.mScrollPos) * mColumnsPerPage;
          if (selection < 0 || selection < firstIcon || selection >= mRollo.mState.iconCount || selection >= firstIcon + (mColumnsPerPage * mRowsPerPage)) {
            selection=firstIcon;
          }
          mRollo.selectIcon(selection,SELECTED_FOCUSED);
          mRollo.mState.save();
        }
 else         if (mLastSelection == SELECTION_HOME) {
          mRollo.setHomeSelected(SELECTED_FOCUSED);
          mRollo.mState.save();
        }
      }
    }
  }
}
Program: 45452
Project: 45452
Buggy source:
public void dumpState(){
  Log.d(TAG,"String_Node_Str" + mRS);
  Log.d(TAG,"String_Node_Str" + mRollo);
  ApplicationInfo.dumpApplicationInfoList(TAG,"String_Node_Str",mAllAppsList);
  Log.d(TAG,"String_Node_Str" + mArrowNavigation);
  Log.d(TAG,"String_Node_Str" + mStartedScrolling);
  Log.d(TAG,"String_Node_Str" + mLastSelection);
  Log.d(TAG,"String_Node_Str" + mLastSelectedIcon);
  Log.d(TAG,"String_Node_Str" + mVelocityTracker);
  Log.d(TAG,"String_Node_Str" + mTouchTracking);
  Log.d(TAG,"String_Node_Str" + mShouldGainFocus);
  Log.d(TAG,"String_Node_Str" + mZoomDirty);
  Log.d(TAG,"String_Node_Str" + mAnimateNextZoom);
  Log.d(TAG,"String_Node_Str" + mZoom);
  Log.d(TAG,"String_Node_Str" + mPosX);
  Log.d(TAG,"String_Node_Str" + mVelocity);
  Log.d(TAG,"String_Node_Str" + mMessageProc);
  if (mRollo != null) {
    mRollo.dumpState();
  }
  if (mRS != null) {
    mRS.contextDump(0);
  }
}

Fixed version (ground truth):
public void dumpState(){
  Log.d(TAG,"String_Node_Str" + mRS);
  Log.d(TAG,"String_Node_Str" + mRollo);
  ApplicationInfo.dumpApplicationInfoList(TAG,"String_Node_Str",mAllAppsList);
  Log.d(TAG,"String_Node_Str" + mArrowNavigation);
  Log.d(TAG,"String_Node_Str" + mStartedScrolling);
  Log.d(TAG,"String_Node_Str" + mLastSelection);
  Log.d(TAG,"String_Node_Str" + mLastSelectedIcon);
  Log.d(TAG,"String_Node_Str" + mVelocityTracker);
  Log.d(TAG,"String_Node_Str" + mTouchTracking);
  Log.d(TAG,"String_Node_Str" + mShouldGainFocus);
  Log.d(TAG,"String_Node_Str" + mZoomDirty);
  Log.d(TAG,"String_Node_Str" + mAnimateNextZoom);
  Log.d(TAG,"String_Node_Str" + mZoom);
  Log.d(TAG,"String_Node_Str" + mRollo.mScrollPos);
  Log.d(TAG,"String_Node_Str" + mVelocity);
  Log.d(TAG,"String_Node_Str" + mMessageProc);
  if (mRollo != null) {
    mRollo.dumpState();
  }
  if (mRS != null) {
    mRS.contextDump(0);
  }
}
Program: 45453
Project: 45453
Buggy source:
@Override public void surfaceDestroyed(SurfaceHolder holder){
  super.surfaceDestroyed(holder);
  mRS.mMessageCallback=null;
}

Fixed version (ground truth):
@Override public void surfaceDestroyed(SurfaceHolder holder){
  super.surfaceDestroyed(holder);
  mRS.mMessageCallback=null;
  mZoomDirty=true;
  mHaveSurface=false;
}
Program: 45454
Project: 45454
Buggy source:
void dirtyCheck(){
  if (mZoomDirty) {
    setZoom(mZoom,mAnimateNextZoom);
  }
}

Fixed version (ground truth):
void dirtyCheck(){
  if (mZoomDirty) {
    setZoom(mNextZoom,mAnimateNextZoom);
  }
}
Program: 45455
Project: 45455
Buggy source:
@Override public void surfaceChanged(SurfaceHolder holder,int format,int w,int h){
  super.surfaceChanged(holder,format,w,h);
  if (mRollo == null) {
    mRollo=new RolloRS();
    mRollo.init(getResources(),w,h);
    if (mAllAppsList != null) {
      mRollo.setApps(mAllAppsList);
    }
    if (mShouldGainFocus) {
      gainFocus();
      mShouldGainFocus=false;
    }
  }
  mRollo.dirtyCheck();
  mRollo.resize(w,h);
  mRS.mMessageCallback=mMessageProc=new AAMessage();
  Resources res=getContext().getResources();
  int barHeight=(int)res.getDimension(R.dimen.button_bar_height);
}

Fixed version (ground truth):
@Override public void surfaceChanged(SurfaceHolder holder,int format,int w,int h){
  super.surfaceChanged(holder,format,w,h);
  mHaveSurface=true;
  if (mRollo == null) {
    mRollo=new RolloRS();
    mRollo.init(getResources(),w,h);
    if (mAllAppsList != null) {
      mRollo.setApps(mAllAppsList);
    }
    if (mShouldGainFocus) {
      gainFocus();
      mShouldGainFocus=false;
    }
  }
  mRollo.dirtyCheck();
  mRollo.resize(w,h);
  mRS.mMessageCallback=mMessageProc=new AAMessage();
  Resources res=getContext().getResources();
  int barHeight=(int)res.getDimension(R.dimen.button_bar_height);
}
Program: 45456
Project: 45456
Buggy source:
/** 
 * Zoom to the specifed level.
 * @param zoom [0..1] 0 is hidden, 1 is open
 */
public void zoom(float zoom,boolean animate){
  cancelLongPress();
  if (mRollo == null) {
    mZoomDirty=true;
    mZoom=zoom;
    mAnimateNextZoom=animate;
    return;
  }
 else {
    mRollo.setZoom(zoom,animate);
  }
}

Fixed version (ground truth):
/** 
 * Zoom to the specifed level.
 * @param zoom [0..1] 0 is hidden, 1 is open
 */
public void zoom(float zoom,boolean animate){
  cancelLongPress();
  mNextZoom=zoom;
  mAnimateNextZoom=animate;
  if (mRollo == null || !mHaveSurface) {
    mZoomDirty=true;
    mZoom=zoom;
    return;
  }
 else {
    mRollo.setZoom(zoom,animate);
  }
}
Program: 45457
Project: 45457
Buggy source:
/** 
 * Handle the allocations for the removed app.  Make sure you call saveAppsList when done.
 */
private void removeApp(int index){
  final int count=mState.iconCount - index - 1;
  final int src=index + 1;
  System.arraycopy(mIcons,src,mIcons,index,count);
  System.arraycopy(mIconIds,src,mIconIds,index,count);
  System.arraycopy(mLabels,src,mLabels,index,count);
  System.arraycopy(mLabelIds,src,mLabelIds,index,count);
  mRollo.mState.iconCount--;
  final int last=mState.iconCount - 1;
  mIcons[last]=null;
  mIconIds[last]=0;
  mLabels[last]=null;
  mLabelIds[last]=0;
}

Fixed version (ground truth):
/** 
 * Handle the allocations for the removed app.  Make sure you call saveAppsList when done.
 */
private void removeApp(int index){
  final int count=mState.iconCount - index - 1;
  final int src=index + 1;
  System.arraycopy(mIcons,src,mIcons,index,count);
  System.arraycopy(mIconIds,src,mIconIds,index,count);
  System.arraycopy(mLabels,src,mLabels,index,count);
  System.arraycopy(mLabelIds,src,mLabelIds,index,count);
  mRollo.mState.iconCount--;
  final int last=mState.iconCount;
  mIcons[last]=null;
  mIconIds[last]=0;
  mLabels[last]=null;
  mLabelIds[last]=0;
}
Program: 45458
Project: 45458
Buggy source:
public void addApps(ArrayList<ApplicationInfo> list){
  if (mAllAppsList == null) {
    return;
  }
  final int N=list.size();
  if (mRollo != null && mRollo.mHasSurface) {
    mRollo.reallocAppsList(mRollo.mState.iconCount + N);
  }
  for (int i=0; i < N; i++) {
    final ApplicationInfo item=list.get(i);
    int index=Collections.binarySearch(mAllAppsList,item,LauncherModel.APP_NAME_COMPARATOR);
    if (index < 0) {
      index=-(index + 1);
    }
    mAllAppsList.add(index,item);
    if (mRollo != null && mRollo.mHasSurface) {
      mRollo.addApp(index,item);
      mRollo.mState.iconCount++;
    }
  }
  if (mRollo != null && mRollo.mHasSurface) {
    mRollo.saveAppsList();
  }
}

Fixed version (ground truth):
public void addApps(ArrayList<ApplicationInfo> list){
  if (mAllAppsList == null) {
    return;
  }
  final int N=list.size();
  if (mRollo != null) {
    mRollo.reallocAppsList(mRollo.mState.iconCount + N);
  }
  for (int i=0; i < N; i++) {
    final ApplicationInfo item=list.get(i);
    int index=Collections.binarySearch(mAllAppsList,item,LauncherModel.APP_NAME_COMPARATOR);
    if (index < 0) {
      index=-(index + 1);
    }
    mAllAppsList.add(index,item);
    if (mRollo != null) {
      mRollo.addApp(index,item);
    }
  }
  if (mRollo != null) {
    mRollo.saveAppsList();
  }
}
Program: 45459
Project: 45459
Buggy source:
private void setApps(ArrayList<ApplicationInfo> list){
  final int count=list != null ? list.size() : 0;
  int allocCount=count;
  if (allocCount < 1) {
    allocCount=1;
  }
  mIcons=new Allocation[count];
  mIconIds=new int[allocCount];
  mAllocIconIds=Allocation.createSized(mRS,Element.USER_I32(mRS),allocCount);
  mLabels=new Allocation[count];
  mLabelIds=new int[allocCount];
  mAllocLabelIds=Allocation.createSized(mRS,Element.USER_I32(mRS),allocCount);
  Element ie8888=Element.RGBA_8888(mRS);
  Utilities.BubbleText bubble=new Utilities.BubbleText(getContext());
  mState.iconCount=count;
  uploadApps(list);
  saveAppsList();
}

Fixed version (ground truth):
private void setApps(ArrayList<ApplicationInfo> list){
  final int count=list != null ? list.size() : 0;
  int allocCount=count;
  if (allocCount < 1) {
    allocCount=1;
  }
  mIcons=new Allocation[count];
  mIconIds=new int[allocCount];
  mAllocIconIds=Allocation.createSized(mRS,Element.USER_I32(mRS),allocCount);
  mLabels=new Allocation[count];
  mLabelIds=new int[allocCount];
  mAllocLabelIds=Allocation.createSized(mRS,Element.USER_I32(mRS),allocCount);
  Element ie8888=Element.RGBA_8888(mRS);
  mState.iconCount=count;
  for (int i=0; i < mState.iconCount; i++) {
    createAppIconAllocations(i,list.get(i));
    uploadAppIcon(i,list.get(i));
  }
  saveAppsList();
}
Program: 45460
Project: 45460
Buggy source:
private void uploadAppIcon(int index,ApplicationInfo item){
  mIcons[index]=Allocation.createFromBitmap(mRS,item.iconBitmap,Element.RGBA_8888(mRS),true);
  frameBitmapAllocMips(mIcons[index],item.iconBitmap.getWidth(),item.iconBitmap.getHeight());
  mLabels[index]=Allocation.createFromBitmap(mRS,item.titleBitmap,Element.RGBA_8888(mRS),true);
  frameBitmapAllocMips(mLabels[index],item.titleBitmap.getWidth(),item.titleBitmap.getHeight());
  mIcons[index].uploadToTexture(0);
  mLabels[index].uploadToTexture(0);
  mIconIds[index]=mIcons[index].getID();
  mLabelIds[index]=mLabels[index].getID();
}

Fixed version (ground truth):
private void uploadAppIcon(int index,ApplicationInfo item){
  if (mIconIds[index] != mIcons[index].getID()) {
    throw new IllegalStateException("String_Node_Str" + index + "String_Node_Str"+ mIcons[index].getID()+ "String_Node_Str"+ mIconIds[index]+ "String_Node_Str"+ item);
  }
  mIcons[index].uploadToTexture(0);
  mLabels[index].uploadToTexture(0);
}
Program: 45461
Project: 45461
Buggy source:
void dirtyCheck(){
  if (mHasSurface) {
    if (mAppsDirty) {
      uploadApps(mAllAppsList);
      saveAppsList();
      mAppsDirty=false;
    }
    if (mZoomDirty) {
      setZoom(mZoom,mAnimateNextZoom);
    }
  }
}

Fixed version (ground truth):
void dirtyCheck(){
  if (mHasSurface) {
    if (mAppsDirty) {
      for (int i=0; i < mState.iconCount; i++) {
        uploadAppIcon(i,mAllAppsList.get(i));
      }
      saveAppsList();
      mAppsDirty=false;
    }
    if (mZoomDirty) {
      setZoom(mZoom,mAnimateNextZoom);
    }
  }
}
Program: 45462
Project: 45462
Buggy source:
public void removeApps(ArrayList<ApplicationInfo> list){
  if (mAllAppsList == null) {
    return;
  }
  final int N=list.size();
  for (int i=0; i < N; i++) {
    final ApplicationInfo item=list.get(i);
    int index=findAppByComponent(mAllAppsList,item);
    if (index >= 0) {
      int ic=mRollo != null ? mRollo.mState.iconCount : 666;
      mAllAppsList.remove(index);
      if (mRollo != null && mRollo.mHasSurface) {
        mRollo.removeApp(index);
      }
    }
 else {
      Log.w(TAG,"String_Node_Str" + item + "String_Node_Str");
    }
  }
  if (mRollo != null && mRollo.mHasSurface) {
    mRollo.saveAppsList();
  }
}

Fixed version (ground truth):
public void removeApps(ArrayList<ApplicationInfo> list){
  if (mAllAppsList == null) {
    return;
  }
  final int N=list.size();
  for (int i=0; i < N; i++) {
    final ApplicationInfo item=list.get(i);
    int index=findAppByComponent(mAllAppsList,item);
    if (index >= 0) {
      int ic=mRollo != null ? mRollo.mState.iconCount : 666;
      mAllAppsList.remove(index);
      if (mRollo != null) {
        mRollo.removeApp(index);
      }
    }
 else {
      Log.w(TAG,"String_Node_Str" + item + "String_Node_Str");
    }
  }
  if (mRollo != null) {
    mRollo.saveAppsList();
  }
}
Program: 45463
Project: 45463
Buggy source:
/** 
 * Handle the allocations for the new app.  Make sure you call saveAppsList when done.
 */
private void addApp(int index,ApplicationInfo item){
  final int count=mState.iconCount - index;
  final int dest=index + 1;
  System.arraycopy(mIcons,index,mIcons,dest,count);
  System.arraycopy(mIconIds,index,mIconIds,dest,count);
  System.arraycopy(mLabels,index,mLabels,dest,count);
  System.arraycopy(mLabelIds,index,mLabelIds,dest,count);
  if (mHasSurface) {
    uploadAppIcon(index,item);
  }
 else {
    mAppsDirty=true;
  }
}

Fixed version (ground truth):
/** 
 * Handle the allocations for the new app.  Make sure you call saveAppsList when done.
 */
private void addApp(int index,ApplicationInfo item){
  final int count=mState.iconCount - index;
  final int dest=index + 1;
  System.arraycopy(mIcons,index,mIcons,dest,count);
  System.arraycopy(mIconIds,index,mIconIds,dest,count);
  System.arraycopy(mLabels,index,mLabels,dest,count);
  System.arraycopy(mLabelIds,index,mLabelIds,dest,count);
  createAppIconAllocations(index,item);
  if (mHasSurface) {
    uploadAppIcon(index,item);
  }
 else {
    mAppsDirty=true;
  }
  mRollo.mState.iconCount++;
}
Program: 45464
Project: 45464
Buggy source:
@Override protected void onFocusChanged(boolean gainFocus,int direction,Rect previouslyFocusedRect){
  super.onFocusChanged(gainFocus,direction,previouslyFocusedRect);
  if (!isVisible()) {
    return;
  }
  if (gainFocus) {
    if (mRollo != null && mRollo.mHasSurface) {
      gainFocus();
    }
 else {
      mShouldGainFocus=true;
    }
  }
 else {
    if (mRollo != null && mRollo.mHasSurface) {
      if (mArrowNavigation) {
        mRollo.clearSelectedIcon();
        mRollo.setHomeSelected(SELECTED_NONE);
        mRollo.mState.save();
        mArrowNavigation=false;
      }
    }
 else {
      mShouldGainFocus=false;
    }
  }
}

Fixed version (ground truth):
@Override protected void onFocusChanged(boolean gainFocus,int direction,Rect previouslyFocusedRect){
  super.onFocusChanged(gainFocus,direction,previouslyFocusedRect);
  if (!isVisible()) {
    return;
  }
  if (gainFocus) {
    if (mRollo != null && mRollo.mHasSurface) {
      gainFocus();
    }
 else {
      mShouldGainFocus=true;
    }
  }
 else {
    if (mRollo != null) {
      if (mArrowNavigation) {
        mRollo.clearSelectedIcon();
        mRollo.setHomeSelected(SELECTED_NONE);
        mRollo.mState.save();
        mArrowNavigation=false;
      }
    }
 else {
      mShouldGainFocus=false;
    }
  }
}
Program: 45465
Project: 45465
Buggy source:
/** 
 * Handle the allocations for the removed app.  Make sure you call saveAppsList when done.
 */
private void removeApp(int index){
  final int count=mState.iconCount - index - 1;
  final int src=index + 1;
  System.arraycopy(mIcons,src,mIcons,index,count);
  System.arraycopy(mIconIds,src,mIconIds,index,count);
  System.arraycopy(mLabels,src,mLabels,index,count);
  System.arraycopy(mLabelIds,src,mLabelIds,index,count);
  mRollo.mState.iconCount--;
  final int last=mState.iconCount - 1;
  mIcons[last]=null;
  mIconIds[last]=0;
  mLabels[last]=null;
  mLabelIds[last]=0;
}

Fixed version (ground truth):
/** 
 * Handle the allocations for the removed app.  Make sure you call saveAppsList when done.
 */
private void removeApp(int index){
  final int count=mState.iconCount - index - 1;
  final int src=index + 1;
  System.arraycopy(mIcons,src,mIcons,index,count);
  System.arraycopy(mIconIds,src,mIconIds,index,count);
  System.arraycopy(mLabels,src,mLabels,index,count);
  System.arraycopy(mLabelIds,src,mLabelIds,index,count);
  mRollo.mState.iconCount--;
  final int last=mState.iconCount;
  mIcons[last]=null;
  mIconIds[last]=0;
  mLabels[last]=null;
  mLabelIds[last]=0;
}
Program: 45466
Project: 45466
Buggy source:
public void addApps(ArrayList<ApplicationInfo> list){
  if (mAllAppsList == null) {
    return;
  }
  final int N=list.size();
  if (mRollo != null && mRollo.mHasSurface) {
    mRollo.reallocAppsList(mRollo.mState.iconCount + N);
  }
  for (int i=0; i < N; i++) {
    final ApplicationInfo item=list.get(i);
    int index=Collections.binarySearch(mAllAppsList,item,LauncherModel.APP_NAME_COMPARATOR);
    if (index < 0) {
      index=-(index + 1);
    }
    mAllAppsList.add(index,item);
    if (mRollo != null && mRollo.mHasSurface) {
      mRollo.addApp(index,item);
      mRollo.mState.iconCount++;
    }
  }
  if (mRollo != null && mRollo.mHasSurface) {
    mRollo.saveAppsList();
  }
}

Fixed version (ground truth):
public void addApps(ArrayList<ApplicationInfo> list){
  if (mAllAppsList == null) {
    return;
  }
  final int N=list.size();
  if (mRollo != null) {
    mRollo.reallocAppsList(mRollo.mState.iconCount + N);
  }
  for (int i=0; i < N; i++) {
    final ApplicationInfo item=list.get(i);
    int index=Collections.binarySearch(mAllAppsList,item,LauncherModel.APP_NAME_COMPARATOR);
    if (index < 0) {
      index=-(index + 1);
    }
    mAllAppsList.add(index,item);
    if (mRollo != null) {
      mRollo.addApp(index,item);
    }
  }
  if (mRollo != null) {
    mRollo.saveAppsList();
  }
}
Program: 45467
Project: 45467
Buggy source:
private void setApps(ArrayList<ApplicationInfo> list){
  final int count=list != null ? list.size() : 0;
  int allocCount=count;
  if (allocCount < 1) {
    allocCount=1;
  }
  mIcons=new Allocation[count];
  mIconIds=new int[allocCount];
  mAllocIconIds=Allocation.createSized(mRS,Element.USER_I32(mRS),allocCount);
  mLabels=new Allocation[count];
  mLabelIds=new int[allocCount];
  mAllocLabelIds=Allocation.createSized(mRS,Element.USER_I32(mRS),allocCount);
  Element ie8888=Element.RGBA_8888(mRS);
  Utilities.BubbleText bubble=new Utilities.BubbleText(getContext());
  mState.iconCount=count;
  uploadApps(list);
  saveAppsList();
}

Fixed version (ground truth):
private void setApps(ArrayList<ApplicationInfo> list){
  final int count=list != null ? list.size() : 0;
  int allocCount=count;
  if (allocCount < 1) {
    allocCount=1;
  }
  mIcons=new Allocation[count];
  mIconIds=new int[allocCount];
  mAllocIconIds=Allocation.createSized(mRS,Element.USER_I32(mRS),allocCount);
  mLabels=new Allocation[count];
  mLabelIds=new int[allocCount];
  mAllocLabelIds=Allocation.createSized(mRS,Element.USER_I32(mRS),allocCount);
  Element ie8888=Element.RGBA_8888(mRS);
  mState.iconCount=count;
  for (int i=0; i < mState.iconCount; i++) {
    createAppIconAllocations(i,list.get(i));
    uploadAppIcon(i,list.get(i));
  }
  saveAppsList();
}
Program: 45468
Project: 45468
Buggy source:
private void uploadAppIcon(int index,ApplicationInfo item){
  mIcons[index]=Allocation.createFromBitmap(mRS,item.iconBitmap,Element.RGBA_8888(mRS),true);
  frameBitmapAllocMips(mIcons[index],item.iconBitmap.getWidth(),item.iconBitmap.getHeight());
  mLabels[index]=Allocation.createFromBitmap(mRS,item.titleBitmap,Element.RGBA_8888(mRS),true);
  frameBitmapAllocMips(mLabels[index],item.titleBitmap.getWidth(),item.titleBitmap.getHeight());
  mIcons[index].uploadToTexture(0);
  mLabels[index].uploadToTexture(0);
  mIconIds[index]=mIcons[index].getID();
  mLabelIds[index]=mLabels[index].getID();
}

Fixed version (ground truth):
private void uploadAppIcon(int index,ApplicationInfo item){
  if (mIconIds[index] != mIcons[index].getID()) {
    throw new IllegalStateException("String_Node_Str" + index + "String_Node_Str"+ mIcons[index].getID()+ "String_Node_Str"+ mIconIds[index]+ "String_Node_Str"+ item);
  }
  mIcons[index].uploadToTexture(0);
  mLabels[index].uploadToTexture(0);
}
Program: 45469
Project: 45469
Buggy source:
void dirtyCheck(){
  if (mHasSurface) {
    if (mAppsDirty) {
      uploadApps(mAllAppsList);
      saveAppsList();
      mAppsDirty=false;
    }
    if (mZoomDirty) {
      setZoom(mZoom,mAnimateNextZoom);
    }
  }
}

Fixed version (ground truth):
void dirtyCheck(){
  if (mHasSurface) {
    if (mAppsDirty) {
      for (int i=0; i < mState.iconCount; i++) {
        uploadAppIcon(i,mAllAppsList.get(i));
      }
      saveAppsList();
      mAppsDirty=false;
    }
    if (mZoomDirty) {
      setZoom(mZoom,mAnimateNextZoom);
    }
  }
}
Program: 45470
Project: 45470
Buggy source:
public void removeApps(ArrayList<ApplicationInfo> list){
  if (mAllAppsList == null) {
    return;
  }
  final int N=list.size();
  for (int i=0; i < N; i++) {
    final ApplicationInfo item=list.get(i);
    int index=findAppByComponent(mAllAppsList,item);
    if (index >= 0) {
      int ic=mRollo != null ? mRollo.mState.iconCount : 666;
      mAllAppsList.remove(index);
      if (mRollo != null && mRollo.mHasSurface) {
        mRollo.removeApp(index);
      }
    }
 else {
      Log.w(TAG,"String_Node_Str" + item + "String_Node_Str");
    }
  }
  if (mRollo != null && mRollo.mHasSurface) {
    mRollo.saveAppsList();
  }
}

Fixed version (ground truth):
public void removeApps(ArrayList<ApplicationInfo> list){
  if (mAllAppsList == null) {
    return;
  }
  final int N=list.size();
  for (int i=0; i < N; i++) {
    final ApplicationInfo item=list.get(i);
    int index=findAppByComponent(mAllAppsList,item);
    if (index >= 0) {
      int ic=mRollo != null ? mRollo.mState.iconCount : 666;
      mAllAppsList.remove(index);
      if (mRollo != null) {
        mRollo.removeApp(index);
      }
    }
 else {
      Log.w(TAG,"String_Node_Str" + item + "String_Node_Str");
    }
  }
  if (mRollo != null) {
    mRollo.saveAppsList();
  }
}
Program: 45471
Project: 45471
Buggy source:
/** 
 * Handle the allocations for the new app.  Make sure you call saveAppsList when done.
 */
private void addApp(int index,ApplicationInfo item){
  final int count=mState.iconCount - index;
  final int dest=index + 1;
  System.arraycopy(mIcons,index,mIcons,dest,count);
  System.arraycopy(mIconIds,index,mIconIds,dest,count);
  System.arraycopy(mLabels,index,mLabels,dest,count);
  System.arraycopy(mLabelIds,index,mLabelIds,dest,count);
  if (mHasSurface) {
    uploadAppIcon(index,item);
  }
 else {
    mAppsDirty=true;
  }
}

Fixed version (ground truth):
/** 
 * Handle the allocations for the new app.  Make sure you call saveAppsList when done.
 */
private void addApp(int index,ApplicationInfo item){
  final int count=mState.iconCount - index;
  final int dest=index + 1;
  System.arraycopy(mIcons,index,mIcons,dest,count);
  System.arraycopy(mIconIds,index,mIconIds,dest,count);
  System.arraycopy(mLabels,index,mLabels,dest,count);
  System.arraycopy(mLabelIds,index,mLabelIds,dest,count);
  createAppIconAllocations(index,item);
  if (mHasSurface) {
    uploadAppIcon(index,item);
  }
 else {
    mAppsDirty=true;
  }
  mRollo.mState.iconCount++;
}
Program: 45472
Project: 45472
Buggy source:
@Override protected void onFocusChanged(boolean gainFocus,int direction,Rect previouslyFocusedRect){
  super.onFocusChanged(gainFocus,direction,previouslyFocusedRect);
  if (!isVisible()) {
    return;
  }
  if (gainFocus) {
    if (mRollo != null && mRollo.mHasSurface) {
      gainFocus();
    }
 else {
      mShouldGainFocus=true;
    }
  }
 else {
    if (mRollo != null && mRollo.mHasSurface) {
      if (mArrowNavigation) {
        mRollo.clearSelectedIcon();
        mRollo.setHomeSelected(SELECTED_NONE);
        mRollo.mState.save();
        mArrowNavigation=false;
      }
    }
 else {
      mShouldGainFocus=false;
    }
  }
}

Fixed version (ground truth):
@Override protected void onFocusChanged(boolean gainFocus,int direction,Rect previouslyFocusedRect){
  super.onFocusChanged(gainFocus,direction,previouslyFocusedRect);
  if (!isVisible()) {
    return;
  }
  if (gainFocus) {
    if (mRollo != null && mRollo.mHasSurface) {
      gainFocus();
    }
 else {
      mShouldGainFocus=true;
    }
  }
 else {
    if (mRollo != null) {
      if (mArrowNavigation) {
        mRollo.clearSelectedIcon();
        mRollo.setHomeSelected(SELECTED_NONE);
        mRollo.mState.save();
        mArrowNavigation=false;
      }
    }
 else {
      mShouldGainFocus=false;
    }
  }
}
Program: 45473
Project: 45473
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  closeSystemDialogs();
  String reason=intent.getStringExtra("String_Node_Str");
  if (!"String_Node_Str".equals(reason)) {
    boolean animate=true;
    closeAllApps(animate);
  }
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  closeSystemDialogs();
  String reason=intent.getStringExtra("String_Node_Str");
  if (!"String_Node_Str".equals(reason)) {
    boolean animate=true;
    if (mPaused || "String_Node_Str".equals(reason)) {
      animate=false;
    }
    closeAllApps(animate);
  }
}
Program: 45474
Project: 45474
Buggy source:
@Override protected void onPause(){
  super.onPause();
  dismissPreview(mPreviousView);
  dismissPreview(mNextView);
  mDragController.cancelDrag();
  unregisterReceiver(mCloseSystemDialogsReceiver);
}

Fixed version (ground truth):
@Override protected void onPause(){
  super.onPause();
  dismissPreview(mPreviousView);
  dismissPreview(mNextView);
  mDragController.cancelDrag();
}
Program: 45475
Project: 45475
Buggy source:
@Override public void onDestroy(){
  super.onDestroy();
  try {
    mAppWidgetHost.stopListening();
  }
 catch (  NullPointerException ex) {
    Log.w(TAG,"String_Node_Str",ex);
  }
  TextKeyListener.getInstance().release();
  mModel.stopLoader();
  unbindDesktopItems();
  AppInfoCache.unbindDrawables();
  getContentResolver().unregisterContentObserver(mWidgetObserver);
  dismissPreview(mPreviousView);
  dismissPreview(mNextView);
}

Fixed version (ground truth):
@Override public void onDestroy(){
  super.onDestroy();
  try {
    mAppWidgetHost.stopListening();
  }
 catch (  NullPointerException ex) {
    Log.w(TAG,"String_Node_Str",ex);
  }
  TextKeyListener.getInstance().release();
  mModel.stopLoader();
  unbindDesktopItems();
  AppInfoCache.unbindDrawables();
  getContentResolver().unregisterContentObserver(mWidgetObserver);
  dismissPreview(mPreviousView);
  dismissPreview(mNextView);
  unregisterReceiver(mCloseSystemDialogsReceiver);
}
Program: 45476
Project: 45476
Buggy source:
@Override protected void onResume(){
  super.onResume();
  IntentFilter filter=new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
  registerReceiver(mCloseSystemDialogsReceiver,filter);
  if (mRestoring) {
    mWorkspaceLoading=true;
    mModel.startLoader(this,true);
    mRestoring=false;
  }
  if (mIsNewIntent) {
    mWorkspace.post(new Runnable(){
      public void run(){
        stopSearch();
      }
    }
);
  }
  mIsNewIntent=false;
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  mPaused=false;
  if (mRestoring) {
    mWorkspaceLoading=true;
    mModel.startLoader(this,true);
    mRestoring=false;
  }
  if (mIsNewIntent) {
    mWorkspace.post(new Runnable(){
      public void run(){
        stopSearch();
      }
    }
);
  }
  mIsNewIntent=false;
}
Program: 45477
Project: 45477
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mModel=((LauncherApplication)getApplication()).setLauncher(this);
  mDragController=new DragController(this);
  mInflater=getLayoutInflater();
  mAppWidgetManager=AppWidgetManager.getInstance(this);
  mAppWidgetHost=new LauncherAppWidgetHost(this,APPWIDGET_HOST_ID);
  mAppWidgetHost.startListening();
  if (PROFILE_STARTUP) {
    android.os.Debug.startMethodTracing("String_Node_Str");
  }
  checkForLocaleChange();
  setWallpaperDimension();
  setContentView(R.layout.launcher);
  setupViews();
  registerContentObservers();
  lockAllApps();
  mSavedState=savedInstanceState;
  restoreState(mSavedState);
  if (PROFILE_STARTUP) {
    android.os.Debug.stopMethodTracing();
  }
  mModel.setAllAppsDirty();
  mModel.setWorkspaceDirty();
  if (!mRestoring) {
    mModel.startLoader(this,true);
  }
  mDefaultKeySsb=new SpannableStringBuilder();
  Selection.setSelection(mDefaultKeySsb,0);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mModel=((LauncherApplication)getApplication()).setLauncher(this);
  mDragController=new DragController(this);
  mInflater=getLayoutInflater();
  mAppWidgetManager=AppWidgetManager.getInstance(this);
  mAppWidgetHost=new LauncherAppWidgetHost(this,APPWIDGET_HOST_ID);
  mAppWidgetHost.startListening();
  if (PROFILE_STARTUP) {
    android.os.Debug.startMethodTracing("String_Node_Str");
  }
  checkForLocaleChange();
  setWallpaperDimension();
  setContentView(R.layout.launcher);
  setupViews();
  registerContentObservers();
  lockAllApps();
  mSavedState=savedInstanceState;
  restoreState(mSavedState);
  if (PROFILE_STARTUP) {
    android.os.Debug.stopMethodTracing();
  }
  mModel.setAllAppsDirty();
  mModel.setWorkspaceDirty();
  if (!mRestoring) {
    mModel.startLoader(this,true);
  }
  mDefaultKeySsb=new SpannableStringBuilder();
  Selection.setSelection(mDefaultKeySsb,0);
  IntentFilter filter=new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
  registerReceiver(mCloseSystemDialogsReceiver,filter);
}