Program: 193245
Project: 193245
Buggy source:
/** 
 * @param windows List of windows on default display.
 * @return bitmap indicating if another pass through layout must be made.
 */
private int handleAppTransitionReadyLocked(WindowList windows){
  int appsCount=mService.mOpeningApps.size();
  if (!transitionGoodToGo(appsCount)) {
    return 0;
  }
  if (DEBUG_APP_TRANSITIONS)   Slog.v(TAG,"String_Node_Str");
  int transit=mService.mAppTransition.getAppTransition();
  if (mService.mSkipAppTransitionAnimation) {
    transit=AppTransition.TRANSIT_UNSET;
  }
  mService.mSkipAppTransitionAnimation=false;
  mService.mNoAnimationNotifyOnTransitionFinished.clear();
  mService.mH.removeMessages(APP_TRANSITION_TIMEOUT);
  mService.rebuildAppWindowListLocked();
  mWallpaperMayChange=false;
  WindowManager.LayoutParams animLp=null;
  int bestAnimLayer=-1;
  boolean fullscreenAnim=false;
  boolean voiceInteraction=false;
  final WindowState lowerWallpaperTarget=mWallpaperControllerLocked.getLowerWallpaperTarget();
  final WindowState upperWallpaperTarget=mWallpaperControllerLocked.getUpperWallpaperTarget();
  boolean openingAppHasWallpaper=false;
  boolean closingAppHasWallpaper=false;
  final AppWindowToken lowerWallpaperAppToken;
  final AppWindowToken upperWallpaperAppToken;
  if (lowerWallpaperTarget == null) {
    lowerWallpaperAppToken=upperWallpaperAppToken=null;
  }
 else {
    lowerWallpaperAppToken=lowerWallpaperTarget.mAppToken;
    upperWallpaperAppToken=upperWallpaperTarget.mAppToken;
  }
  int i;
  final int closingAppsCount=mService.mClosingApps.size();
  appsCount=closingAppsCount + mService.mOpeningApps.size();
  for (i=0; i < appsCount; i++) {
    final AppWindowToken wtoken;
    if (i < closingAppsCount) {
      wtoken=mService.mClosingApps.valueAt(i);
      if (wtoken == lowerWallpaperAppToken || wtoken == upperWallpaperAppToken) {
        closingAppHasWallpaper=true;
      }
    }
 else {
      wtoken=mService.mOpeningApps.valueAt(i - closingAppsCount);
      if (wtoken == lowerWallpaperAppToken || wtoken == upperWallpaperAppToken) {
        openingAppHasWallpaper=true;
      }
    }
    voiceInteraction|=wtoken.voiceInteraction;
    if (wtoken.appFullscreen) {
      WindowState ws=wtoken.findMainWindow();
      if (ws != null) {
        animLp=ws.mAttrs;
        bestAnimLayer=ws.mLayer;
        fullscreenAnim=true;
      }
    }
 else     if (!fullscreenAnim) {
      WindowState ws=wtoken.findMainWindow();
      if (ws != null) {
        if (ws.mLayer > bestAnimLayer) {
          animLp=ws.mAttrs;
          bestAnimLayer=ws.mLayer;
        }
      }
    }
  }
  transit=maybeUpdateTransitToWallpaper(transit,openingAppHasWallpaper,closingAppHasWallpaper,lowerWallpaperTarget,upperWallpaperTarget);
  if (!mService.mPolicy.allowAppAnimationsLw()) {
    if (DEBUG_APP_TRANSITIONS)     Slog.v(TAG,"String_Node_Str");
    animLp=null;
  }
  processApplicationsAnimatingInPlace(transit);
  AppWindowToken topClosingApp=null;
  int topClosingLayer=0;
  appsCount=mService.mClosingApps.size();
  for (i=0; i < appsCount; i++) {
    AppWindowToken wtoken=mService.mClosingApps.valueAt(i);
    final AppWindowAnimator appAnimator=wtoken.mAppAnimator;
    if (DEBUG_APP_TRANSITIONS)     Slog.v(TAG,"String_Node_Str" + wtoken);
    appAnimator.clearThumbnail();
    appAnimator.animation=null;
    wtoken.inPendingTransaction=false;
    mService.setTokenVisibilityLocked(wtoken,animLp,false,transit,false,voiceInteraction);
    wtoken.updateReportedVisibilityLocked();
    wtoken.allDrawn=true;
    wtoken.deferClearAllDrawn=false;
    if (wtoken.startingWindow != null && !wtoken.startingWindow.mExiting) {
      mService.scheduleRemoveStartingWindowLocked(wtoken);
    }
    mService.mAnimator.mAppWindowAnimating|=appAnimator.isAnimating();
    if (animLp != null) {
      int layer=-1;
      for (int j=0; j < wtoken.windows.size(); j++) {
        WindowState win=wtoken.windows.get(j);
        if (win.mWinAnimator.mAnimLayer > layer) {
          layer=win.mWinAnimator.mAnimLayer;
        }
      }
      if (topClosingApp == null || layer > topClosingLayer) {
        topClosingApp=wtoken;
        topClosingLayer=layer;
      }
    }
  }
  AppWindowToken topOpeningApp=null;
  appsCount=mService.mOpeningApps.size();
  for (i=0; i < appsCount; i++) {
    AppWindowToken wtoken=mService.mOpeningApps.valueAt(i);
    final AppWindowAnimator appAnimator=wtoken.mAppAnimator;
    if (DEBUG_APP_TRANSITIONS)     Slog.v(TAG,"String_Node_Str" + wtoken);
    if (!appAnimator.usingTransferredAnimation) {
      appAnimator.clearThumbnail();
      appAnimator.animation=null;
    }
    wtoken.inPendingTransaction=false;
    if (!mService.setTokenVisibilityLocked(wtoken,animLp,true,transit,false,voiceInteraction)) {
      mService.mNoAnimationNotifyOnTransitionFinished.add(wtoken.token);
    }
    wtoken.updateReportedVisibilityLocked();
    wtoken.waitingToShow=false;
    appAnimator.mAllAppWinAnimators.clear();
    final int windowsCount=wtoken.allAppWindows.size();
    for (int j=0; j < windowsCount; j++) {
      appAnimator.mAllAppWinAnimators.add(wtoken.allAppWindows.get(j).mWinAnimator);
    }
    if (SHOW_LIGHT_TRANSACTIONS)     Slog.i(TAG,"String_Node_Str");
    SurfaceControl.openTransaction();
    try {
      mService.mAnimator.mAnimating|=appAnimator.showAllWindowsLocked();
    }
  finally {
      SurfaceControl.closeTransaction();
      if (SHOW_LIGHT_TRANSACTIONS)       Slog.i(TAG,"String_Node_Str");
    }
    mService.mAnimator.mAppWindowAnimating|=appAnimator.isAnimating();
    int topOpeningLayer=0;
    if (animLp != null) {
      int layer=-1;
      for (int j=0; j < wtoken.windows.size(); j++) {
        final WindowState win=wtoken.windows.get(j);
        if (win.mAppToken == null || !win.mAppToken.mWillReplaceWindow) {
          win.mExiting=false;
        }
        if (win.mWinAnimator.mAnimLayer > layer) {
          layer=win.mWinAnimator.mAnimLayer;
        }
      }
      if (topOpeningApp == null || layer > topOpeningLayer) {
        topOpeningApp=wtoken;
        topOpeningLayer=layer;
      }
    }
    createThumbnailAppAnimator(transit,wtoken,topOpeningLayer,topClosingLayer);
    wtoken.restoreSavedSurfaces();
  }
  AppWindowAnimator openingAppAnimator=(topOpeningApp == null) ? null : topOpeningApp.mAppAnimator;
  AppWindowAnimator closingAppAnimator=(topClosingApp == null) ? null : topClosingApp.mAppAnimator;
  mService.mAppTransition.goodToGo(openingAppAnimator,closingAppAnimator);
  mService.mAppTransition.postAnimationCallback();
  mService.mAppTransition.clear();
  mService.mOpeningApps.clear();
  mService.mClosingApps.clear();
  mService.getDefaultDisplayContentLocked().layoutNeeded=true;
  if (windows == mService.getDefaultWindowListLocked() && !mService.moveInputMethodWindowsIfNeededLocked(true)) {
    mService.assignLayersLocked(windows);
  }
  mService.updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES,true);
  mService.mFocusMayChange=false;
  mService.notifyActivityDrawnForKeyguard();
  return FINISH_LAYOUT_REDO_LAYOUT | FINISH_LAYOUT_REDO_CONFIG;
}

