nus-yam/ex-repair huggingface dataset:
Program: 195292
Project: 195292
Buggy source:
@Override public int checkRtl(CharSequence cs,int start,int count){
  boolean haveUnlookedFor=false;
  for (int i=start, e=start + count; i < e; ++i) {
switch (isRtlText(Character.getDirectionality(cs.charAt(i)))) {
case STATE_TRUE:
      if (mLookForRtl) {
        return STATE_TRUE;
      }
    haveUnlookedFor=true;
  break;
case STATE_FALSE:
if (!mLookForRtl) {
  return STATE_FALSE;
}
haveUnlookedFor=true;
break;
default :
break;
}
}
if (haveUnlookedFor) {
return mLookForRtl ? STATE_FALSE : STATE_TRUE;
}
return STATE_UNKNOWN;
}

Fixed version (ground truth):
@Override public int checkRtl(CharSequence cs,int start,int count){
  boolean haveUnlookedFor=false;
  int openIsolateCount=0;
  for (int cp, i=start, end=start + count; i < end; i+=Character.charCount(cp)) {
    cp=Character.codePointAt(cs,i);
    if (0x2066 <= cp && cp <= 0x2068) {
      openIsolateCount+=1;
    }
 else     if (cp == 0x2069) {
      if (openIsolateCount > 0)       openIsolateCount-=1;
    }
 else     if (openIsolateCount == 0) {
switch (isRtlCodePoint(cp)) {
case STATE_TRUE:
        if (mLookForRtl) {
          return STATE_TRUE;
        }
      haveUnlookedFor=true;
    break;
case STATE_FALSE:
  if (!mLookForRtl) {
    return STATE_FALSE;
  }
haveUnlookedFor=true;
break;
default :
break;
}
}
}
if (haveUnlookedFor) {
return mLookForRtl ? STATE_FALSE : STATE_TRUE;
}
return STATE_UNKNOWN;
}
Program: 195294
Project: 195294
Buggy source:
public void setTrackingHeadsUp(boolean tracking){
  if (tracking) {
    mNotificationStackScroller.setTrackingHeadsUp(true);
  }
}

Fixed version (ground truth):
public void setTrackingHeadsUp(boolean tracking){
  if (tracking) {
    mNotificationStackScroller.setTrackingHeadsUp(true);
    mExpandingFromHeadsUp=true;
  }
}
Program: 195295
Project: 195295
Buggy source:
private void updateNotificationTranslucency(){
  float alpha=(getNotificationsTopY() + mNotificationStackScroller.getItemHeight()) / (mQsMinExpansionHeight + mNotificationStackScroller.getBottomStackPeekSize() - mNotificationStackScroller.getCollapseSecondCardPadding());
  alpha=Math.max(0,Math.min(alpha,1));
  alpha=(float)Math.pow(alpha,0.75);
  if (alpha != 1f && mNotificationStackScroller.getLayerType() != LAYER_TYPE_HARDWARE) {
    mNotificationStackScroller.setLayerType(LAYER_TYPE_HARDWARE,null);
  }
 else   if (alpha == 1f && mNotificationStackScroller.getLayerType() == LAYER_TYPE_HARDWARE) {
    mNotificationStackScroller.setLayerType(LAYER_TYPE_NONE,null);
  }
  mNotificationStackScroller.setAlpha(alpha);
}

Fixed version (ground truth):
private void updateNotificationTranslucency(){
  float alpha;
  if (mExpandingFromHeadsUp || mHeadsUpManager.hasPinnedHeadsUp()) {
    alpha=1f;
  }
 else {
    alpha=(getNotificationsTopY() + mNotificationStackScroller.getItemHeight()) / (mQsMinExpansionHeight + mNotificationStackScroller.getBottomStackPeekSize() - mNotificationStackScroller.getCollapseSecondCardPadding());
    alpha=Math.max(0,Math.min(alpha,1));
    alpha=(float)Math.pow(alpha,0.75);
    if (alpha != 1f && mNotificationStackScroller.getLayerType() != LAYER_TYPE_HARDWARE) {
      mNotificationStackScroller.setLayerType(LAYER_TYPE_HARDWARE,null);
    }
 else     if (alpha == 1f && mNotificationStackScroller.getLayerType() == LAYER_TYPE_HARDWARE) {
      mNotificationStackScroller.setLayerType(LAYER_TYPE_NONE,null);
    }
  }
  mNotificationStackScroller.setAlpha(alpha);
}
Program: 195296
Project: 195296
Buggy source:
private float getHeaderTranslation(){
  if (mStatusBar.getBarState() == StatusBarState.KEYGUARD) {
    return 0;
  }
  if (mNotificationStackScroller.getNotGoneChildCount() == 0) {
    if (mExpandedHeight / HEADER_RUBBERBAND_FACTOR >= mQsMinExpansionHeight) {
      return 0;
    }
 else {
      return mExpandedHeight / HEADER_RUBBERBAND_FACTOR - mQsMinExpansionHeight;
    }
  }
  float paddingOffset=mNotificationStackScroller.getPaddingOffset();
  float translation=paddingOffset / HEADER_RUBBERBAND_FACTOR;
  if (mHeadsUpManager.hasPinnedHeadsUp() || mExpansionIsFromHeadsUp) {
    translation=mNotificationStackScroller.getTopPadding() + mNotificationStackScroller.getPaddingOffset() - mNotificationTopPadding - mQsMinExpansionHeight;
  }
  return Math.min(0,translation);
}

Fixed version (ground truth):
private float getHeaderTranslation(){
  if (mStatusBar.getBarState() == StatusBarState.KEYGUARD) {
    return 0;
  }
  if (mNotificationStackScroller.getNotGoneChildCount() == 0) {
    if (mExpandedHeight / HEADER_RUBBERBAND_FACTOR >= mQsMinExpansionHeight) {
      return 0;
    }
 else {
      return mExpandedHeight / HEADER_RUBBERBAND_FACTOR - mQsMinExpansionHeight;
    }
  }
  float stackTranslation=mNotificationStackScroller.getStackTranslation();
  float translation=stackTranslation / HEADER_RUBBERBAND_FACTOR;
  if (mHeadsUpManager.hasPinnedHeadsUp() || mExpansionIsFromHeadsUp) {
    translation=mNotificationStackScroller.getTopPadding() + stackTranslation - mNotificationTopPadding - mQsMinExpansionHeight;
  }
  return Math.min(0,translation);
}
Program: 195297
Project: 195297
Buggy source:
@Override public void OnPinnedHeadsUpExistChanged(final boolean exist,boolean changeImmediatly){
  if (exist != mPinnedHeadsUpExist) {
    mPinnedHeadsUpExist=exist;
    if (!exist) {
      mNotificationStackScroller.performOnAnimationFinished(mHeadsUpExistenceChangedRunnable);
    }
 else {
      mHeadsUpExistenceChangedRunnable.run();
    }
  }
}

