Program: 192449
Project: 192449
Buggy source:
@Override public void setAppVisibility(IBinder token,boolean visible){
  if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,"String_Node_Str")) {
    throw new SecurityException("String_Node_Str");
  }
  AppWindowToken wtoken;
synchronized (mWindowMap) {
    wtoken=findAppWindowToken(token);
    if (wtoken == null) {
      Slog.w(TAG_WM,"String_Node_Str" + token);
      return;
    }
    if (DEBUG_APP_TRANSITIONS || DEBUG_ORIENTATION)     Slog.v(TAG_WM,"String_Node_Str" + token + "String_Node_Str"+ visible+ "String_Node_Str"+ mAppTransition+ "String_Node_Str"+ wtoken.hidden+ "String_Node_Str"+ wtoken.hiddenRequested+ "String_Node_Str"+ Debug.getCallers(6));
    mOpeningApps.remove(wtoken);
    mClosingApps.remove(wtoken);
    wtoken.waitingToShow=false;
    wtoken.hiddenRequested=!visible;
    if (!visible && wtoken.appDied) {
      wtoken.appDied=false;
      wtoken.removeAllWindows();
    }
 else     if (visible) {
      if (DEBUG_ADD_REMOVE)       Slog.v(TAG_WM,"String_Node_Str" + wtoken);
      wtoken.mAppStopped=false;
      wtoken.setWindowsExiting(false);
      mOpeningApps.add(wtoken);
      wtoken.startingMoved=false;
      if (wtoken.hidden) {
        wtoken.allDrawn=false;
        wtoken.deferClearAllDrawn=false;
        wtoken.waitingToShow=true;
        if (wtoken.clientHidden) {
          wtoken.clientHidden=false;
          wtoken.sendAppVisibilityToClients();
        }
      }
    }
    if (okToDisplay() && mAppTransition.isTransitionSet()) {
      if (!wtoken.mAppAnimator.usingTransferredAnimation && (!wtoken.startingDisplayed || mSkipAppTransitionAnimation)) {
        if (DEBUG_APP_TRANSITIONS)         Slog.v(TAG_WM,"String_Node_Str" + wtoken);
        wtoken.mAppAnimator.setDummyAnimation();
      }
      wtoken.inPendingTransaction=true;
      if (visible) {
        wtoken.mEnteringAnimation=true;
      }
 else {
        wtoken.setWindowsExiting(true);
        mClosingApps.add(wtoken);
        wtoken.mEnteringAnimation=false;
      }
      if (mAppTransition.getAppTransition() == AppTransition.TRANSIT_TASK_OPEN_BEHIND) {
        final WindowState win=findFocusedWindowLocked(getDefaultDisplayContentLocked());
        if (win != null) {
          final AppWindowToken focusedToken=win.mAppToken;
          if (focusedToken != null) {
            if (DEBUG_APP_TRANSITIONS)             Slog.d(TAG_WM,"String_Node_Str" + "String_Node_Str" + focusedToken + "String_Node_Str");
            focusedToken.hidden=true;
            mOpeningApps.add(focusedToken);
          }
        }
      }
      return;
    }
    final long origId=Binder.clearCallingIdentity();
    wtoken.inPendingTransaction=false;
    setTokenVisibilityLocked(wtoken,null,visible,AppTransition.TRANSIT_UNSET,true,wtoken.voiceInteraction);
    wtoken.updateReportedVisibilityLocked();
    Binder.restoreCallingIdentity(origId);
  }
}

Fixed version (ground truth):
@Override public void setAppVisibility(IBinder token,boolean visible){
  if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,"String_Node_Str")) {
    throw new SecurityException("String_Node_Str");
  }
  AppWindowToken wtoken;
synchronized (mWindowMap) {
    wtoken=findAppWindowToken(token);
    if (wtoken == null) {
      Slog.w(TAG_WM,"String_Node_Str" + token);
      return;
    }
    if (DEBUG_APP_TRANSITIONS || DEBUG_ORIENTATION)     Slog.v(TAG_WM,"String_Node_Str" + token + "String_Node_Str"+ visible+ "String_Node_Str"+ mAppTransition+ "String_Node_Str"+ wtoken.hidden+ "String_Node_Str"+ wtoken.hiddenRequested+ "String_Node_Str"+ Debug.getCallers(6));
    mOpeningApps.remove(wtoken);
    mClosingApps.remove(wtoken);
    wtoken.waitingToShow=false;
    wtoken.hiddenRequested=!visible;
    if (!visible && wtoken.appDied) {
      wtoken.appDied=false;
      wtoken.removeAllWindows();
    }
 else     if (visible) {
      if (DEBUG_ADD_REMOVE)       Slog.v(TAG_WM,"String_Node_Str" + wtoken);
      wtoken.mAppStopped=false;
      mOpeningApps.add(wtoken);
      wtoken.startingMoved=false;
      if (wtoken.hidden) {
        wtoken.allDrawn=false;
        wtoken.deferClearAllDrawn=false;
        wtoken.waitingToShow=true;
        if (wtoken.clientHidden) {
          wtoken.clientHidden=false;
          wtoken.sendAppVisibilityToClients();
        }
      }
    }
    if (okToDisplay() && mAppTransition.isTransitionSet()) {
      if (wtoken.mAppAnimator.usingTransferredAnimation && wtoken.mAppAnimator.animation == null) {
        Slog.wtf(TAG_WM,"String_Node_Str" + wtoken + "String_Node_Str");
      }
      if (!wtoken.mAppAnimator.usingTransferredAnimation && (!wtoken.startingDisplayed || mSkipAppTransitionAnimation)) {
        if (DEBUG_APP_TRANSITIONS)         Slog.v(TAG_WM,"String_Node_Str" + wtoken);
        wtoken.mAppAnimator.setDummyAnimation();
      }
      wtoken.inPendingTransaction=true;
      if (visible) {
        wtoken.mEnteringAnimation=true;
      }
 else {
        mClosingApps.add(wtoken);
        wtoken.mEnteringAnimation=false;
      }
      if (mAppTransition.getAppTransition() == AppTransition.TRANSIT_TASK_OPEN_BEHIND) {
        final WindowState win=findFocusedWindowLocked(getDefaultDisplayContentLocked());
        if (win != null) {
          final AppWindowToken focusedToken=win.mAppToken;
          if (focusedToken != null) {
            if (DEBUG_APP_TRANSITIONS)             Slog.d(TAG_WM,"String_Node_Str" + "String_Node_Str" + focusedToken + "String_Node_Str");
            focusedToken.hidden=true;
            mOpeningApps.add(focusedToken);
          }
        }
      }
      return;
    }
    final long origId=Binder.clearCallingIdentity();
    wtoken.inPendingTransaction=false;
    setTokenVisibilityLocked(wtoken,null,visible,AppTransition.TRANSIT_UNSET,true,wtoken.voiceInteraction);
    wtoken.updateReportedVisibilityLocked();
    Binder.restoreCallingIdentity(origId);
  }
}