nus-yam/ex-repair huggingface dataset:
Program: 199367
Project: 199367
Buggy source:
private int submitCaptureRequest(List<CaptureRequest> requestList,CaptureListener listener,Handler handler,boolean repeating) throws CameraAccessException {
  if (listener != null) {
    handler=checkHandler(handler);
  }
synchronized (mLock) {
    checkIfCameraClosed();
    int requestId;
    if (repeating) {
      stopRepeating();
    }
    LongParcelable lastFrameNumberRef=new LongParcelable();
    try {
      requestId=mRemoteDevice.submitRequestList(requestList,repeating,lastFrameNumberRef);
      if (DEBUG) {
        Log.v(TAG,"String_Node_Str" + lastFrameNumberRef.getNumber());
      }
    }
 catch (    CameraRuntimeException e) {
      throw e.asChecked();
    }
catch (    RemoteException e) {
      return -1;
    }
    if (listener != null) {
      mCaptureListenerMap.put(requestId,new CaptureListenerHolder(listener,requestList,handler,repeating));
    }
    long lastFrameNumber=lastFrameNumberRef.getNumber();
    if (repeating) {
      if (mRepeatingRequestId != REQUEST_ID_NONE) {
        checkEarlyTriggerSequenceComplete(mRepeatingRequestId,lastFrameNumber);
      }
      mRepeatingRequestId=requestId;
    }
 else {
      mFrameNumberRequestPairs.add(new SimpleEntry<Long,Integer>(lastFrameNumber,requestId));
    }
    if (mIdle) {
      mDeviceHandler.post(mCallOnActive);
    }
    mIdle=false;
    return requestId;
  }
}

Fixed version (ground truth):
private int submitCaptureRequest(List<CaptureRequest> requestList,CaptureListener listener,Handler handler,boolean repeating) throws CameraAccessException {
  if (listener != null) {
    handler=checkHandler(handler);
  }
synchronized (mLock) {
    checkIfCameraClosed();
    int requestId;
    if (repeating) {
      stopRepeating();
    }
    LongParcelable lastFrameNumberRef=new LongParcelable();
    try {
      requestId=mRemoteDevice.submitRequestList(requestList,repeating,lastFrameNumberRef);
      if (DEBUG) {
        Log.v(TAG,"String_Node_Str" + lastFrameNumberRef.getNumber());
      }
    }
 catch (    CameraRuntimeException e) {
      throw e.asChecked();
    }
catch (    RemoteException e) {
      return -1;
    }
    if (listener != null) {
      mCaptureListenerMap.put(requestId,new CaptureListenerHolder(listener,requestList,handler,repeating));
    }
 else {
      if (DEBUG) {
        Log.d(TAG,"String_Node_Str" + requestId + "String_Node_Str");
      }
    }
    long lastFrameNumber=lastFrameNumberRef.getNumber();
    if (repeating) {
      if (mRepeatingRequestId != REQUEST_ID_NONE) {
        checkEarlyTriggerSequenceComplete(mRepeatingRequestId,lastFrameNumber);
      }
      mRepeatingRequestId=requestId;
    }
 else {
      mFrameNumberRequestPairs.add(new SimpleEntry<Long,Integer>(lastFrameNumber,requestId));
    }
    if (mIdle) {
      mDeviceHandler.post(mCallOnActive);
    }
    mIdle=false;
    return requestId;
  }
}
Program: 199370
Project: 199370
Buggy source:
/** 
 * Update the height of the   {@link #mNotificationStackScroller} to the new expanded height.This is much more efficient than doing it over the layout pass.
 * @param expandedHeight the new expanded height
 */
private void updateNotificationStackHeight(float expandedHeight){
  mNotificationStackScroller.setIsExpanded(expandedHeight > 0.0f);
  float childOffset=getRelativeTop(mNotificationStackScroller) - mNotificationParent.getTranslationY();
  int newStackHeight=(int)(expandedHeight - childOffset);
  int itemHeight=mNotificationStackScroller.getItemHeight();
  int bottomStackPeekSize=mNotificationStackScroller.getBottomStackPeekSize();
  int minStackHeight=itemHeight + bottomStackPeekSize;
  if (newStackHeight >= minStackHeight) {
    mNotificationParent.setTranslationY(0);
    mNotificationStackScroller.setCurrentStackHeight(newStackHeight);
  }
 else {
    int translationY=(newStackHeight - minStackHeight);
    float partiallyThere=(float)newStackHeight / minStackHeight;
    partiallyThere=Math.max(0,partiallyThere);
    translationY+=(1 - partiallyThere) * bottomStackPeekSize;
    mNotificationParent.setTranslationY(translationY);
    mNotificationStackScroller.setCurrentStackHeight((int)(expandedHeight - (childOffset + translationY)));
  }
}

Fixed version (ground truth):
/** 
 * Update the height of the   {@link #mNotificationStackScroller} to the new expanded height.This is much more efficient than doing it over the layout pass.
 * @param expandedHeight the new expanded height
 */
private void updateNotificationStackHeight(float expandedHeight){
  if (mExpandedHeight == expandedHeight)   return;
  mExpandedHeight=expandedHeight;
  mNotificationStackScroller.setIsExpanded(expandedHeight > 0.0f);
  float childOffset=getRelativeTop(mNotificationStackScroller) - mNotificationParent.getTranslationY();
  int newStackHeight=(int)(expandedHeight - childOffset);
  int itemHeight=mNotificationStackScroller.getItemHeight();
  int bottomStackPeekSize=mNotificationStackScroller.getBottomStackPeekSize();
  int minStackHeight=itemHeight + bottomStackPeekSize;
  if (newStackHeight >= minStackHeight) {
    mNotificationParent.setTranslationY(0);
    mNotificationStackScroller.setCurrentStackHeight(newStackHeight);
  }
 else {
    int translationY=(newStackHeight - minStackHeight);
    float partiallyThere=(float)newStackHeight / minStackHeight;
    partiallyThere=Math.max(0,partiallyThere);
    translationY+=(1 - partiallyThere) * bottomStackPeekSize;
    mNotificationParent.setTranslationY(translationY);
    mNotificationStackScroller.setCurrentStackHeight((int)(expandedHeight - (childOffset + translationY)));
  }
}
Program: 199372
Project: 199372
Buggy source:
private void positionSettings(float dy){
  final int h=mFlipSettingsView.getMeasuredHeight();
  final int ph=mNotificationPanel.getMeasuredHeight();
  if (mSettingsClosing) {
    dy=Math.min(Math.max(-ph,dy),0);
    mFlipSettingsView.setTranslationY(dy);
    mStackScroller.setTranslationY(ph + dy);
  }
 else {
    dy=Math.min(Math.max(0,dy),ph);
    mFlipSettingsView.setTranslationY(-h + dy - mNotificationPadding * 2);
    mStackScroller.setTranslationY(dy);
  }
}