Fixed version (ground truth):
@Override public void OnPinnedHeadsUpExistChanged(final boolean exist,boolean changeImmediatly){
  if (exist != mPinnedHeadsUpExist) {
    mPinnedHeadsUpExist=exist;
    if (exist) {
      mHeadsUpExistenceChangedRunnable.run();
      updateNotificationTranslucency();
    }
 else {
      mNotificationStackScroller.performOnAnimationFinished(mHeadsUpExistenceChangedRunnable);
    }
  }
}
Program: 195298
Project: 195298
Buggy source:
@Override protected void onExpandingFinished(){
  super.onExpandingFinished();
  mNotificationStackScroller.onExpansionStopped();
  mHeadsUpManager.onExpandingFinished();
  mIsExpanding=false;
  mScrollYOverride=-1;
  if (mExpandedHeight == 0f) {
    setListening(false);
  }
 else {
    setListening(true);
  }
  mQsExpandImmediate=false;
  mTwoFingerQsExpandPossible=false;
  mExpansionIsFromHeadsUp=false;
  mNotificationStackScroller.setTrackingHeadsUp(mHeadsUpTouchHelper.isTrackingHeadsUp());
}

Fixed version (ground truth):
@Override protected void onExpandingFinished(){
  super.onExpandingFinished();
  mNotificationStackScroller.onExpansionStopped();
  mHeadsUpManager.onExpandingFinished();
  mIsExpanding=false;
  mScrollYOverride=-1;
  if (mExpandedHeight == 0f) {
    setListening(false);
  }
 else {
    setListening(true);
  }
  mQsExpandImmediate=false;
  mTwoFingerQsExpandPossible=false;
  mExpansionIsFromHeadsUp=false;
  mNotificationStackScroller.setTrackingHeadsUp(mHeadsUpTouchHelper.isTrackingHeadsUp());
  mExpandingFromHeadsUp=mHeadsUpTouchHelper.isTrackingHeadsUp();
}
Program: 195299
Project: 195299
Buggy source:
/** 
 * Update the height of the stack to a new height.
 * @param height the new height of the stack
 */
public void setStackHeight(float height){
  mLastSetStackHeight=height;
  setIsExpanded(height > 0.0f);
  int newStackHeight=(int)height;
  int minStackHeight=getMinStackHeight();
  int stackHeight;
  float paddingOffset;
  boolean trackingHeadsUp=mTrackingHeadsUp;
  int normalExpandPositionStart=trackingHeadsUp ? mHeadsUpManager.getTopHeadsUpHeight() : minStackHeight;
  if (newStackHeight - mTopPadding - mTopPaddingOverflow >= normalExpandPositionStart || getNotGoneChildCount() == 0) {
    paddingOffset=mTopPaddingOverflow;
    stackHeight=newStackHeight;
  }
 else {
    int translationY=(newStackHeight - minStackHeight);
    float partiallyThere=(newStackHeight - mTopPadding - mTopPaddingOverflow) / minStackHeight;
    partiallyThere=Math.max(0,partiallyThere);
    if (!trackingHeadsUp) {
      translationY+=(1 - partiallyThere) * (mBottomStackPeekSize + mCollapseSecondCardPadding);
    }
 else {
      translationY=(int)(height - mHeadsUpManager.getTopHeadsUpHeight());
    }
    paddingOffset=translationY - mTopPadding;
    stackHeight=(int)(height - (translationY - mTopPadding));
  }
  if (stackHeight != mCurrentStackHeight) {
    mCurrentStackHeight=stackHeight;
    updateAlgorithmHeightAndPadding();
    requestChildrenUpdate();
  }
  setPaddingOffset(paddingOffset);
}

Fixed version (ground truth):
/** 
 * Update the height of the stack to a new height.
 * @param height the new height of the stack
 */
public void setStackHeight(float height){
  mLastSetStackHeight=height;
  setIsExpanded(height > 0.0f);
  int newStackHeight=(int)height;
  int minStackHeight=getMinStackHeight();
  int stackHeight;
  float paddingOffset;
  boolean trackingHeadsUp=mTrackingHeadsUp;
  int normalExpandPositionStart=trackingHeadsUp ? mHeadsUpManager.getTopHeadsUpHeight() : minStackHeight;
  if (newStackHeight - mTopPadding - mTopPaddingOverflow >= normalExpandPositionStart || getNotGoneChildCount() == 0) {
    paddingOffset=mTopPaddingOverflow;
    stackHeight=newStackHeight;
  }
 else {
    int translationY=(newStackHeight - minStackHeight);
    float partiallyThere=(newStackHeight - mTopPadding - mTopPaddingOverflow) / minStackHeight;
    partiallyThere=Math.max(0,partiallyThere);
    if (!trackingHeadsUp) {
      translationY+=(1 - partiallyThere) * (mBottomStackPeekSize + mCollapseSecondCardPadding);
    }
 else {
      translationY=(int)(height - mHeadsUpManager.getTopHeadsUpHeight());
    }
    paddingOffset=translationY - mTopPadding;
    stackHeight=(int)(height - (translationY - mTopPadding));
  }
  if (stackHeight != mCurrentStackHeight) {
    mCurrentStackHeight=stackHeight;
    updateAlgorithmHeightAndPadding();
    requestChildrenUpdate();
  }
  setStackTranslation(paddingOffset);
}
Program: 195300
Project: 195300
Buggy source:
/** 
 * @return the y position of the first notification
 */
public float getNotificationsTopY(){
  return mTopPadding + getTranslationY();
}

Fixed version (ground truth):
/** 
 * @return the y position of the first notification
 */
public float getNotificationsTopY(){
  return mTopPadding + getStackTranslation();
}
Program: 195301
Project: 195301
Buggy source:
public void setHeadsUpManager(HeadsUpManager headsUpManager){
  mHeadsUpManager=headsUpManager;
  mAmbientState.setHeadsUpManager(headsUpManager);
}

Fixed version (ground truth):
public void setHeadsUpManager(HeadsUpManager headsUpManager){
  mHeadsUpManager=headsUpManager;
  mAmbientState.setHeadsUpManager(headsUpManager);
  mStackScrollAlgorithm.setHeadsUpManager(headsUpManager);
}
Program: 195302
Project: 195302
Buggy source:
public float getBottomMostNotificationBottom(){
  final int count=getChildCount();
  float max=0;
  for (int childIdx=0; childIdx < count; childIdx++) {
    ExpandableView child=(ExpandableView)getChildAt(childIdx);
    if (child.getVisibility() == GONE) {
      continue;
    }
    float bottom=child.getTranslationY() + child.getActualHeight();
    if (bottom > max) {
      max=bottom;
    }
  }
  return max + getTranslationY();
}

