nus-yam/ex-repair huggingface dataset:
Program: 179805
Project: 179805
Buggy source:
@Override public void surfaceChanged(SurfaceHolder holder,int format,int w,int h){
  super.surfaceChanged(holder,format,w,h);
  if (mRollo == null) {
    mRollo=new RolloRS();
    mRollo.init(getResources(),w,h);
    if (mAllAppsList != null) {
      mRollo.setApps(mAllAppsList);
    }
    if (mShouldGainFocus) {
      gainFocus();
      mShouldGainFocus=false;
    }
  }
  mRollo.dirtyCheck();
  mRollo.resize(w,h);
  mRS.mMessageCallback=mMessageProc=new AAMessage();
  Resources res=getContext().getResources();
  int barHeight=(int)res.getDimension(R.dimen.button_bar_height);
}

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

Fixed version (ground truth):
/** 
 * Zoom to the specifed level.
 * @param zoom [0..1] 0 is hidden, 1 is open
 */
public void zoom(float zoom,boolean animate){
  cancelLongPress();
  mNextZoom=zoom;
  mAnimateNextZoom=animate;
  if (mRollo == null || !mHaveSurface) {
    mZoomDirty=true;
    mZoom=zoom;
    return;
  }
 else {
    mRollo.setZoom(zoom,animate);
  }
}
Program: 179807
Project: 179807
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: 179808
Project: 179808
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: 179809
Project: 179809
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: 179810
Project: 179810
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: 179811
Project: 179811
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: 179812
Project: 179812
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: 179813
Project: 179813
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: 179814
Project: 179814
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: 179815
Project: 179815
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: 179816
Project: 179816
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: 179817
Project: 179817
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: 179818
Project: 179818
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: 179819
Project: 179819
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: 179820
Project: 179820
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: 179821
Project: 179821
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: 179822
Project: 179822
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: 179823
Project: 179823
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: 179824
Project: 179824
Buggy source:
@Override protected void onResume(){
  super.onResume();
  IntentFilter filter=new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
  registerReceiver(mCloseSystemDialogsReceiver,filter);
  if (mRestoring) {
    mWorkspaceLoading=true;
    mModel.startLoader(this,true);
    mRestoring=false;
  }
  if (mIsNewIntent) {
    mWorkspace.post(new Runnable(){
      public void run(){
        stopSearch();
      }
    }
);
  }
  mIsNewIntent=false;
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  mPaused=false;
  if (mRestoring) {
    mWorkspaceLoading=true;
    mModel.startLoader(this,true);
    mRestoring=false;
  }
  if (mIsNewIntent) {
    mWorkspace.post(new Runnable(){
      public void run(){
        stopSearch();
      }
    }
);
  }
  mIsNewIntent=false;
}
Program: 179825
Project: 179825
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: 179826
Project: 179826
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: 179827
Project: 179827
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: 179828
Project: 179828
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: 179829
Project: 179829
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: 179830
Project: 179830
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: 179831
Project: 179831
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: 179832
Project: 179832
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: 179833
Project: 179833
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: 179834
Project: 179834
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: 179835
Project: 179835
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: 179836
Project: 179836
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: 179837
Project: 179837
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: 179838
Project: 179838
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: 179839
Project: 179839
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: 179840
Project: 179840
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: 179841
Project: 179841
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: 179842
Project: 179842
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: 179843
Project: 179843
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: 179844
Project: 179844
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: 179845
Project: 179845
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: 179846
Project: 179846
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();
  }
}