Fixed version (ground truth):
private void positionSettings(float dy){
  if (mSettingsClosing) {
    final int ph=mNotificationPanel.getMeasuredHeight();
    dy=Math.min(Math.max(-ph,dy),0);
    mFlipSettingsView.setTranslationY(dy);
    mStackScroller.setTranslationY(ph + dy);
  }
 else {
    final int h=mFlipSettingsView.getBottom();
    dy=Math.min(Math.max(0,dy),h);
    mFlipSettingsView.setTranslationY(-h + dy);
    mStackScroller.setTranslationY(dy);
  }
}
Program: 199373
Project: 199373
Buggy source:
public void flipToNotifications(){
  mNotificationButtonAnim=start(setVisibilityWhenDone(ObjectAnimator.ofFloat(mNotificationButton,View.ALPHA,0f).setDuration(FLIP_DURATION),mNotificationButton,View.INVISIBLE));
  mSettingsButton.setVisibility(View.VISIBLE);
  mSettingsButtonAnim=start(ObjectAnimator.ofFloat(mSettingsButton,View.ALPHA,1f).setDuration(FLIP_DURATION));
}

Fixed version (ground truth):
public void flipToNotifications(){
  mNotificationButtonAnim=start(setVisibilityWhenDone(ObjectAnimator.ofFloat(mNotificationButton,View.ALPHA,0f).setDuration(FLIP_DURATION_OUT),mNotificationButton,View.INVISIBLE));
  mSettingsButton.setVisibility(View.VISIBLE);
  mSettingsButtonAnim=start(startDelay(FLIP_DURATION_OUT,ObjectAnimator.ofFloat(mSettingsButton,View.ALPHA,1f).setDuration(FLIP_DURATION_IN)));
}
Program: 199374
Project: 199374
Buggy source:
public void flipToSettings(){
  mSettingsButtonAnim=start(setVisibilityWhenDone(ObjectAnimator.ofFloat(mSettingsButton,View.ALPHA,0f).setDuration(FLIP_DURATION),mStackScroller,View.INVISIBLE));
  mNotificationButton.setVisibility(View.VISIBLE);
  mNotificationButtonAnim=start(ObjectAnimator.ofFloat(mNotificationButton,View.ALPHA,1f).setDuration(FLIP_DURATION));
}

Fixed version (ground truth):
public void flipToSettings(){
  mSettingsButtonAnim=start(setVisibilityWhenDone(ObjectAnimator.ofFloat(mSettingsButton,View.ALPHA,0f).setDuration(FLIP_DURATION_OUT),mStackScroller,View.INVISIBLE));
  mNotificationButton.setVisibility(View.VISIBLE);
  mNotificationButtonAnim=start(startDelay(FLIP_DURATION_OUT,ObjectAnimator.ofFloat(mNotificationButton,View.ALPHA,1f).setDuration(FLIP_DURATION_IN)));
}
Program: 199375
Project: 199375
Buggy source:
@Override public boolean onTouchEvent(MotionEvent event){
  if (mScrim.getAlpha() == 1) {
    mScrim.animate().alpha(0).setDuration(1000).start();
    sShowScrim=false;
  }
  return super.onTouchEvent(event);
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent event){
  if (mScrim != null) {
    sShowScrim=false;
    removeView(mScrim);
  }
  return super.onTouchEvent(event);
}
Program: 199377
Project: 199377
Buggy source:
@Override protected void onDraw(Canvas canvas){
  final int w=getMeasuredWidth();
  final int h=getMeasuredHeight();
  final int f=mStrokeWidth * 3 / 4;
  canvas.drawPath(line(f,h / 2,w - f,h / 2),mLinePaint);
  canvas.drawPath(line(w / 2,f,w / 2,h - f),mLinePaint);
  final int s=mStrokeWidth;
  mTextPaint.setTextAlign(Paint.Align.RIGHT);
  canvas.drawText("String_Node_Str",w / 2 - s,h / 2 - s,mTextPaint);
  mTextPaint.setTextAlign(Paint.Align.LEFT);
  canvas.drawText("String_Node_Str",w / 2 + s,h / 2 - s,mTextPaint);
  mTextPaint.setTextAlign(Paint.Align.RIGHT);
  drawUnder(canvas,"String_Node_Str",w / 2 - s,h / 2 + s);
  mTextPaint.setTextAlign(Paint.Align.LEFT);
  drawUnder(canvas,"String_Node_Str",w / 2 + s,h / 2 + s);
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  final int w=getMeasuredWidth();
  final int h=getMeasuredHeight();
  final int f=mStrokeWidth * 3 / 4;
  canvas.drawColor(SCRIM);
  canvas.drawPath(line(f,h / 2,w - f,h / 2),mLinePaint);
  canvas.drawPath(line(w / 2,f,w / 2,h - f),mLinePaint);
  final int s=mStrokeWidth;
  mTextPaint.setTextAlign(Paint.Align.RIGHT);
  canvas.drawText("String_Node_Str",w / 2 - s,h / 2 - s,mTextPaint);
  mTextPaint.setTextAlign(Paint.Align.LEFT);
  canvas.drawText("String_Node_Str",w / 2 + s,h / 2 - s,mTextPaint);
  mTextPaint.setTextAlign(Paint.Align.RIGHT);
  drawUnder(canvas,"String_Node_Str",w / 2 - s,h / 2 + s);
  mTextPaint.setTextAlign(Paint.Align.LEFT);
  drawUnder(canvas,"String_Node_Str",w / 2 + s,h / 2 + s);
}
Program: 199378
Project: 199378
Buggy source:
@Override protected void onFinishInflate(){
  super.onFinishInflate();
  mScrim=new ScrimView(mContext);
  addView(mScrim);
  mScrim.setAlpha(sShowScrim ? 1 : 0);
  LayoutTransition transitions=getLayoutTransition();
}

Fixed version (ground truth):
@Override protected void onFinishInflate(){
  super.onFinishInflate();
  if (sShowScrim) {
    mScrim=new ScrimView(mContext);
    addView(mScrim);
  }
  LayoutTransition transitions=getLayoutTransition();
}
Program: 199379
Project: 199379
Buggy source:
/** 
 * Update the height of the   {@link #mNotificationStackScroller} to the new expanded height.This is much more efficient than doing it over the layout pass.
 * @param expandedHeight the new expanded height
 */
private void updateNotificationStackHeight(float expandedHeight){
  mNotificationStackScroller.setIsExpanded(expandedHeight > 0.0f);
  float childOffset=getRelativeTop(mNotificationStackScroller) - mNotificationParent.getTranslationY();
  int newStackHeight=(int)(expandedHeight - childOffset);
  int itemHeight=mNotificationStackScroller.getItemHeight();
  int bottomStackPeekSize=mNotificationStackScroller.getBottomStackPeekSize();
  int minStackHeight=itemHeight + bottomStackPeekSize;
  if (newStackHeight >= minStackHeight) {
    mNotificationParent.setTranslationY(0);
    mNotificationStackScroller.setCurrentStackHeight(newStackHeight);
  }
 else {
    int translationY=(newStackHeight - minStackHeight);
    float partiallyThere=(float)newStackHeight / minStackHeight;
    partiallyThere=Math.max(0,partiallyThere);
    translationY+=(1 - partiallyThere) * bottomStackPeekSize;
    mNotificationParent.setTranslationY(translationY);
    mNotificationStackScroller.setCurrentStackHeight((int)(expandedHeight - (childOffset + translationY)));
  }
}

Fixed version (ground truth):
/** 
 * Update the height of the   {@link #mNotificationStackScroller} to the new expanded height.This is much more efficient than doing it over the layout pass.
 * @param expandedHeight the new expanded height
 */
