Program: 23815
Project: 23815
Buggy source:
private void removeWindowInnerLocked(Session session,WindowState win){
  mKeyWaiter.finishedKey(session,win.mClient,true,KeyWaiter.RETURN_NOTHING);
  mKeyWaiter.releasePendingPointerLocked(win.mSession);
  mKeyWaiter.releasePendingTrackballLocked(win.mSession);
  win.mRemoved=true;
  if (mInputMethodTarget == win) {
    moveInputMethodWindowsIfNeededLocked(false);
  }
  mPolicy.removeWindowLw(win);
  win.removeLocked();
  mWindowMap.remove(win.mClient.asBinder());
  mWindows.remove(win);
  if (mInputMethodWindow == win) {
    mInputMethodWindow=null;
  }
 else   if (win.mAttrs.type == TYPE_INPUT_METHOD_DIALOG) {
    mInputMethodDialogs.remove(win);
  }
  final WindowToken token=win.mToken;
  final AppWindowToken atoken=win.mAppToken;
  token.windows.remove(win);
  if (atoken != null) {
    atoken.allAppWindows.remove(win);
  }
  if (localLOGV)   Log.v(TAG,"String_Node_Str" + win + "String_Node_Str"+ token.windows.size());
  if (token.windows.size() == 0) {
    if (!token.explicit) {
      mTokenMap.remove(token.token);
      mTokenList.remove(token);
    }
 else     if (atoken != null) {
      atoken.firstWindowDrawn=false;
    }
  }
  if (atoken != null) {
    if (atoken.startingWindow == win) {
      atoken.startingWindow=null;
    }
 else     if (atoken.allAppWindows.size() == 0 && atoken.startingData != null) {
      atoken.startingData=null;
    }
 else     if (atoken.allAppWindows.size() == 1 && atoken.startingView != null) {
      if (DEBUG_STARTING_WINDOW) {
        Log.v(TAG,"String_Node_Str" + token + "String_Node_Str");
      }
      Message m=mH.obtainMessage(H.REMOVE_STARTING,atoken);
      mH.sendMessage(m);
    }
  }
  if (win.mAttrs.type == TYPE_WALLPAPER || (win.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
    adjustWallpaperWindowsLocked();
  }
  if (!mInLayout) {
    assignLayersLocked();
    mLayoutNeeded=true;
    performLayoutAndPlaceSurfacesLocked();
    if (win.mAppToken != null) {
      win.mAppToken.updateReportedVisibilityLocked();
    }
  }
}

Fixed version (ground truth):
private void removeWindowInnerLocked(Session session,WindowState win){
  mKeyWaiter.finishedKey(session,win.mClient,true,KeyWaiter.RETURN_NOTHING);
  mKeyWaiter.releasePendingPointerLocked(win.mSession);
  mKeyWaiter.releasePendingTrackballLocked(win.mSession);
  win.mRemoved=true;
  if (mInputMethodTarget == win) {
    moveInputMethodWindowsIfNeededLocked(false);
  }
  if (false) {
    RuntimeException e=new RuntimeException("String_Node_Str");
    e.fillInStackTrace();
    Log.w(TAG,"String_Node_Str" + win,e);
  }
  mPolicy.removeWindowLw(win);
  win.removeLocked();
  mWindowMap.remove(win.mClient.asBinder());
  mWindows.remove(win);
  if (mInputMethodWindow == win) {
    mInputMethodWindow=null;
  }
 else   if (win.mAttrs.type == TYPE_INPUT_METHOD_DIALOG) {
    mInputMethodDialogs.remove(win);
  }
  final WindowToken token=win.mToken;
  final AppWindowToken atoken=win.mAppToken;
  token.windows.remove(win);
  if (atoken != null) {
    atoken.allAppWindows.remove(win);
  }
  if (localLOGV)   Log.v(TAG,"String_Node_Str" + win + "String_Node_Str"+ token.windows.size());
  if (token.windows.size() == 0) {
    if (!token.explicit) {
      mTokenMap.remove(token.token);
      mTokenList.remove(token);
    }
 else     if (atoken != null) {
      atoken.firstWindowDrawn=false;
    }
  }
  if (atoken != null) {
    if (atoken.startingWindow == win) {
      atoken.startingWindow=null;
    }
 else     if (atoken.allAppWindows.size() == 0 && atoken.startingData != null) {
      atoken.startingData=null;
    }
 else     if (atoken.allAppWindows.size() == 1 && atoken.startingView != null) {
      if (DEBUG_STARTING_WINDOW) {
        Log.v(TAG,"String_Node_Str" + token + "String_Node_Str");
      }
      Message m=mH.obtainMessage(H.REMOVE_STARTING,atoken);
      mH.sendMessage(m);
    }
  }
  if (win.mAttrs.type == TYPE_WALLPAPER || (win.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
    adjustWallpaperWindowsLocked();
  }
  if (!mInLayout) {
    assignLayersLocked();
    mLayoutNeeded=true;
    performLayoutAndPlaceSurfacesLocked();
    if (win.mAppToken != null) {
      win.mAppToken.updateReportedVisibilityLocked();
    }
  }
}