Fixed version (ground truth):
public float getBottomMostNotificationBottom(){
  final int count=getChildCount();
  float max=0;
  for (int childIdx=0; childIdx < count; childIdx++) {
    ExpandableView child=(ExpandableView)getChildAt(childIdx);
    if (child.getVisibility() == GONE) {
      continue;
    }
    float bottom=child.getTranslationY() + child.getActualHeight();
    if (bottom > max) {
      max=bottom;
    }
  }
  return max + getStackTranslation();
}
Program: 195303
Project: 195303
Buggy source:
private void updateFirstChildHeightWhileExpanding(ViewGroup hostView){
  mFirstChildWhileExpanding=(ExpandableView)findFirstVisibleChild(hostView);
  if (mFirstChildWhileExpanding != null) {
    if (mExpandedOnStart) {
      mFirstChildMaxHeight=StackStateAnimator.getFinalActualHeight(mFirstChildWhileExpanding);
    }
 else {
      updateFirstChildMaxSizeToMaxHeight();
    }
  }
 else {
    mFirstChildMaxHeight=0;
  }
}

Fixed version (ground truth):
private void updateFirstChildHeightWhileExpanding(ViewGroup hostView){
  mFirstChildWhileExpanding=(ExpandableView)findFirstVisibleChild(hostView);
  if (mFirstChildWhileExpanding != null) {
    if (mExpandedOnStart) {
      mFirstChildMaxHeight=StackStateAnimator.getFinalActualHeight(mFirstChildWhileExpanding);
      if (mFirstChildWhileExpanding instanceof ExpandableNotificationRow) {
        ExpandableNotificationRow row=(ExpandableNotificationRow)mFirstChildWhileExpanding;
        if (row.isHeadsUp()) {
          mFirstChildMaxHeight+=mCollapsedSize - row.getHeadsUpHeight();
        }
      }
    }
 else {
      updateFirstChildMaxSizeToMaxHeight();
    }
  }
 else {
    mFirstChildMaxHeight=0;
  }
}
Program: 195304
Project: 195304
Buggy source:
private int getMaxAllowedChildHeight(View child,AmbientState ambientState){
  if (child instanceof ExpandableNotificationRow) {
    ExpandableNotificationRow row=(ExpandableNotificationRow)child;
    if (ambientState != null && ambientState.getTopHeadsUpEntry() == child) {
      int extraSize=row.getIntrinsicHeight() - row.getHeadsUpHeight();
      return mCollapsedSize + extraSize;
    }
    return row.getIntrinsicHeight();
  }
 else   if (child instanceof ExpandableView) {
    ExpandableView expandableView=(ExpandableView)child;
    return expandableView.getActualHeight();
  }
  return child == null ? mCollapsedSize : child.getHeight();
}

Fixed version (ground truth):
private int getMaxAllowedChildHeight(View child,AmbientState ambientState){
  if (child instanceof ExpandableNotificationRow) {
    ExpandableNotificationRow row=(ExpandableNotificationRow)child;
    if (ambientState == null && row.isHeadsUp() || ambientState != null && ambientState.getTopHeadsUpEntry() == child) {
      int extraSize=row.getIntrinsicHeight() - row.getHeadsUpHeight();
      return mCollapsedSize + extraSize;
    }
    return row.getIntrinsicHeight();
  }
 else   if (child instanceof ExpandableView) {
    ExpandableView expandableView=(ExpandableView)child;
    return expandableView.getActualHeight();
  }
  return child == null ? mCollapsedSize : child.getHeight();
}
Program: 195305
Project: 195305
Buggy source:
private View findFirstVisibleChild(ViewGroup container){
  int childCount=container.getChildCount();
  for (int i=0; i < childCount; i++) {
    View child=container.getChildAt(i);
    if (child.getVisibility() != View.GONE) {
      return child;
    }
  }
  return null;
}

Fixed version (ground truth):
private View findFirstVisibleChild(ViewGroup container){
  if (mHeadsUpManager != null && mHeadsUpManager.getTopEntry() != null) {
    return mHeadsUpManager.getTopEntry().entry.row;
  }
  int childCount=container.getChildCount();
  for (int i=0; i < childCount; i++) {
    View child=container.getChildAt(i);
    if (child.getVisibility() != View.GONE) {
      return child;
    }
  }
  return null;
}
Program: 195306
Project: 195306
Buggy source:
@Override protected void onLayout(boolean changed,int left,int top,int right,int bottom){
  super.onLayout(changed,left,top,right,bottom);
  if (!mActualHeightInitialized && mActualHeight == 0) {
    int initialHeight=getInitialHeight();
    if (initialHeight != 0) {
      setContentHeight(initialHeight);
    }
  }
}

Fixed version (ground truth):
@Override protected void onLayout(boolean changed,int left,int top,int right,int bottom){
  super.onLayout(changed,left,top,right,bottom);
  if (!mActualHeightInitialized && mActualHeight == 0) {
    int initialHeight=getInitialHeight();
    if (initialHeight != 0) {
      setContentHeight(initialHeight);
    }
  }
  updateClipping();
}
Program: 195307
Project: 195307
Buggy source:
private void updateMaxHeights(){
  int intrinsicBefore=getIntrinsicHeight();
  View expandedChild=mPrivateLayout.getExpandedChild();
  if (expandedChild == null) {
    expandedChild=mPrivateLayout.getContractedChild();
  }
  mMaxExpandHeight=expandedChild.getHeight();
  View headsUpChild=mPrivateLayout.getHeadsUpChild();
  if (headsUpChild != null) {
    mHeadsUpHeight=headsUpChild.getHeight();
  }
  if (intrinsicBefore != getIntrinsicHeight()) {
    notifyHeightChanged(false);
  }
}

Fixed version (ground truth):
private void updateMaxHeights(){
  int intrinsicBefore=getIntrinsicHeight();
  View expandedChild=mPrivateLayout.getExpandedChild();
  if (expandedChild == null) {
    expandedChild=mPrivateLayout.getContractedChild();
  }
  mMaxExpandHeight=expandedChild.getHeight();
  View headsUpChild=mPrivateLayout.getHeadsUpChild();
  if (headsUpChild == null) {
    headsUpChild=mPrivateLayout.getContractedChild();
  }
  mHeadsUpHeight=headsUpChild.getHeight();
  if (intrinsicBefore != getIntrinsicHeight()) {
    notifyHeightChanged(false);
  }
}
Program: 195308
Project: 195308
Buggy source:
public NotificationContentView(Context context,AttributeSet attrs){
  super(context,attrs);
  mFadePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.ADD));
  reset(true);
}

Fixed version (ground truth):
public NotificationContentView(Context context,AttributeSet attrs){
  super(context,attrs);
  mFadePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.ADD));
  mSmallHeight=getResources().getDimensionPixelSize(R.dimen.notification_min_height);
  mHeadsUpHeight=getResources().getDimensionPixelSize(R.dimen.notification_mid_height);
  reset(true);
}
Program: 195309
Project: 195309
Buggy source:
public void setContractedChild(View child){
  if (mContractedChild != null) {
    mContractedChild.animate().cancel();
    removeView(mContractedChild);
  }
  sanitizeLayoutParams(child,mSmallHeight);
  addView(child);
  mContractedChild=child;
  mContractedWrapper=NotificationViewWrapper.wrap(getContext(),child);
  selectLayout(false,true);
  mContractedWrapper.setDark(mDark,false,0);
}