private void updateNotificationStackHeight(float expandedHeight){
  if (mExpandedHeight == expandedHeight)   return;
  mExpandedHeight=expandedHeight;
  mNotificationStackScroller.setIsExpanded(expandedHeight > 0.0f);
  float childOffset=getRelativeTop(mNotificationStackScroller) - mNotificationParent.getTranslationY();
  int newStackHeight=(int)(expandedHeight - childOffset);
  int itemHeight=mNotificationStackScroller.getItemHeight();
  int bottomStackPeekSize=mNotificationStackScroller.getBottomStackPeekSize();
  int minStackHeight=itemHeight + bottomStackPeekSize;
  if (newStackHeight >= minStackHeight) {
    mNotificationParent.setTranslationY(0);
    mNotificationStackScroller.setCurrentStackHeight(newStackHeight);
  }
 else {
    int translationY=(newStackHeight - minStackHeight);
    float partiallyThere=(float)newStackHeight / minStackHeight;
    partiallyThere=Math.max(0,partiallyThere);
    translationY+=(1 - partiallyThere) * bottomStackPeekSize;
    mNotificationParent.setTranslationY(translationY);
    mNotificationStackScroller.setCurrentStackHeight((int)(expandedHeight - (childOffset + translationY)));
  }
}
Program: 199381
Project: 199381
Buggy source:
private void positionSettings(float dy){
  final int h=mFlipSettingsView.getMeasuredHeight();
  final int ph=mNotificationPanel.getMeasuredHeight();
  if (mSettingsClosing) {
    dy=Math.min(Math.max(-ph,dy),0);
    mFlipSettingsView.setTranslationY(dy);
    mStackScroller.setTranslationY(ph + dy);
  }
 else {
    dy=Math.min(Math.max(0,dy),ph);
    mFlipSettingsView.setTranslationY(-h + dy - mNotificationPadding * 2);
    mStackScroller.setTranslationY(dy);
  }
}

Fixed version (ground truth):
private void positionSettings(float dy){
  if (mSettingsClosing) {
    final int ph=mNotificationPanel.getMeasuredHeight();
    dy=Math.min(Math.max(-ph,dy),0);
    mFlipSettingsView.setTranslationY(dy);
    mStackScroller.setTranslationY(ph + dy);
  }
 else {
    final int h=mFlipSettingsView.getBottom();
    dy=Math.min(Math.max(0,dy),h);
    mFlipSettingsView.setTranslationY(-h + dy);
    mStackScroller.setTranslationY(dy);
  }
}
Program: 199382
Project: 199382
Buggy source:
public void flipToNotifications(){
  mNotificationButtonAnim=start(setVisibilityWhenDone(ObjectAnimator.ofFloat(mNotificationButton,View.ALPHA,0f).setDuration(FLIP_DURATION),mNotificationButton,View.INVISIBLE));
  mSettingsButton.setVisibility(View.VISIBLE);
  mSettingsButtonAnim=start(ObjectAnimator.ofFloat(mSettingsButton,View.ALPHA,1f).setDuration(FLIP_DURATION));
}

Fixed version (ground truth):
public void flipToNotifications(){
  mNotificationButtonAnim=start(setVisibilityWhenDone(ObjectAnimator.ofFloat(mNotificationButton,View.ALPHA,0f).setDuration(FLIP_DURATION_OUT),mNotificationButton,View.INVISIBLE));
  mSettingsButton.setVisibility(View.VISIBLE);
  mSettingsButtonAnim=start(startDelay(FLIP_DURATION_OUT,ObjectAnimator.ofFloat(mSettingsButton,View.ALPHA,1f).setDuration(FLIP_DURATION_IN)));
}
Program: 199383
Project: 199383
Buggy source:
public void flipToSettings(){
  mSettingsButtonAnim=start(setVisibilityWhenDone(ObjectAnimator.ofFloat(mSettingsButton,View.ALPHA,0f).setDuration(FLIP_DURATION),mStackScroller,View.INVISIBLE));
  mNotificationButton.setVisibility(View.VISIBLE);
  mNotificationButtonAnim=start(ObjectAnimator.ofFloat(mNotificationButton,View.ALPHA,1f).setDuration(FLIP_DURATION));
}

Fixed version (ground truth):
public void flipToSettings(){
  mSettingsButtonAnim=start(setVisibilityWhenDone(ObjectAnimator.ofFloat(mSettingsButton,View.ALPHA,0f).setDuration(FLIP_DURATION_OUT),mStackScroller,View.INVISIBLE));
  mNotificationButton.setVisibility(View.VISIBLE);
  mNotificationButtonAnim=start(startDelay(FLIP_DURATION_OUT,ObjectAnimator.ofFloat(mNotificationButton,View.ALPHA,1f).setDuration(FLIP_DURATION_IN)));
}
Program: 199384
Project: 199384
Buggy source:
@Override public boolean onTouchEvent(MotionEvent event){
  if (mScrim.getAlpha() == 1) {
    mScrim.animate().alpha(0).setDuration(1000).start();
    sShowScrim=false;
  }
  return super.onTouchEvent(event);
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent event){
  if (mScrim != null) {
    sShowScrim=false;
    removeView(mScrim);
  }
  return super.onTouchEvent(event);
}
Program: 199386
Project: 199386
Buggy source:
@Override protected void onDraw(Canvas canvas){
  final int w=getMeasuredWidth();
  final int h=getMeasuredHeight();
  final int f=mStrokeWidth * 3 / 4;
  canvas.drawPath(line(f,h / 2,w - f,h / 2),mLinePaint);
  canvas.drawPath(line(w / 2,f,w / 2,h - f),mLinePaint);
  final int s=mStrokeWidth;
  mTextPaint.setTextAlign(Paint.Align.RIGHT);
  canvas.drawText("String_Node_Str",w / 2 - s,h / 2 - s,mTextPaint);
  mTextPaint.setTextAlign(Paint.Align.LEFT);
  canvas.drawText("String_Node_Str",w / 2 + s,h / 2 - s,mTextPaint);
  mTextPaint.setTextAlign(Paint.Align.RIGHT);
  drawUnder(canvas,"String_Node_Str",w / 2 - s,h / 2 + s);
  mTextPaint.setTextAlign(Paint.Align.LEFT);
  drawUnder(canvas,"String_Node_Str",w / 2 + s,h / 2 + s);
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  final int w=getMeasuredWidth();
  final int h=getMeasuredHeight();
  final int f=mStrokeWidth * 3 / 4;
  canvas.drawColor(SCRIM);
  canvas.drawPath(line(f,h / 2,w - f,h / 2),mLinePaint);
  canvas.drawPath(line(w / 2,f,w / 2,h - f),mLinePaint);
  final int s=mStrokeWidth;
  mTextPaint.setTextAlign(Paint.Align.RIGHT);
  canvas.drawText("String_Node_Str",w / 2 - s,h / 2 - s,mTextPaint);
  mTextPaint.setTextAlign(Paint.Align.LEFT);
  canvas.drawText("String_Node_Str",w / 2 + s,h / 2 - s,mTextPaint);
  mTextPaint.setTextAlign(Paint.Align.RIGHT);
  drawUnder(canvas,"String_Node_Str",w / 2 - s,h / 2 + s);
  mTextPaint.setTextAlign(Paint.Align.LEFT);
  drawUnder(canvas,"String_Node_Str",w / 2 + s,h / 2 + s);
}
Program: 199387
Project: 199387
Buggy source:
@Override protected void onFinishInflate(){
  super.onFinishInflate();
  mScrim=new ScrimView(mContext);
  addView(mScrim);
  mScrim.setAlpha(sShowScrim ? 1 : 0);
  LayoutTransition transitions=getLayoutTransition();
}

