nus-yam/ex-repair huggingface dataset:
Program: 193587
Project: 193587
Buggy source:
VoiceInteractionManagerServiceImpl(Context context,Handler handler,Object lock,int userHandle,ComponentName service){
  mContext=context;
  mHandler=handler;
  mLock=lock;
  mUser=userHandle;
  mComponent=service;
  mAm=ActivityManagerNative.getDefault();
  VoiceInteractionServiceInfo info;
  try {
    info=new VoiceInteractionServiceInfo(context.getPackageManager(),service);
  }
 catch (  PackageManager.NameNotFoundException e) {
    Slog.w(TAG,"String_Node_Str" + service);
    mInfo=null;
    mSessionComponentName=null;
    mIWindowManager=null;
    mValid=false;
    return;
  }
  mInfo=info;
  if (mInfo.getParseError() != null) {
    Slog.w(TAG,"String_Node_Str" + mInfo.getParseError());
    mSessionComponentName=null;
    mIWindowManager=null;
    mValid=false;
    return;
  }
  mValid=true;
  mSessionComponentName=new ComponentName(service.getPackageName(),mInfo.getSessionService());
  mIWindowManager=IWindowManager.Stub.asInterface(ServiceManager.getService(Context.WINDOW_SERVICE));
  IntentFilter filter=new IntentFilter();
  filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
  mContext.registerReceiver(mBroadcastReceiver,filter,null,handler);
}

Fixed version (ground truth):
VoiceInteractionManagerServiceImpl(Context context,Handler handler,Object lock,int userHandle,ComponentName service){
  mContext=context;
  mHandler=handler;
  mLock=lock;
  mUser=userHandle;
  mComponent=service;
  mAm=ActivityManagerNative.getDefault();
  VoiceInteractionServiceInfo info;
  try {
    info=new VoiceInteractionServiceInfo(context.getPackageManager(),service,mUser);
  }
 catch (  RemoteException|PackageManager.NameNotFoundException e) {
    Slog.w(TAG,"String_Node_Str" + service,e);
    mInfo=null;
    mSessionComponentName=null;
    mIWindowManager=null;
    mValid=false;
    return;
  }
  mInfo=info;
  if (mInfo.getParseError() != null) {
    Slog.w(TAG,"String_Node_Str" + mInfo.getParseError());
    mSessionComponentName=null;
    mIWindowManager=null;
    mValid=false;
    return;
  }
  mValid=true;
  mSessionComponentName=new ComponentName(service.getPackageName(),mInfo.getSessionService());
  mIWindowManager=IWindowManager.Stub.asInterface(ServiceManager.getService(Context.WINDOW_SERVICE));
  IntentFilter filter=new IntentFilter();
  filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
  mContext.registerReceiver(mBroadcastReceiver,filter,null,handler);
}
Program: 193588
Project: 193588
Buggy source:
public void dumpLocked(FileDescriptor fd,PrintWriter pw,String[] args){
  if (!mValid) {
    pw.print("String_Node_Str");
    if (mInfo == null) {
      pw.println("String_Node_Str");
    }
 else {
      pw.println(mInfo.getParseError());
    }
    return;
  }
  pw.print("String_Node_Str");
  pw.println(mComponent.flattenToShortString());
  pw.print("String_Node_Str");
  pw.println(mInfo.getSessionService());
  pw.print("String_Node_Str");
  pw.println(mInfo.getSettingsActivity());
  if (mDisabledShowContext != 0) {
    pw.print("String_Node_Str");
    pw.println(Integer.toHexString(mDisabledShowContext));
  }
  pw.print("String_Node_Str");
  pw.print(mBound);
  pw.print("String_Node_Str");
  pw.println(mService);
  if (mActiveSession != null) {
    pw.println("String_Node_Str");
    mActiveSession.dump("String_Node_Str",pw);
  }
}

Fixed version (ground truth):
public void dumpLocked(FileDescriptor fd,PrintWriter pw,String[] args){
  if (!mValid) {
    pw.print("String_Node_Str");
    if (mInfo == null) {
      pw.println("String_Node_Str");
    }
 else {
      pw.println(mInfo.getParseError());
    }
    return;
  }
  pw.print("String_Node_Str");
  pw.println(mUser);
  pw.print("String_Node_Str");
  pw.println(mComponent.flattenToShortString());
  pw.print("String_Node_Str");
  pw.println(mInfo.getSessionService());
  pw.println("String_Node_Str");
  mInfo.getServiceInfo().dump(new PrintWriterPrinter(pw),"String_Node_Str");
  pw.println("String_Node_Str");
  mInfo.getServiceInfo().applicationInfo.dump(new PrintWriterPrinter(pw),"String_Node_Str");
  pw.print("String_Node_Str");
  pw.println(mInfo.getRecognitionService());
  pw.print("String_Node_Str");
  pw.println(mInfo.getSettingsActivity());
  pw.print("String_Node_Str");
  pw.println(mInfo.getSupportsAssist());
  pw.print("String_Node_Str");
  pw.println(mInfo.getSupportsLaunchFromKeyguard());
  if (mDisabledShowContext != 0) {
    pw.print("String_Node_Str");
    pw.println(Integer.toHexString(mDisabledShowContext));
  }
  pw.print("String_Node_Str");
  pw.print(mBound);
  pw.print("String_Node_Str");
  pw.println(mService);
  if (mActiveSession != null) {
    pw.println("String_Node_Str");
    mActiveSession.dump("String_Node_Str",pw);
  }
}
Program: 193589
Project: 193589
Buggy source:
VoiceInteractionManagerServiceImpl(Context context,Handler handler,Object lock,int userHandle,ComponentName service){
  mContext=context;
  mHandler=handler;
  mLock=lock;
  mUser=userHandle;
  mComponent=service;
  mAm=ActivityManagerNative.getDefault();
  VoiceInteractionServiceInfo info;
  try {
    info=new VoiceInteractionServiceInfo(context.getPackageManager(),service);
  }
 catch (  PackageManager.NameNotFoundException e) {
    Slog.w(TAG,"String_Node_Str" + service);
    mInfo=null;
    mSessionComponentName=null;
    mIWindowManager=null;
    mValid=false;
    return;
  }
  mInfo=info;
  if (mInfo.getParseError() != null) {
    Slog.w(TAG,"String_Node_Str" + mInfo.getParseError());
    mSessionComponentName=null;
    mIWindowManager=null;
    mValid=false;
    return;
  }
  mValid=true;
  mSessionComponentName=new ComponentName(service.getPackageName(),mInfo.getSessionService());
  mIWindowManager=IWindowManager.Stub.asInterface(ServiceManager.getService(Context.WINDOW_SERVICE));
  IntentFilter filter=new IntentFilter();
  filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
  mContext.registerReceiver(mBroadcastReceiver,filter,null,handler);
}