Fixed version (ground truth):
public void setContractedChild(View child){
  if (mContractedChild != null) {
    mContractedChild.animate().cancel();
    removeView(mContractedChild);
  }
  addView(child);
  mContractedChild=child;
  mContractedWrapper=NotificationViewWrapper.wrap(getContext(),child);
  selectLayout(false,true);
  mContractedWrapper.setDark(mDark,false,0);
}
Program: 195310
Project: 195310
Buggy source:
public void reset(boolean resetActualHeight){
  if (mContractedChild != null) {
    mContractedChild.animate().cancel();
  }
  if (mExpandedChild != null) {
    mExpandedChild.animate().cancel();
  }
  if (mHeadsUpChild != null) {
    mHeadsUpChild.animate().cancel();
  }
  removeAllViews();
  mContractedChild=null;
  mExpandedChild=null;
  mSmallHeight=getResources().getDimensionPixelSize(R.dimen.notification_min_height);
  mHeadsUpHeight=getResources().getDimensionPixelSize(R.dimen.notification_mid_height);
  mVisibleView=CONTRACTED;
  if (resetActualHeight) {
    mContentHeight=mSmallHeight;
  }
}

Fixed version (ground truth):
public void reset(boolean resetActualHeight){
  if (mContractedChild != null) {
    mContractedChild.animate().cancel();
  }
  if (mExpandedChild != null) {
    mExpandedChild.animate().cancel();
  }
  if (mHeadsUpChild != null) {
    mHeadsUpChild.animate().cancel();
  }
  removeAllViews();
  mContractedChild=null;
  mExpandedChild=null;
  mHeadsUpChild=null;
  mVisibleView=CONTRACTED;
  if (resetActualHeight) {
    mContentHeight=mSmallHeight;
  }
}
Program: 195311
Project: 195311
Buggy source:
private int calculateVisibleView(){
  boolean noExpandedChild=mExpandedChild == null;
  if (mIsHeadsUp) {
    if (mContentHeight <= mHeadsUpHeight || noExpandedChild) {
      return HEADSUP;
    }
 else {
      return EXPANDED;
    }
  }
 else {
    if (mContentHeight <= mSmallHeight || noExpandedChild) {
      return CONTRACTED;
    }
 else {
      return EXPANDED;
    }
  }
}

Fixed version (ground truth):
private int calculateVisibleView(){
  boolean noExpandedChild=mExpandedChild == null;
  if (mIsHeadsUp && mHeadsUpChild != null) {
    if (mContentHeight <= mHeadsUpChild.getHeight() || noExpandedChild) {
      return HEADSUP;
    }
 else {
      return EXPANDED;
    }
  }
 else {
    if (mContentHeight <= mSmallHeight || noExpandedChild) {
      return CONTRACTED;
    }
 else {
      return EXPANDED;
    }
  }
}
Program: 195313
Project: 195313
Buggy source:
@Override protected void onHeightUpdated(float expandedHeight){
  if (!mQsExpanded || mQsExpandImmediate || mIsExpanding && mQsExpandedWhenExpandingStarted) {
    positionClockAndNotifications();
  }
  if (mQsExpandImmediate || mQsExpanded && !mQsTracking && mQsExpansionAnimator == null && !mQsExpansionFromOverscroll) {
    float t;
    if (mKeyguardShowing) {
      t=expandedHeight / getMaxPanelHeight();
    }
 else {
      float panelHeightQsCollapsed=mNotificationStackScroller.getIntrinsicPadding() + mNotificationStackScroller.getMinStackHeight();
      float panelHeightQsExpanded=calculatePanelHeightQsExpanded();
      t=(expandedHeight - panelHeightQsCollapsed) / (panelHeightQsExpanded - panelHeightQsCollapsed);
    }
    setQsExpansion(mQsMinExpansionHeight + t * (getTempQsMaxExpansion() - mQsMinExpansionHeight));
  }
  mNotificationStackScroller.setStackHeight(expandedHeight);
  updateHeader();
  updateUnlockIcon();
  updateNotificationTranslucency();
  mHeadsUpManager.setIsExpanded(!isShadeCollapsed());
  mNotificationStackScroller.setShadeExpanded(!isShadeCollapsed());
  if (DEBUG) {
    invalidate();
  }
}

Fixed version (ground truth):
@Override protected void onHeightUpdated(float expandedHeight){
  if (!mQsExpanded || mQsExpandImmediate || mIsExpanding && mQsExpandedWhenExpandingStarted) {
    positionClockAndNotifications();
  }
  if (mQsExpandImmediate || mQsExpanded && !mQsTracking && mQsExpansionAnimator == null && !mQsExpansionFromOverscroll) {
    float t;
    if (mKeyguardShowing) {
      t=expandedHeight / getMaxPanelHeight();
    }
 else {
      float panelHeightQsCollapsed=mNotificationStackScroller.getIntrinsicPadding() + mNotificationStackScroller.getMinStackHeight();
      float panelHeightQsExpanded=calculatePanelHeightQsExpanded();
      t=(expandedHeight - panelHeightQsCollapsed) / (panelHeightQsExpanded - panelHeightQsCollapsed);
    }
    setQsExpansion(mQsMinExpansionHeight + t * (getTempQsMaxExpansion() - mQsMinExpansionHeight));
  }
  mNotificationStackScroller.setStackHeight(expandedHeight);
  updateHeader();
  updateUnlockIcon();
  updateNotificationTranslucency();
  mHeadsUpManager.setIsExpanded(expandedHeight != 0);
  mNotificationStackScroller.setShadeExpanded(!isShadeCollapsed());
  if (DEBUG) {
    invalidate();
  }
}
Program: 195314
Project: 195314
Buggy source:
/** 
 * Called when updating or posting a notification to the heads up.
 */
public void updateNotification(NotificationData.Entry headsUp,boolean alert){
  if (DEBUG)   Log.v(TAG,"String_Node_Str");
  headsUp.row.setChildrenExpanded(false,false);
  headsUp.row.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
  if (alert) {
    HeadsUpEntry headsUpEntry=mHeadsUpEntries.get(headsUp.key);
    headsUpEntry.updateEntry();
    headsUpEntry.entry.row.setInShade(mIsExpanded);
  }
}

Fixed version (ground truth):
/** 
 * Called when updating or posting a notification to the heads up.
 */
public void updateNotification(NotificationData.Entry headsUp,boolean alert){
  if (DEBUG)   Log.v(TAG,"String_Node_Str");
  headsUp.row.setChildrenExpanded(false,false);
  headsUp.row.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
  if (alert) {
    HeadsUpEntry headsUpEntry=mHeadsUpEntries.get(headsUp.key);
    headsUpEntry.updateEntry();
    setEntryToShade(headsUpEntry,mIsExpanded);
  }
}
Program: 195315
Project: 195315
Buggy source:
public void setIsExpanded(boolean isExpanded){
  mIsExpanded=isExpanded;
}

