Program: 191888
Project: 191888
Buggy source:
boolean setTokenVisibilityLocked(AppWindowToken wtoken,WindowManager.LayoutParams lp,boolean visible,int transit,boolean performLayout,boolean isVoiceInteraction){
  boolean delayed=false;
  if (wtoken.clientHidden == visible) {
    wtoken.clientHidden=!visible;
    wtoken.sendAppVisibilityToClients();
  }
  boolean visibilityChanged=false;
  if (wtoken.hidden == visible || (wtoken.hidden && wtoken.mIsExiting) || (visible && wtoken.waitingForReplacement())) {
    boolean changed=false;
    if (DEBUG_APP_TRANSITIONS)     Slog.v(TAG_WM,"String_Node_Str" + wtoken + "String_Node_Str"+ wtoken.hidden+ "String_Node_Str"+ performLayout);
    boolean runningAppAnimation=false;
    if (transit != AppTransition.TRANSIT_UNSET) {
      if (wtoken.mAppAnimator.animation == AppWindowAnimator.sDummyAnimation) {
        wtoken.mAppAnimator.setNullAnimation();
      }
      if (applyAnimationLocked(wtoken,lp,transit,visible,isVoiceInteraction)) {
        delayed=runningAppAnimation=true;
      }
      WindowState window=wtoken.findMainWindow();
      if (window != null && mAccessibilityController != null && window.getDisplayId() == Display.DEFAULT_DISPLAY) {
        mAccessibilityController.onAppWindowTransitionLocked(window,transit);
      }
      changed=true;
    }
    final int windowsCount=wtoken.allAppWindows.size();
    for (int i=0; i < windowsCount; i++) {
      WindowState win=wtoken.allAppWindows.get(i);
      if (win == wtoken.startingWindow) {
        if (!visible && win.isVisibleNow() && wtoken.mAppAnimator.isAnimating()) {
          win.mAnimatingExit=true;
          win.mRemoveOnExit=true;
          win.mWindowRemovalAllowed=true;
        }
        continue;
      }
      if (visible) {
        if (!win.isVisibleNow()) {
          if (!runningAppAnimation) {
            win.mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_ENTER,true);
            if (mAccessibilityController != null && win.getDisplayId() == Display.DEFAULT_DISPLAY) {
              mAccessibilityController.onWindowTransitionLocked(win,WindowManagerPolicy.TRANSIT_ENTER);
            }
          }
          changed=true;
          win.setDisplayLayoutNeeded();
        }
      }
 else       if (win.isVisibleNow()) {
        if (!runningAppAnimation) {
          win.mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_EXIT,false);
          if (mAccessibilityController != null && win.getDisplayId() == Display.DEFAULT_DISPLAY) {
            mAccessibilityController.onWindowTransitionLocked(win,WindowManagerPolicy.TRANSIT_EXIT);
          }
        }
        changed=true;
        win.setDisplayLayoutNeeded();
      }
    }
    wtoken.hidden=wtoken.hiddenRequested=!visible;
    visibilityChanged=true;
    if (!visible) {
      unsetAppFreezingScreenLocked(wtoken,true,true);
    }
 else {
      WindowState swin=wtoken.startingWindow;
      if (swin != null && !swin.isDrawnLw()) {
        swin.mPolicyVisibility=false;
        swin.mPolicyVisibilityAfterAnim=false;
      }
    }
    if (DEBUG_APP_TRANSITIONS)     Slog.v(TAG_WM,"String_Node_Str" + wtoken + "String_Node_Str"+ wtoken.hidden+ "String_Node_Str"+ wtoken.hiddenRequested);
    if (changed) {
      mInputMonitor.setUpdateInputWindowsNeededLw();
      if (performLayout) {
        updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES,false);
        mWindowPlacerLocked.performSurfacePlacement();
      }
      mInputMonitor.updateInputWindowsLw(false);
    }
  }
  if (wtoken.mAppAnimator.animation != null) {
    delayed=true;
  }
  for (int i=wtoken.allAppWindows.size() - 1; i >= 0 && !delayed; i--) {
    if (wtoken.allAppWindows.get(i).mWinAnimator.isWindowAnimationSet()) {
      delayed=true;
    }
  }
  if (visibilityChanged && !delayed) {
    if (visible) {
      wtoken.mEnteringAnimation=true;
      mActivityManagerAppTransitionNotifier.onAppTransitionFinishedLocked(wtoken.token);
    }
    getDefaultDisplayContentLocked().getDockedDividerController().notifyAppVisibilityChanged(wtoken,visible);
  }
  return delayed;
}