Fixed version (ground truth):
VoiceInteractionManagerServiceImpl(Context context,Handler handler,Object lock,int userHandle,ComponentName service){
  mContext=context;
  mHandler=handler;
  mLock=lock;
  mUser=userHandle;
  mComponent=service;
  mAm=ActivityManagerNative.getDefault();
  VoiceInteractionServiceInfo info;
  try {
    info=new VoiceInteractionServiceInfo(context.getPackageManager(),service,mUser);
  }
 catch (  RemoteException|PackageManager.NameNotFoundException e) {
    Slog.w(TAG,"String_Node_Str" + service,e);
    mInfo=null;
    mSessionComponentName=null;
    mIWindowManager=null;
    mValid=false;
    return;
  }
  mInfo=info;
  if (mInfo.getParseError() != null) {
    Slog.w(TAG,"String_Node_Str" + mInfo.getParseError());
    mSessionComponentName=null;
    mIWindowManager=null;
    mValid=false;
    return;
  }
  mValid=true;
  mSessionComponentName=new ComponentName(service.getPackageName(),mInfo.getSessionService());
  mIWindowManager=IWindowManager.Stub.asInterface(ServiceManager.getService(Context.WINDOW_SERVICE));
  IntentFilter filter=new IntentFilter();
  filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
  mContext.registerReceiver(mBroadcastReceiver,filter,null,handler);
}
Program: 193590
Project: 193590
Buggy source:
public void dumpLocked(FileDescriptor fd,PrintWriter pw,String[] args){
  if (!mValid) {
    pw.print("String_Node_Str");
    if (mInfo == null) {
      pw.println("String_Node_Str");
    }
 else {
      pw.println(mInfo.getParseError());
    }
    return;
  }
  pw.print("String_Node_Str");
  pw.println(mComponent.flattenToShortString());
  pw.print("String_Node_Str");
  pw.println(mInfo.getSessionService());
  pw.print("String_Node_Str");
  pw.println(mInfo.getSettingsActivity());
  if (mDisabledShowContext != 0) {
    pw.print("String_Node_Str");
    pw.println(Integer.toHexString(mDisabledShowContext));
  }
  pw.print("String_Node_Str");
  pw.print(mBound);
  pw.print("String_Node_Str");
  pw.println(mService);
  if (mActiveSession != null) {
    pw.println("String_Node_Str");
    mActiveSession.dump("String_Node_Str",pw);
  }
}

Fixed version (ground truth):
public void dumpLocked(FileDescriptor fd,PrintWriter pw,String[] args){
  if (!mValid) {
    pw.print("String_Node_Str");
    if (mInfo == null) {
      pw.println("String_Node_Str");
    }
 else {
      pw.println(mInfo.getParseError());
    }
    return;
  }
  pw.print("String_Node_Str");
  pw.println(mUser);
  pw.print("String_Node_Str");
  pw.println(mComponent.flattenToShortString());
  pw.print("String_Node_Str");
  pw.println(mInfo.getSessionService());
  pw.println("String_Node_Str");
  mInfo.getServiceInfo().dump(new PrintWriterPrinter(pw),"String_Node_Str");
  pw.println("String_Node_Str");
  mInfo.getServiceInfo().applicationInfo.dump(new PrintWriterPrinter(pw),"String_Node_Str");
  pw.print("String_Node_Str");
  pw.println(mInfo.getRecognitionService());
  pw.print("String_Node_Str");
  pw.println(mInfo.getSettingsActivity());
  pw.print("String_Node_Str");
  pw.println(mInfo.getSupportsAssist());
  pw.print("String_Node_Str");
  pw.println(mInfo.getSupportsLaunchFromKeyguard());
  if (mDisabledShowContext != 0) {
    pw.print("String_Node_Str");
    pw.println(Integer.toHexString(mDisabledShowContext));
  }
  pw.print("String_Node_Str");
  pw.print(mBound);
  pw.print("String_Node_Str");
  pw.println(mService);
  if (mActiveSession != null) {
    pw.println("String_Node_Str");
    mActiveSession.dump("String_Node_Str",pw);
  }
}
Program: 193593
Project: 193593
Buggy source:
private void readFromParcelInner(Parcel parcel,int length){
  if (length == 0) {
    mParcelledData=EMPTY_PARCEL;
    return;
  }
  int magic=parcel.readInt();
  if (magic != BUNDLE_MAGIC) {
    throw new IllegalStateException("String_Node_Str" + Integer.toHexString(magic));
  }
  int offset=parcel.dataPosition();
  parcel.setDataPosition(offset + length);
  Parcel p=Parcel.obtain();
  p.setDataPosition(0);
  p.appendFrom(parcel,offset,length);
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + Integer.toHexString(System.identityHashCode(this)) + "String_Node_Str"+ length+ "String_Node_Str"+ offset);
  p.setDataPosition(0);
  mParcelledData=p;
}

Fixed version (ground truth):
private void readFromParcelInner(Parcel parcel,int length){
  if (length < 0) {
    throw new RuntimeException("String_Node_Str" + length);
  }
 else   if (length == 0) {
    mParcelledData=EMPTY_PARCEL;
    return;
  }
  int magic=parcel.readInt();
  if (magic != BUNDLE_MAGIC) {
    throw new IllegalStateException("String_Node_Str" + Integer.toHexString(magic));
  }
  int offset=parcel.dataPosition();
  parcel.setDataPosition(MathUtils.addOrThrow(offset,length));
  Parcel p=Parcel.obtain();
  p.setDataPosition(0);
  p.appendFrom(parcel,offset,length);
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + Integer.toHexString(System.identityHashCode(this)) + "String_Node_Str"+ length+ "String_Node_Str"+ offset);
  p.setDataPosition(0);
  mParcelledData=p;
}
Program: 193594
Project: 193594
Buggy source:
public ParcelableParcel(Parcel src,ClassLoader loader){
  mParcel=Parcel.obtain();
  mClassLoader=loader;
  int size=src.readInt();
  int pos=src.dataPosition();
  mParcel.appendFrom(src,src.dataPosition(),size);
  src.setDataPosition(pos + size);
}

Fixed version (ground truth):
public ParcelableParcel(Parcel src,ClassLoader loader){
  mParcel=Parcel.obtain();
  mClassLoader=loader;
  int size=src.readInt();
  if (size < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  int pos=src.dataPosition();
  src.setDataPosition(MathUtils.addOrThrow(pos,size));
  mParcel.appendFrom(src,pos,size);
}
Program: 193596
Project: 193596
Buggy source:
private void readFromParcelInner(Parcel parcel,int length){
  if (length == 0) {
    mParcelledData=EMPTY_PARCEL;
    return;
  }
  int magic=parcel.readInt();
  if (magic != BUNDLE_MAGIC) {
    throw new IllegalStateException("String_Node_Str" + Integer.toHexString(magic));
  }
  int offset=parcel.dataPosition();
  parcel.setDataPosition(offset + length);
  Parcel p=Parcel.obtain();
  p.setDataPosition(0);
  p.appendFrom(parcel,offset,length);
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + Integer.toHexString(System.identityHashCode(this)) + "String_Node_Str"+ length+ "String_Node_Str"+ offset);
  p.setDataPosition(0);
  mParcelledData=p;
}

