nus-yam/ex-repair huggingface dataset:
Program: 23290
Project: 23290
Buggy source:
private View addViewAbove(View theView,int position){
  int abovePosition=position - 1;
  View view=obtainView(abovePosition);
  int edgeOfNewChild=theView.getTop() - mDividerHeight;
  setupChild(view,abovePosition,edgeOfNewChild,false,mListPadding.left,false,false);
  return view;
}

Fixed version (ground truth):
private View addViewAbove(View theView,int position){
  int abovePosition=position - 1;
  View view=obtainView(abovePosition,mIsScrap);
  int edgeOfNewChild=theView.getTop() - mDividerHeight;
  setupChild(view,abovePosition,edgeOfNewChild,false,mListPadding.left,false,mIsScrap[0]);
  return view;
}
Program: 23291
Project: 23291
Buggy source:
private View addViewBelow(View theView,int position){
  int belowPosition=position + 1;
  View view=obtainView(belowPosition);
  int edgeOfNewChild=theView.getBottom() + mDividerHeight;
  setupChild(view,belowPosition,edgeOfNewChild,true,mListPadding.left,false,false);
  return view;
}

Fixed version (ground truth):
private View addViewBelow(View theView,int position){
  int belowPosition=position + 1;
  View view=obtainView(belowPosition,mIsScrap);
  int edgeOfNewChild=theView.getBottom() + mDividerHeight;
  setupChild(view,belowPosition,edgeOfNewChild,true,mListPadding.left,false,mIsScrap[0]);
  return view;
}
Program: 23292
Project: 23292
Buggy source:
/** 
 * Obtain the view and add it to our list of children. The view can be made fresh, converted from an unused view, or used as is if it was in the recycle bin.
 * @param position Logical position in the list
 * @param y Top or bottom edge of the view to add
 * @param flow If flow is true, align top edge to y. If false, align bottomedge to y.
 * @param childrenLeft Left edge where children should be positioned
 * @param selected Is this position selected?
 * @return View that was added
 */
private View makeAndAddView(int position,int y,boolean flow,int childrenLeft,boolean selected){
  View child;
  if (!mDataChanged) {
    child=mRecycler.getActiveView(position);
    if (child != null) {
      if (ViewDebug.TRACE_RECYCLER) {
        ViewDebug.trace(child,ViewDebug.RecyclerTraceType.RECYCLE_FROM_ACTIVE_HEAP,position,getChildCount());
      }
      setupChild(child,position,y,flow,childrenLeft,selected,true);
      return child;
    }
  }
  child=obtainView(position);
  setupChild(child,position,y,flow,childrenLeft,selected,false);
  return child;
}

Fixed version (ground truth):
/** 
 * Obtain the view and add it to our list of children. The view can be made fresh, converted from an unused view, or used as is if it was in the recycle bin.
 * @param position Logical position in the list
 * @param y Top or bottom edge of the view to add
 * @param flow If flow is true, align top edge to y. If false, align bottomedge to y.
 * @param childrenLeft Left edge where children should be positioned
 * @param selected Is this position selected?
 * @return View that was added
 */
private View makeAndAddView(int position,int y,boolean flow,int childrenLeft,boolean selected){
  View child;
  if (!mDataChanged) {
    child=mRecycler.getActiveView(position);
    if (child != null) {
      if (ViewDebug.TRACE_RECYCLER) {
        ViewDebug.trace(child,ViewDebug.RecyclerTraceType.RECYCLE_FROM_ACTIVE_HEAP,position,getChildCount());
      }
      setupChild(child,position,y,flow,childrenLeft,selected,true);
      return child;
    }
  }
  child=obtainView(position,mIsScrap);
  setupChild(child,position,y,flow,childrenLeft,selected,mIsScrap[0]);
  return child;
}
Program: 23294
Project: 23294
Buggy source:
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  super.onMeasure(widthMeasureSpec,heightMeasureSpec);
  int widthMode=MeasureSpec.getMode(widthMeasureSpec);
  int heightMode=MeasureSpec.getMode(heightMeasureSpec);
  int widthSize=MeasureSpec.getSize(widthMeasureSpec);
  int heightSize=MeasureSpec.getSize(heightMeasureSpec);
  int childWidth=0;
  int childHeight=0;
  mItemCount=mAdapter == null ? 0 : mAdapter.getCount();
  if (mItemCount > 0 && (widthMode == MeasureSpec.UNSPECIFIED || heightMode == MeasureSpec.UNSPECIFIED)) {
    final View child=obtainView(0);
    measureScrapChild(child,0,widthMeasureSpec);
    childWidth=child.getMeasuredWidth();
    childHeight=child.getMeasuredHeight();
    if (recycleOnMeasure()) {
      mRecycler.addScrapView(child);
    }
  }
  if (widthMode == MeasureSpec.UNSPECIFIED) {
    widthSize=mListPadding.left + mListPadding.right + childWidth+ getVerticalScrollbarWidth();
  }
  if (heightMode == MeasureSpec.UNSPECIFIED) {
    heightSize=mListPadding.top + mListPadding.bottom + childHeight+ getVerticalFadingEdgeLength() * 2;
  }
  if (heightMode == MeasureSpec.AT_MOST) {
    heightSize=measureHeightOfChildren(widthMeasureSpec,0,NO_POSITION,heightSize,-1);
  }
  setMeasuredDimension(widthSize,heightSize);
  mWidthMeasureSpec=widthMeasureSpec;
}

Fixed version (ground truth):
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  super.onMeasure(widthMeasureSpec,heightMeasureSpec);
  int widthMode=MeasureSpec.getMode(widthMeasureSpec);
  int heightMode=MeasureSpec.getMode(heightMeasureSpec);
  int widthSize=MeasureSpec.getSize(widthMeasureSpec);
  int heightSize=MeasureSpec.getSize(heightMeasureSpec);
  int childWidth=0;
  int childHeight=0;
  mItemCount=mAdapter == null ? 0 : mAdapter.getCount();
  if (mItemCount > 0 && (widthMode == MeasureSpec.UNSPECIFIED || heightMode == MeasureSpec.UNSPECIFIED)) {
    final View child=obtainView(0,mIsScrap);
    measureScrapChild(child,0,widthMeasureSpec);
    childWidth=child.getMeasuredWidth();
    childHeight=child.getMeasuredHeight();
    if (recycleOnMeasure()) {
      mRecycler.addScrapView(child);
    }
  }
  if (widthMode == MeasureSpec.UNSPECIFIED) {
    widthSize=mListPadding.left + mListPadding.right + childWidth+ getVerticalScrollbarWidth();
  }
  if (heightMode == MeasureSpec.UNSPECIFIED) {
    heightSize=mListPadding.top + mListPadding.bottom + childHeight+ getVerticalFadingEdgeLength() * 2;
  }
  if (heightMode == MeasureSpec.AT_MOST) {
    heightSize=measureHeightOfChildren(widthMeasureSpec,0,NO_POSITION,heightSize,-1);
  }
  setMeasuredDimension(widthSize,heightSize);
  mWidthMeasureSpec=widthMeasureSpec;
}
Program: 23296
Project: 23296
Buggy source:
/** 
 * Move all views remaining in mActiveViews to mScrapViews.
 */