Fixed version (ground truth):
boolean setTokenVisibilityLocked(AppWindowToken wtoken,WindowManager.LayoutParams lp,boolean visible,int transit,boolean performLayout,boolean isVoiceInteraction){
  boolean delayed=false;
  if (wtoken.clientHidden == visible) {
    wtoken.clientHidden=!visible;
    wtoken.sendAppVisibilityToClients();
  }
  boolean visibilityChanged=false;
  if (wtoken.hidden == visible || (wtoken.hidden && wtoken.mIsExiting) || (visible && wtoken.waitingForReplacement())) {
    boolean changed=false;
    if (DEBUG_APP_TRANSITIONS)     Slog.v(TAG_WM,"String_Node_Str" + wtoken + "String_Node_Str"+ wtoken.hidden+ "String_Node_Str"+ performLayout);
    boolean runningAppAnimation=false;
    if (transit != AppTransition.TRANSIT_UNSET) {
      if (wtoken.mAppAnimator.animation == AppWindowAnimator.sDummyAnimation) {
        wtoken.mAppAnimator.setNullAnimation();
      }
      if (applyAnimationLocked(wtoken,lp,transit,visible,isVoiceInteraction)) {
        delayed=runningAppAnimation=true;
      }
      WindowState window=wtoken.findMainWindow();
      if (window != null && mAccessibilityController != null && window.getDisplayId() == Display.DEFAULT_DISPLAY) {
        mAccessibilityController.onAppWindowTransitionLocked(window,transit);
      }
      changed=true;
    }
    final int windowsCount=wtoken.allAppWindows.size();
    for (int i=0; i < windowsCount; i++) {
      WindowState win=wtoken.allAppWindows.get(i);
      if (win == wtoken.startingWindow) {
        if (!visible && win.isVisibleNow() && wtoken.mAppAnimator.isAnimating()) {
          win.mAnimatingExit=true;
          win.mRemoveOnExit=true;
          win.mWindowRemovalAllowed=true;
        }
        continue;
      }
      if (visible) {
        if (!win.isVisibleNow()) {
          if (!runningAppAnimation) {
            win.mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_ENTER,true);
            if (mAccessibilityController != null && win.getDisplayId() == Display.DEFAULT_DISPLAY) {
              mAccessibilityController.onWindowTransitionLocked(win,WindowManagerPolicy.TRANSIT_ENTER);
            }
          }
          changed=true;
          win.setDisplayLayoutNeeded();
        }
      }
 else       if (win.isVisibleNow()) {
        if (!runningAppAnimation) {
          win.mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_EXIT,false);
          if (mAccessibilityController != null && win.getDisplayId() == Display.DEFAULT_DISPLAY) {
            mAccessibilityController.onWindowTransitionLocked(win,WindowManagerPolicy.TRANSIT_EXIT);
          }
        }
        changed=true;
        win.setDisplayLayoutNeeded();
      }
    }
    wtoken.hidden=wtoken.hiddenRequested=!visible;
    visibilityChanged=true;
    if (!visible) {
      unsetAppFreezingScreenLocked(wtoken,true,true);
    }
 else {
      WindowState swin=wtoken.startingWindow;
      if (swin != null && !swin.isDrawnLw()) {
        swin.mPolicyVisibility=false;
        swin.mPolicyVisibilityAfterAnim=false;
      }
    }
    if (DEBUG_APP_TRANSITIONS)     Slog.v(TAG_WM,"String_Node_Str" + wtoken + "String_Node_Str"+ wtoken.hidden+ "String_Node_Str"+ wtoken.hiddenRequested);
    if (changed) {
      mInputMonitor.setUpdateInputWindowsNeededLw();
      if (performLayout) {
        updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES,false);
        mWindowPlacerLocked.performSurfacePlacement();
      }
      mInputMonitor.updateInputWindowsLw(false);
    }
  }
  if (wtoken.mAppAnimator.animation != null) {
    delayed=true;
  }
  for (int i=wtoken.allAppWindows.size() - 1; i >= 0 && !delayed; i--) {
    if (wtoken.allAppWindows.get(i).mWinAnimator.isWindowAnimationSet()) {
      delayed=true;
    }
  }
  if (visibilityChanged) {
    if (visible && !delayed) {
      wtoken.mEnteringAnimation=true;
      mActivityManagerAppTransitionNotifier.onAppTransitionFinishedLocked(wtoken.token);
    }
    if (!mClosingApps.contains(wtoken) && !mOpeningApps.contains(wtoken)) {
      getDefaultDisplayContentLocked().getDockedDividerController().notifyAppVisibilityChanged(wtoken,visible);
    }
  }
  return delayed;
}