Fixed version (ground truth):
private void readFromParcelInner(Parcel parcel,int length){
  if (length < 0) {
    throw new RuntimeException("String_Node_Str" + length);
  }
 else   if (length == 0) {
    mParcelledData=EMPTY_PARCEL;
    return;
  }
  int magic=parcel.readInt();
  if (magic != BUNDLE_MAGIC) {
    throw new IllegalStateException("String_Node_Str" + Integer.toHexString(magic));
  }
  int offset=parcel.dataPosition();
  parcel.setDataPosition(MathUtils.addOrThrow(offset,length));
  Parcel p=Parcel.obtain();
  p.setDataPosition(0);
  p.appendFrom(parcel,offset,length);
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + Integer.toHexString(System.identityHashCode(this)) + "String_Node_Str"+ length+ "String_Node_Str"+ offset);
  p.setDataPosition(0);
  mParcelledData=p;
}
Program: 193597
Project: 193597
Buggy source:
public ParcelableParcel(Parcel src,ClassLoader loader){
  mParcel=Parcel.obtain();
  mClassLoader=loader;
  int size=src.readInt();
  int pos=src.dataPosition();
  mParcel.appendFrom(src,src.dataPosition(),size);
  src.setDataPosition(pos + size);
}

Fixed version (ground truth):
public ParcelableParcel(Parcel src,ClassLoader loader){
  mParcel=Parcel.obtain();
  mClassLoader=loader;
  int size=src.readInt();
  if (size < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  int pos=src.dataPosition();
  src.setDataPosition(MathUtils.addOrThrow(pos,size));
  mParcel.appendFrom(src,pos,size);
}
Program: 193600
Project: 193600
Buggy source:
/** 
 * Updates the configuration to the current context 
 */
public static RecentsConfiguration reinitialize(Context context,SystemServicesProxy ssp){
  if (sInstance == null) {
    sInstance=new RecentsConfiguration(context);
  }
  int configHashCode=context.getResources().getConfiguration().hashCode();
  if (sPrevConfigurationHashCode != configHashCode) {
    sInstance.update(context);
    sPrevConfigurationHashCode=configHashCode;
  }
  sInstance.updateOnReinitialize(context,ssp);
  return sInstance;
}

Fixed version (ground truth):
/** 
 * Updates the configuration to the current context 
 */
public static RecentsConfiguration reinitialize(Context context,SystemServicesProxy ssp){
  if (sInstance == null) {
    sInstance=new RecentsConfiguration(context);
  }
  int configHashCode=context.getResources().getConfiguration().hashCode();
  if (sPrevConfigurationHashCode != configHashCode) {
    sInstance.update(context);
    sPrevConfigurationHashCode=configHashCode;
  }
  sInstance.reinitializeWithApplicationContext(context.getApplicationContext(),ssp);
  return sInstance;
}
Program: 193602
Project: 193602
Buggy source:
/** 
 * Updates the configuration to the current context 
 */
public static RecentsConfiguration reinitialize(Context context,SystemServicesProxy ssp){
  if (sInstance == null) {
    sInstance=new RecentsConfiguration(context);
  }
  int configHashCode=context.getResources().getConfiguration().hashCode();
  if (sPrevConfigurationHashCode != configHashCode) {
    sInstance.update(context);
    sPrevConfigurationHashCode=configHashCode;
  }
  sInstance.updateOnReinitialize(context,ssp);
  return sInstance;
}

Fixed version (ground truth):
/** 
 * Updates the configuration to the current context 
 */
public static RecentsConfiguration reinitialize(Context context,SystemServicesProxy ssp){
  if (sInstance == null) {
    sInstance=new RecentsConfiguration(context);
  }
  int configHashCode=context.getResources().getConfiguration().hashCode();
  if (sPrevConfigurationHashCode != configHashCode) {
    sInstance.update(context);
    sPrevConfigurationHashCode=configHashCode;
  }
  sInstance.reinitializeWithApplicationContext(context.getApplicationContext(),ssp);
  return sInstance;
}
Program: 193603
Project: 193603
Buggy source:
@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  ListMenuItemView selectedItem=(ListMenuItemView)getSelectedView();
  if (selectedItem != null && keyCode == mAdvanceKey) {
    if (selectedItem.isEnabled() && ((ListMenuItemView)selectedItem).getItemData().hasSubMenu()) {
      performItemClick(selectedItem,getSelectedItemPosition(),getSelectedItemId());
    }
    return true;
  }
 else   if (selectedItem != null && keyCode == mRetreatKey) {
    setSelectedPositionInt(-1);
    setNextSelectedPositionInt(-1);
    ((MenuAdapter)getAdapter()).getAdapterMenu().close();
    return true;
  }
  return super.onKeyDown(keyCode,event);
}

Fixed version (ground truth):
@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  ListMenuItemView selectedItem=(ListMenuItemView)getSelectedView();
  if (selectedItem != null && keyCode == mAdvanceKey) {
    if (selectedItem.isEnabled() && ((ListMenuItemView)selectedItem).getItemData().hasSubMenu()) {
      performItemClick(selectedItem,getSelectedItemPosition(),getSelectedItemId());
    }
    return true;
  }
 else   if (selectedItem != null && keyCode == mRetreatKey) {
    setSelectedPositionInt(INVALID_POSITION);
    setNextSelectedPositionInt(INVALID_POSITION);
    ((MenuAdapter)getAdapter()).getAdapterMenu().close();
    return true;
  }
  return super.onKeyDown(keyCode,event);
}
Program: 193604
Project: 193604
Buggy source:
@Override public void run(){
  int nextMenuIndex=mListViews.indexOf(nextView);
  if (nextMenuIndex != -1 && nextView.getSelectedView() == null) {
    mPopupWindows.get(nextMenuIndex).setExitTransition(null);
    nextAdapter.getAdapterMenu().close();
  }
}

Fixed version (ground truth):
@Override public void run(){
  int nextMenuIndex=mListViews.indexOf(nextView);
  if (nextMenuIndex != -1 && nextView.getSelectedView() == null) {
    for (int i=nextMenuIndex; i < mPopupWindows.size(); i++) {
      final MenuPopupWindow popupWindow=mPopupWindows.get(i);
      popupWindow.setExitTransition(null);
      popupWindow.setAnimationStyle(0);
    }
    nextAdapter.getAdapterMenu().close();
  }
}
Program: 193605
Project: 193605
Buggy source:
/** 
 * Initializes a new cascading-capable menu popup.
 * @param parent A parent view to get the {@link android.view.View#getWindowToken()} token from.
 */
public CascadingMenuPopup(Context context,View anchor,int popupStyleAttr,int popupStyleRes,boolean overflowOnly){
  mContext=Preconditions.checkNotNull(context);
  mAnchorView=Preconditions.checkNotNull(anchor);
  mPopupStyleAttr=popupStyleAttr;
  mPopupStyleRes=popupStyleRes;
  mOverflowOnly=overflowOnly;
  mForceShowIcon=false;
  final Resources res=context.getResources();
  final Configuration config=res.getConfiguration();
  mLayoutDirection=config.getLayoutDirection();
  mPreferredPosition=mLayoutDirection == View.LAYOUT_DIRECTION_RTL ? HORIZ_POSITION_LEFT : HORIZ_POSITION_RIGHT;
  mMenuMaxWidth=Math.max(res.getDisplayMetrics().widthPixels / 2,res.getDimensionPixelSize(com.android.internal.R.dimen.config_prefDialogWidth));
  mPopupWindows=new ArrayList<MenuPopupWindow>();
  mListViews=new ArrayList<DropDownListView>();
  mOffsets=new ArrayList<int[]>();
  mSubMenuHoverHandler=new Handler();
}