void scrapActiveViews(){
  final View[] activeViews=mActiveViews;
  final boolean hasListener=mRecyclerListener != null;
  final boolean multipleScraps=mViewTypeCount > 1;
  ArrayList<View> scrapViews=mCurrentScrap;
  final int count=activeViews.length;
  for (int i=0; i < count; ++i) {
    final View victim=activeViews[i];
    if (victim != null) {
      int whichScrap=((AbsListView.LayoutParams)victim.getLayoutParams()).viewType;
      activeViews[i]=null;
      if (whichScrap == AdapterView.ITEM_VIEW_TYPE_IGNORE) {
        continue;
      }
      if (multipleScraps) {
        scrapViews=mScrapViews[whichScrap];
      }
      scrapViews.add(victim);
      if (hasListener) {
        mRecyclerListener.onMovedToScrapHeap(victim);
      }
      if (ViewDebug.TRACE_RECYCLER) {
        ViewDebug.trace(victim,ViewDebug.RecyclerTraceType.MOVE_FROM_ACTIVE_TO_SCRAP_HEAP,mFirstActivePosition + i,-1);
      }
    }
  }
  pruneScrapViews();
}

Fixed version (ground truth):
/** 
 * Move all views remaining in mActiveViews to mScrapViews.
 */
void scrapActiveViews(){
  final View[] activeViews=mActiveViews;
  final boolean hasListener=mRecyclerListener != null;
  final boolean multipleScraps=mViewTypeCount > 1;
  ArrayList<View> scrapViews=mCurrentScrap;
  final int count=activeViews.length;
  for (int i=0; i < count; ++i) {
    final View victim=activeViews[i];
    if (victim != null) {
      int whichScrap=((AbsListView.LayoutParams)victim.getLayoutParams()).viewType;
      activeViews[i]=null;
      if (whichScrap == AdapterView.ITEM_VIEW_TYPE_IGNORE) {
        removeDetachedView(victim,false);
        continue;
      }
      if (multipleScraps) {
        scrapViews=mScrapViews[whichScrap];
      }
      scrapViews.add(victim);
      if (hasListener) {
        mRecyclerListener.onMovedToScrapHeap(victim);
      }
      if (ViewDebug.TRACE_RECYCLER) {
        ViewDebug.trace(victim,ViewDebug.RecyclerTraceType.MOVE_FROM_ACTIVE_TO_SCRAP_HEAP,mFirstActivePosition + i,-1);
      }
    }
  }
  pruneScrapViews();
}
Program: 23297
Project: 23297
Buggy source:
@Override protected void onDetachedFromWindow(){
  super.onDetachedFromWindow();
  dismissPopup();
  final ViewTreeObserver treeObserver=getViewTreeObserver();
  if (treeObserver != null) {
    treeObserver.removeOnTouchModeChangeListener(this);
    if (mTextFilterEnabled && mPopup != null) {
      treeObserver.removeGlobalOnLayoutListener(this);
      mGlobalLayoutListenerAddedFilter=false;
    }
  }
}

Fixed version (ground truth):
@Override protected void onDetachedFromWindow(){
  super.onDetachedFromWindow();
  dismissPopup();
  mRecycler.clear();
  final ViewTreeObserver treeObserver=getViewTreeObserver();
  if (treeObserver != null) {
    treeObserver.removeOnTouchModeChangeListener(this);
    if (mTextFilterEnabled && mPopup != null) {
      treeObserver.removeGlobalOnLayoutListener(this);
      mGlobalLayoutListenerAddedFilter=false;
    }
  }
}
Program: 23298
Project: 23298
Buggy source:
/** 
 * <p>Avoids jarring scrolling effect by ensuring that list elements made of a text view fit on a single line.</p>
 * @param position the item index in the list to get a view for
 * @return the view for the specified item
 */
@Override protected View obtainView(int position){
  View view=super.obtainView(position);
  if (view instanceof TextView) {
    ((TextView)view).setHorizontallyScrolling(true);
  }
  return view;
}

Fixed version (ground truth):
/** 
 * <p>Avoids jarring scrolling effect by ensuring that list elements made of a text view fit on a single line.</p>
 * @param position the item index in the list to get a view for
 * @return the view for the specified item
 */
@Override View obtainView(int position,boolean[] isScrap){
  View view=super.obtainView(position,isScrap);
  if (view instanceof TextView) {
    ((TextView)view).setHorizontallyScrolling(true);
  }
  return view;
}
Program: 23299
Project: 23299
Buggy source:
/** 
 * Obtain the view and add it to our list of children. The view can be made fresh, converted from an unused view, or used as is if it was in the recycle bin.
 * @param position Logical position in the list
 * @param y Top or bottom edge of the view to add
 * @param flow if true, align top edge to y. If false, align bottom edge toy.
 * @param childrenLeft Left edge where children should be positioned
 * @param selected Is this position selected?
 * @param where to add new item in the list
 * @return View that was added
 */
private View makeAndAddView(int position,int y,boolean flow,int childrenLeft,boolean selected,int where){
  View child;
  if (!mDataChanged) {
    child=mRecycler.getActiveView(position);
    if (child != null) {
      setupChild(child,position,y,flow,childrenLeft,selected,true,where);
      return child;
    }
  }
  child=obtainView(position);
  setupChild(child,position,y,flow,childrenLeft,selected,false,where);
  return child;
}

Fixed version (ground truth):
/** 
 * Obtain the view and add it to our list of children. The view can be made fresh, converted from an unused view, or used as is if it was in the recycle bin.
 * @param position Logical position in the list
 * @param y Top or bottom edge of the view to add
 * @param flow if true, align top edge to y. If false, align bottom edge toy.
 * @param childrenLeft Left edge where children should be positioned
 * @param selected Is this position selected?
 * @param where to add new item in the list
 * @return View that was added
 */
