nus-yam/ex-repair huggingface dataset:
Program: 45478
Project: 45478
Buggy source:
/** 
 * 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 - Go to a screen that's not the default, then all apps, and launch and app, and go back - 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 - Launch an app and turn off the screen while in that app - Go back with home key - Go back with back key - From all apps - From workspace
 */
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 - from center screen - from other screens - Back from all apps - from center screen - from other screens - Launch app from workspace and quit - with back - with home - Launch app from all apps and quit - with back - with home - Go to a screen that's not the default, then all apps, and launch and app, and go back - 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 - Launch an app and turn off the screen while in that app - Go back with home key - Go back with back key  TODO: make this not go to workspace - From all apps - From workspace
 */
void closeAllApps(boolean animated){
  if (mAllAppsGrid.isVisible()) {
    mAllAppsGrid.zoom(0.0f,animated);
    mAllAppsGrid.setFocusable(false);
    mWorkspace.getChildAt(mWorkspace.getCurrentScreen()).requestFocus();
    mWorkspace.startFading(true);
  }
}
Program: 45479
Project: 45479
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: 45480
Project: 45480
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: 45481
Project: 45481
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: 45482
Project: 45482
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: 45483
Project: 45483
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: 45484
Project: 45484
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: 45485
Project: 45485
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: 45486
Project: 45486
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: 45487
Project: 45487
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: 45488
Project: 45488
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: 45489
Project: 45489
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: 45490
Project: 45490
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: 45491
Project: 45491
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;
  }
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  mPaused=false;
  if (mRestoring) {
    mWorkspaceLoading=true;
    mModel.startLoader(this,true);
    mRestoring=false;
  }
}
Program: 45492
Project: 45492
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);
}
Program: 45493
Project: 45493
Buggy source:
/** 
 * 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 - Go to a screen that's not the default, then all apps, and launch and app, and go back - 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 - Launch an app and turn off the screen while in that app - Go back with home key - Go back with back key - From all apps - From workspace
 */
void closeAllApps(boolean animated){
  if (mAllAppsGrid.isVisible()) {
    mAllAppsGrid.zoom(0.0f,animated);
    mAllAppsGrid.setFocusable(false);
    mWorkspace.getChildAt(mWorkspace.getCurrentScreen()).requestFocus();
  }
}

Fixed version (ground truth):
/** 
 * Things to test when changing this code. - Home from workspace - from center screen - from other screens - Home from all apps - from center screen - from other screens - Back from all apps - from center screen - from other screens - Launch app from workspace and quit - with back - with home - Launch app from all apps and quit - with back - with home - Go to a screen that's not the default, then all apps, and launch and app, and go back - 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 - Launch an app and turn off the screen while in that app - Go back with home key - Go back with back key  TODO: make this not go to workspace - From all apps - From workspace
 */
void closeAllApps(boolean animated){
  if (mAllAppsGrid.isVisible()) {
    mAllAppsGrid.zoom(0.0f,animated);
    mAllAppsGrid.setFocusable(false);
    mWorkspace.getChildAt(mWorkspace.getCurrentScreen()).requestFocus();
  }
}
Program: 45494
Project: 45494
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: 45495
Project: 45495
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: 45496
Project: 45496
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: 45497
Project: 45497
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: 45498
Project: 45498
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: 45499
Project: 45499
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: 45500
Project: 45500
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: 45501
Project: 45501
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: 45502
Project: 45502
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: 45507
Project: 45507
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: 45508
Project: 45508
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: 45509
Project: 45509
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: 45510
Project: 45510
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: 45511
Project: 45511
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: 45512
Project: 45512
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: 45513
Project: 45513
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: 45514
Project: 45514
Buggy source:
void moveToDefaultScreen(){
  snapToScreen(mDefaultScreen);
  getChildAt(mDefaultScreen).requestFocus();
}

