Program: 3001
Project: 3001
Buggy source:
/** 
 * Called by a ViewGroup subclass to remove child views from itself, when it must first know its size on screen before it can calculate how many child views it will render. An example is a Gallery or a ListView, which may "have" 50 children, but actually only render the number of children that can currently fit inside the object on screen. Do not call this method unless you are extending ViewGroup and understand the view measuring and layout pipeline. <p><strong>Note:</strong> do not invoke this method from  {@link #draw(android.graphics.Canvas)},   {@link #onDraw(android.graphics.Canvas)},  {@link #dispatchDraw(android.graphics.Canvas)} or any related method.</p>
 */
public void removeAllViewsInLayout(){
  final int count=mChildrenCount;
  if (count <= 0) {
    return;
  }
  final View[] children=mChildren;
  mChildrenCount=0;
  final View focused=mFocused;
  final boolean detach=mAttachInfo != null;
  View clearChildFocus=null;
  needGlobalAttributesUpdate(false);
  for (int i=count - 1; i >= 0; i--) {
    final View view=children[i];
    if (mTransition != null) {
      mTransition.removeChild(this,view);
    }
    if (view == focused) {
      view.unFocus();
      clearChildFocus=view;
    }
    view.clearAccessibilityFocus();
    cancelTouchTarget(view);
    cancelHoverTarget(view);
    if (view.getAnimation() != null || (mTransitioningViews != null && mTransitioningViews.contains(view))) {
      addDisappearingView(view);
    }
 else     if (detach) {
      view.dispatchDetachedFromWindow();
    }
    if (view.hasTransientState()) {
      childHasTransientStateChanged(view,false);
    }
    onViewRemoved(view);
    view.mParent=null;
    children[i]=null;
  }
  if (clearChildFocus != null) {
    clearChildFocus(clearChildFocus);
    ensureInputFocusOnFirstFocusable();
  }
}

Fixed version (ground truth):
/** 
 * Called by a ViewGroup subclass to remove child views from itself, when it must first know its size on screen before it can calculate how many child views it will render. An example is a Gallery or a ListView, which may "have" 50 children, but actually only render the number of children that can currently fit inside the object on screen. Do not call this method unless you are extending ViewGroup and understand the view measuring and layout pipeline. <p><strong>Note:</strong> do not invoke this method from  {@link #draw(android.graphics.Canvas)},   {@link #onDraw(android.graphics.Canvas)},  {@link #dispatchDraw(android.graphics.Canvas)} or any related method.</p>
 */
public void removeAllViewsInLayout(){
  final int count=mChildrenCount;
  if (count <= 0) {
    return;
  }
  final View[] children=mChildren;
  mChildrenCount=0;
  final View focused=mFocused;
  final boolean detach=mAttachInfo != null;
  boolean clearChildFocus=false;
  needGlobalAttributesUpdate(false);
  for (int i=count - 1; i >= 0; i--) {
    final View view=children[i];
    if (mTransition != null) {
      mTransition.removeChild(this,view);
    }
    if (view == focused) {
      view.unFocus();
      clearChildFocus=true;
    }
    if (view.isAccessibilityFocused()) {
      view.clearAccessibilityFocus();
    }
    cancelTouchTarget(view);
    cancelHoverTarget(view);
    if (view.getAnimation() != null || (mTransitioningViews != null && mTransitioningViews.contains(view))) {
      addDisappearingView(view);
    }
 else     if (detach) {
      view.dispatchDetachedFromWindow();
    }
    if (view.hasTransientState()) {
      childHasTransientStateChanged(view,false);
    }
    onViewRemoved(view);
    view.mParent=null;
    children[i]=null;
  }
  if (clearChildFocus) {
    clearChildFocus(focused);
    if (!rootViewRequestFocus()) {
      notifyGlobalFocusCleared(focused);
    }
  }
}