Fixed version (ground truth):
/** 
 * Initializes a new cascading-capable menu popup.
 * @param parent A parent view to get the {@link android.view.View#getWindowToken()} token from.
 */
public CascadingMenuPopup(Context context,View anchor,int popupStyleAttr,int popupStyleRes,boolean overflowOnly){
  mContext=Preconditions.checkNotNull(context);
  mAnchorView=Preconditions.checkNotNull(anchor);
  mPopupStyleAttr=popupStyleAttr;
  mPopupStyleRes=popupStyleRes;
  mOverflowOnly=overflowOnly;
  mForceShowIcon=false;
  final Resources res=context.getResources();
  final Configuration config=res.getConfiguration();
  mLayoutDirection=config.getLayoutDirection();
  mLastPosition=getInitialMenuPosition();
  mMenuMaxWidth=Math.max(res.getDisplayMetrics().widthPixels / 2,res.getDimensionPixelSize(com.android.internal.R.dimen.config_prefDialogWidth));
  mPopupWindows=new ArrayList<MenuPopupWindow>();
  mListViews=new ArrayList<DropDownListView>();
  mOffsets=new ArrayList<int[]>();
  mPositions=new ArrayList<Integer>();
  mSubMenuHoverHandler=new Handler();
}
Program: 193606
Project: 193606
Buggy source:
/** 
 * Determines whether the next submenu (of the given width) should display on the right or on the left of the most recent menu.
 * @param nextMenuWidth Width of the next submenu to display.
 * @return The position to display it.
 */
@HorizPosition private int getNextMenuPosition(int nextMenuWidth){
  ListView lastListView=mListViews.get(mListViews.size() - 1);
  final int[] screenLocation=new int[2];
  lastListView.getLocationOnScreen(screenLocation);
  final Rect displayFrame=new Rect();
  mShownAnchorView.getWindowVisibleDisplayFrame(displayFrame);
  if (mPreferredPosition == HORIZ_POSITION_RIGHT) {
    final int right=screenLocation[0] + lastListView.getWidth() + nextMenuWidth;
    if (right > displayFrame.right) {
      return HORIZ_POSITION_LEFT;
    }
    return HORIZ_POSITION_RIGHT;
  }
 else {
    final int left=screenLocation[0] - nextMenuWidth;
    if (left < 0) {
      return HORIZ_POSITION_RIGHT;
    }
    return HORIZ_POSITION_LEFT;
  }
}

Fixed version (ground truth):
/** 
 * Determines whether the next submenu (of the given width) should display on the right or on the left of the most recent menu.
 * @param nextMenuWidth Width of the next submenu to display.
 * @return The position to display it.
 */
@HorizPosition private int getNextMenuPosition(int nextMenuWidth){
  ListView lastListView=mListViews.get(mListViews.size() - 1);
  final int[] screenLocation=new int[2];
  lastListView.getLocationOnScreen(screenLocation);
  final Rect displayFrame=new Rect();
  mShownAnchorView.getWindowVisibleDisplayFrame(displayFrame);
  if (mLastPosition == HORIZ_POSITION_RIGHT) {
    final int right=screenLocation[0] + lastListView.getWidth() + nextMenuWidth;
    if (right > displayFrame.right) {
      return HORIZ_POSITION_LEFT;
    }
    return HORIZ_POSITION_RIGHT;
  }
 else {
    final int left=screenLocation[0] - nextMenuWidth;
    if (left < 0) {
      return HORIZ_POSITION_RIGHT;
    }
    return HORIZ_POSITION_LEFT;
  }
}
Program: 193609
Project: 193609
Buggy source:
@Override public void onCloseMenu(MenuBuilder menu,boolean allMenusAreClosing){
  int menuIndex=-1;
  boolean wasSelected=false;
  for (int i=0; i < mListViews.size(); i++) {
    ListView view=mListViews.get(i);
    MenuAdapter adapter=(MenuAdapter)view.getAdapter();
    if (menuIndex == -1 && menu == adapter.mAdapterMenu) {
      menuIndex=i;
      wasSelected=view.getSelectedView() != null;
    }
    if (menuIndex != -1) {
      adapter.mAdapterMenu.removeMenuPresenter(this);
    }
  }
  if (menuIndex != -1) {
    for (int i=menuIndex; i < mPopupWindows.size(); i++) {
      mPopupWindows.get(i).dismiss();
    }
    mPopupWindows.subList(menuIndex,mPopupWindows.size()).clear();
    mListViews.subList(menuIndex,mListViews.size()).clear();
    mOffsets.subList(menuIndex,mOffsets.size()).clear();
    if (mListViews.size() > 0) {
      mListViews.get(mListViews.size() - 1).requestFocus();
    }
  }
  if (mListViews.size() == 0 || wasSelected) {
    dismiss();
    if (mPresenterCallback != null) {
      mPresenterCallback.onCloseMenu(menu,allMenusAreClosing);
    }
  }
  if (mPopupWindows.size() == 0) {
    if (mTreeObserver != null) {
      if (mTreeObserver.isAlive()) {
        mTreeObserver.removeGlobalOnLayoutListener(mGlobalLayoutListener);
      }
      mTreeObserver=null;
    }
    mShownAnchorView.removeOnAttachStateChangeListener(mAttachStateChangeListener);
    mOnDismissListener.onDismiss();
  }
}

Fixed version (ground truth):
@Override public void onCloseMenu(MenuBuilder menu,boolean allMenusAreClosing){
  int menuIndex=-1;
  boolean wasSelected=false;
  for (int i=0; i < mListViews.size(); i++) {
    ListView view=mListViews.get(i);
    MenuAdapter adapter=(MenuAdapter)view.getAdapter();
    if (menuIndex == -1 && menu == adapter.mAdapterMenu) {
      menuIndex=i;
      wasSelected=view.getSelectedView() != null;
    }
    if (menuIndex != -1) {
      adapter.mAdapterMenu.removeMenuPresenter(this);
    }
  }
  if (menuIndex != -1) {
    for (int i=menuIndex; i < mPopupWindows.size(); i++) {
      mPopupWindows.get(i).dismiss();
    }
    mPopupWindows.subList(menuIndex,mPopupWindows.size()).clear();
    mListViews.subList(menuIndex,mListViews.size()).clear();
    mOffsets.subList(menuIndex,mOffsets.size()).clear();
    mPositions.subList(menuIndex,mPositions.size()).clear();
    if (mPositions.size() > 0) {
      mLastPosition=mPositions.get(mPositions.size() - 1);
    }
 else {
      mLastPosition=getInitialMenuPosition();
    }
  }
  if (mListViews.size() == 0 || wasSelected) {
    dismiss();
    if (mPresenterCallback != null) {
      mPresenterCallback.onCloseMenu(menu,allMenusAreClosing);
    }
  }
  if (mPopupWindows.size() == 0) {
    if (mTreeObserver != null) {
      if (mTreeObserver.isAlive()) {
        mTreeObserver.removeGlobalOnLayoutListener(mGlobalLayoutListener);
      }
      mTreeObserver=null;
    }
    mShownAnchorView.removeOnAttachStateChangeListener(mAttachStateChangeListener);
    mOnDismissListener.onDismiss();
  }
}
Program: 193610
Project: 193610
Buggy source:
@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  ListMenuItemView selectedItem=(ListMenuItemView)getSelectedView();
  if (selectedItem != null && keyCode == mAdvanceKey) {
    if (selectedItem.isEnabled() && ((ListMenuItemView)selectedItem).getItemData().hasSubMenu()) {
      performItemClick(selectedItem,getSelectedItemPosition(),getSelectedItemId());
    }
    return true;
  }
 else   if (selectedItem != null && keyCode == mRetreatKey) {
    setSelectedPositionInt(-1);
    setNextSelectedPositionInt(-1);
    ((MenuAdapter)getAdapter()).getAdapterMenu().close();
    return true;
  }
  return super.onKeyDown(keyCode,event);
}