private View makeAndAddView(int position,int y,boolean flow,int childrenLeft,boolean selected,int where){
  View child;
  if (!mDataChanged) {
    child=mRecycler.getActiveView(position);
    if (child != null) {
      setupChild(child,position,y,flow,childrenLeft,selected,true,where);
      return child;
    }
  }
  child=obtainView(position,mIsScrap);
  setupChild(child,position,y,flow,childrenLeft,selected,mIsScrap[0],where);
  return child;
}
Program: 23301
Project: 23301
Buggy source:
private View addViewAbove(View theView,int position){
  int abovePosition=position - 1;
  View view=obtainView(abovePosition);
  int edgeOfNewChild=theView.getTop() - mDividerHeight;
  setupChild(view,abovePosition,edgeOfNewChild,false,mListPadding.left,false,false);
  return view;
}

Fixed version (ground truth):
private View addViewAbove(View theView,int position){
  int abovePosition=position - 1;
  View view=obtainView(abovePosition,mIsScrap);
  int edgeOfNewChild=theView.getTop() - mDividerHeight;
  setupChild(view,abovePosition,edgeOfNewChild,false,mListPadding.left,false,mIsScrap[0]);
  return view;
}
Program: 23302
Project: 23302
Buggy source:
private View addViewBelow(View theView,int position){
  int belowPosition=position + 1;
  View view=obtainView(belowPosition);
  int edgeOfNewChild=theView.getBottom() + mDividerHeight;
  setupChild(view,belowPosition,edgeOfNewChild,true,mListPadding.left,false,false);
  return view;
}

Fixed version (ground truth):
private View addViewBelow(View theView,int position){
  int belowPosition=position + 1;
  View view=obtainView(belowPosition,mIsScrap);
  int edgeOfNewChild=theView.getBottom() + mDividerHeight;
  setupChild(view,belowPosition,edgeOfNewChild,true,mListPadding.left,false,mIsScrap[0]);
  return view;
}
Program: 23303
Project: 23303
Buggy source:
/** 
 * Obtain the view and add it to our list of children. The view can be made fresh, converted from an unused view, or used as is if it was in the recycle bin.
 * @param position Logical position in the list
 * @param y Top or bottom edge of the view to add
 * @param flow If flow is true, align top edge to y. If false, align bottomedge to y.
 * @param childrenLeft Left edge where children should be positioned
 * @param selected Is this position selected?
 * @return View that was added
 */
private View makeAndAddView(int position,int y,boolean flow,int childrenLeft,boolean selected){
  View child;
  if (!mDataChanged) {
    child=mRecycler.getActiveView(position);
    if (child != null) {
      if (ViewDebug.TRACE_RECYCLER) {
        ViewDebug.trace(child,ViewDebug.RecyclerTraceType.RECYCLE_FROM_ACTIVE_HEAP,position,getChildCount());
      }
      setupChild(child,position,y,flow,childrenLeft,selected,true);
      return child;
    }
  }
  child=obtainView(position);
  setupChild(child,position,y,flow,childrenLeft,selected,false);
  return child;
}

Fixed version (ground truth):
/** 
 * Obtain the view and add it to our list of children. The view can be made fresh, converted from an unused view, or used as is if it was in the recycle bin.
 * @param position Logical position in the list
 * @param y Top or bottom edge of the view to add
 * @param flow If flow is true, align top edge to y. If false, align bottomedge to y.
 * @param childrenLeft Left edge where children should be positioned
 * @param selected Is this position selected?
 * @return View that was added
 */
private View makeAndAddView(int position,int y,boolean flow,int childrenLeft,boolean selected){
  View child;
  if (!mDataChanged) {
    child=mRecycler.getActiveView(position);
    if (child != null) {
      if (ViewDebug.TRACE_RECYCLER) {
        ViewDebug.trace(child,ViewDebug.RecyclerTraceType.RECYCLE_FROM_ACTIVE_HEAP,position,getChildCount());
      }
      setupChild(child,position,y,flow,childrenLeft,selected,true);
      return child;
    }
  }
  child=obtainView(position,mIsScrap);
  setupChild(child,position,y,flow,childrenLeft,selected,mIsScrap[0]);
  return child;
}
Program: 23305
Project: 23305
Buggy source:
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  super.onMeasure(widthMeasureSpec,heightMeasureSpec);
  int widthMode=MeasureSpec.getMode(widthMeasureSpec);
  int heightMode=MeasureSpec.getMode(heightMeasureSpec);
  int widthSize=MeasureSpec.getSize(widthMeasureSpec);
  int heightSize=MeasureSpec.getSize(heightMeasureSpec);
  int childWidth=0;
  int childHeight=0;
  mItemCount=mAdapter == null ? 0 : mAdapter.getCount();
  if (mItemCount > 0 && (widthMode == MeasureSpec.UNSPECIFIED || heightMode == MeasureSpec.UNSPECIFIED)) {
    final View child=obtainView(0);
    measureScrapChild(child,0,widthMeasureSpec);
    childWidth=child.getMeasuredWidth();
    childHeight=child.getMeasuredHeight();
    if (recycleOnMeasure()) {
      mRecycler.addScrapView(child);
    }
  }
  if (widthMode == MeasureSpec.UNSPECIFIED) {
    widthSize=mListPadding.left + mListPadding.right + childWidth+ getVerticalScrollbarWidth();
  }
  if (heightMode == MeasureSpec.UNSPECIFIED) {
    heightSize=mListPadding.top + mListPadding.bottom + childHeight+ getVerticalFadingEdgeLength() * 2;
  }
  if (heightMode == MeasureSpec.AT_MOST) {
    heightSize=measureHeightOfChildren(widthMeasureSpec,0,NO_POSITION,heightSize,-1);
  }
  setMeasuredDimension(widthSize,heightSize);
  mWidthMeasureSpec=widthMeasureSpec;
}

