nus-yam/ex-repair huggingface dataset:
Program: 83693
Project: 83693
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: 83694
Project: 83694
Buggy source:
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);
    }
  }
}

Fixed version (ground truth):
void dirtyCheck(){
  if (mHasSurface) {
    if (mAppsDirty && mAllAppsList != null) {
      for (int i=0; i < mState.iconCount; i++) {
        uploadAppIcon(i,mAllAppsList.get(i));
      }
      saveAppsList();
      mAppsDirty=false;
    }
    if (mZoomDirty) {
      setZoom(mZoom,mAnimateNextZoom);
    }
  }
}
Program: 83695
Project: 83695
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: 83696
Project: 83696
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: 83697
Project: 83697
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: 83698
Project: 83698
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: 83699
Project: 83699
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: 83700
Project: 83700
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: 83701
Project: 83701
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: 83702
Project: 83702
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: 83703
Project: 83703
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: 83704
Project: 83704
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: 83705
Project: 83705
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: 83706
Project: 83706
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: 83707
Project: 83707
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: 83708
Project: 83708
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: 83709
Project: 83709
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: 83710
Project: 83710
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: 83711
Project: 83711
Buggy source:
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);
    }
  }
}

Fixed version (ground truth):
void dirtyCheck(){
  if (mHasSurface) {
    if (mAppsDirty && mAllAppsList != null) {
      for (int i=0; i < mState.iconCount; i++) {
        uploadAppIcon(i,mAllAppsList.get(i));
      }
      saveAppsList();
      mAppsDirty=false;
    }
    if (mZoomDirty) {
      setZoom(mZoom,mAnimateNextZoom);
    }
  }
}
Program: 83712
Project: 83712
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: 83713
Project: 83713
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: 83714
Project: 83714
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: 83715
Project: 83715
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: 83716
Project: 83716
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: 83717
Project: 83717
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: 83718
Project: 83718
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: 83719
Project: 83719
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: 83720
Project: 83720
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  closeSystemDialogs();
}

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;
    closeAllApps(animate);
  }
}
Program: 83721
Project: 83721
Buggy source:
void closeSystemDialogs(){
  closeAllApps(true);
  getWindow().closeAllPanels();
  try {
    dismissDialog(DIALOG_CREATE_SHORTCUT);
  }
 catch (  Exception e) {
  }
  try {
    dismissDialog(DIALOG_RENAME_FOLDER);
  }
 catch (  Exception e) {
  }
  mWaitingForResult=false;
}

Fixed version (ground truth):
void closeSystemDialogs(){
  getWindow().closeAllPanels();
  try {
    dismissDialog(DIALOG_CREATE_SHORTCUT);
  }
 catch (  Exception e) {
  }
  try {
    dismissDialog(DIALOG_RENAME_FOLDER);
  }
 catch (  Exception e) {
  }
  mWaitingForResult=false;
}
Program: 83722
Project: 83722
Buggy source:
void closeAllApps(boolean animated){
  if (mAllAppsGrid.isVisible()) {
    mAllAppsGrid.zoom(0.0f,animated);
    mAllAppsGrid.setFocusable(false);
    mWorkspace.getChildAt(mWorkspace.getCurrentScreen()).requestFocus();
    mWorkspace.startFading(true);
  }
}

Fixed version (ground truth):
/** 
 * Things to test when changing this code: - Home from workspace - from center screen - from other screens - Home from all apps - Back from all apps - Launch app from workspace and quit - with back - with home - Launch app from all apps and quit - with back - with home - On workspace, long press power and go back - with back - with home - On all apps, long press power and go back - with back - with home - On workspace, power off - On all apps, power off
 */
void closeAllApps(boolean animated){
  if (mAllAppsGrid.isVisible()) {
    mAllAppsGrid.zoom(0.0f,animated);
    mAllAppsGrid.setFocusable(false);
    mWorkspace.getChildAt(mWorkspace.getCurrentScreen()).requestFocus();
    mWorkspace.startFading(true);
  }
}
Program: 83724
Project: 83724
Buggy source:
private void bindAllApps(){
synchronized (mLock) {
    final ArrayList<ApplicationInfo> results=mAllAppsList.added;
    mAllAppsList.added=new ArrayList<ApplicationInfo>();
    mHandler.post(new Runnable(){
      public void run(){
        final long t=SystemClock.uptimeMillis();
        final int count=results.size();
        Callbacks callbacks=tryGetCallbacks();
        if (callbacks != null) {
          callbacks.bindAllApplications(results);
        }
        if (DEBUG_LOADERS) {
          Log.d(TAG,"String_Node_Str" + count + "String_Node_Str"+ (SystemClock.uptimeMillis() - t)+ "String_Node_Str");
        }
      }
    }
);
  }
}