Fixed version (ground truth):
@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  ListMenuItemView selectedItem=(ListMenuItemView)getSelectedView();
  if (selectedItem != null && keyCode == mAdvanceKey) {
    if (selectedItem.isEnabled() && ((ListMenuItemView)selectedItem).getItemData().hasSubMenu()) {
      performItemClick(selectedItem,getSelectedItemPosition(),getSelectedItemId());
    }
    return true;
  }
 else   if (selectedItem != null && keyCode == mRetreatKey) {
    setSelectedPositionInt(INVALID_POSITION);
    setNextSelectedPositionInt(INVALID_POSITION);
    ((MenuAdapter)getAdapter()).getAdapterMenu().close();
    return true;
  }
  return super.onKeyDown(keyCode,event);
}
Program: 193611
Project: 193611
Buggy source:
@Override public void run(){
  int nextMenuIndex=mListViews.indexOf(nextView);
  if (nextMenuIndex != -1 && nextView.getSelectedView() == null) {
    mPopupWindows.get(nextMenuIndex).setExitTransition(null);
    nextAdapter.getAdapterMenu().close();
  }
}

Fixed version (ground truth):
@Override public void run(){
  int nextMenuIndex=mListViews.indexOf(nextView);
  if (nextMenuIndex != -1 && nextView.getSelectedView() == null) {
    for (int i=nextMenuIndex; i < mPopupWindows.size(); i++) {
      final MenuPopupWindow popupWindow=mPopupWindows.get(i);
      popupWindow.setExitTransition(null);
      popupWindow.setAnimationStyle(0);
    }
    nextAdapter.getAdapterMenu().close();
  }
}
Program: 193612
Project: 193612
Buggy source:
/** 
 * Initializes a new cascading-capable menu popup.
 * @param parent A parent view to get the {@link android.view.View#getWindowToken()} token from.
 */
public CascadingMenuPopup(Context context,View anchor,int popupStyleAttr,int popupStyleRes,boolean overflowOnly){
  mContext=Preconditions.checkNotNull(context);
  mAnchorView=Preconditions.checkNotNull(anchor);
  mPopupStyleAttr=popupStyleAttr;
  mPopupStyleRes=popupStyleRes;
  mOverflowOnly=overflowOnly;
  mForceShowIcon=false;
  final Resources res=context.getResources();
  final Configuration config=res.getConfiguration();
  mLayoutDirection=config.getLayoutDirection();
  mPreferredPosition=mLayoutDirection == View.LAYOUT_DIRECTION_RTL ? HORIZ_POSITION_LEFT : HORIZ_POSITION_RIGHT;
  mMenuMaxWidth=Math.max(res.getDisplayMetrics().widthPixels / 2,res.getDimensionPixelSize(com.android.internal.R.dimen.config_prefDialogWidth));
  mPopupWindows=new ArrayList<MenuPopupWindow>();
  mListViews=new ArrayList<DropDownListView>();
  mOffsets=new ArrayList<int[]>();
  mSubMenuHoverHandler=new Handler();
}

Fixed version (ground truth):
/** 
 * Initializes a new cascading-capable menu popup.
 * @param parent A parent view to get the {@link android.view.View#getWindowToken()} token from.
 */
public CascadingMenuPopup(Context context,View anchor,int popupStyleAttr,int popupStyleRes,boolean overflowOnly){
  mContext=Preconditions.checkNotNull(context);
  mAnchorView=Preconditions.checkNotNull(anchor);
  mPopupStyleAttr=popupStyleAttr;
  mPopupStyleRes=popupStyleRes;
  mOverflowOnly=overflowOnly;
  mForceShowIcon=false;
  final Resources res=context.getResources();
  final Configuration config=res.getConfiguration();
  mLayoutDirection=config.getLayoutDirection();
  mLastPosition=getInitialMenuPosition();
  mMenuMaxWidth=Math.max(res.getDisplayMetrics().widthPixels / 2,res.getDimensionPixelSize(com.android.internal.R.dimen.config_prefDialogWidth));
  mPopupWindows=new ArrayList<MenuPopupWindow>();
  mListViews=new ArrayList<DropDownListView>();
  mOffsets=new ArrayList<int[]>();
  mPositions=new ArrayList<Integer>();
  mSubMenuHoverHandler=new Handler();
}
Program: 193613
Project: 193613
Buggy source:
/** 
 * Determines whether the next submenu (of the given width) should display on the right or on the left of the most recent menu.
 * @param nextMenuWidth Width of the next submenu to display.
 * @return The position to display it.
 */
@HorizPosition private int getNextMenuPosition(int nextMenuWidth){
  ListView lastListView=mListViews.get(mListViews.size() - 1);
  final int[] screenLocation=new int[2];
  lastListView.getLocationOnScreen(screenLocation);
  final Rect displayFrame=new Rect();
  mShownAnchorView.getWindowVisibleDisplayFrame(displayFrame);
  if (mPreferredPosition == HORIZ_POSITION_RIGHT) {
    final int right=screenLocation[0] + lastListView.getWidth() + nextMenuWidth;
    if (right > displayFrame.right) {
      return HORIZ_POSITION_LEFT;
    }
    return HORIZ_POSITION_RIGHT;
  }
 else {
    final int left=screenLocation[0] - nextMenuWidth;
    if (left < 0) {
      return HORIZ_POSITION_RIGHT;
    }
    return HORIZ_POSITION_LEFT;
  }
}

Fixed version (ground truth):
/** 
 * Determines whether the next submenu (of the given width) should display on the right or on the left of the most recent menu.
 * @param nextMenuWidth Width of the next submenu to display.
 * @return The position to display it.
 */
