Program: 191435
Project: 191435
Buggy source:
private void setBackground(TypedArray a,View topPanel,View contentPanel,View customPanel,View buttonPanel,boolean hasTitle,boolean hasCustomView,boolean hasButtons){
  int fullDark=0;
  int topDark=0;
  int centerDark=0;
  int bottomDark=0;
  int fullBright=0;
  int topBright=0;
  int centerBright=0;
  int bottomBright=0;
  int bottomMedium=0;
  final boolean needsDefaultBackgrounds=a.getBoolean(R.styleable.AlertDialog_needsDefaultBackgrounds,true);
  if (needsDefaultBackgrounds) {
    fullDark=R.drawable.popup_full_dark;
    topDark=R.drawable.popup_top_dark;
    centerDark=R.drawable.popup_center_dark;
    bottomDark=R.drawable.popup_bottom_dark;
    fullBright=R.drawable.popup_full_bright;
    topBright=R.drawable.popup_top_bright;
    centerBright=R.drawable.popup_center_bright;
    bottomBright=R.drawable.popup_bottom_bright;
    bottomMedium=R.drawable.popup_bottom_medium;
  }
  topBright=a.getResourceId(R.styleable.AlertDialog_topBright,topBright);
  topDark=a.getResourceId(R.styleable.AlertDialog_topDark,topDark);
  centerBright=a.getResourceId(R.styleable.AlertDialog_centerBright,centerBright);
  centerDark=a.getResourceId(R.styleable.AlertDialog_centerDark,centerDark);
  final View[] views=new View[4];
  final boolean[] light=new boolean[4];
  View lastView=null;
  boolean lastLight=false;
  int pos=0;
  if (hasTitle) {
    views[pos]=topPanel;
    light[pos]=false;
    pos++;
  }
  views[pos]=contentPanel.getVisibility() == View.GONE ? null : contentPanel;
  light[pos]=mListView != null;
  pos++;
  if (hasCustomView) {
    views[pos]=customPanel;
    light[pos]=mForceInverseBackground;
    pos++;
  }
  if (hasButtons) {
    views[pos]=buttonPanel;
    light[pos]=true;
  }
  boolean setView=false;
  for (pos=0; pos < views.length; pos++) {
    final View v=views[pos];
    if (v == null) {
      continue;
    }
    if (lastView != null) {
      if (!setView) {
        lastView.setBackgroundResource(lastLight ? topBright : topDark);
      }
 else {
        lastView.setBackgroundResource(lastLight ? centerBright : centerDark);
      }
      setView=true;
    }
    lastView=v;
    lastLight=light[pos];
  }
  if (lastView != null) {
    if (setView) {
      bottomBright=a.getResourceId(R.styleable.AlertDialog_bottomBright,bottomBright);
      bottomMedium=a.getResourceId(R.styleable.AlertDialog_bottomMedium,bottomMedium);
      bottomDark=a.getResourceId(R.styleable.AlertDialog_bottomDark,bottomDark);
      lastView.setBackgroundResource(lastLight ? (hasButtons ? bottomMedium : bottomBright) : bottomDark);
    }
 else {
      fullBright=a.getResourceId(R.styleable.AlertDialog_fullBright,fullBright);
      fullDark=a.getResourceId(R.styleable.AlertDialog_fullDark,fullDark);
      lastView.setBackgroundResource(lastLight ? fullBright : fullDark);
    }
  }
  final ListView listView=mListView;
  if (listView != null && mAdapter != null) {
    listView.setAdapter(mAdapter);
    final int checkedItem=mCheckedItem;
    if (checkedItem > -1) {
      listView.setItemChecked(checkedItem,true);
      listView.setSelection(checkedItem);
    }
  }
}

Fixed version (ground truth):
private void setBackground(TypedArray a,View topPanel,View contentPanel,View customPanel,View buttonPanel,boolean hasTitle,boolean hasCustomView,boolean hasButtons){
  int fullDark=0;
  int topDark=0;
  int centerDark=0;
  int bottomDark=0;
  int fullBright=0;
  int topBright=0;
  int centerBright=0;
  int bottomBright=0;
  int bottomMedium=0;
  final boolean needsDefaultBackgrounds=a.getBoolean(R.styleable.AlertDialog_needsDefaultBackgrounds,true);
  if (needsDefaultBackgrounds) {
    fullDark=R.drawable.popup_full_dark;
    topDark=R.drawable.popup_top_dark;
    centerDark=R.drawable.popup_center_dark;
    bottomDark=R.drawable.popup_bottom_dark;
    fullBright=R.drawable.popup_full_bright;
    topBright=R.drawable.popup_top_bright;
    centerBright=R.drawable.popup_center_bright;
    bottomBright=R.drawable.popup_bottom_bright;
    bottomMedium=R.drawable.popup_bottom_medium;
  }
  topBright=a.getResourceId(R.styleable.AlertDialog_topBright,topBright);
  topDark=a.getResourceId(R.styleable.AlertDialog_topDark,topDark);
  centerBright=a.getResourceId(R.styleable.AlertDialog_centerBright,centerBright);
  centerDark=a.getResourceId(R.styleable.AlertDialog_centerDark,centerDark);
  final View[] views=new View[4];
  final boolean[] light=new boolean[4];
  View lastView=null;
  boolean lastLight=false;
  int pos=0;
  if (hasTitle) {
    views[pos]=topPanel;
    light[pos]=false;
    pos++;
  }
  views[pos]=contentPanel.getVisibility() == View.GONE ? null : contentPanel;
  light[pos]=mListView != null;
  pos++;
  if (hasCustomView) {
    views[pos]=customPanel;
    light[pos]=mForceInverseBackground;
    pos++;
  }
  if (hasButtons) {
    views[pos]=buttonPanel;
    light[pos]=true;
  }
  boolean setView=false;
  for (pos=0; pos < views.length; pos++) {
    final View v=views[pos];
    if (v == null) {
      continue;
    }
    if (lastView != null) {
      if (!setView) {
        lastView.setBackgroundResource(lastLight ? topBright : topDark);
      }
 else {
        lastView.setBackgroundResource(lastLight ? centerBright : centerDark);
      }
      setView=true;
    }
    lastView=v;
    lastLight=light[pos];
  }
  if (lastView != null) {
    if (setView) {
      bottomBright=a.getResourceId(R.styleable.AlertDialog_bottomBright,bottomBright);
      bottomMedium=a.getResourceId(R.styleable.AlertDialog_bottomMedium,bottomMedium);
      bottomDark=a.getResourceId(R.styleable.AlertDialog_bottomDark,bottomDark);
      lastView.setBackgroundResource(lastLight ? (hasButtons ? bottomMedium : bottomBright) : bottomDark);
    }
 else {
      fullBright=a.getResourceId(R.styleable.AlertDialog_fullBright,fullBright);
      fullDark=a.getResourceId(R.styleable.AlertDialog_fullDark,fullDark);
      lastView.setBackgroundResource(lastLight ? fullBright : fullDark);
    }
  }
  final ListView listView=mListView;
  if (listView != null && mAdapter != null) {
    listView.setAdapter(mAdapter);
    final int checkedItem=mCheckedItem;
    if (checkedItem > -1) {
      listView.setItemChecked(checkedItem + listView.getHeaderViewsCount(),true);
      listView.setSelection(checkedItem + listView.getHeaderViewsCount());
    }
  }
}