Fixed version (ground truth):
@Override protected void onFinishInflate(){
  super.onFinishInflate();
  if (sShowScrim) {
    mScrim=new ScrimView(mContext);
    addView(mScrim);
  }
  LayoutTransition transitions=getLayoutTransition();
}
Program: 199388
Project: 199388
Buggy source:
/** 
 * Update the height of the   {@link #mNotificationStackScroller} to the new expanded height.This is much more efficient than doing it over the layout pass.
 * @param expandedHeight the new expanded height
 */
private void updateNotificationStackHeight(float expandedHeight){
  mNotificationStackScroller.setIsExpanded(expandedHeight > 0.0f);
  float childOffset=getRelativeTop(mNotificationStackScroller) - mNotificationParent.getTranslationY();
  int newStackHeight=(int)(expandedHeight - childOffset);
  int itemHeight=mNotificationStackScroller.getItemHeight();
  int bottomStackPeekSize=mNotificationStackScroller.getBottomStackPeekSize();
  int minStackHeight=itemHeight + bottomStackPeekSize;
  if (newStackHeight >= minStackHeight) {
    mNotificationParent.setTranslationY(0);
    mNotificationStackScroller.setCurrentStackHeight(newStackHeight);
  }
 else {
    int translationY=(newStackHeight - minStackHeight);
    float partiallyThere=(float)newStackHeight / minStackHeight;
    partiallyThere=Math.max(0,partiallyThere);
    translationY+=(1 - partiallyThere) * bottomStackPeekSize;
    mNotificationParent.setTranslationY(translationY);
    mNotificationStackScroller.setCurrentStackHeight((int)(expandedHeight - (childOffset + translationY)));
  }
}

Fixed version (ground truth):
/** 
 * Update the height of the   {@link #mNotificationStackScroller} to the new expanded height.This is much more efficient than doing it over the layout pass.
 * @param expandedHeight the new expanded height
 */
private void updateNotificationStackHeight(float expandedHeight){
  if (mExpandedHeight == expandedHeight)   return;
  mExpandedHeight=expandedHeight;
  mNotificationStackScroller.setIsExpanded(expandedHeight > 0.0f);
  float childOffset=getRelativeTop(mNotificationStackScroller) - mNotificationParent.getTranslationY();
  int newStackHeight=(int)(expandedHeight - childOffset);
  int itemHeight=mNotificationStackScroller.getItemHeight();
  int bottomStackPeekSize=mNotificationStackScroller.getBottomStackPeekSize();
  int minStackHeight=itemHeight + bottomStackPeekSize;
  if (newStackHeight >= minStackHeight) {
    mNotificationParent.setTranslationY(0);
    mNotificationStackScroller.setCurrentStackHeight(newStackHeight);
  }
 else {
    int translationY=(newStackHeight - minStackHeight);
    float partiallyThere=(float)newStackHeight / minStackHeight;
    partiallyThere=Math.max(0,partiallyThere);
    translationY+=(1 - partiallyThere) * bottomStackPeekSize;
    mNotificationParent.setTranslationY(translationY);
    mNotificationStackScroller.setCurrentStackHeight((int)(expandedHeight - (childOffset + translationY)));
  }
}
Program: 199390
Project: 199390
Buggy source:
private void positionSettings(float dy){
  final int h=mFlipSettingsView.getMeasuredHeight();
  final int ph=mNotificationPanel.getMeasuredHeight();
  if (mSettingsClosing) {
    dy=Math.min(Math.max(-ph,dy),0);
    mFlipSettingsView.setTranslationY(dy);
    mStackScroller.setTranslationY(ph + dy);
  }
 else {
    dy=Math.min(Math.max(0,dy),ph);
    mFlipSettingsView.setTranslationY(-h + dy - mNotificationPadding * 2);
    mStackScroller.setTranslationY(dy);
  }
}

Fixed version (ground truth):
private void positionSettings(float dy){
  if (mSettingsClosing) {
    final int ph=mNotificationPanel.getMeasuredHeight();
    dy=Math.min(Math.max(-ph,dy),0);
    mFlipSettingsView.setTranslationY(dy);
    mStackScroller.setTranslationY(ph + dy);
  }
 else {
    final int h=mFlipSettingsView.getBottom();
    dy=Math.min(Math.max(0,dy),h);
    mFlipSettingsView.setTranslationY(-h + dy);
    mStackScroller.setTranslationY(dy);
  }
}
Program: 199391
Project: 199391
Buggy source:
public void flipToNotifications(){
  mNotificationButtonAnim=start(setVisibilityWhenDone(ObjectAnimator.ofFloat(mNotificationButton,View.ALPHA,0f).setDuration(FLIP_DURATION),mNotificationButton,View.INVISIBLE));
  mSettingsButton.setVisibility(View.VISIBLE);
  mSettingsButtonAnim=start(ObjectAnimator.ofFloat(mSettingsButton,View.ALPHA,1f).setDuration(FLIP_DURATION));
}

Fixed version (ground truth):
public void flipToNotifications(){
  mNotificationButtonAnim=start(setVisibilityWhenDone(ObjectAnimator.ofFloat(mNotificationButton,View.ALPHA,0f).setDuration(FLIP_DURATION_OUT),mNotificationButton,View.INVISIBLE));
  mSettingsButton.setVisibility(View.VISIBLE);
  mSettingsButtonAnim=start(startDelay(FLIP_DURATION_OUT,ObjectAnimator.ofFloat(mSettingsButton,View.ALPHA,1f).setDuration(FLIP_DURATION_IN)));
}
Program: 199392
Project: 199392
Buggy source:
public void flipToSettings(){
  mSettingsButtonAnim=start(setVisibilityWhenDone(ObjectAnimator.ofFloat(mSettingsButton,View.ALPHA,0f).setDuration(FLIP_DURATION),mStackScroller,View.INVISIBLE));
  mNotificationButton.setVisibility(View.VISIBLE);
  mNotificationButtonAnim=start(ObjectAnimator.ofFloat(mNotificationButton,View.ALPHA,1f).setDuration(FLIP_DURATION));
}