@HorizPosition private int getNextMenuPosition(int nextMenuWidth){
  ListView lastListView=mListViews.get(mListViews.size() - 1);
  final int[] screenLocation=new int[2];
  lastListView.getLocationOnScreen(screenLocation);
  final Rect displayFrame=new Rect();
  mShownAnchorView.getWindowVisibleDisplayFrame(displayFrame);
  if (mLastPosition == HORIZ_POSITION_RIGHT) {
    final int right=screenLocation[0] + lastListView.getWidth() + nextMenuWidth;
    if (right > displayFrame.right) {
      return HORIZ_POSITION_LEFT;
    }
    return HORIZ_POSITION_RIGHT;
  }
 else {
    final int left=screenLocation[0] - nextMenuWidth;
    if (left < 0) {
      return HORIZ_POSITION_RIGHT;
    }
    return HORIZ_POSITION_LEFT;
  }
}
Program: 193616
Project: 193616
Buggy source:
@Override public void onCloseMenu(MenuBuilder menu,boolean allMenusAreClosing){
  int menuIndex=-1;
  boolean wasSelected=false;
  for (int i=0; i < mListViews.size(); i++) {
    ListView view=mListViews.get(i);
    MenuAdapter adapter=(MenuAdapter)view.getAdapter();
    if (menuIndex == -1 && menu == adapter.mAdapterMenu) {
      menuIndex=i;
      wasSelected=view.getSelectedView() != null;
    }
    if (menuIndex != -1) {
      adapter.mAdapterMenu.removeMenuPresenter(this);
    }
  }
  if (menuIndex != -1) {
    for (int i=menuIndex; i < mPopupWindows.size(); i++) {
      mPopupWindows.get(i).dismiss();
    }
    mPopupWindows.subList(menuIndex,mPopupWindows.size()).clear();
    mListViews.subList(menuIndex,mListViews.size()).clear();
    mOffsets.subList(menuIndex,mOffsets.size()).clear();
    if (mListViews.size() > 0) {
      mListViews.get(mListViews.size() - 1).requestFocus();
    }
  }
  if (mListViews.size() == 0 || wasSelected) {
    dismiss();
    if (mPresenterCallback != null) {
      mPresenterCallback.onCloseMenu(menu,allMenusAreClosing);
    }
  }
  if (mPopupWindows.size() == 0) {
    if (mTreeObserver != null) {
      if (mTreeObserver.isAlive()) {
        mTreeObserver.removeGlobalOnLayoutListener(mGlobalLayoutListener);
      }
      mTreeObserver=null;
    }
    mShownAnchorView.removeOnAttachStateChangeListener(mAttachStateChangeListener);
    mOnDismissListener.onDismiss();
  }
}

Fixed version (ground truth):
@Override public void onCloseMenu(MenuBuilder menu,boolean allMenusAreClosing){
  int menuIndex=-1;
  boolean wasSelected=false;
  for (int i=0; i < mListViews.size(); i++) {
    ListView view=mListViews.get(i);
    MenuAdapter adapter=(MenuAdapter)view.getAdapter();
    if (menuIndex == -1 && menu == adapter.mAdapterMenu) {
      menuIndex=i;
      wasSelected=view.getSelectedView() != null;
    }
    if (menuIndex != -1) {
      adapter.mAdapterMenu.removeMenuPresenter(this);
    }
  }
  if (menuIndex != -1) {
    for (int i=menuIndex; i < mPopupWindows.size(); i++) {
      mPopupWindows.get(i).dismiss();
    }
    mPopupWindows.subList(menuIndex,mPopupWindows.size()).clear();
    mListViews.subList(menuIndex,mListViews.size()).clear();
    mOffsets.subList(menuIndex,mOffsets.size()).clear();
    mPositions.subList(menuIndex,mPositions.size()).clear();
    if (mPositions.size() > 0) {
      mLastPosition=mPositions.get(mPositions.size() - 1);
    }
 else {
      mLastPosition=getInitialMenuPosition();
    }
  }
  if (mListViews.size() == 0 || wasSelected) {
    dismiss();
    if (mPresenterCallback != null) {
      mPresenterCallback.onCloseMenu(menu,allMenusAreClosing);
    }
  }
  if (mPopupWindows.size() == 0) {
    if (mTreeObserver != null) {
      if (mTreeObserver.isAlive()) {
        mTreeObserver.removeGlobalOnLayoutListener(mGlobalLayoutListener);
      }
      mTreeObserver=null;
    }
    mShownAnchorView.removeOnAttachStateChangeListener(mAttachStateChangeListener);
    mOnDismissListener.onDismiss();
  }
}
Program: 193617
Project: 193617
Buggy source:
void updateDisplayInfo(final DisplayContent displayContent){
  if (displayContent == null) {
    return;
  }
  if (mFullscreen) {
    setBounds(null,Configuration.EMPTY);
    return;
  }
  final int newRotation=displayContent.getDisplayInfo().rotation;
  if (mRotation == newRotation) {
    return;
  }
  final int rotationDelta=DisplayContent.deltaRotation(mRotation,newRotation);
  displayContent.getLogicalDisplayRect(mTmpRect);
switch (rotationDelta) {
case Surface.ROTATION_0:
    mTmpRect2.set(mBounds);
  break;
case Surface.ROTATION_90:
mTmpRect2.top=mTmpRect.bottom - mBounds.right;
mTmpRect2.left=mBounds.top;
mTmpRect2.right=mTmpRect2.left + mBounds.height();
mTmpRect2.bottom=mTmpRect2.top + mBounds.width();
break;
case Surface.ROTATION_180:
mTmpRect2.top=mTmpRect.bottom - mBounds.bottom;
mTmpRect2.left=mTmpRect.right - mBounds.right;
mTmpRect2.right=mTmpRect2.left + mBounds.width();
mTmpRect2.bottom=mTmpRect2.top + mBounds.height();
break;
case Surface.ROTATION_270:
mTmpRect2.top=mBounds.left;
mTmpRect2.left=mTmpRect.right - mBounds.bottom;
mTmpRect2.right=mTmpRect2.left + mBounds.height();
mTmpRect2.bottom=mTmpRect2.top + mBounds.width();
break;
}
setBounds(mTmpRect2,mOverrideConfig);
}

Fixed version (ground truth):
void updateDisplayInfo(final DisplayContent displayContent){
  if (displayContent == null) {
    return;
  }
  if (mFullscreen) {
    setBounds(null,Configuration.EMPTY);
    return;
  }
  final int newRotation=displayContent.getDisplayInfo().rotation;
  if (mRotation == newRotation) {
    return;
  }
  mTmpRect2.set(mBounds);
  displayContent.rotateBounds(mRotation,newRotation,mTmpRect2);
  setBounds(mTmpRect2,mOverrideConfig);
}
Program: 193618
Project: 193618
Buggy source:
private boolean setBounds(Rect bounds){
  boolean oldFullscreen=mFullscreen;
  if (mDisplayContent != null) {
    mDisplayContent.getLogicalDisplayRect(mTmpRect);
    if (bounds == null) {
      bounds=mTmpRect;
      mFullscreen=true;
    }
 else {
      if (!bounds.intersect(mTmpRect)) {
        return false;
      }
      mFullscreen=mTmpRect.equals(bounds);
    }
  }
  if (bounds == null) {
    return false;
  }
  if (mBounds.equals(bounds) && oldFullscreen == mFullscreen) {
    return false;
  }
  mAnimationBackgroundSurface.setBounds(bounds);
  mBounds.set(bounds);
  return true;
}