Fixed version (ground truth):
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  super.onMeasure(widthMeasureSpec,heightMeasureSpec);
  int widthMode=MeasureSpec.getMode(widthMeasureSpec);
  int heightMode=MeasureSpec.getMode(heightMeasureSpec);
  int widthSize=MeasureSpec.getSize(widthMeasureSpec);
  int heightSize=MeasureSpec.getSize(heightMeasureSpec);
  int childWidth=0;
  int childHeight=0;
  mItemCount=mAdapter == null ? 0 : mAdapter.getCount();
  if (mItemCount > 0 && (widthMode == MeasureSpec.UNSPECIFIED || heightMode == MeasureSpec.UNSPECIFIED)) {
    final View child=obtainView(0,mIsScrap);
    measureScrapChild(child,0,widthMeasureSpec);
    childWidth=child.getMeasuredWidth();
    childHeight=child.getMeasuredHeight();
    if (recycleOnMeasure()) {
      mRecycler.addScrapView(child);
    }
  }
  if (widthMode == MeasureSpec.UNSPECIFIED) {
    widthSize=mListPadding.left + mListPadding.right + childWidth+ getVerticalScrollbarWidth();
  }
  if (heightMode == MeasureSpec.UNSPECIFIED) {
    heightSize=mListPadding.top + mListPadding.bottom + childHeight+ getVerticalFadingEdgeLength() * 2;
  }
  if (heightMode == MeasureSpec.AT_MOST) {
    heightSize=measureHeightOfChildren(widthMeasureSpec,0,NO_POSITION,heightSize,-1);
  }
  setMeasuredDimension(widthSize,heightSize);
  mWidthMeasureSpec=widthMeasureSpec;
}
Program: 23307
Project: 23307
Buggy source:
public void run(AccountManagerFuture<Account[]> future){
  boolean hasSAMLAccount=true;
  try {
    hasSAMLAccount=future.getResult().length > 0;
  }
 catch (  OperationCanceledException e) {
  }
catch (  IOException e) {
  }
catch (  AuthenticatorException e) {
  }
  mEnableFallback=!hasSAMLAccount;
  if (mUnlockScreen == null) {
    Log.w(TAG,"String_Node_Str");
  }
 else   if (mUnlockScreen instanceof UnlockScreen) {
    ((UnlockScreen)mUnlockScreen).setEnableFallback(true);
  }
}

Fixed version (ground truth):
public void run(AccountManagerFuture<Account[]> future){
  int samlAccounts=0;
  try {
    samlAccounts=future.getResult().length;
  }
 catch (  OperationCanceledException e) {
  }
catch (  IOException e) {
  }
catch (  AuthenticatorException e) {
  }
  mEnableFallback=samlAccounts < mNumAccounts;
  if (mUnlockScreen == null) {
    Log.w(TAG,"String_Node_Str");
  }
 else   if (mUnlockScreen instanceof UnlockScreen) {
    ((UnlockScreen)mUnlockScreen).setEnableFallback(mEnableFallback);
  }
}
Program: 23309
Project: 23309
Buggy source:
public void run(AccountManagerFuture<Account[]> future){
  boolean hasSAMLAccount=true;
  try {
    hasSAMLAccount=future.getResult().length > 0;
  }
 catch (  OperationCanceledException e) {
  }
catch (  IOException e) {
  }
catch (  AuthenticatorException e) {
  }
  mEnableFallback=!hasSAMLAccount;
  if (mUnlockScreen == null) {
    Log.w(TAG,"String_Node_Str");
  }
 else   if (mUnlockScreen instanceof UnlockScreen) {
    ((UnlockScreen)mUnlockScreen).setEnableFallback(true);
  }
}

Fixed version (ground truth):
public void run(AccountManagerFuture<Account[]> future){
  int samlAccounts=0;
  try {
    samlAccounts=future.getResult().length;
  }
 catch (  OperationCanceledException e) {
  }
catch (  IOException e) {
  }
catch (  AuthenticatorException e) {
  }
  mEnableFallback=samlAccounts < mNumAccounts;
  if (mUnlockScreen == null) {
    Log.w(TAG,"String_Node_Str");
  }
 else   if (mUnlockScreen instanceof UnlockScreen) {
    ((UnlockScreen)mUnlockScreen).setEnableFallback(mEnableFallback);
  }
}
Program: 23311
Project: 23311
Buggy source:
public void onWindowResize(int w,int h){
synchronized (sGLThreadManager) {
    mWidth=w;
    mHeight=h;
    mSizeChanged=true;
    mRequestRender=true;
    sGLThreadManager.notifyAll();
  }
}

Fixed version (ground truth):
public void onWindowResize(int w,int h){
synchronized (sGLThreadManager) {
    mWidth=w;
    mHeight=h;
    mSizeChanged=true;
    mRequestRender=true;
    mRenderComplete=false;
    sGLThreadManager.notifyAll();
    while (!mExited && !mPaused && !mRenderComplete) {
      if (LOG_SURFACE) {
        Log.i("String_Node_Str","String_Node_Str");
      }
      try {
        sGLThreadManager.wait();
      }
 catch (      InterruptedException ex) {
        Thread.currentThread().interrupt();
      }
    }
  }
}
Program: 23313
Project: 23313
Buggy source:
public void onWindowResize(int w,int h){
synchronized (sGLThreadManager) {
    mWidth=w;
    mHeight=h;
    mSizeChanged=true;
    mRequestRender=true;
    sGLThreadManager.notifyAll();
  }
}

Fixed version (ground truth):
public void onWindowResize(int w,int h){
synchronized (sGLThreadManager) {
    mWidth=w;
    mHeight=h;
    mSizeChanged=true;
    mRequestRender=true;
    mRenderComplete=false;
    sGLThreadManager.notifyAll();
    while (!mExited && !mPaused && !mRenderComplete) {
      if (LOG_SURFACE) {
        Log.i("String_Node_Str","String_Node_Str");
      }
      try {
        sGLThreadManager.wait();
      }
 catch (      InterruptedException ex) {
        Thread.currentThread().interrupt();
      }
    }
  }
}
Program: 23315
Project: 23315
Buggy source:
/** 
 * Default implementation of   {@link KeyEvent.Callback#onKeyMultiple(int,int,KeyEvent) KeyEvent.Callback.onKeyMultiple()}: perform clicking of the view when   {@link KeyEvent#KEYCODE_DPAD_CENTER} or{@link KeyEvent#KEYCODE_ENTER} is released.
 * @param keyCode A key code that represents the button pressed, from{@link android.view.KeyEvent}.
 * @param event   The KeyEvent object that defines the button action.
 */
public boolean onKeyUp(int keyCode,KeyEvent event){
  boolean result=false;
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
{
      if ((mViewFlags & ENABLED_MASK) == DISABLED) {
        return true;
      }
      if ((mViewFlags & CLICKABLE) == CLICKABLE && isPressed()) {
        setPressed(false);
        if (!mHasPerformedLongPress) {
          cancelLongPress();
          result=performClick();
        }
      }
      break;
    }
}
return result;
}

Fixed version (ground truth):
/** 
 * Default implementation of   {@link KeyEvent.Callback#onKeyMultiple(int,int,KeyEvent) KeyEvent.Callback.onKeyMultiple()}: perform clicking of the view when   {@link KeyEvent#KEYCODE_DPAD_CENTER} or{@link KeyEvent#KEYCODE_ENTER} is released.
 * @param keyCode A key code that represents the button pressed, from{@link android.view.KeyEvent}.
 * @param event   The KeyEvent object that defines the button action.
 */