Fixed version (ground truth):
public void flipToSettings(){
  mSettingsButtonAnim=start(setVisibilityWhenDone(ObjectAnimator.ofFloat(mSettingsButton,View.ALPHA,0f).setDuration(FLIP_DURATION_OUT),mStackScroller,View.INVISIBLE));
  mNotificationButton.setVisibility(View.VISIBLE);
  mNotificationButtonAnim=start(startDelay(FLIP_DURATION_OUT,ObjectAnimator.ofFloat(mNotificationButton,View.ALPHA,1f).setDuration(FLIP_DURATION_IN)));
}
Program: 199393
Project: 199393
Buggy source:
@Override public boolean onTouchEvent(MotionEvent event){
  if (mScrim.getAlpha() == 1) {
    mScrim.animate().alpha(0).setDuration(1000).start();
    sShowScrim=false;
  }
  return super.onTouchEvent(event);
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent event){
  if (mScrim != null) {
    sShowScrim=false;
    removeView(mScrim);
  }
  return super.onTouchEvent(event);
}
Program: 199395
Project: 199395
Buggy source:
@Override protected void onDraw(Canvas canvas){
  final int w=getMeasuredWidth();
  final int h=getMeasuredHeight();
  final int f=mStrokeWidth * 3 / 4;
  canvas.drawPath(line(f,h / 2,w - f,h / 2),mLinePaint);
  canvas.drawPath(line(w / 2,f,w / 2,h - f),mLinePaint);
  final int s=mStrokeWidth;
  mTextPaint.setTextAlign(Paint.Align.RIGHT);
  canvas.drawText("String_Node_Str",w / 2 - s,h / 2 - s,mTextPaint);
  mTextPaint.setTextAlign(Paint.Align.LEFT);
  canvas.drawText("String_Node_Str",w / 2 + s,h / 2 - s,mTextPaint);
  mTextPaint.setTextAlign(Paint.Align.RIGHT);
  drawUnder(canvas,"String_Node_Str",w / 2 - s,h / 2 + s);
  mTextPaint.setTextAlign(Paint.Align.LEFT);
  drawUnder(canvas,"String_Node_Str",w / 2 + s,h / 2 + s);
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  final int w=getMeasuredWidth();
  final int h=getMeasuredHeight();
  final int f=mStrokeWidth * 3 / 4;
  canvas.drawColor(SCRIM);
  canvas.drawPath(line(f,h / 2,w - f,h / 2),mLinePaint);
  canvas.drawPath(line(w / 2,f,w / 2,h - f),mLinePaint);
  final int s=mStrokeWidth;
  mTextPaint.setTextAlign(Paint.Align.RIGHT);
  canvas.drawText("String_Node_Str",w / 2 - s,h / 2 - s,mTextPaint);
  mTextPaint.setTextAlign(Paint.Align.LEFT);
  canvas.drawText("String_Node_Str",w / 2 + s,h / 2 - s,mTextPaint);
  mTextPaint.setTextAlign(Paint.Align.RIGHT);
  drawUnder(canvas,"String_Node_Str",w / 2 - s,h / 2 + s);
  mTextPaint.setTextAlign(Paint.Align.LEFT);
  drawUnder(canvas,"String_Node_Str",w / 2 + s,h / 2 + s);
}
Program: 199396
Project: 199396
Buggy source:
@Override protected void onFinishInflate(){
  super.onFinishInflate();
  mScrim=new ScrimView(mContext);
  addView(mScrim);
  mScrim.setAlpha(sShowScrim ? 1 : 0);
  LayoutTransition transitions=getLayoutTransition();
}

Fixed version (ground truth):
@Override protected void onFinishInflate(){
  super.onFinishInflate();
  if (sShowScrim) {
    mScrim=new ScrimView(mContext);
    addView(mScrim);
  }
  LayoutTransition transitions=getLayoutTransition();
}
Program: 199397
Project: 199397
Buggy source:
private void adjustScreenOrientation(State state){
  if (!state.isKeyguardShowingAndNotOccluded() || mKeyguardScreenRotation) {
    mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_USER;
  }
 else {
    mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
  }
}

Fixed version (ground truth):
private void adjustScreenOrientation(State state){
  if (state.isKeyguardShowingAndNotOccluded()) {
    if (mKeyguardScreenRotation) {
      mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_USER;
    }
 else {
      mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
    }
  }
 else {
    mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
  }
}
Program: 199398
Project: 199398
Buggy source:
private void adjustScreenOrientation(State state){
  if (!state.isKeyguardShowingAndNotOccluded() || mKeyguardScreenRotation) {
    mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_USER;
  }
 else {
    mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
  }
}

Fixed version (ground truth):
private void adjustScreenOrientation(State state){
  if (state.isKeyguardShowingAndNotOccluded()) {
    if (mKeyguardScreenRotation) {
      mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_USER;
    }
 else {
      mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
    }
  }
 else {
    mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
  }
}
Program: 199399
Project: 199399
Buggy source:
private void adjustScreenOrientation(State state){
  if (!state.isKeyguardShowingAndNotOccluded() || mKeyguardScreenRotation) {
    mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_USER;
  }
 else {
    mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
  }
}

Fixed version (ground truth):
private void adjustScreenOrientation(State state){
  if (state.isKeyguardShowingAndNotOccluded()) {
    if (mKeyguardScreenRotation) {
      mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_USER;
    }
 else {
      mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
    }
  }
 else {
    mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
  }
}
Program: 199400
Project: 199400
Buggy source:
private void adjustScreenOrientation(State state){
  if (!state.isKeyguardShowingAndNotOccluded() || mKeyguardScreenRotation) {
    mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_USER;
  }
 else {
    mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
  }
}

Fixed version (ground truth):
private void adjustScreenOrientation(State state){
  if (state.isKeyguardShowingAndNotOccluded()) {
    if (mKeyguardScreenRotation) {
      mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_USER;
    }
 else {
      mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
    }
  }
 else {
    mLp.screenOrientation=ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
  }
}
Program: 199401
Project: 199401
Buggy source:
public boolean hasPlaybackDevices(){
  return mHasPlaybackDevices;
}

Fixed version (ground truth):
public boolean hasPlaybackDevices(int card){
  for (int index=0; index < deviceRecords_.size(); index++) {
    AlsaDeviceRecord deviceRecord=deviceRecords_.get(index);
    if (deviceRecord.mCardNum == card && deviceRecord.mDeviceType == AlsaDeviceRecord.kDeviceType_Audio && deviceRecord.mDeviceDir == AlsaDeviceRecord.kDeviceDir_Playback) {
      return true;
    }
  }
  return false;
}
Program: 199402
Project: 199402
Buggy source:
public boolean hasCaptureDevices(){
  return mHasCaptureDevices;
}

Fixed version (ground truth):
public boolean hasCaptureDevices(int card){
  for (int index=0; index < deviceRecords_.size(); index++) {
    AlsaDeviceRecord deviceRecord=deviceRecords_.get(index);
    if (deviceRecord.mCardNum == card && deviceRecord.mDeviceType == AlsaDeviceRecord.kDeviceType_Audio && deviceRecord.mDeviceDir == AlsaDeviceRecord.kDeviceDir_Capture) {
      return true;
    }
  }
  return false;
}
Program: 199403
Project: 199403
Buggy source:
public boolean hasMIDIDevices(){
  return mHasMIDIDevices;
}

