nus-yam/ex-repair huggingface dataset:
Program: 179847
Project: 179847
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: 179848
Project: 179848
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: 179849
Project: 179849
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: 179850
Project: 179850
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: 179851
Project: 179851
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: 179852
Project: 179852
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: 179857
Project: 179857
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: 179858
Project: 179858
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: 179859
Project: 179859
Buggy source:
void moveToDefaultScreen(){
  snapToScreen(mDefaultScreen);
  getChildAt(mDefaultScreen).requestFocus();
}

Fixed version (ground truth):
void moveToDefaultScreen(boolean animate){
  snapToScreen(mDefaultScreen,animate);
  getChildAt(mDefaultScreen).requestFocus();
}
Program: 179860
Project: 179860
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: 179861
Project: 179861
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: 179862
Project: 179862
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: 179863
Project: 179863
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: 179864
Project: 179864
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: 179865
Project: 179865
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: 179866
Project: 179866
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: 179867
Project: 179867
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: 179868
Project: 179868
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: 179869
Project: 179869
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: 179870
Project: 179870
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: 179871
Project: 179871
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: 179872
Project: 179872
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: 179873
Project: 179873
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: 179874
Project: 179874
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: 179875
Project: 179875
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: 179876
Project: 179876
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: 179877
Project: 179877
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: 179878
Project: 179878
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: 179879
Project: 179879
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: 179880
Project: 179880
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: 179881
Project: 179881
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: 179882
Project: 179882
Buggy source:
void moveToDefaultScreen(){
  snapToScreen(mDefaultScreen);
  getChildAt(mDefaultScreen).requestFocus();
}

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

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

Fixed version (ground truth):
void moveToDefaultScreen(boolean animate){
  snapToScreen(mDefaultScreen,animate);
  getChildAt(mDefaultScreen).requestFocus();
}
Program: 179891
Project: 179891
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: 179892
Project: 179892
Buggy source:
public boolean onLongClick(View v){
switch (v.getId()) {
case R.id.previous_screen:
    showPreviousPreview(v);
  return true;
case R.id.next_screen:
showNextPreview(v);
return true;
}
if (isWorkspaceLocked()) {
return false;
}
if (!(v instanceof CellLayout)) {
v=(View)v.getParent();
}
CellLayout.CellInfo cellInfo=(CellLayout.CellInfo)v.getTag();
if (cellInfo == null) {
return true;
}
if (mWorkspace.allowLongPress()) {
if (cellInfo.cell == null) {
if (cellInfo.valid) {
mWorkspace.setAllowLongPress(false);
showAddDialog(cellInfo);
}
}
 else {
if (!(cellInfo.cell instanceof Folder)) {
mWorkspace.startDrag(cellInfo);
}
}
}
return true;
}

Fixed version (ground truth):
public boolean onLongClick(View v){
switch (v.getId()) {
case R.id.previous_screen:
    if (!isAllAppsVisible()) {
      mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
      showPreviousPreview(v);
    }
  return true;
case R.id.next_screen:
if (!isAllAppsVisible()) {
  mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
  showNextPreview(v);
}
return true;
}
if (isWorkspaceLocked()) {
return false;
}
if (!(v instanceof CellLayout)) {
v=(View)v.getParent();
}
CellLayout.CellInfo cellInfo=(CellLayout.CellInfo)v.getTag();
if (cellInfo == null) {
return true;
}
if (mWorkspace.allowLongPress()) {
if (cellInfo.cell == null) {
if (cellInfo.valid) {
mWorkspace.setAllowLongPress(false);
showAddDialog(cellInfo);
}
}
 else {
if (!(cellInfo.cell instanceof Folder)) {
mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
mWorkspace.startDrag(cellInfo);
}
}
}
return true;
}
Program: 179894
Project: 179894
Buggy source:
/** 
 * Adds the specified child in the specified screen. The position and dimension of the child are defined by x, y, spanX and spanY.
 * @param child The child to add in one of the workspace's screens.
 * @param screen The screen in which to add the child.
 * @param spanX The number of cells spanned horizontally by the child.
 * @param spanY The number of cells spanned vertically by the child.
 */
void fitInScreen(View child,int screen,int spanX,int spanY){
  if (screen < 0 || screen >= getChildCount()) {
    throw new IllegalStateException("String_Node_Str" + getChildCount());
  }
  final CellLayout group=(CellLayout)getChildAt(screen);
  boolean vacant=group.getVacantCell(mTempCell,spanX,spanY);
  if (vacant) {
    group.addView(child,new CellLayout.LayoutParams(mTempCell[0],mTempCell[1],spanX,spanY));
    child.setOnLongClickListener(mLongClickListener);
    if (!(child instanceof Folder)) {
      child.setOnLongClickListener(mLongClickListener);
    }
    if (child instanceof DropTarget) {
      mDragController.addDropTarget((DropTarget)child);
    }
  }
}

Fixed version (ground truth):
/** 
 * Adds the specified child in the specified screen. The position and dimension of the child are defined by x, y, spanX and spanY.
 * @param child The child to add in one of the workspace's screens.
 * @param screen The screen in which to add the child.
 * @param spanX The number of cells spanned horizontally by the child.
 * @param spanY The number of cells spanned vertically by the child.
 */
void fitInScreen(View child,int screen,int spanX,int spanY){
  if (screen < 0 || screen >= getChildCount()) {
    throw new IllegalStateException("String_Node_Str" + getChildCount());
  }
  final CellLayout group=(CellLayout)getChildAt(screen);
  boolean vacant=group.getVacantCell(mTempCell,spanX,spanY);
  if (vacant) {
    group.addView(child,new CellLayout.LayoutParams(mTempCell[0],mTempCell[1],spanX,spanY));
    child.setHapticFeedbackEnabled(false);
    child.setOnLongClickListener(mLongClickListener);
    if (child instanceof DropTarget) {
      mDragController.addDropTarget((DropTarget)child);
    }
  }
}