public boolean onKeyUp(int keyCode,KeyEvent event){
  boolean result=false;
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
{
      if ((mViewFlags & ENABLED_MASK) == DISABLED) {
        return true;
      }
      if ((mViewFlags & CLICKABLE) == CLICKABLE && isPressed()) {
        setPressed(false);
        if (!mHasPerformedLongPress) {
          removeLongPressCallback();
          result=performClick();
        }
      }
      break;
    }
}
return result;
}
Program: 23316
Project: 23316
Buggy source:
private void resetPressedState(){
  if ((mViewFlags & ENABLED_MASK) == DISABLED) {
    return;
  }
  if (isPressed()) {
    setPressed(false);
    if (!mHasPerformedLongPress) {
      cancelLongPress();
    }
  }
}

Fixed version (ground truth):
private void resetPressedState(){
  if ((mViewFlags & ENABLED_MASK) == DISABLED) {
    return;
  }
  if (isPressed()) {
    setPressed(false);
    if (!mHasPerformedLongPress) {
      removeLongPressCallback();
    }
  }
}
Program: 23317
Project: 23317
Buggy source:
/** 
 * Cancels a pending long press.  Your subclass can use this if you want the context menu to come up if the user presses and holds at the same place, but you don't want it to come up if they press and then move around enough to cause scrolling.
 */
public void cancelLongPress(){
  if (mPendingCheckForLongPress != null) {
    removeCallbacks(mPendingCheckForLongPress);
  }
}

Fixed version (ground truth):
/** 
 * Cancels a pending long press.  Your subclass can use this if you want the context menu to come up if the user presses and holds at the same place, but you don't want it to come up if they press and then move around enough to cause scrolling.
 */
public void cancelLongPress(){
  removeLongPressCallback();
}
Program: 23319
Project: 23319
Buggy source:
/** 
 * Called when the window containing this view gains or loses focus.  Note that this is separate from view focus: to receive key events, both your view and its window must have focus.  If a window is displayed on top of yours that takes input focus, then your own window will lose focus but the view focus will remain unchanged.
 * @param hasWindowFocus True if the window containing this view now hasfocus, false otherwise.
 */
public void onWindowFocusChanged(boolean hasWindowFocus){
  InputMethodManager imm=InputMethodManager.peekInstance();
  if (!hasWindowFocus) {
    if (isPressed()) {
      setPressed(false);
    }
    if (imm != null && (mPrivateFlags & FOCUSED) != 0) {
      imm.focusOut(this);
    }
    cancelLongPress();
    onFocusLost();
  }
 else   if (imm != null && (mPrivateFlags & FOCUSED) != 0) {
    imm.focusIn(this);
  }
  refreshDrawableState();
}

Fixed version (ground truth):
/** 
 * Called when the window containing this view gains or loses focus.  Note that this is separate from view focus: to receive key events, both your view and its window must have focus.  If a window is displayed on top of yours that takes input focus, then your own window will lose focus but the view focus will remain unchanged.
 * @param hasWindowFocus True if the window containing this view now hasfocus, false otherwise.
 */
public void onWindowFocusChanged(boolean hasWindowFocus){
  InputMethodManager imm=InputMethodManager.peekInstance();
  if (!hasWindowFocus) {
    if (isPressed()) {
      setPressed(false);
    }
    if (imm != null && (mPrivateFlags & FOCUSED) != 0) {
      imm.focusOut(this);
    }
    removeLongPressCallback();
    onFocusLost();
  }
 else   if (imm != null && (mPrivateFlags & FOCUSED) != 0) {
    imm.focusIn(this);
  }
  refreshDrawableState();
}
Program: 23320
Project: 23320
Buggy source:
/** 
 * This is called when the view is detached from a window.  At this point it no longer has a surface for drawing.
 * @see #onAttachedToWindow()
 */
protected void onDetachedFromWindow(){
  cancelLongPress();
  destroyDrawingCache();
}

Fixed version (ground truth):
/** 
 * This is called when the view is detached from a window.  At this point it no longer has a surface for drawing.
 * @see #onAttachedToWindow()
 */
protected void onDetachedFromWindow(){
  removeLongPressCallback();
  destroyDrawingCache();
}
Program: 23321
Project: 23321
Buggy source:
/** 
 * When visibility is set to   {@link #VISIBLE} or {@link #INVISIBLE},  {@link #inflate()} is invoked and this StubbedView is replaced in its parentby the inflated layout resource.
 * @param visibility One of {@link #VISIBLE},   {@link #INVISIBLE}, or   {@link #GONE}.
 * @see #inflate() 
 */
@Override public void setVisibility(int visibility){
  if (mInflatedViewRef != null) {
    View view=mInflatedViewRef.get();
    if (view != null) {
      view.setVisibility(visibility);
    }
 else {
      throw new IllegalStateException("String_Node_Str");
    }
  }
 else   if (visibility == VISIBLE || visibility == INVISIBLE) {
    super.setVisibility(visibility);
    inflate();
  }
}

Fixed version (ground truth):
/** 
 * When visibility is set to   {@link #VISIBLE} or {@link #INVISIBLE},  {@link #inflate()} is invoked and this StubbedView is replaced in its parentby the inflated layout resource.
 * @param visibility One of {@link #VISIBLE},   {@link #INVISIBLE}, or   {@link #GONE}.
 * @see #inflate() 
 */
@Override public void setVisibility(int visibility){
  if (mInflatedViewRef != null) {
    View view=mInflatedViewRef.get();
    if (view != null) {
      view.setVisibility(visibility);
    }
 else {
      throw new IllegalStateException("String_Node_Str");
    }
  }
 else {
    super.setVisibility(visibility);
    if (visibility == VISIBLE || visibility == INVISIBLE) {
      inflate();
    }
  }
}
Program: 23322
Project: 23322
Buggy source:
/** 
 * Inflates the layout resource identified by   {@link #getLayoutResource()}and replaces this StubbedView in its parent by the inflated layout resource.
 * @return The inflated layout resource.
 */