Fixed version (ground truth):
public boolean hasMIDIDevices(int card){
  for (int index=0; index < deviceRecords_.size(); index++) {
    AlsaDeviceRecord deviceRecord=deviceRecords_.get(index);
    if (deviceRecord.mCardNum == card && deviceRecord.mDeviceType == AlsaDeviceRecord.kDeviceType_MIDI) {
      return true;
    }
  }
  return false;
}
Program: 199405
Project: 199405
Buggy source:
private void endUsbDeviceAdded(){
  if (DEBUG_AUDIO) {
    Slog.d(TAG,"String_Node_Str");
  }
  if (mNewInterface != null) {
    mNewInterface.setEndpoints(mNewEndpoints.toArray(new UsbEndpoint[mNewEndpoints.size()]));
  }
  if (mNewConfiguration != null) {
    mNewConfiguration.setInterfaces(mNewInterfaces.toArray(new UsbInterface[mNewInterfaces.size()]));
  }
synchronized (mLock) {
    if (mNewDevice != null) {
      mNewDevice.setConfigurations(mNewConfigurations.toArray(new UsbConfiguration[mNewConfigurations.size()]));
      mDevices.put(mNewDevice.getDeviceName(),mNewDevice);
      Slog.d(TAG,"String_Node_Str" + mNewDevice);
      getCurrentSettings().deviceAttached(mNewDevice);
    }
 else {
      Slog.e(TAG,"String_Node_Str");
    }
    mNewDevice=null;
    mNewConfigurations=null;
    mNewInterfaces=null;
    mNewEndpoints=null;
  }
}

Fixed version (ground truth):
private void endUsbDeviceAdded(){
  if (DEBUG_AUDIO) {
    Slog.d(TAG,"String_Node_Str");
  }
  if (mNewInterface != null) {
    mNewInterface.setEndpoints(mNewEndpoints.toArray(new UsbEndpoint[mNewEndpoints.size()]));
  }
  if (mNewConfiguration != null) {
    mNewConfiguration.setInterfaces(mNewInterfaces.toArray(new UsbInterface[mNewInterfaces.size()]));
  }
  final int kUsbClassId_Audio=0x01;
  boolean isAudioDevice=false;
  for (int ntrfaceIndex=0; !isAudioDevice && ntrfaceIndex < mNewInterfaces.size(); ntrfaceIndex++) {
    UsbInterface ntrface=mNewInterfaces.get(ntrfaceIndex);
    if (ntrface.getInterfaceClass() == kUsbClassId_Audio) {
      isAudioDevice=true;
    }
  }
synchronized (mLock) {
    if (mNewDevice != null) {
      mNewDevice.setConfigurations(mNewConfigurations.toArray(new UsbConfiguration[mNewConfigurations.size()]));
      mDevices.put(mNewDevice.getDeviceName(),mNewDevice);
      Slog.d(TAG,"String_Node_Str" + mNewDevice);
      getCurrentSettings().deviceAttached(mNewDevice);
    }
 else {
      Slog.e(TAG,"String_Node_Str");
    }
    mNewDevice=null;
    mNewConfigurations=null;
    mNewInterfaces=null;
    mNewEndpoints=null;
  }
  if (!isAudioDevice) {
    return;
  }
  AlsaCardsParser cardsParser=new AlsaCardsParser();
  cardsParser.scan();
  AlsaDevicesParser devicesParser=new AlsaDevicesParser();
  devicesParser.scan();
  mConnectedUsbCard=cardsParser.getNumCardRecords() - 1;
  mConnectedUsbDeviceNum=0;
  if (!waitForAlsaFile(mConnectedUsbCard,mConnectedUsbDeviceNum,false)) {
    return;
  }
  mConnectedHasPlayback=devicesParser.hasPlaybackDevices(mConnectedUsbCard);
  mConnectedHasCapture=devicesParser.hasCaptureDevices(mConnectedUsbCard);
  mConnectedHasMIDI=devicesParser.hasMIDIDevices(mConnectedUsbCard);
  if (DEBUG_AUDIO) {
    Slog.d(TAG,"String_Node_Str" + mConnectedHasPlayback + "String_Node_Str"+ mConnectedHasCapture);
  }
  sendDeviceNotification(mConnectedUsbCard,mConnectedUsbDeviceNum,true,mConnectedHasPlayback,mConnectedHasCapture,mConnectedHasMIDI);
}
Program: 199406
Project: 199406
Buggy source:
private void usbDeviceRemoved(String deviceName){
  if (DEBUG_AUDIO) {
    Slog.d(TAG,"String_Node_Str" + deviceName);
  }
  sendDeviceNotification(1,0,false,false,false,false);
synchronized (mLock) {
    UsbDevice device=mDevices.remove(deviceName);
    if (device != null) {
      getCurrentSettings().deviceDetached(device);
    }
  }
}

Fixed version (ground truth):
private void usbDeviceRemoved(String deviceName){
  if (DEBUG_AUDIO) {
    Slog.d(TAG,"String_Node_Str" + deviceName);
  }
  if (mConnectedUsbCard != -1 && mConnectedUsbDeviceNum != -1) {
    sendDeviceNotification(mConnectedUsbCard,mConnectedUsbDeviceNum,false,mConnectedHasPlayback,mConnectedHasCapture,mConnectedHasMIDI);
    mConnectedUsbCard=-1;
    mConnectedUsbDeviceNum=-1;
    mConnectedHasPlayback=false;
    mConnectedHasCapture=false;
    mConnectedHasMIDI=false;
  }
synchronized (mLock) {
    UsbDevice device=mDevices.remove(deviceName);
    if (device != null) {
      getCurrentSettings().deviceDetached(device);
    }
  }
}
Program: 199407
Project: 199407
Buggy source:
private boolean beginUsbDeviceAdded(String deviceName,int vendorID,int productID,int deviceClass,int deviceSubclass,int deviceProtocol,String manufacturerName,String productName,String serialNumber){
  if (DEBUG_AUDIO) {
    Slog.d(TAG,"String_Node_Str" + deviceName + "String_Node_Str");
    Slog.d(TAG,"String_Node_Str");
    Slog.d(TAG,"String_Node_Str" + deviceName + "String_Node_Str"+ vendorID+ "String_Node_Str"+ productID+ "String_Node_Str"+ deviceClass+ "String_Node_Str"+ deviceSubclass+ "String_Node_Str"+ deviceProtocol);
  }
  if (!isBuiltInUsbDevice(deviceName)) {
    com.android.alsascan.AlsaDevicesParser devicesParser=new com.android.alsascan.AlsaDevicesParser();
    devicesParser.scan();
    boolean hasPlaybackDevices=devicesParser.hasPlaybackDevices();
    boolean hasCaptureDevices=devicesParser.hasCaptureDevices();
    boolean hasMIDI=devicesParser.hasMIDIDevices();
    if (DEBUG_AUDIO) {
      Slog.d(TAG,"String_Node_Str" + hasPlaybackDevices + "String_Node_Str"+ hasCaptureDevices);
    }
    int cardNum=1;
    int deviceNum=0;
    sendDeviceNotification(cardNum,deviceNum,true,hasPlaybackDevices,hasCaptureDevices,hasMIDI);
  }
  if (isBlackListed(deviceName) || isBlackListed(deviceClass,deviceSubclass,deviceProtocol)) {
    return false;
  }
synchronized (mLock) {
    if (mDevices.get(deviceName) != null) {
      Slog.w(TAG,"String_Node_Str" + deviceName);
      return false;
    }
    if (mNewDevice != null) {
      Slog.e(TAG,"String_Node_Str");
      return false;
    }
    mNewDevice=new UsbDevice(deviceName,vendorID,productID,deviceClass,deviceSubclass,deviceProtocol,manufacturerName,productName,serialNumber);
    mNewConfigurations=new ArrayList<UsbConfiguration>();
    mNewInterfaces=new ArrayList<UsbInterface>();
    mNewEndpoints=new ArrayList<UsbEndpoint>();
  }
  return true;
}