Fixed version (ground truth):
private boolean setBounds(Rect bounds){
  boolean oldFullscreen=mFullscreen;
  int rotation=Surface.ROTATION_0;
  if (mDisplayContent != null) {
    mDisplayContent.getLogicalDisplayRect(mTmpRect);
    rotation=mDisplayContent.getDisplayInfo().rotation;
    if (bounds == null) {
      bounds=mTmpRect;
      mFullscreen=true;
    }
 else {
      if (!bounds.intersect(mTmpRect)) {
        return false;
      }
      mFullscreen=mTmpRect.equals(bounds);
    }
  }
  if (bounds == null) {
    return false;
  }
  if (mBounds.equals(bounds) && oldFullscreen == mFullscreen && mRotation == rotation) {
    return false;
  }
  mAnimationBackgroundSurface.setBounds(bounds);
  mBounds.set(bounds);
  mRotation=rotation;
  return true;
}
Program: 193619
Project: 193619
Buggy source:
void updateDisplayInfo(Rect bounds){
  if (mDisplayContent != null) {
    if (bounds != null) {
      setBounds(bounds);
    }
 else {
      setBounds(mFullscreen ? null : mBounds);
    }
    for (int taskNdx=mTasks.size() - 1; taskNdx >= 0; --taskNdx) {
      mTasks.get(taskNdx).updateDisplayInfo(mDisplayContent);
    }
  }
}

Fixed version (ground truth):
void updateDisplayInfo(Rect bounds){
  if (mDisplayContent != null) {
    if (bounds != null) {
      setBounds(bounds);
    }
 else     if (mFullscreen) {
      setBounds(null);
    }
 else {
      TmpRect2.set(mBounds);
      mDisplayContent.rotateBounds(mRotation,mDisplayContent.getDisplayInfo().rotation,TmpRect2);
      setBounds(TmpRect2);
    }
    for (int taskNdx=mTasks.size() - 1; taskNdx >= 0; --taskNdx) {
      mTasks.get(taskNdx).updateDisplayInfo(mDisplayContent);
    }
  }
}
Program: 193620
Project: 193620
Buggy source:
void updateDisplayInfo(final DisplayContent displayContent){
  if (displayContent == null) {
    return;
  }
  if (mFullscreen) {
    setBounds(null,Configuration.EMPTY);
    return;
  }
  final int newRotation=displayContent.getDisplayInfo().rotation;
  if (mRotation == newRotation) {
    return;
  }
  final int rotationDelta=DisplayContent.deltaRotation(mRotation,newRotation);
  displayContent.getLogicalDisplayRect(mTmpRect);
switch (rotationDelta) {
case Surface.ROTATION_0:
    mTmpRect2.set(mBounds);
  break;
case Surface.ROTATION_90:
mTmpRect2.top=mTmpRect.bottom - mBounds.right;
mTmpRect2.left=mBounds.top;
mTmpRect2.right=mTmpRect2.left + mBounds.height();
mTmpRect2.bottom=mTmpRect2.top + mBounds.width();
break;
case Surface.ROTATION_180:
mTmpRect2.top=mTmpRect.bottom - mBounds.bottom;
mTmpRect2.left=mTmpRect.right - mBounds.right;
mTmpRect2.right=mTmpRect2.left + mBounds.width();
mTmpRect2.bottom=mTmpRect2.top + mBounds.height();
break;
case Surface.ROTATION_270:
mTmpRect2.top=mBounds.left;
mTmpRect2.left=mTmpRect.right - mBounds.bottom;
mTmpRect2.right=mTmpRect2.left + mBounds.height();
mTmpRect2.bottom=mTmpRect2.top + mBounds.width();
break;
}
setBounds(mTmpRect2,mOverrideConfig);
}

Fixed version (ground truth):
void updateDisplayInfo(final DisplayContent displayContent){
  if (displayContent == null) {
    return;
  }
  if (mFullscreen) {
    setBounds(null,Configuration.EMPTY);
    return;
  }
  final int newRotation=displayContent.getDisplayInfo().rotation;
  if (mRotation == newRotation) {
    return;
  }
  mTmpRect2.set(mBounds);
  displayContent.rotateBounds(mRotation,newRotation,mTmpRect2);
  setBounds(mTmpRect2,mOverrideConfig);
}
Program: 193621
Project: 193621
Buggy source:
private boolean setBounds(Rect bounds){
  boolean oldFullscreen=mFullscreen;
  if (mDisplayContent != null) {
    mDisplayContent.getLogicalDisplayRect(mTmpRect);
    if (bounds == null) {
      bounds=mTmpRect;
      mFullscreen=true;
    }
 else {
      if (!bounds.intersect(mTmpRect)) {
        return false;
      }
      mFullscreen=mTmpRect.equals(bounds);
    }
  }
  if (bounds == null) {
    return false;
  }
  if (mBounds.equals(bounds) && oldFullscreen == mFullscreen) {
    return false;
  }
  mAnimationBackgroundSurface.setBounds(bounds);
  mBounds.set(bounds);
  return true;
}

Fixed version (ground truth):
private boolean setBounds(Rect bounds){
  boolean oldFullscreen=mFullscreen;
  int rotation=Surface.ROTATION_0;
  if (mDisplayContent != null) {
    mDisplayContent.getLogicalDisplayRect(mTmpRect);
    rotation=mDisplayContent.getDisplayInfo().rotation;
    if (bounds == null) {
      bounds=mTmpRect;
      mFullscreen=true;
    }
 else {
      if (!bounds.intersect(mTmpRect)) {
        return false;
      }
      mFullscreen=mTmpRect.equals(bounds);
    }
  }
  if (bounds == null) {
    return false;
  }
  if (mBounds.equals(bounds) && oldFullscreen == mFullscreen && mRotation == rotation) {
    return false;
  }
  mAnimationBackgroundSurface.setBounds(bounds);
  mBounds.set(bounds);
  mRotation=rotation;
  return true;
}
Program: 193622
Project: 193622
Buggy source:
void updateDisplayInfo(Rect bounds){
  if (mDisplayContent != null) {
    if (bounds != null) {
      setBounds(bounds);
    }
 else {
      setBounds(mFullscreen ? null : mBounds);
    }
    for (int taskNdx=mTasks.size() - 1; taskNdx >= 0; --taskNdx) {
      mTasks.get(taskNdx).updateDisplayInfo(mDisplayContent);
    }
  }
}

