Program: 199376
Project: 199376
Buggy source:
@Override protected void onLayout(boolean changed,int left,int top,int right,int bottom){
  mScrim.bringToFront();
  final int N=getChildCount();
  final boolean isLayoutRtl=isLayoutRtl();
  final int width=getWidth();
  int x=getPaddingStart();
  int y=getPaddingTop();
  int cursor=0;
  int maxRows=mKeyguardShowing ? mMaxRowsOnKeyguard : mMaxRows;
  for (int i=0; i < N; ++i) {
    if (getChildAt(i).equals(mScrim)) {
      int w=right - left - getPaddingLeft()- getPaddingRight();
      int h=bottom - top - getPaddingTop()- getPaddingBottom();
      mScrim.measure(MeasureSpec.makeMeasureSpec(w,MeasureSpec.EXACTLY),MeasureSpec.makeMeasureSpec(h,MeasureSpec.EXACTLY));
      mScrim.layout(getPaddingLeft(),getPaddingTop(),right,bottom);
      continue;
    }
    QuickSettingsTileView child=(QuickSettingsTileView)getChildAt(i);
    ViewGroup.LayoutParams lp=child.getLayoutParams();
    if (child.getVisibility() != GONE) {
      final int col=cursor % mNumColumns;
      final int colSpan=child.getColumnSpan();
      final int childWidth=lp.width;
      final int childHeight=lp.height;
      int row=(int)(cursor / mNumColumns);
      if (row >= maxRows)       continue;
      if ((col + colSpan) > mNumColumns) {
        x=getPaddingStart();
        y+=childHeight + mCellGap;
        row++;
      }
      final int childLeft=(isLayoutRtl) ? width - x - childWidth : x;
      final int childRight=childLeft + childWidth;
      final int childTop=y;
      final int childBottom=childTop + childHeight;
      child.layout(childLeft,childTop,childRight,childBottom);
      cursor+=child.getColumnSpan();
      if (cursor < (((row + 1) * mNumColumns))) {
        x+=childWidth + mCellGap;
      }
 else {
        x=getPaddingStart();
        y+=childHeight + mCellGap;
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void onLayout(boolean changed,int left,int top,int right,int bottom){
  if (mScrim != null) {
    mScrim.bringToFront();
  }
  final int N=getChildCount();
  final boolean isLayoutRtl=isLayoutRtl();
  final int width=getWidth();
  int x=getPaddingStart();
  int y=getPaddingTop();
  int cursor=0;
  int maxRows=mKeyguardShowing ? mMaxRowsOnKeyguard : mMaxRows;
  for (int i=0; i < N; ++i) {
    if (getChildAt(i).equals(mScrim)) {
      int w=right - left - getPaddingLeft()- getPaddingRight();
      int h=bottom - top - getPaddingTop()- getPaddingBottom();
      mScrim.measure(MeasureSpec.makeMeasureSpec(w,MeasureSpec.EXACTLY),MeasureSpec.makeMeasureSpec(h,MeasureSpec.EXACTLY));
      mScrim.layout(getPaddingLeft(),getPaddingTop(),right,bottom);
      continue;
    }
    QuickSettingsTileView child=(QuickSettingsTileView)getChildAt(i);
    ViewGroup.LayoutParams lp=child.getLayoutParams();
    if (child.getVisibility() != GONE) {
      final int col=cursor % mNumColumns;
      final int colSpan=child.getColumnSpan();
      final int childWidth=lp.width;
      final int childHeight=lp.height;
      int row=(int)(cursor / mNumColumns);
      if (row >= maxRows)       continue;
      if ((col + colSpan) > mNumColumns) {
        x=getPaddingStart();
        y+=childHeight + mCellGap;
        row++;
      }
      final int childLeft=(isLayoutRtl) ? width - x - childWidth : x;
      final int childRight=childLeft + childWidth;
      final int childTop=y;
      final int childBottom=childTop + childHeight;
      child.layout(childLeft,childTop,childRight,childBottom);
      cursor+=child.getColumnSpan();
      if (cursor < (((row + 1) * mNumColumns))) {
        x+=childWidth + mCellGap;
      }
 else {
        x=getPaddingStart();
        y+=childHeight + mCellGap;
      }
    }
  }
}