Fixed version (ground truth):
private boolean beginUsbDeviceAdded(String deviceName,int vendorID,int productID,int deviceClass,int deviceSubclass,int deviceProtocol,String manufacturerName,String productName,String serialNumber){
  if (DEBUG_AUDIO) {
    Slog.d(TAG,"String_Node_Str" + deviceName + "String_Node_Str");
    Slog.d(TAG,"String_Node_Str" + deviceName + "String_Node_Str"+ vendorID+ "String_Node_Str"+ productID+ "String_Node_Str"+ deviceClass+ "String_Node_Str"+ deviceSubclass+ "String_Node_Str"+ deviceProtocol);
  }
  if (isBlackListed(deviceName) || isBlackListed(deviceClass,deviceSubclass,deviceProtocol)) {
    return false;
  }
synchronized (mLock) {
    if (mDevices.get(deviceName) != null) {
      Slog.w(TAG,"String_Node_Str" + deviceName);
      return false;
    }
    if (mNewDevice != null) {
      Slog.e(TAG,"String_Node_Str");
      return false;
    }
    mNewDevice=new UsbDevice(deviceName,vendorID,productID,deviceClass,deviceSubclass,deviceProtocol,manufacturerName,productName,serialNumber);
    mNewConfigurations=new ArrayList<UsbConfiguration>();
    mNewInterfaces=new ArrayList<UsbInterface>();
    mNewEndpoints=new ArrayList<UsbEndpoint>();
  }
  return true;
}
Program: 199408
Project: 199408
Buggy source:
public boolean hasPlaybackDevices(){
  return mHasPlaybackDevices;
}

Fixed version (ground truth):
public boolean hasPlaybackDevices(int card){
  for (int index=0; index < deviceRecords_.size(); index++) {
    AlsaDeviceRecord deviceRecord=deviceRecords_.get(index);
    if (deviceRecord.mCardNum == card && deviceRecord.mDeviceType == AlsaDeviceRecord.kDeviceType_Audio && deviceRecord.mDeviceDir == AlsaDeviceRecord.kDeviceDir_Playback) {
      return true;
    }
  }
  return false;
}
Program: 199409
Project: 199409
Buggy source:
public boolean hasCaptureDevices(){
  return mHasCaptureDevices;
}

Fixed version (ground truth):
public boolean hasCaptureDevices(int card){
  for (int index=0; index < deviceRecords_.size(); index++) {
    AlsaDeviceRecord deviceRecord=deviceRecords_.get(index);
    if (deviceRecord.mCardNum == card && deviceRecord.mDeviceType == AlsaDeviceRecord.kDeviceType_Audio && deviceRecord.mDeviceDir == AlsaDeviceRecord.kDeviceDir_Capture) {
      return true;
    }
  }
  return false;
}
Program: 199410
Project: 199410
Buggy source:
public boolean hasMIDIDevices(){
  return mHasMIDIDevices;
}

Fixed version (ground truth):
public boolean hasMIDIDevices(int card){
  for (int index=0; index < deviceRecords_.size(); index++) {
    AlsaDeviceRecord deviceRecord=deviceRecords_.get(index);
    if (deviceRecord.mCardNum == card && deviceRecord.mDeviceType == AlsaDeviceRecord.kDeviceType_MIDI) {
      return true;
    }
  }
  return false;
}
Program: 199412
Project: 199412
Buggy source:
private void endUsbDeviceAdded(){
  if (DEBUG_AUDIO) {
    Slog.d(TAG,"String_Node_Str");
  }
  if (mNewInterface != null) {
    mNewInterface.setEndpoints(mNewEndpoints.toArray(new UsbEndpoint[mNewEndpoints.size()]));
  }
  if (mNewConfiguration != null) {
    mNewConfiguration.setInterfaces(mNewInterfaces.toArray(new UsbInterface[mNewInterfaces.size()]));
  }
synchronized (mLock) {
    if (mNewDevice != null) {
      mNewDevice.setConfigurations(mNewConfigurations.toArray(new UsbConfiguration[mNewConfigurations.size()]));
      mDevices.put(mNewDevice.getDeviceName(),mNewDevice);
      Slog.d(TAG,"String_Node_Str" + mNewDevice);
      getCurrentSettings().deviceAttached(mNewDevice);
    }
 else {
      Slog.e(TAG,"String_Node_Str");
    }
    mNewDevice=null;
    mNewConfigurations=null;
    mNewInterfaces=null;
    mNewEndpoints=null;
  }
}

Fixed version (ground truth):
private void endUsbDeviceAdded(){
  if (DEBUG_AUDIO) {
    Slog.d(TAG,"String_Node_Str");
  }
  if (mNewInterface != null) {
    mNewInterface.setEndpoints(mNewEndpoints.toArray(new UsbEndpoint[mNewEndpoints.size()]));
  }
  if (mNewConfiguration != null) {
    mNewConfiguration.setInterfaces(mNewInterfaces.toArray(new UsbInterface[mNewInterfaces.size()]));
  }
  final int kUsbClassId_Audio=0x01;
  boolean isAudioDevice=false;
  for (int ntrfaceIndex=0; !isAudioDevice && ntrfaceIndex < mNewInterfaces.size(); ntrfaceIndex++) {
    UsbInterface ntrface=mNewInterfaces.get(ntrfaceIndex);
    if (ntrface.getInterfaceClass() == kUsbClassId_Audio) {
      isAudioDevice=true;
    }
  }
synchronized (mLock) {
    if (mNewDevice != null) {
      mNewDevice.setConfigurations(mNewConfigurations.toArray(new UsbConfiguration[mNewConfigurations.size()]));
      mDevices.put(mNewDevice.getDeviceName(),mNewDevice);
      Slog.d(TAG,"String_Node_Str" + mNewDevice);
      getCurrentSettings().deviceAttached(mNewDevice);
    }
 else {
      Slog.e(TAG,"String_Node_Str");
    }
    mNewDevice=null;
    mNewConfigurations=null;
    mNewInterfaces=null;
    mNewEndpoints=null;
  }
  if (!isAudioDevice) {
    return;
  }
  AlsaCardsParser cardsParser=new AlsaCardsParser();
  cardsParser.scan();
  AlsaDevicesParser devicesParser=new AlsaDevicesParser();
  devicesParser.scan();
  mConnectedUsbCard=cardsParser.getNumCardRecords() - 1;
  mConnectedUsbDeviceNum=0;
  if (!waitForAlsaFile(mConnectedUsbCard,mConnectedUsbDeviceNum,false)) {
    return;
  }
  mConnectedHasPlayback=devicesParser.hasPlaybackDevices(mConnectedUsbCard);
  mConnectedHasCapture=devicesParser.hasCaptureDevices(mConnectedUsbCard);
  mConnectedHasMIDI=devicesParser.hasMIDIDevices(mConnectedUsbCard);
  if (DEBUG_AUDIO) {
    Slog.d(TAG,"String_Node_Str" + mConnectedHasPlayback + "String_Node_Str"+ mConnectedHasCapture);
  }
  sendDeviceNotification(mConnectedUsbCard,mConnectedUsbDeviceNum,true,mConnectedHasPlayback,mConnectedHasCapture,mConnectedHasMIDI);
}
Program: 199413
Project: 199413
Buggy source:
private void usbDeviceRemoved(String deviceName){
  if (DEBUG_AUDIO) {
    Slog.d(TAG,"String_Node_Str" + deviceName);
  }
  sendDeviceNotification(1,0,false,false,false,false);
synchronized (mLock) {
    UsbDevice device=mDevices.remove(deviceName);
    if (device != null) {
      getCurrentSettings().deviceDetached(device);
    }
  }
}