public View inflate(){
  final ViewParent viewParent=getParent();
  if (viewParent != null && viewParent instanceof ViewGroup) {
    if (mLayoutResource != 0) {
      final ViewGroup parent=(ViewGroup)viewParent;
      final LayoutInflater factory=LayoutInflater.from(mContext);
      final View view=factory.inflate(mLayoutResource,parent,false);
      if (mInflatedId != NO_ID) {
        view.setId(mInflatedId);
      }
      final int index=parent.indexOfChild(this);
      parent.removeViewInLayout(this);
      final ViewGroup.LayoutParams layoutParams=getLayoutParams();
      if (layoutParams != null) {
        parent.addView(view,index,layoutParams);
      }
 else {
        parent.addView(view,index);
      }
      mInflatedViewRef=new WeakReference(view);
      if (mInflateListener != null) {
        mInflateListener.onInflate(this,view);
      }
      return view;
    }
 else {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
 else {
    throw new IllegalStateException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Inflates the layout resource identified by   {@link #getLayoutResource()}and replaces this StubbedView in its parent by the inflated layout resource.
 * @return The inflated layout resource.
 */
public View inflate(){
  final ViewParent viewParent=getParent();
  if (viewParent != null && viewParent instanceof ViewGroup) {
    if (mLayoutResource != 0) {
      final ViewGroup parent=(ViewGroup)viewParent;
      final LayoutInflater factory=LayoutInflater.from(mContext);
      final View view=factory.inflate(mLayoutResource,parent,false);
      if (mInflatedId != NO_ID) {
        view.setId(mInflatedId);
      }
      final int index=parent.indexOfChild(this);
      parent.removeViewInLayout(this);
      final ViewGroup.LayoutParams layoutParams=getLayoutParams();
      if (layoutParams != null) {
        parent.addView(view,index,layoutParams);
      }
 else {
        parent.addView(view,index);
      }
      mInflatedViewRef=new WeakReference<View>(view);
      if (mInflateListener != null) {
        mInflateListener.onInflate(this,view);
      }
      return view;
    }
 else {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
 else {
    throw new IllegalStateException("String_Node_Str");
  }
}
Program: 23323
Project: 23323
Buggy source:
private final void sendIntent(int headset){
  if ((mHeadsetState & headset) != (mPrevHeadsetState & headset)) {
    Intent intent=new Intent(Intent.ACTION_HEADSET_PLUG);
    intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
    int state=0;
    int microphone=0;
    if ((headset & HEADSETS_WITH_MIC) != 0) {
      microphone=1;
    }
    if ((mHeadsetState & headset) != 0) {
      state=1;
    }
    intent.putExtra("String_Node_Str",state);
    intent.putExtra("String_Node_Str",mHeadsetName);
    intent.putExtra("String_Node_Str",microphone);
    if (LOG)     Log.v(TAG,"String_Node_Str" + state + "String_Node_Str"+ mHeadsetName+ "String_Node_Str"+ microphone);
    ActivityManagerNative.broadcastStickyIntent(intent,null);
  }
}

Fixed version (ground truth):
private final void sendIntent(int headset,int headsetState,int prevHeadsetState,String headsetName){
  if ((headsetState & headset) != (prevHeadsetState & headset)) {
    Intent intent=new Intent(Intent.ACTION_HEADSET_PLUG);
    intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
    int state=0;
    int microphone=0;
    if ((headset & HEADSETS_WITH_MIC) != 0) {
      microphone=1;
    }
    if ((headsetState & headset) != 0) {
      state=1;
    }
    intent.putExtra("String_Node_Str",state);
    intent.putExtra("String_Node_Str",headsetName);
    intent.putExtra("String_Node_Str",microphone);
    if (LOG)     Log.v(TAG,"String_Node_Str" + state + "String_Node_Str"+ headsetName+ "String_Node_Str"+ microphone);
    ActivityManagerNative.broadcastStickyIntent(intent,null);
  }
}
Program: 23324
Project: 23324
Buggy source:
@Override public void handleMessage(Message msg){
  if (mPendingIntent) {
    sendIntents();
    mPendingIntent=false;
  }
  mWakeLock.release();
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  sendIntents(msg.arg1,msg.arg2,(String)msg.obj);
  mWakeLock.release();
}
Program: 23325
Project: 23325
Buggy source:
private synchronized final void update(String newName,int newState){
  int headsetState=newState & SUPPORTED_HEADSETS;
  int newOrOld=headsetState | mHeadsetState;
  if (mHeadsetState == headsetState || ((newOrOld & (newOrOld - 1)) != 0)) {
    return;
  }
  mHeadsetName=newName;
  mPrevHeadsetState=mHeadsetState;
  mHeadsetState=headsetState;
  mPendingIntent=true;
  if (headsetState == 0) {
    Intent intent=new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    mContext.sendBroadcast(intent);
    mWakeLock.acquire();
    mHandler.sendEmptyMessageDelayed(0,1000);
  }
 else {
    sendIntents();
    mPendingIntent=false;
  }
}

Fixed version (ground truth):
private synchronized final void update(String newName,int newState){
  int headsetState=newState & SUPPORTED_HEADSETS;
  int newOrOld=headsetState | mHeadsetState;
  if (mHeadsetState == headsetState || ((newOrOld & (newOrOld - 1)) != 0)) {
    return;
  }
  mHeadsetName=newName;
  mPrevHeadsetState=mHeadsetState;
  mHeadsetState=headsetState;
  if (headsetState == 0) {
    Intent intent=new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    mContext.sendBroadcast(intent);
    mWakeLock.acquire();
    mHandler.sendMessageDelayed(mHandler.obtainMessage(0,mHeadsetState,mPrevHeadsetState,mHeadsetName),1000);
  }
 else {
    sendIntents(mHeadsetState,mPrevHeadsetState,mHeadsetName);
  }
}
Program: 23326
Project: 23326
Buggy source:
private synchronized final void sendIntents(){
  int allHeadsets=SUPPORTED_HEADSETS;
  for (int curHeadset=1; allHeadsets != 0; curHeadset<<=1) {
    if ((curHeadset & allHeadsets) != 0) {
      sendIntent(curHeadset);
      allHeadsets&=~curHeadset;
    }
  }
}

Fixed version (ground truth):
private synchronized final void sendIntents(int headsetState,int prevHeadsetState,String headsetName){
  int allHeadsets=SUPPORTED_HEADSETS;
  for (int curHeadset=1; allHeadsets != 0; curHeadset<<=1) {
    if ((curHeadset & allHeadsets) != 0) {
      sendIntent(curHeadset,headsetState,prevHeadsetState,headsetName);
      allHeadsets&=~curHeadset;
    }
  }
}
Program: 23327
Project: 23327
Buggy source:
private final void sendIntent(int headset){
  if ((mHeadsetState & headset) != (mPrevHeadsetState & headset)) {
    Intent intent=new Intent(Intent.ACTION_HEADSET_PLUG);
    intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
    int state=0;
    int microphone=0;
    if ((headset & HEADSETS_WITH_MIC) != 0) {
      microphone=1;
    }
    if ((mHeadsetState & headset) != 0) {
      state=1;
    }
    intent.putExtra("String_Node_Str",state);
    intent.putExtra("String_Node_Str",mHeadsetName);
    intent.putExtra("String_Node_Str",microphone);
    if (LOG)     Log.v(TAG,"String_Node_Str" + state + "String_Node_Str"+ mHeadsetName+ "String_Node_Str"+ microphone);
    ActivityManagerNative.broadcastStickyIntent(intent,null);
  }
}

Fixed version (ground truth):
private final void sendIntent(int headset,int headsetState,int prevHeadsetState,String headsetName){
  if ((headsetState & headset) != (prevHeadsetState & headset)) {
    Intent intent=new Intent(Intent.ACTION_HEADSET_PLUG);
    intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
    int state=0;
    int microphone=0;
    if ((headset & HEADSETS_WITH_MIC) != 0) {
      microphone=1;
    }
    if ((headsetState & headset) != 0) {
      state=1;
    }
    intent.putExtra("String_Node_Str",state);
    intent.putExtra("String_Node_Str",headsetName);
    intent.putExtra("String_Node_Str",microphone);
    if (LOG)     Log.v(TAG,"String_Node_Str" + state + "String_Node_Str"+ headsetName+ "String_Node_Str"+ microphone);
    ActivityManagerNative.broadcastStickyIntent(intent,null);
  }
}
Program: 23328
Project: 23328
Buggy source:
@Override public void handleMessage(Message msg){
  if (mPendingIntent) {
    sendIntents();
    mPendingIntent=false;
  }
  mWakeLock.release();
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  sendIntents(msg.arg1,msg.arg2,(String)msg.obj);
  mWakeLock.release();
}
Program: 23329
Project: 23329
Buggy source:
private synchronized final void update(String newName,int newState){
  int headsetState=newState & SUPPORTED_HEADSETS;
  int newOrOld=headsetState | mHeadsetState;
  if (mHeadsetState == headsetState || ((newOrOld & (newOrOld - 1)) != 0)) {
    return;
  }
  mHeadsetName=newName;
  mPrevHeadsetState=mHeadsetState;
  mHeadsetState=headsetState;
  mPendingIntent=true;
  if (headsetState == 0) {
    Intent intent=new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    mContext.sendBroadcast(intent);
    mWakeLock.acquire();
    mHandler.sendEmptyMessageDelayed(0,1000);
  }
 else {
    sendIntents();
    mPendingIntent=false;
  }
}

Fixed version (ground truth):
private synchronized final void update(String newName,int newState){
  int headsetState=newState & SUPPORTED_HEADSETS;
  int newOrOld=headsetState | mHeadsetState;
  if (mHeadsetState == headsetState || ((newOrOld & (newOrOld - 1)) != 0)) {
    return;
  }
  mHeadsetName=newName;
  mPrevHeadsetState=mHeadsetState;
  mHeadsetState=headsetState;
  if (headsetState == 0) {
    Intent intent=new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    mContext.sendBroadcast(intent);
    mWakeLock.acquire();
    mHandler.sendMessageDelayed(mHandler.obtainMessage(0,mHeadsetState,mPrevHeadsetState,mHeadsetName),1000);
  }
 else {
    sendIntents(mHeadsetState,mPrevHeadsetState,mHeadsetName);
  }
}
Program: 23330
Project: 23330
Buggy source:
private synchronized final void sendIntents(){
  int allHeadsets=SUPPORTED_HEADSETS;
  for (int curHeadset=1; allHeadsets != 0; curHeadset<<=1) {
    if ((curHeadset & allHeadsets) != 0) {
      sendIntent(curHeadset);
      allHeadsets&=~curHeadset;
    }
  }
}

Fixed version (ground truth):
private synchronized final void sendIntents(int headsetState,int prevHeadsetState,String headsetName){
  int allHeadsets=SUPPORTED_HEADSETS;
  for (int curHeadset=1; allHeadsets != 0; curHeadset<<=1) {
    if ((curHeadset & allHeadsets) != 0) {
      sendIntent(curHeadset,headsetState,prevHeadsetState,headsetName);
      allHeadsets&=~curHeadset;
    }
  }
}
Program: 23331
Project: 23331
Buggy source:
private final void sendIntent(int headset){
  if ((mHeadsetState & headset) != (mPrevHeadsetState & headset)) {
    Intent intent=new Intent(Intent.ACTION_HEADSET_PLUG);
    intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
    int state=0;
    int microphone=0;
    if ((headset & HEADSETS_WITH_MIC) != 0) {
      microphone=1;
    }
    if ((mHeadsetState & headset) != 0) {
      state=1;
    }
    intent.putExtra("String_Node_Str",state);
    intent.putExtra("String_Node_Str",mHeadsetName);
    intent.putExtra("String_Node_Str",microphone);
    if (LOG)     Log.v(TAG,"String_Node_Str" + state + "String_Node_Str"+ mHeadsetName+ "String_Node_Str"+ microphone);
    ActivityManagerNative.broadcastStickyIntent(intent,null);
  }
}

Fixed version (ground truth):
private final void sendIntent(int headset,int headsetState,int prevHeadsetState,String headsetName){
  if ((headsetState & headset) != (prevHeadsetState & headset)) {
    Intent intent=new Intent(Intent.ACTION_HEADSET_PLUG);
    intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
    int state=0;
    int microphone=0;
    if ((headset & HEADSETS_WITH_MIC) != 0) {
      microphone=1;
    }
    if ((headsetState & headset) != 0) {
      state=1;
    }
    intent.putExtra("String_Node_Str",state);
    intent.putExtra("String_Node_Str",headsetName);
    intent.putExtra("String_Node_Str",microphone);
    if (LOG)     Log.v(TAG,"String_Node_Str" + state + "String_Node_Str"+ headsetName+ "String_Node_Str"+ microphone);
    ActivityManagerNative.broadcastStickyIntent(intent,null);
  }
}
Program: 23332
Project: 23332
Buggy source:
@Override public void handleMessage(Message msg){
  if (mPendingIntent) {
    sendIntents();
    mPendingIntent=false;
  }
  mWakeLock.release();
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  sendIntents(msg.arg1,msg.arg2,(String)msg.obj);
  mWakeLock.release();
}
Program: 23333
Project: 23333
Buggy source:
private synchronized final void update(String newName,int newState){
  int headsetState=newState & SUPPORTED_HEADSETS;
  int newOrOld=headsetState | mHeadsetState;
  if (mHeadsetState == headsetState || ((newOrOld & (newOrOld - 1)) != 0)) {
    return;
  }
  mHeadsetName=newName;
  mPrevHeadsetState=mHeadsetState;
  mHeadsetState=headsetState;
  mPendingIntent=true;
  if (headsetState == 0) {
    Intent intent=new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    mContext.sendBroadcast(intent);
    mWakeLock.acquire();
    mHandler.sendEmptyMessageDelayed(0,1000);
  }
 else {
    sendIntents();
    mPendingIntent=false;
  }
}

Fixed version (ground truth):
private synchronized final void update(String newName,int newState){
  int headsetState=newState & SUPPORTED_HEADSETS;
  int newOrOld=headsetState | mHeadsetState;
  if (mHeadsetState == headsetState || ((newOrOld & (newOrOld - 1)) != 0)) {
    return;
  }
  mHeadsetName=newName;
  mPrevHeadsetState=mHeadsetState;
  mHeadsetState=headsetState;
  if (headsetState == 0) {
    Intent intent=new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    mContext.sendBroadcast(intent);
    mWakeLock.acquire();
    mHandler.sendMessageDelayed(mHandler.obtainMessage(0,mHeadsetState,mPrevHeadsetState,mHeadsetName),1000);
  }
 else {
    sendIntents(mHeadsetState,mPrevHeadsetState,mHeadsetName);
  }
}
Program: 23334
Project: 23334
Buggy source:
private synchronized final void sendIntents(){
  int allHeadsets=SUPPORTED_HEADSETS;
  for (int curHeadset=1; allHeadsets != 0; curHeadset<<=1) {
    if ((curHeadset & allHeadsets) != 0) {
      sendIntent(curHeadset);
      allHeadsets&=~curHeadset;
    }
  }
}

Fixed version (ground truth):
private synchronized final void sendIntents(int headsetState,int prevHeadsetState,String headsetName){
  int allHeadsets=SUPPORTED_HEADSETS;
  for (int curHeadset=1; allHeadsets != 0; curHeadset<<=1) {
    if ((curHeadset & allHeadsets) != 0) {
      sendIntent(curHeadset,headsetState,prevHeadsetState,headsetName);
      allHeadsets&=~curHeadset;
    }
  }
}
Program: 23335
Project: 23335
Buggy source:
private final void sendIntent(int headset){
  if ((mHeadsetState & headset) != (mPrevHeadsetState & headset)) {
    Intent intent=new Intent(Intent.ACTION_HEADSET_PLUG);
    intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
    int state=0;
    int microphone=0;
    if ((headset & HEADSETS_WITH_MIC) != 0) {
      microphone=1;
    }
    if ((mHeadsetState & headset) != 0) {
      state=1;
    }
    intent.putExtra("String_Node_Str",state);
    intent.putExtra("String_Node_Str",mHeadsetName);
    intent.putExtra("String_Node_Str",microphone);
    if (LOG)     Log.v(TAG,"String_Node_Str" + state + "String_Node_Str"+ mHeadsetName+ "String_Node_Str"+ microphone);
    ActivityManagerNative.broadcastStickyIntent(intent,null);
  }
}

Fixed version (ground truth):
private final void sendIntent(int headset,int headsetState,int prevHeadsetState,String headsetName){
  if ((headsetState & headset) != (prevHeadsetState & headset)) {
    Intent intent=new Intent(Intent.ACTION_HEADSET_PLUG);
    intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
    int state=0;
    int microphone=0;
    if ((headset & HEADSETS_WITH_MIC) != 0) {
      microphone=1;
    }
    if ((headsetState & headset) != 0) {
      state=1;
    }
    intent.putExtra("String_Node_Str",state);
    intent.putExtra("String_Node_Str",headsetName);
    intent.putExtra("String_Node_Str",microphone);
    if (LOG)     Log.v(TAG,"String_Node_Str" + state + "String_Node_Str"+ headsetName+ "String_Node_Str"+ microphone);
    ActivityManagerNative.broadcastStickyIntent(intent,null);
  }
}
Program: 23336
Project: 23336
Buggy source:
@Override public void handleMessage(Message msg){
  if (mPendingIntent) {
    sendIntents();
    mPendingIntent=false;
  }
  mWakeLock.release();
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  sendIntents(msg.arg1,msg.arg2,(String)msg.obj);
  mWakeLock.release();
}
Program: 23337
Project: 23337
Buggy source:
private synchronized final void update(String newName,int newState){
  int headsetState=newState & SUPPORTED_HEADSETS;
  int newOrOld=headsetState | mHeadsetState;
  if (mHeadsetState == headsetState || ((newOrOld & (newOrOld - 1)) != 0)) {
    return;
  }
  mHeadsetName=newName;
  mPrevHeadsetState=mHeadsetState;
  mHeadsetState=headsetState;
  mPendingIntent=true;
  if (headsetState == 0) {
    Intent intent=new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    mContext.sendBroadcast(intent);
    mWakeLock.acquire();
    mHandler.sendEmptyMessageDelayed(0,1000);
  }
 else {
    sendIntents();
    mPendingIntent=false;
  }
}

Fixed version (ground truth):
private synchronized final void update(String newName,int newState){
  int headsetState=newState & SUPPORTED_HEADSETS;
  int newOrOld=headsetState | mHeadsetState;
  if (mHeadsetState == headsetState || ((newOrOld & (newOrOld - 1)) != 0)) {
    return;
  }
  mHeadsetName=newName;
  mPrevHeadsetState=mHeadsetState;
  mHeadsetState=headsetState;
  if (headsetState == 0) {
    Intent intent=new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    mContext.sendBroadcast(intent);
    mWakeLock.acquire();
    mHandler.sendMessageDelayed(mHandler.obtainMessage(0,mHeadsetState,mPrevHeadsetState,mHeadsetName),1000);
  }
 else {
    sendIntents(mHeadsetState,mPrevHeadsetState,mHeadsetName);
  }
}
Program: 23338
Project: 23338
Buggy source:
private synchronized final void sendIntents(){
  int allHeadsets=SUPPORTED_HEADSETS;
  for (int curHeadset=1; allHeadsets != 0; curHeadset<<=1) {
    if ((curHeadset & allHeadsets) != 0) {
      sendIntent(curHeadset);
      allHeadsets&=~curHeadset;
    }
  }
}

Fixed version (ground truth):
private synchronized final void sendIntents(int headsetState,int prevHeadsetState,String headsetName){
  int allHeadsets=SUPPORTED_HEADSETS;
  for (int curHeadset=1; allHeadsets != 0; curHeadset<<=1) {
    if ((curHeadset & allHeadsets) != 0) {
      sendIntent(curHeadset,headsetState,prevHeadsetState,headsetName);
      allHeadsets&=~curHeadset;
    }
  }
}