Fixed version (ground truth):
/** 
 * @param windows List of windows on default display.
 * @return bitmap indicating if another pass through layout must be made.
 */
private int handleAppTransitionReadyLocked(WindowList windows){
  int appsCount=mService.mOpeningApps.size();
  if (!transitionGoodToGo(appsCount)) {
    return 0;
  }
  if (DEBUG_APP_TRANSITIONS)   Slog.v(TAG,"String_Node_Str");
  int transit=mService.mAppTransition.getAppTransition();
  if (mService.mSkipAppTransitionAnimation) {
    transit=AppTransition.TRANSIT_UNSET;
  }
  mService.mSkipAppTransitionAnimation=false;
  mService.mNoAnimationNotifyOnTransitionFinished.clear();
  mService.mH.removeMessages(APP_TRANSITION_TIMEOUT);
  mService.rebuildAppWindowListLocked();
  mWallpaperMayChange=false;
  WindowManager.LayoutParams animLp=null;
  int bestAnimLayer=-1;
  boolean fullscreenAnim=false;
  boolean voiceInteraction=false;
  final WindowState lowerWallpaperTarget=mWallpaperControllerLocked.getLowerWallpaperTarget();
  final WindowState upperWallpaperTarget=mWallpaperControllerLocked.getUpperWallpaperTarget();
  boolean openingAppHasWallpaper=false;
  boolean closingAppHasWallpaper=false;
  final AppWindowToken lowerWallpaperAppToken;
  final AppWindowToken upperWallpaperAppToken;
  if (lowerWallpaperTarget == null) {
    lowerWallpaperAppToken=upperWallpaperAppToken=null;
  }
 else {
    lowerWallpaperAppToken=lowerWallpaperTarget.mAppToken;
    upperWallpaperAppToken=upperWallpaperTarget.mAppToken;
  }
  int i;
  final int closingAppsCount=mService.mClosingApps.size();
  appsCount=closingAppsCount + mService.mOpeningApps.size();
  for (i=0; i < appsCount; i++) {
    final AppWindowToken wtoken;
    if (i < closingAppsCount) {
      wtoken=mService.mClosingApps.valueAt(i);
      if (wtoken == lowerWallpaperAppToken || wtoken == upperWallpaperAppToken) {
        closingAppHasWallpaper=true;
      }
    }
 else {
      wtoken=mService.mOpeningApps.valueAt(i - closingAppsCount);
      if (wtoken == lowerWallpaperAppToken || wtoken == upperWallpaperAppToken) {
        openingAppHasWallpaper=true;
      }
    }
    voiceInteraction|=wtoken.voiceInteraction;
    if (wtoken.appFullscreen) {
      WindowState ws=wtoken.findMainWindow();
      if (ws != null) {
        animLp=ws.mAttrs;
        bestAnimLayer=ws.mLayer;
        fullscreenAnim=true;
      }
    }
 else     if (!fullscreenAnim) {
      WindowState ws=wtoken.findMainWindow();
      if (ws != null) {
        if (ws.mLayer > bestAnimLayer) {
          animLp=ws.mAttrs;
          bestAnimLayer=ws.mLayer;
        }
      }
    }
  }
  transit=maybeUpdateTransitToWallpaper(transit,openingAppHasWallpaper,closingAppHasWallpaper,lowerWallpaperTarget,upperWallpaperTarget);
  if (!mService.mPolicy.allowAppAnimationsLw()) {
    if (DEBUG_APP_TRANSITIONS)     Slog.v(TAG,"String_Node_Str");
    animLp=null;
  }
  processApplicationsAnimatingInPlace(transit);
  AppWindowToken topClosingApp=null;
  int topClosingLayer=0;
  appsCount=mService.mClosingApps.size();
  for (i=0; i < appsCount; i++) {
    AppWindowToken wtoken=mService.mClosingApps.valueAt(i);
    final AppWindowAnimator appAnimator=wtoken.mAppAnimator;
    if (DEBUG_APP_TRANSITIONS)     Slog.v(TAG,"String_Node_Str" + wtoken);
    appAnimator.clearThumbnail();
    appAnimator.animation=null;
    wtoken.inPendingTransaction=false;
    mService.setTokenVisibilityLocked(wtoken,animLp,false,transit,false,voiceInteraction);
    wtoken.updateReportedVisibilityLocked();
    wtoken.allDrawn=true;
    wtoken.deferClearAllDrawn=false;
    if (wtoken.startingWindow != null && !wtoken.startingWindow.mExiting) {
      mService.scheduleRemoveStartingWindowLocked(wtoken);
    }
    mService.mAnimator.mAppWindowAnimating|=appAnimator.isAnimating();
    if (animLp != null) {
      int layer=-1;
      for (int j=0; j < wtoken.windows.size(); j++) {
        WindowState win=wtoken.windows.get(j);
        if (win.mWinAnimator.mAnimLayer > layer) {
          layer=win.mWinAnimator.mAnimLayer;
        }
      }
      if (topClosingApp == null || layer > topClosingLayer) {
        topClosingApp=wtoken;
        topClosingLayer=layer;
      }
    }
  }
  AppWindowToken topOpeningApp=null;
  appsCount=mService.mOpeningApps.size();
  for (i=0; i < appsCount; i++) {
    AppWindowToken wtoken=mService.mOpeningApps.valueAt(i);
    final AppWindowAnimator appAnimator=wtoken.mAppAnimator;
    if (DEBUG_APP_TRANSITIONS)     Slog.v(TAG,"String_Node_Str" + wtoken);
    if (!appAnimator.usingTransferredAnimation) {
      appAnimator.clearThumbnail();
      appAnimator.animation=null;
    }
    wtoken.inPendingTransaction=false;
    if (!mService.setTokenVisibilityLocked(wtoken,animLp,true,transit,false,voiceInteraction)) {
      mService.mNoAnimationNotifyOnTransitionFinished.add(wtoken.token);
    }
    wtoken.updateReportedVisibilityLocked();
    wtoken.waitingToShow=false;
    appAnimator.mAllAppWinAnimators.clear();
    final int windowsCount=wtoken.allAppWindows.size();
    for (int j=0; j < windowsCount; j++) {
      appAnimator.mAllAppWinAnimators.add(wtoken.allAppWindows.get(j).mWinAnimator);
    }
    if (SHOW_LIGHT_TRANSACTIONS)     Slog.i(TAG,"String_Node_Str");
    SurfaceControl.openTransaction();
    try {
      mService.mAnimator.orAnimating(appAnimator.showAllWindowsLocked());
    }
  finally {
      SurfaceControl.closeTransaction();
      if (SHOW_LIGHT_TRANSACTIONS)       Slog.i(TAG,"String_Node_Str");
    }
    mService.mAnimator.mAppWindowAnimating|=appAnimator.isAnimating();
    int topOpeningLayer=0;
    if (animLp != null) {
      int layer=-1;
      for (int j=0; j < wtoken.windows.size(); j++) {
        final WindowState win=wtoken.windows.get(j);
        if (win.mAppToken == null || !win.mAppToken.mWillReplaceWindow) {
          win.mExiting=false;
        }
        if (win.mWinAnimator.mAnimLayer > layer) {
          layer=win.mWinAnimator.mAnimLayer;
        }
      }
      if (topOpeningApp == null || layer > topOpeningLayer) {
        topOpeningApp=wtoken;
        topOpeningLayer=layer;
      }
    }
    createThumbnailAppAnimator(transit,wtoken,topOpeningLayer,topClosingLayer);
    wtoken.restoreSavedSurfaces();
  }
  AppWindowAnimator openingAppAnimator=(topOpeningApp == null) ? null : topOpeningApp.mAppAnimator;
  AppWindowAnimator closingAppAnimator=(topClosingApp == null) ? null : topClosingApp.mAppAnimator;
  mService.mAppTransition.goodToGo(openingAppAnimator,closingAppAnimator);
  mService.mAppTransition.postAnimationCallback();
  mService.mAppTransition.clear();
  mService.mOpeningApps.clear();
  mService.mClosingApps.clear();
  mService.getDefaultDisplayContentLocked().layoutNeeded=true;
  if (windows == mService.getDefaultWindowListLocked() && !mService.moveInputMethodWindowsIfNeededLocked(true)) {
    mService.assignLayersLocked(windows);
  }
  mService.updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES,true);
  mService.mFocusMayChange=false;
  mService.notifyActivityDrawnForKeyguard();
  return FINISH_LAYOUT_REDO_LAYOUT | FINISH_LAYOUT_REDO_CONFIG;
}