Fixed version (ground truth):
public void setIsExpanded(boolean isExpanded){
  if (isExpanded != mIsExpanded) {
    mIsExpanded=isExpanded;
    if (isExpanded) {
      releaseAllToShade();
    }
  }
}
Program: 195316
Project: 195316
Buggy source:
private void addHeadsUpEntry(NotificationData.Entry entry){
  HeadsUpEntry headsUpEntry=mEntryPool.acquire();
  headsUpEntry.setEntry(entry);
  mHeadsUpEntries.put(entry.key,headsUpEntry);
  entry.row.setHeadsUp(true);
  if (!entry.row.isInShade() && mIsExpanded) {
    headsUpEntry.entry.row.setInShade(true);
  }
  updatePinnedHeadsUpState(false);
  for (  OnHeadsUpChangedListener listener : mListeners) {
    listener.OnHeadsUpStateChanged(entry,true);
  }
  entry.row.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
}

Fixed version (ground truth):
private void addHeadsUpEntry(NotificationData.Entry entry){
  HeadsUpEntry headsUpEntry=mEntryPool.acquire();
  headsUpEntry.setEntry(entry);
  mHeadsUpEntries.put(entry.key,headsUpEntry);
  entry.row.setHeadsUp(true);
  if (!entry.row.isInShade() && mIsExpanded) {
    setEntryToShade(headsUpEntry,true);
  }
  updatePinnedHeadsUpState(false);
  for (  OnHeadsUpChangedListener listener : mListeners) {
    listener.OnHeadsUpStateChanged(entry,true);
  }
  entry.row.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
}
Program: 195317
Project: 195317
Buggy source:
private void generateHeadsUpAnimationEvents(){
  for (  Pair<ExpandableNotificationRow,Boolean> eventPair : mHeadsUpChangeAnimations) {
    ExpandableNotificationRow row=eventPair.first;
    boolean isHeadsUp=eventPair.second;
    int type=AnimationEvent.ANIMATION_TYPE_HEADS_UP_OTHER;
    boolean onBottom=false;
    if (!row.isInShade() && !isHeadsUp) {
      type=AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR;
    }
 else     if (mAddedHeadsUpChildren.contains(row)) {
      if (!row.isInShade() || shouldHunAppearFromBottom(row)) {
        type=AnimationEvent.ANIMATION_TYPE_HEADS_UP_APPEAR;
      }
 else {
        type=AnimationEvent.ANIMATION_TYPE_ADD;
      }
      onBottom=row.isInShade();
    }
    AnimationEvent event=new AnimationEvent(row,type);
    event.headsUpFromBottom=onBottom;
    mAnimationEvents.add(event);
  }
  mHeadsUpChangeAnimations.clear();
  mAddedHeadsUpChildren.clear();
}

Fixed version (ground truth):
private void generateHeadsUpAnimationEvents(){
  for (  Pair<ExpandableNotificationRow,Boolean> eventPair : mHeadsUpChangeAnimations) {
    ExpandableNotificationRow row=eventPair.first;
    boolean isHeadsUp=eventPair.second;
    int type=AnimationEvent.ANIMATION_TYPE_HEADS_UP_OTHER;
    boolean onBottom=false;
    if (!row.isInShade() && !isHeadsUp) {
      type=AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR;
    }
 else     if (mAddedHeadsUpChildren.contains(row) || (!row.isInShade() && !mIsExpanded)) {
      if (!row.isInShade() || shouldHunAppearFromBottom(row)) {
        type=AnimationEvent.ANIMATION_TYPE_HEADS_UP_APPEAR;
      }
 else {
        type=AnimationEvent.ANIMATION_TYPE_ADD;
      }
      onBottom=row.isInShade();
    }
    AnimationEvent event=new AnimationEvent(row,type);
    event.headsUpFromBottom=onBottom;
    mAnimationEvents.add(event);
  }
  mHeadsUpChangeAnimations.clear();
  mAddedHeadsUpChildren.clear();
}
Program: 195318
Project: 195318
Buggy source:
private boolean isPinnedHeadsUp(View v){
  if (v instanceof ExpandableNotificationRow) {
    ExpandableNotificationRow row=(ExpandableNotificationRow)v;
    return row.isHeadsUp() && !row.isInShade();
  }
  return false;
}

Fixed version (ground truth):
public boolean isPinnedHeadsUp(View v){
  if (v instanceof ExpandableNotificationRow) {
    ExpandableNotificationRow row=(ExpandableNotificationRow)v;
    return row.isHeadsUp() && !row.isInShade();
  }
  return false;
}
Program: 195319
Project: 195319
Buggy source:
private void updateHeadsUpStates(StackScrollState resultState,AmbientState ambientState){
  TreeSet<HeadsUpManager.HeadsUpEntry> headsUpEntries=ambientState.getSortedHeadsUpEntries();
  for (  HeadsUpManager.HeadsUpEntry entry : headsUpEntries) {
    ExpandableNotificationRow row=entry.entry.row;
    StackViewState childState=resultState.getViewStateForView(row);
    if (!row.isInShade()) {
      childState.yTranslation=0;
    }
    if (ambientState.getTopHeadsUpEntry() == row) {
      childState.height+=row.getHeadsUpHeight() - mCollapsedSize;
    }
    childState.height=Math.max(childState.height,row.getHeadsUpHeight());
    childState.yTranslation=Math.min(childState.yTranslation,ambientState.getMaxHeadsUpTranslation() - childState.height);
  }
}

Fixed version (ground truth):
private void updateHeadsUpStates(StackScrollState resultState,AmbientState ambientState){
  TreeSet<HeadsUpManager.HeadsUpEntry> headsUpEntries=ambientState.getSortedHeadsUpEntries();
  for (  HeadsUpManager.HeadsUpEntry entry : headsUpEntries) {
    ExpandableNotificationRow row=entry.entry.row;
    StackViewState childState=resultState.getViewStateForView(row);
    ExpandableNotificationRow topHeadsUpEntry=ambientState.getTopHeadsUpEntry();
    boolean isTopEntry=topHeadsUpEntry == row;
    if (!row.isInShade()) {
      childState.yTranslation=0;
      childState.height=row.getHeadsUpHeight();
      if (!isTopEntry) {
        StackViewState topState=resultState.getViewStateForView(topHeadsUpEntry);
        childState.height=row.getHeadsUpHeight();
        childState.yTranslation=Math.min(childState.yTranslation,topState.yTranslation + topState.height - childState.height);
      }
    }
 else     if (mIsExpanded) {
      if (isTopEntry) {
        childState.height+=row.getHeadsUpHeight() - mCollapsedSize;
      }
      childState.height=Math.max(childState.height,row.getHeadsUpHeight());
      float bottomPosition=ambientState.getMaxHeadsUpTranslation() - childState.height;
      childState.yTranslation=Math.min(childState.yTranslation,bottomPosition);
    }
  }
}
Program: 195320
Project: 195320
Buggy source:
/** 
 * Determines if a view should not perform an animation and applies it directly.
 * @return true if no animation should be performed
 */