Fixed version (ground truth):
void moveToDefaultScreen(boolean animate){
  snapToScreen(mDefaultScreen,animate);
  getChildAt(mDefaultScreen).requestFocus();
}
Program: 45515
Project: 45515
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: 45516
Project: 45516
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: 45517
Project: 45517
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: 45518
Project: 45518
Buggy source:
void moveToDefaultScreen(){
  snapToScreen(mDefaultScreen);
  getChildAt(mDefaultScreen).requestFocus();
}

Fixed version (ground truth):
void moveToDefaultScreen(boolean animate){
  snapToScreen(mDefaultScreen,animate);
  getChildAt(mDefaultScreen).requestFocus();
}
Program: 45519
Project: 45519
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: 45520
Project: 45520
Buggy source:
@Override public boolean dispatchKeyEvent(KeyEvent event){
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_BACK:
      return true;
case KeyEvent.KEYCODE_HOME:
    return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
  if (SystemProperties.getInt("String_Node_Str",0) != 0) {
    dumpState();
    return true;
  }
break;
}
}
 else if (event.getAction() == KeyEvent.ACTION_UP) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_BACK:
if (!event.isCanceled()) {
mWorkspace.dispatchKeyEvent(event);
if (isAllAppsVisible()) {
  closeAllApps(true);
}
 else {
  closeFolder();
}
dismissPreview(mPreviousView);
dismissPreview(mNextView);
}
return true;
case KeyEvent.KEYCODE_HOME:
return true;
}
}
return super.dispatchKeyEvent(event);
}

Fixed version (ground truth):
@Override public boolean dispatchKeyEvent(KeyEvent event){
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_BACK:
      return true;
case KeyEvent.KEYCODE_HOME:
    return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
  if (SystemProperties.getInt("String_Node_Str",0) != 0) {
    dumpState();
    return true;
  }
break;
}
}
 else if (event.getAction() == KeyEvent.ACTION_UP) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_BACK:
if (event.isTracking() && !event.isCanceled()) {
mWorkspace.dispatchKeyEvent(event);
if (isAllAppsVisible()) {
  closeAllApps(true);
}
 else {
  closeFolder();
}
dismissPreview(mPreviousView);
dismissPreview(mNextView);
}
return true;
case KeyEvent.KEYCODE_HOME:
return true;
}
}
return super.dispatchKeyEvent(event);
}
Program: 45521
Project: 45521
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: 45522
Project: 45522
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: 45523
Project: 45523
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: 45524
Project: 45524
Buggy source:
@Override public boolean dispatchKeyEvent(KeyEvent event){
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_BACK:
      return true;
case KeyEvent.KEYCODE_HOME:
    return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
  if (SystemProperties.getInt("String_Node_Str",0) != 0) {
    dumpState();
    return true;
  }
break;
}
}
 else if (event.getAction() == KeyEvent.ACTION_UP) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_BACK:
if (!event.isCanceled()) {
mWorkspace.dispatchKeyEvent(event);
if (isAllAppsVisible()) {
  closeAllApps(true);
}
 else {
  closeFolder();
}
dismissPreview(mPreviousView);
dismissPreview(mNextView);
}
return true;
case KeyEvent.KEYCODE_HOME:
return true;
}
}
return super.dispatchKeyEvent(event);
}

Fixed version (ground truth):
@Override public boolean dispatchKeyEvent(KeyEvent event){
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_BACK:
      return true;
case KeyEvent.KEYCODE_HOME:
    return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
  if (SystemProperties.getInt("String_Node_Str",0) != 0) {
    dumpState();
    return true;
  }
break;
}
}
 else if (event.getAction() == KeyEvent.ACTION_UP) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_BACK:
if (event.isTracking() && !event.isCanceled()) {
mWorkspace.dispatchKeyEvent(event);
if (isAllAppsVisible()) {
  closeAllApps(true);
}
 else {
  closeFolder();
}
dismissPreview(mPreviousView);
dismissPreview(mNextView);
}
return true;
case KeyEvent.KEYCODE_HOME:
return true;
}
}
return super.dispatchKeyEvent(event);
}