nus-yam/ex-repair huggingface dataset:
Program: 182745
Project: 182745
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: 182746
Project: 182746
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: 182747
Project: 182747
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: 182748
Project: 182748
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: 182750
Project: 182750
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: 182751
Project: 182751
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: 182752
Project: 182752
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: 182754
Project: 182754
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: 182756
Project: 182756
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: 182759
Project: 182759
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: 182760
Project: 182760
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: 182762
Project: 182762
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: 182764
Project: 182764
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: 182765
Project: 182765
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: 182766
Project: 182766
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: 182768
Project: 182768
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: 182769
Project: 182769
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: 182770
Project: 182770
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: 182771
Project: 182771
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: 182772
Project: 182772
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: 182773
Project: 182773
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: 182774
Project: 182774
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: 182775
Project: 182775
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: 182776
Project: 182776
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: 182777
Project: 182777
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: 182778
Project: 182778
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: 182779
Project: 182779
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: 182780
Project: 182780
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: 182781
Project: 182781
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: 182782
Project: 182782
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: 182783
Project: 182783
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: 182784
Project: 182784
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: 182785
Project: 182785
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: 182786
Project: 182786
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: 182787
Project: 182787
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: 182788
Project: 182788
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: 182789
Project: 182789
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: 182790
Project: 182790
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: 182791
Project: 182791
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: 182792
Project: 182792
Buggy source:
public final void scheduleRelaunchActivity(IBinder token,List<ResultInfo> pendingResults,List<Intent> pendingNewIntents,int configChanges,boolean notResumed){
  ActivityRecord r=new ActivityRecord();
  r.token=token;
  r.pendingResults=pendingResults;
  r.pendingIntents=pendingNewIntents;
  r.startsNotResumed=notResumed;
synchronized (mRelaunchingActivities) {
    mRelaunchingActivities.add(r);
  }
  queueOrSendMessage(H.RELAUNCH_ACTIVITY,r,configChanges);
}

Fixed version (ground truth):
public final void scheduleRelaunchActivity(IBinder token,List<ResultInfo> pendingResults,List<Intent> pendingNewIntents,int configChanges,boolean notResumed,Configuration config){
  ActivityRecord r=new ActivityRecord();
  r.token=token;
  r.pendingResults=pendingResults;
  r.pendingIntents=pendingNewIntents;
  r.startsNotResumed=notResumed;
  r.createdConfig=config;
synchronized (mRelaunchingActivities) {
    mRelaunchingActivities.add(r);
  }
  queueOrSendMessage(H.RELAUNCH_ACTIVITY,r,configChanges);
}