private boolean applyWithoutAnimation(ExpandableView child,StackViewState viewState,StackScrollState finalState){
  if (mShadeExpanded) {
    return false;
  }
  if (getChildTag(child,TAG_ANIMATOR_TRANSLATION_Y) != null) {
    return false;
  }
  if (mHeadsUpDisappearChildren.contains(child) || mHeadsUpAppearChildren.contains(child)) {
    return false;
  }
  finalState.applyState(child,viewState);
  return true;
}

Fixed version (ground truth):
/** 
 * Determines if a view should not perform an animation and applies it directly.
 * @return true if no animation should be performed
 */
private boolean applyWithoutAnimation(ExpandableView child,StackViewState viewState,StackScrollState finalState){
  if (mShadeExpanded) {
    return false;
  }
  if (getChildTag(child,TAG_ANIMATOR_TRANSLATION_Y) != null) {
    return false;
  }
  if (mHeadsUpDisappearChildren.contains(child) || mHeadsUpAppearChildren.contains(child)) {
    return false;
  }
  if (mHostLayout.isPinnedHeadsUp(child)) {
    return false;
  }
  finalState.applyState(child,viewState);
  return true;
}
Program: 195322
Project: 195322
Buggy source:
public HeadsUpManager(final Context context,ViewTreeObserver observer){
  Resources resources=context.getResources();
  mTouchSensitivityDelay=resources.getInteger(R.integer.heads_up_sensitivity_delay);
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + mTouchSensitivityDelay);
  mSnoozedPackages=new ArrayMap<>();
  mDefaultSnoozeLengthMs=resources.getInteger(R.integer.heads_up_default_snooze_length_ms);
  mSnoozeLengthMs=mDefaultSnoozeLengthMs;
  mMinimumDisplayTime=resources.getInteger(R.integer.heads_up_notification_minimum_time);
  mHeadsUpNotificationDecay=200000000;
  ;
  mClock=new Clock();
  mSnoozeLengthMs=Settings.Global.getInt(context.getContentResolver(),SETTING_HEADS_UP_SNOOZE_LENGTH_MS,mDefaultSnoozeLengthMs);
  mSettingsObserver=new ContentObserver(mHandler){
    @Override public void onChange(    boolean selfChange){
      final int packageSnoozeLengthMs=Settings.Global.getInt(context.getContentResolver(),SETTING_HEADS_UP_SNOOZE_LENGTH_MS,-1);
      if (packageSnoozeLengthMs > -1 && packageSnoozeLengthMs != mSnoozeLengthMs) {
        mSnoozeLengthMs=packageSnoozeLengthMs;
        if (DEBUG)         Log.v(TAG,"String_Node_Str" + mSnoozeLengthMs);
      }
    }
  }
;
  context.getContentResolver().registerContentObserver(Settings.Global.getUriFor(SETTING_HEADS_UP_SNOOZE_LENGTH_MS),false,mSettingsObserver);
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + mSnoozeLengthMs);
  observer.addOnComputeInternalInsetsListener(this);
}

Fixed version (ground truth):
public HeadsUpManager(final Context context,ViewTreeObserver observer){
  Resources resources=context.getResources();
  mTouchSensitivityDelay=resources.getInteger(R.integer.heads_up_sensitivity_delay);
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + mTouchSensitivityDelay);
  mSnoozedPackages=new ArrayMap<>();
  mDefaultSnoozeLengthMs=resources.getInteger(R.integer.heads_up_default_snooze_length_ms);
  mSnoozeLengthMs=mDefaultSnoozeLengthMs;
  mMinimumDisplayTime=resources.getInteger(R.integer.heads_up_notification_minimum_time);
  mHeadsUpNotificationDecay=resources.getInteger(R.integer.heads_up_notification_decay);
  mClock=new Clock();
  mSnoozeLengthMs=Settings.Global.getInt(context.getContentResolver(),SETTING_HEADS_UP_SNOOZE_LENGTH_MS,mDefaultSnoozeLengthMs);
  mSettingsObserver=new ContentObserver(mHandler){
    @Override public void onChange(    boolean selfChange){
      final int packageSnoozeLengthMs=Settings.Global.getInt(context.getContentResolver(),SETTING_HEADS_UP_SNOOZE_LENGTH_MS,-1);
      if (packageSnoozeLengthMs > -1 && packageSnoozeLengthMs != mSnoozeLengthMs) {
        mSnoozeLengthMs=packageSnoozeLengthMs;
        if (DEBUG)         Log.v(TAG,"String_Node_Str" + mSnoozeLengthMs);
      }
    }
  }
;
  context.getContentResolver().registerContentObserver(Settings.Global.getUriFor(SETTING_HEADS_UP_SNOOZE_LENGTH_MS),false,mSettingsObserver);
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + mSnoozeLengthMs);
  observer.addOnComputeInternalInsetsListener(this);
}
Program: 195323
Project: 195323
Buggy source:
private void updateContentHeight(){
  int height=0;
  for (int i=0; i < getChildCount(); i++) {
    View child=getChildAt(i);
    if (child.getVisibility() != View.GONE) {
      if (height != 0) {
        height+=mPaddingBetweenElements;
      }
      if (child instanceof ExpandableNotificationRow) {
        ExpandableNotificationRow row=(ExpandableNotificationRow)child;
        height+=row.getIntrinsicHeight();
      }
 else       if (child instanceof ExpandableView) {
        ExpandableView expandableView=(ExpandableView)child;
        height+=expandableView.getActualHeight();
      }
    }
  }
  mContentHeight=height + mTopPadding;
}

Fixed version (ground truth):
private void updateContentHeight(){
  int height=0;
  for (int i=0; i < getChildCount(); i++) {
    View child=getChildAt(i);
    if (child.getVisibility() != View.GONE) {
      if (height != 0) {
        height+=mPaddingBetweenElements;
      }
      if (child instanceof ExpandableView) {
        ExpandableView expandableView=(ExpandableView)child;
        height+=expandableView.getIntrinsicHeight();
      }
    }
  }
  mContentHeight=height + mTopPadding;
}
Program: 195324
Project: 195324
Buggy source:
private void updateHeadsUpStates(StackScrollState resultState,AmbientState ambientState){
  TreeSet<HeadsUpManager.HeadsUpEntry> headsUpEntries=ambientState.getSortedHeadsUpEntries();
  for (  HeadsUpManager.HeadsUpEntry entry : headsUpEntries) {
    ExpandableNotificationRow row=entry.entry.row;
    StackViewState childState=resultState.getViewStateForView(row);
    ExpandableNotificationRow topHeadsUpEntry=ambientState.getTopHeadsUpEntry();
    boolean isTopEntry=topHeadsUpEntry == row;
    if (!row.isInShade()) {
      childState.yTranslation=0;
      childState.height=row.getHeadsUpHeight();
      if (!isTopEntry) {
        StackViewState topState=resultState.getViewStateForView(topHeadsUpEntry);
        childState.height=row.getHeadsUpHeight();
        childState.yTranslation=Math.min(childState.yTranslation,topState.yTranslation + topState.height - childState.height);
      }
    }
 else     if (mIsExpanded) {
      if (isTopEntry) {
        childState.height+=row.getHeadsUpHeight() - mCollapsedSize;
      }
      childState.height=Math.max(childState.height,row.getHeadsUpHeight());
      float bottomPosition=ambientState.getMaxHeadsUpTranslation() - childState.height;
      childState.yTranslation=Math.min(childState.yTranslation,bottomPosition);
    }
  }
}