Fixed version (ground truth):
private void usbDeviceRemoved(String deviceName){
  if (DEBUG_AUDIO) {
    Slog.d(TAG,"String_Node_Str" + deviceName);
  }
  if (mConnectedUsbCard != -1 && mConnectedUsbDeviceNum != -1) {
    sendDeviceNotification(mConnectedUsbCard,mConnectedUsbDeviceNum,false,mConnectedHasPlayback,mConnectedHasCapture,mConnectedHasMIDI);
    mConnectedUsbCard=-1;
    mConnectedUsbDeviceNum=-1;
    mConnectedHasPlayback=false;
    mConnectedHasCapture=false;
    mConnectedHasMIDI=false;
  }
synchronized (mLock) {
    UsbDevice device=mDevices.remove(deviceName);
    if (device != null) {
      getCurrentSettings().deviceDetached(device);
    }
  }
}
Program: 199414
Project: 199414
Buggy source:
private boolean beginUsbDeviceAdded(String deviceName,int vendorID,int productID,int deviceClass,int deviceSubclass,int deviceProtocol,String manufacturerName,String productName,String serialNumber){
  if (DEBUG_AUDIO) {
    Slog.d(TAG,"String_Node_Str" + deviceName + "String_Node_Str");
    Slog.d(TAG,"String_Node_Str");
    Slog.d(TAG,"String_Node_Str" + deviceName + "String_Node_Str"+ vendorID+ "String_Node_Str"+ productID+ "String_Node_Str"+ deviceClass+ "String_Node_Str"+ deviceSubclass+ "String_Node_Str"+ deviceProtocol);
  }
  if (!isBuiltInUsbDevice(deviceName)) {
    com.android.alsascan.AlsaDevicesParser devicesParser=new com.android.alsascan.AlsaDevicesParser();
    devicesParser.scan();
    boolean hasPlaybackDevices=devicesParser.hasPlaybackDevices();
    boolean hasCaptureDevices=devicesParser.hasCaptureDevices();
    boolean hasMIDI=devicesParser.hasMIDIDevices();
    if (DEBUG_AUDIO) {
      Slog.d(TAG,"String_Node_Str" + hasPlaybackDevices + "String_Node_Str"+ hasCaptureDevices);
    }
    int cardNum=1;
    int deviceNum=0;
    sendDeviceNotification(cardNum,deviceNum,true,hasPlaybackDevices,hasCaptureDevices,hasMIDI);
  }
  if (isBlackListed(deviceName) || isBlackListed(deviceClass,deviceSubclass,deviceProtocol)) {
    return false;
  }
synchronized (mLock) {
    if (mDevices.get(deviceName) != null) {
      Slog.w(TAG,"String_Node_Str" + deviceName);
      return false;
    }
    if (mNewDevice != null) {
      Slog.e(TAG,"String_Node_Str");
      return false;
    }
    mNewDevice=new UsbDevice(deviceName,vendorID,productID,deviceClass,deviceSubclass,deviceProtocol,manufacturerName,productName,serialNumber);
    mNewConfigurations=new ArrayList<UsbConfiguration>();
    mNewInterfaces=new ArrayList<UsbInterface>();
    mNewEndpoints=new ArrayList<UsbEndpoint>();
  }
  return true;
}

Fixed version (ground truth):
private boolean beginUsbDeviceAdded(String deviceName,int vendorID,int productID,int deviceClass,int deviceSubclass,int deviceProtocol,String manufacturerName,String productName,String serialNumber){
  if (DEBUG_AUDIO) {
    Slog.d(TAG,"String_Node_Str" + deviceName + "String_Node_Str");
    Slog.d(TAG,"String_Node_Str" + deviceName + "String_Node_Str"+ vendorID+ "String_Node_Str"+ productID+ "String_Node_Str"+ deviceClass+ "String_Node_Str"+ deviceSubclass+ "String_Node_Str"+ deviceProtocol);
  }
  if (isBlackListed(deviceName) || isBlackListed(deviceClass,deviceSubclass,deviceProtocol)) {
    return false;
  }
synchronized (mLock) {
    if (mDevices.get(deviceName) != null) {
      Slog.w(TAG,"String_Node_Str" + deviceName);
      return false;
    }
    if (mNewDevice != null) {
      Slog.e(TAG,"String_Node_Str");
      return false;
    }
    mNewDevice=new UsbDevice(deviceName,vendorID,productID,deviceClass,deviceSubclass,deviceProtocol,manufacturerName,productName,serialNumber);
    mNewConfigurations=new ArrayList<UsbConfiguration>();
    mNewInterfaces=new ArrayList<UsbInterface>();
    mNewEndpoints=new ArrayList<UsbEndpoint>();
  }
  return true;
}
Program: 199415
Project: 199415
Buggy source:
public boolean hasPlaybackDevices(){
  return mHasPlaybackDevices;
}

Fixed version (ground truth):
public boolean hasPlaybackDevices(int card){
  for (int index=0; index < deviceRecords_.size(); index++) {
    AlsaDeviceRecord deviceRecord=deviceRecords_.get(index);
    if (deviceRecord.mCardNum == card && deviceRecord.mDeviceType == AlsaDeviceRecord.kDeviceType_Audio && deviceRecord.mDeviceDir == AlsaDeviceRecord.kDeviceDir_Playback) {
      return true;
    }
  }
  return false;
}
Program: 199416
Project: 199416
Buggy source:
public boolean hasCaptureDevices(){
  return mHasCaptureDevices;
}

Fixed version (ground truth):
public boolean hasCaptureDevices(int card){
  for (int index=0; index < deviceRecords_.size(); index++) {
    AlsaDeviceRecord deviceRecord=deviceRecords_.get(index);
    if (deviceRecord.mCardNum == card && deviceRecord.mDeviceType == AlsaDeviceRecord.kDeviceType_Audio && deviceRecord.mDeviceDir == AlsaDeviceRecord.kDeviceDir_Capture) {
      return true;
    }
  }
  return false;
}
Program: 199417
Project: 199417
Buggy source:
public boolean hasMIDIDevices(){
  return mHasMIDIDevices;
}

Fixed version (ground truth):
public boolean hasMIDIDevices(int card){
  for (int index=0; index < deviceRecords_.size(); index++) {
    AlsaDeviceRecord deviceRecord=deviceRecords_.get(index);
    if (deviceRecord.mCardNum == card && deviceRecord.mDeviceType == AlsaDeviceRecord.kDeviceType_MIDI) {
      return true;
    }
  }
  return false;
}