Fixed version (ground truth):
void updateDisplayInfo(Rect bounds){
  if (mDisplayContent != null) {
    if (bounds != null) {
      setBounds(bounds);
    }
 else     if (mFullscreen) {
      setBounds(null);
    }
 else {
      TmpRect2.set(mBounds);
      mDisplayContent.rotateBounds(mRotation,mDisplayContent.getDisplayInfo().rotation,TmpRect2);
      setBounds(TmpRect2);
    }
    for (int taskNdx=mTasks.size() - 1; taskNdx >= 0; --taskNdx) {
      mTasks.get(taskNdx).updateDisplayInfo(mDisplayContent);
    }
  }
}
Program: 193623
Project: 193623
Buggy source:
void setTouchExcludeRegion(Task focusedTask){
  mTouchExcludeRegion.set(mBaseDisplayRect);
  WindowList windows=getWindowList();
  final int delta=mService.dipToPixel(RESIZE_HANDLE_WIDTH_IN_DP,mDisplayMetrics);
  for (int i=windows.size() - 1; i >= 0; --i) {
    final WindowState win=windows.get(i);
    final Task task=win.mAppToken != null ? win.getTask() : null;
    if (win.isVisibleLw() && task != null) {
      final boolean isFreeformed=task.inFreeformWorkspace();
      if (task != focusedTask || isFreeformed) {
        mTmpRect.set(win.mVisibleFrame);
        mTmpRect.intersect(win.mVisibleInsets);
        if (isFreeformed) {
          mTmpRect.inset(-delta,-delta);
        }
        mTouchExcludeRegion.op(mTmpRect,Region.Op.DIFFERENCE);
      }
      if (task == focusedTask && isFreeformed) {
        mTmpRect.inset(delta,delta);
        mTouchExcludeRegion.op(mTmpRect,Region.Op.UNION);
      }
    }
  }
  if (mTapDetector != null) {
    mTapDetector.setTouchExcludeRegion(mTouchExcludeRegion);
  }
}

Fixed version (ground truth):
void setTouchExcludeRegion(Task focusedTask){
  mTouchExcludeRegion.set(mBaseDisplayRect);
  WindowList windows=getWindowList();
  final int delta=mService.dipToPixel(RESIZE_HANDLE_WIDTH_IN_DP,mDisplayMetrics);
  for (int i=windows.size() - 1; i >= 0; --i) {
    final WindowState win=windows.get(i);
    final Task task=win.getTask();
    if (win.isVisibleLw() && task != null) {
      final boolean isFreeformed=task.inFreeformWorkspace();
      if (task != focusedTask || isFreeformed) {
        mTmpRect.set(win.mVisibleFrame);
        mTmpRect.intersect(win.mVisibleInsets);
        if (isFreeformed) {
          mTmpRect.inset(-delta,-delta);
        }
        mTouchExcludeRegion.op(mTmpRect,Region.Op.DIFFERENCE);
      }
      if (task == focusedTask && isFreeformed) {
        mTmpRect.inset(delta,delta);
        mTouchExcludeRegion.op(mTmpRect,Region.Op.UNION);
      }
    }
  }
  if (mTapDetector != null) {
    mTapDetector.setTouchExcludeRegion(mTouchExcludeRegion);
  }
}
Program: 193625
Project: 193625
Buggy source:
boolean inFreeformWorkspace(){
  final Task task=mAppToken != null ? getTask() : null;
  return task != null && task.inFreeformWorkspace();
}

Fixed version (ground truth):
boolean inFreeformWorkspace(){
  final Task task=getTask();
  return task != null && task.inFreeformWorkspace();
}
Program: 193626
Project: 193626
Buggy source:
boolean isDragResizing(){
  final Task task=mAppToken != null ? getTask() : null;
  return mService.mTaskPositioner != null && mService.mTaskPositioner.isTaskResizing(task);
}

Fixed version (ground truth):
boolean isDragResizing(){
  final Task task=getTask();
  return mService.mTaskPositioner != null && mService.mTaskPositioner.isTaskResizing(task);
}
Program: 193627
Project: 193627
Buggy source:
TaskStack getStack(){
  Task task=getTask();
  if (task != null) {
    if (task.mStack != null) {
      return task.mStack;
    }
  }
  return mDisplayContent.getHomeStack();
}

Fixed version (ground truth):
TaskStack getStack(){
  Task task=getTask();
  if (task != null) {
    if (task.mStack != null) {
      return task.mStack;
    }
  }
  return null;
}
Program: 193628
Project: 193628
Buggy source:
Task getTask(){
  AppWindowToken wtoken=mAppToken == null ? mService.mFocusedApp : mAppToken;
  if (wtoken == null) {
    return null;
  }
  final Task task=wtoken.mTask;
  return task;
}

Fixed version (ground truth):
Task getTask(){
  return mAppToken != null ? mAppToken.mTask : null;
}
Program: 193630
Project: 193630
Buggy source:
void setTouchExcludeRegion(Task focusedTask){
  mTouchExcludeRegion.set(mBaseDisplayRect);
  WindowList windows=getWindowList();
  final int delta=mService.dipToPixel(RESIZE_HANDLE_WIDTH_IN_DP,mDisplayMetrics);
  for (int i=windows.size() - 1; i >= 0; --i) {
    final WindowState win=windows.get(i);
    final Task task=win.mAppToken != null ? win.getTask() : null;
    if (win.isVisibleLw() && task != null) {
      final boolean isFreeformed=task.inFreeformWorkspace();
      if (task != focusedTask || isFreeformed) {
        mTmpRect.set(win.mVisibleFrame);
        mTmpRect.intersect(win.mVisibleInsets);
        if (isFreeformed) {
          mTmpRect.inset(-delta,-delta);
        }
        mTouchExcludeRegion.op(mTmpRect,Region.Op.DIFFERENCE);
      }
      if (task == focusedTask && isFreeformed) {
        mTmpRect.inset(delta,delta);
        mTouchExcludeRegion.op(mTmpRect,Region.Op.UNION);
      }
    }
  }
  if (mTapDetector != null) {
    mTapDetector.setTouchExcludeRegion(mTouchExcludeRegion);
  }
}

Fixed version (ground truth):
void setTouchExcludeRegion(Task focusedTask){
  mTouchExcludeRegion.set(mBaseDisplayRect);
  WindowList windows=getWindowList();
  final int delta=mService.dipToPixel(RESIZE_HANDLE_WIDTH_IN_DP,mDisplayMetrics);
  for (int i=windows.size() - 1; i >= 0; --i) {
    final WindowState win=windows.get(i);
    final Task task=win.getTask();
    if (win.isVisibleLw() && task != null) {
      final boolean isFreeformed=task.inFreeformWorkspace();
      if (task != focusedTask || isFreeformed) {
        mTmpRect.set(win.mVisibleFrame);
        mTmpRect.intersect(win.mVisibleInsets);
        if (isFreeformed) {
          mTmpRect.inset(-delta,-delta);
        }
        mTouchExcludeRegion.op(mTmpRect,Region.Op.DIFFERENCE);
      }
      if (task == focusedTask && isFreeformed) {
        mTmpRect.inset(delta,delta);
        mTouchExcludeRegion.op(mTmpRect,Region.Op.UNION);
      }
    }
  }
  if (mTapDetector != null) {
    mTapDetector.setTouchExcludeRegion(mTouchExcludeRegion);
  }
}
Program: 193632
Project: 193632
Buggy source:
boolean inFreeformWorkspace(){
  final Task task=mAppToken != null ? getTask() : null;
  return task != null && task.inFreeformWorkspace();
}

Fixed version (ground truth):
boolean inFreeformWorkspace(){
  final Task task=getTask();
  return task != null && task.inFreeformWorkspace();
}