Fixed version (ground truth):
private void updateHeadsUpStates(StackScrollState resultState,AmbientState ambientState){
  TreeSet<HeadsUpManager.HeadsUpEntry> headsUpEntries=ambientState.getSortedHeadsUpEntries();
  for (  HeadsUpManager.HeadsUpEntry entry : headsUpEntries) {
    ExpandableNotificationRow row=entry.entry.row;
    StackViewState childState=resultState.getViewStateForView(row);
    ExpandableNotificationRow topHeadsUpEntry=ambientState.getTopHeadsUpEntry();
    boolean isTopEntry=topHeadsUpEntry == row;
    if (!row.isInShade()) {
      childState.yTranslation=0;
      childState.height=row.getHeadsUpHeight();
      if (!isTopEntry) {
        StackViewState topState=resultState.getViewStateForView(topHeadsUpEntry);
        childState.height=row.getHeadsUpHeight();
        childState.yTranslation=topState.yTranslation + topState.height - childState.height;
      }
    }
 else     if (mIsExpanded) {
      if (isTopEntry) {
        childState.height+=row.getHeadsUpHeight() - mCollapsedSize;
      }
      childState.height=Math.max(childState.height,row.getHeadsUpHeight());
      float bottomPosition=ambientState.getMaxHeadsUpTranslation() - childState.height;
      childState.yTranslation=Math.min(childState.yTranslation,bottomPosition);
    }
  }
}
Program: 195325
Project: 195325
Buggy source:
public void setHeadsUp(boolean isHeadsUp){
  mIsHeadsUp=isHeadsUp;
  mPrivateLayout.setHeadsUp(isHeadsUp);
}

Fixed version (ground truth):
public void setHeadsUp(boolean isHeadsUp){
  int intrinsicBefore=getIntrinsicHeight();
  mIsHeadsUp=isHeadsUp;
  mPrivateLayout.setHeadsUp(isHeadsUp);
  if (intrinsicBefore != getIntrinsicHeight()) {
    notifyHeightChanged(false);
  }
}
Program: 195326
Project: 195326
Buggy source:
/** 
 * Returns a map of the names/values of the runtime statistics that   {@link #getRuntimeStat()} supports.
 * @return a map of the names/values of the supported runtime statistics.
 * @hide
 */
public static Map<String,String> getRuntimeStats(){
  return VMDebug.getRuntimeStats();
}

Fixed version (ground truth):
/** 
 * Returns a map of the names/values of the runtime statistics that   {@link #getRuntimeStat(String)} supports.
 * @return a map of the names/values of the supported runtime statistics.
 * @hide
 */
public static Map<String,String> getRuntimeStats(){
  return VMDebug.getRuntimeStats();
}
Program: 195327
Project: 195327
Buggy source:
/** 
 * Returns a map of the names/values of the runtime statistics that   {@link #getRuntimeStat()} supports.
 * @return a map of the names/values of the supported runtime statistics.
 * @hide
 */
public static Map<String,String> getRuntimeStats(){
  return VMDebug.getRuntimeStats();
}

Fixed version (ground truth):
/** 
 * Returns a map of the names/values of the runtime statistics that   {@link #getRuntimeStat(String)} supports.
 * @return a map of the names/values of the supported runtime statistics.
 * @hide
 */
public static Map<String,String> getRuntimeStats(){
  return VMDebug.getRuntimeStats();
}
Program: 195328
Project: 195328
Buggy source:
/** 
 * Returns a map of the names/values of the runtime statistics that   {@link #getRuntimeStat()} supports.
 * @return a map of the names/values of the supported runtime statistics.
 * @hide
 */
public static Map<String,String> getRuntimeStats(){
  return VMDebug.getRuntimeStats();
}

Fixed version (ground truth):
/** 
 * Returns a map of the names/values of the runtime statistics that   {@link #getRuntimeStat(String)} supports.
 * @return a map of the names/values of the supported runtime statistics.
 * @hide
 */
public static Map<String,String> getRuntimeStats(){
  return VMDebug.getRuntimeStats();
}
Program: 195329
Project: 195329
Buggy source:
/** 
 * Returns a map of the names/values of the runtime statistics that   {@link #getRuntimeStat()} supports.
 * @return a map of the names/values of the supported runtime statistics.
 * @hide
 */
public static Map<String,String> getRuntimeStats(){
  return VMDebug.getRuntimeStats();
}

Fixed version (ground truth):
/** 
 * Returns a map of the names/values of the runtime statistics that   {@link #getRuntimeStat(String)} supports.
 * @return a map of the names/values of the supported runtime statistics.
 * @hide
 */
public static Map<String,String> getRuntimeStats(){
  return VMDebug.getRuntimeStats();
}
Program: 195330
Project: 195330
Buggy source:
/** 
 * Returns a map of the names/values of the runtime statistics that   {@link #getRuntimeStat()} supports.
 * @return a map of the names/values of the supported runtime statistics.
 * @hide
 */
public static Map<String,String> getRuntimeStats(){
  return VMDebug.getRuntimeStats();
}

Fixed version (ground truth):
/** 
 * Returns a map of the names/values of the runtime statistics that   {@link #getRuntimeStat(String)} supports.
 * @return a map of the names/values of the supported runtime statistics.
 * @hide
 */