Fixed version (ground truth):
private void bindAllApps(){
synchronized (mLock) {
    final ArrayList<ApplicationInfo> results=(ArrayList<ApplicationInfo>)mAllAppsList.data.clone();
    mAllAppsList.added=new ArrayList<ApplicationInfo>();
    mHandler.post(new Runnable(){
      public void run(){
        final long t=SystemClock.uptimeMillis();
        final int count=results.size();
        Callbacks callbacks=tryGetCallbacks();
        if (callbacks != null) {
          callbacks.bindAllApplications(results);
        }
        if (DEBUG_LOADERS) {
          Log.d(TAG,"String_Node_Str" + count + "String_Node_Str"+ (SystemClock.uptimeMillis() - t)+ "String_Node_Str");
        }
      }
    }
);
  }
}
Program: 83725
Project: 83725
Buggy source:
@Override protected void onNewIntent(Intent intent){
  super.onNewIntent(intent);
  if (Intent.ACTION_MAIN.equals(intent.getAction())) {
    closeSystemDialogs();
    mWaitingForResult=false;
    mIsNewIntent=true;
    if (!mWorkspace.isDefaultScreenShowing()) {
      mWorkspace.moveToDefaultScreen();
    }
    closeAllApps(false);
    final View v=getWindow().peekDecorView();
    if (v != null && v.getWindowToken() != null) {
      InputMethodManager imm=(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(v.getWindowToken(),0);
    }
  }
}

Fixed version (ground truth):
@Override protected void onNewIntent(Intent intent){
  super.onNewIntent(intent);
  if (Intent.ACTION_MAIN.equals(intent.getAction())) {
    closeSystemDialogs();
    mIsNewIntent=true;
    if (!mWorkspace.isDefaultScreenShowing()) {
      mWorkspace.moveToDefaultScreen();
    }
    closeAllApps(false);
    final View v=getWindow().peekDecorView();
    if (v != null && v.getWindowToken() != null) {
      InputMethodManager imm=(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(v.getWindowToken(),0);
    }
  }
}
Program: 83726
Project: 83726
Buggy source:
void closeSystemDialogs(){
  closeAllApps(false);
  getWindow().closeAllPanels();
  try {
    dismissDialog(DIALOG_CREATE_SHORTCUT);
  }
 catch (  Exception e) {
  }
  try {
    dismissDialog(DIALOG_RENAME_FOLDER);
  }
 catch (  Exception e) {
  }
}

Fixed version (ground truth):
void closeSystemDialogs(){
  closeAllApps(false);
  getWindow().closeAllPanels();
  try {
    dismissDialog(DIALOG_CREATE_SHORTCUT);
  }
 catch (  Exception e) {
  }
  try {
    dismissDialog(DIALOG_RENAME_FOLDER);
  }
 catch (  Exception e) {
  }
  mWaitingForResult=false;
}
Program: 83727
Project: 83727
Buggy source:
@Override protected void onNewIntent(Intent intent){
  super.onNewIntent(intent);
  if (Intent.ACTION_MAIN.equals(intent.getAction())) {
    closeSystemDialogs();
    mIsNewIntent=true;
    if (!mWorkspace.isDefaultScreenShowing()) {
      mWorkspace.moveToDefaultScreen();
    }
    closeAllApps(false);
    final View v=getWindow().peekDecorView();
    if (v != null && v.getWindowToken() != null) {
      InputMethodManager imm=(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(v.getWindowToken(),0);
    }
  }
}

Fixed version (ground truth):
@Override protected void onNewIntent(Intent intent){
  super.onNewIntent(intent);
  if (Intent.ACTION_MAIN.equals(intent.getAction())) {
    closeSystemDialogs();
    mIsNewIntent=true;
    boolean alreadyOnHome=((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
    boolean allAppsVisible=isAllAppsVisible();
    if (!mWorkspace.isDefaultScreenShowing()) {
      mWorkspace.moveToDefaultScreen(alreadyOnHome && !allAppsVisible);
    }
    closeAllApps(alreadyOnHome && allAppsVisible);
    final View v=getWindow().peekDecorView();
    if (v != null && v.getWindowToken() != null) {
      InputMethodManager imm=(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(v.getWindowToken(),0);
    }
  }
}
Program: 83728
Project: 83728
Buggy source:
void closeSystemDialogs(){
  closeAllApps(false);
  getWindow().closeAllPanels();
  try {
    dismissDialog(DIALOG_CREATE_SHORTCUT);
  }
 catch (  Exception e) {
  }
  try {
    dismissDialog(DIALOG_RENAME_FOLDER);
  }
 catch (  Exception e) {
  }
  mWaitingForResult=false;
}

Fixed version (ground truth):
void closeSystemDialogs(){
  closeAllApps(true);
  getWindow().closeAllPanels();
  try {
    dismissDialog(DIALOG_CREATE_SHORTCUT);
  }
 catch (  Exception e) {
  }
  try {
    dismissDialog(DIALOG_RENAME_FOLDER);
  }
 catch (  Exception e) {
  }
  mWaitingForResult=false;
}
Program: 83729
Project: 83729
Buggy source:
void moveToDefaultScreen(){
  snapToScreen(mDefaultScreen);
  getChildAt(mDefaultScreen).requestFocus();
}

Fixed version (ground truth):
void moveToDefaultScreen(boolean animate){
  snapToScreen(mDefaultScreen,animate);
  getChildAt(mDefaultScreen).requestFocus();
}
Program: 83730
Project: 83730
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 * 300;
  awakenScrollBars(duration);
  mScroller.startScroll(mScrollX,0,delta,0,duration);
  invalidate();
}

Fixed version (ground truth):
void snapToScreen(int whichScreen,boolean animate){
  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 * 300;
  awakenScrollBars(duration);
  mScroller.startScroll(mScrollX,0,delta,0,animate ? duration : 1);
  invalidate();
}
Program: 83732
Project: 83732
Buggy source:
@Override protected void onNewIntent(Intent intent){
  super.onNewIntent(intent);
  if (Intent.ACTION_MAIN.equals(intent.getAction())) {
    closeSystemDialogs();
    mWaitingForResult=false;
    mIsNewIntent=true;
    if (!mWorkspace.isDefaultScreenShowing()) {
      mWorkspace.moveToDefaultScreen();
    }
    closeAllApps(false);
    final View v=getWindow().peekDecorView();
    if (v != null && v.getWindowToken() != null) {
      InputMethodManager imm=(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(v.getWindowToken(),0);
    }
  }
}

Fixed version (ground truth):
@Override protected void onNewIntent(Intent intent){
  super.onNewIntent(intent);
  if (Intent.ACTION_MAIN.equals(intent.getAction())) {
    closeSystemDialogs();
    mIsNewIntent=true;
    if (!mWorkspace.isDefaultScreenShowing()) {
      mWorkspace.moveToDefaultScreen();
    }
    closeAllApps(false);
    final View v=getWindow().peekDecorView();
    if (v != null && v.getWindowToken() != null) {
      InputMethodManager imm=(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(v.getWindowToken(),0);
    }
  }
}
Program: 83733
Project: 83733
Buggy source:
void closeSystemDialogs(){
  closeAllApps(false);
  getWindow().closeAllPanels();
  try {
    dismissDialog(DIALOG_CREATE_SHORTCUT);
  }
 catch (  Exception e) {
  }
  try {
    dismissDialog(DIALOG_RENAME_FOLDER);
  }
 catch (  Exception e) {
  }
}

Fixed version (ground truth):
void closeSystemDialogs(){
  closeAllApps(false);
  getWindow().closeAllPanels();
  try {
    dismissDialog(DIALOG_CREATE_SHORTCUT);
  }
 catch (  Exception e) {
  }
  try {
    dismissDialog(DIALOG_RENAME_FOLDER);
  }
 catch (  Exception e) {
  }
  mWaitingForResult=false;
}
Program: 83734
Project: 83734
Buggy source:
@Override protected void onNewIntent(Intent intent){
  super.onNewIntent(intent);
  if (Intent.ACTION_MAIN.equals(intent.getAction())) {
    closeSystemDialogs();
    mIsNewIntent=true;
    if (!mWorkspace.isDefaultScreenShowing()) {
      mWorkspace.moveToDefaultScreen();
    }
    closeAllApps(false);
    final View v=getWindow().peekDecorView();
    if (v != null && v.getWindowToken() != null) {
      InputMethodManager imm=(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(v.getWindowToken(),0);
    }
  }
}

Fixed version (ground truth):
@Override protected void onNewIntent(Intent intent){
  super.onNewIntent(intent);
  if (Intent.ACTION_MAIN.equals(intent.getAction())) {
    closeSystemDialogs();
    mIsNewIntent=true;
    boolean alreadyOnHome=((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
    boolean allAppsVisible=isAllAppsVisible();
    if (!mWorkspace.isDefaultScreenShowing()) {
      mWorkspace.moveToDefaultScreen(alreadyOnHome && !allAppsVisible);
    }
    closeAllApps(alreadyOnHome && allAppsVisible);
    final View v=getWindow().peekDecorView();
    if (v != null && v.getWindowToken() != null) {
      InputMethodManager imm=(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(v.getWindowToken(),0);
    }
  }
}
Program: 83735
Project: 83735
Buggy source:
void closeSystemDialogs(){
  closeAllApps(false);
  getWindow().closeAllPanels();
  try {
    dismissDialog(DIALOG_CREATE_SHORTCUT);
  }
 catch (  Exception e) {
  }
  try {
    dismissDialog(DIALOG_RENAME_FOLDER);
  }
 catch (  Exception e) {
  }
  mWaitingForResult=false;
}

Fixed version (ground truth):
void closeSystemDialogs(){
  closeAllApps(true);
  getWindow().closeAllPanels();
  try {
    dismissDialog(DIALOG_CREATE_SHORTCUT);
  }
 catch (  Exception e) {
  }
  try {
    dismissDialog(DIALOG_RENAME_FOLDER);
  }
 catch (  Exception e) {
  }
  mWaitingForResult=false;
}
Program: 83736
Project: 83736
Buggy source:
void moveToDefaultScreen(){
  snapToScreen(mDefaultScreen);
  getChildAt(mDefaultScreen).requestFocus();
}

Fixed version (ground truth):
void moveToDefaultScreen(boolean animate){
  snapToScreen(mDefaultScreen,animate);
  getChildAt(mDefaultScreen).requestFocus();
}
Program: 83737
Project: 83737
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 * 300;
  awakenScrollBars(duration);
  mScroller.startScroll(mScrollX,0,delta,0,duration);
  invalidate();
}

Fixed version (ground truth):
void snapToScreen(int whichScreen,boolean animate){
  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 * 300;
  awakenScrollBars(duration);
  mScroller.startScroll(mScrollX,0,delta,0,animate ? duration : 1);
  invalidate();
}
Program: 83738
Project: 83738
Buggy source:
private void bindAllApps(){
synchronized (mLock) {
    final ArrayList<ApplicationInfo> results=mAllAppsList.added;
    mAllAppsList.added=new ArrayList<ApplicationInfo>();
    mHandler.post(new Runnable(){
      public void run(){
        final long t=SystemClock.uptimeMillis();
        final int count=results.size();
        Callbacks callbacks=tryGetCallbacks();
        if (callbacks != null) {
          callbacks.bindAllApplications(results);
        }
        if (DEBUG_LOADERS) {
          Log.d(TAG,"String_Node_Str" + count + "String_Node_Str"+ (SystemClock.uptimeMillis() - t)+ "String_Node_Str");
        }
      }
    }
);
  }
}

Fixed version (ground truth):
private void bindAllApps(){
synchronized (mLock) {
    final ArrayList<ApplicationInfo> results=(ArrayList<ApplicationInfo>)mAllAppsList.data.clone();
    mAllAppsList.added=new ArrayList<ApplicationInfo>();
    mHandler.post(new Runnable(){
      public void run(){
        final long t=SystemClock.uptimeMillis();
        final int count=results.size();
        Callbacks callbacks=tryGetCallbacks();
        if (callbacks != null) {
          callbacks.bindAllApplications(results);
        }
        if (DEBUG_LOADERS) {
          Log.d(TAG,"String_Node_Str" + count + "String_Node_Str"+ (SystemClock.uptimeMillis() - t)+ "String_Node_Str");
        }
      }
    }
);
  }
}
Program: 83740
Project: 83740
Buggy source:
@Override protected void onNewIntent(Intent intent){
  super.onNewIntent(intent);
  if (Intent.ACTION_MAIN.equals(intent.getAction())) {
    closeSystemDialogs();
    mIsNewIntent=true;
    if (!mWorkspace.isDefaultScreenShowing()) {
      mWorkspace.moveToDefaultScreen();
    }
    closeAllApps(false);
    final View v=getWindow().peekDecorView();
    if (v != null && v.getWindowToken() != null) {
      InputMethodManager imm=(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(v.getWindowToken(),0);
    }
  }
}

Fixed version (ground truth):
@Override protected void onNewIntent(Intent intent){
  super.onNewIntent(intent);
  if (Intent.ACTION_MAIN.equals(intent.getAction())) {
    closeSystemDialogs();
    mIsNewIntent=true;
    boolean alreadyOnHome=((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
    boolean allAppsVisible=isAllAppsVisible();
    if (!mWorkspace.isDefaultScreenShowing()) {
      mWorkspace.moveToDefaultScreen(alreadyOnHome && !allAppsVisible);
    }
    closeAllApps(alreadyOnHome && allAppsVisible);
    final View v=getWindow().peekDecorView();
    if (v != null && v.getWindowToken() != null) {
      InputMethodManager imm=(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(v.getWindowToken(),0);
    }
  }
}