public static Map<String,String> getRuntimeStats(){
  return VMDebug.getRuntimeStats();
}
Program: 195332
Project: 195332
Buggy source:
public static boolean checkHasWifiPowerReporting(Context context,PowerProfile profile){
  WifiManager manager=context.getSystemService(WifiManager.class);
  if (manager.isEnhancedPowerReportingSupported()) {
    if (profile.getAveragePower(PowerProfile.POWER_WIFI_CONTROLLER_IDLE) != 0 && profile.getAveragePower(PowerProfile.POWER_WIFI_CONTROLLER_RX) != 0 && profile.getAveragePower(PowerProfile.POWER_WIFI_CONTROLLER_TX) != 0) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
public static boolean checkHasWifiPowerReporting(BatteryStats stats,PowerProfile profile){
  return stats.hasWifiActivityReporting() && profile.getAveragePower(PowerProfile.POWER_WIFI_CONTROLLER_IDLE) != 0 && profile.getAveragePower(PowerProfile.POWER_WIFI_CONTROLLER_RX) != 0 && profile.getAveragePower(PowerProfile.POWER_WIFI_CONTROLLER_TX) != 0;
}
Program: 195336
Project: 195336
Buggy source:
/** 
 * Distribute Bluetooth energy info and network traffic to apps.
 * @param info The energy information from the bluetooth controller.
 */
public void updateBluetoothStateLocked(@Nullable final BluetoothActivityEnergyInfo info){
  if (info != null && mOnBatteryInternal && false) {
    mBluetoothActivityCounters[CONTROLLER_RX_TIME].addCountLocked(info.getControllerRxTimeMillis());
    mBluetoothActivityCounters[CONTROLLER_TX_TIME].addCountLocked(info.getControllerTxTimeMillis());
    mBluetoothActivityCounters[CONTROLLER_IDLE_TIME].addCountLocked(info.getControllerIdleTimeMillis());
    mBluetoothActivityCounters[CONTROLLER_POWER_DRAIN].addCountLocked(info.getControllerEnergyUsed());
  }
}

Fixed version (ground truth):
/** 
 * Distribute Bluetooth energy info and network traffic to apps.
 * @param info The energy information from the bluetooth controller.
 */
public void updateBluetoothStateLocked(@Nullable final BluetoothActivityEnergyInfo info){
  if (info != null && mOnBatteryInternal && false) {
    mHasBluetoothEnergyReporting=true;
    mBluetoothActivityCounters[CONTROLLER_RX_TIME].addCountLocked(info.getControllerRxTimeMillis());
    mBluetoothActivityCounters[CONTROLLER_TX_TIME].addCountLocked(info.getControllerTxTimeMillis());
    mBluetoothActivityCounters[CONTROLLER_IDLE_TIME].addCountLocked(info.getControllerIdleTimeMillis());
    mBluetoothActivityCounters[CONTROLLER_POWER_DRAIN].addCountLocked(info.getControllerEnergyUsed());
  }
}
Program: 195337
Project: 195337
Buggy source:
@Override public void calculateRemaining(BatterySipper app,BatteryStats stats,long rawRealtimeUs,long rawUptimeUs,int statsType){
  final long idleTimeMs=stats.getWifiControllerActivity(BatteryStats.CONTROLLER_IDLE_TIME,statsType);
  final long rxTimeMs=stats.getWifiControllerActivity(BatteryStats.CONTROLLER_RX_TIME,statsType);
  final long txTimeMs=stats.getWifiControllerActivity(BatteryStats.CONTROLLER_TX_TIME,statsType);
  app.wifiRunningTimeMs=idleTimeMs + rxTimeMs + txTimeMs;
  double powerDrain=stats.getWifiControllerActivity(BatteryStats.CONTROLLER_POWER_DRAIN,statsType) / (1000 * 60 * 60);
  if (powerDrain == 0) {
    powerDrain=((idleTimeMs * mIdleCurrentMa) + (txTimeMs * mTxCurrentMa) + (rxTimeMs * mRxCurrentMa)) / (1000 * 60 * 60);
  }
  app.wifiPowerMah=Math.max(0,powerDrain - mTotalAppPowerDrain);
}

Fixed version (ground truth):
@Override public void calculateRemaining(BatterySipper app,BatteryStats stats,long rawRealtimeUs,long rawUptimeUs,int statsType){
  final long idleTimeMs=stats.getWifiControllerActivity(BatteryStats.CONTROLLER_IDLE_TIME,statsType);
  final long rxTimeMs=stats.getWifiControllerActivity(BatteryStats.CONTROLLER_RX_TIME,statsType);
  final long txTimeMs=stats.getWifiControllerActivity(BatteryStats.CONTROLLER_TX_TIME,statsType);
  app.wifiRunningTimeMs=idleTimeMs + rxTimeMs + txTimeMs;
  double powerDrain=stats.getWifiControllerActivity(BatteryStats.CONTROLLER_POWER_DRAIN,statsType) / (1000 * 60 * 60);
  if (powerDrain == 0) {
    powerDrain=((idleTimeMs * mIdleCurrentMa) + (txTimeMs * mTxCurrentMa) + (rxTimeMs * mRxCurrentMa)) / (1000 * 60 * 60);
  }
  app.wifiPowerMah=Math.max(0,powerDrain - mTotalAppPowerDrain);
  if (DEBUG) {
    Log.d(TAG,"String_Node_Str" + BatteryStatsHelper.makemAh(app.wifiPowerMah));
  }
}
Program: 195339
Project: 195339
Buggy source:
public static boolean checkHasWifiPowerReporting(Context context,PowerProfile profile){
  WifiManager manager=context.getSystemService(WifiManager.class);
  if (manager.isEnhancedPowerReportingSupported()) {
    if (profile.getAveragePower(PowerProfile.POWER_WIFI_CONTROLLER_IDLE) != 0 && profile.getAveragePower(PowerProfile.POWER_WIFI_CONTROLLER_RX) != 0 && profile.getAveragePower(PowerProfile.POWER_WIFI_CONTROLLER_TX) != 0) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
public static boolean checkHasWifiPowerReporting(BatteryStats stats,PowerProfile profile){
  return stats.hasWifiActivityReporting() && profile.getAveragePower(PowerProfile.POWER_WIFI_CONTROLLER_IDLE) != 0 && profile.getAveragePower(PowerProfile.POWER_WIFI_CONTROLLER_RX) != 0 && profile.getAveragePower(PowerProfile.POWER_WIFI_CONTROLLER_TX) != 0;
}
Program: 195343
Project: 195343
Buggy source:
/** 
 * Distribute Bluetooth energy info and network traffic to apps.
 * @param info The energy information from the bluetooth controller.
 */
public void updateBluetoothStateLocked(@Nullable final BluetoothActivityEnergyInfo info){
  if (info != null && mOnBatteryInternal && false) {
    mBluetoothActivityCounters[CONTROLLER_RX_TIME].addCountLocked(info.getControllerRxTimeMillis());
    mBluetoothActivityCounters[CONTROLLER_TX_TIME].addCountLocked(info.getControllerTxTimeMillis());
    mBluetoothActivityCounters[CONTROLLER_IDLE_TIME].addCountLocked(info.getControllerIdleTimeMillis());
    mBluetoothActivityCounters[CONTROLLER_POWER_DRAIN].addCountLocked(info.getControllerEnergyUsed());
  }
}

Fixed version (ground truth):
/** 
 * Distribute Bluetooth energy info and network traffic to apps.
 * @param info The energy information from the bluetooth controller.
 */
public void updateBluetoothStateLocked(@Nullable final BluetoothActivityEnergyInfo info){
  if (info != null && mOnBatteryInternal && false) {
    mHasBluetoothEnergyReporting=true;
    mBluetoothActivityCounters[CONTROLLER_RX_TIME].addCountLocked(info.getControllerRxTimeMillis());
    mBluetoothActivityCounters[CONTROLLER_TX_TIME].addCountLocked(info.getControllerTxTimeMillis());
    mBluetoothActivityCounters[CONTROLLER_IDLE_TIME].addCountLocked(info.getControllerIdleTimeMillis());
    mBluetoothActivityCounters[CONTROLLER_POWER_DRAIN].addCountLocked(info.getControllerEnergyUsed());
  }
}