Program: 191940
Project: 191940
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 (!mAppTransition.isTransitionSet() && mAppTransition.isReady()) {
        mOpeningApps.add(wtoken);
      }
      wtoken.startingMoved=false;
      if (wtoken.hidden || wtoken.mAppStopped) {
        wtoken.allDrawn=false;
        wtoken.deferClearAllDrawn=false;
        wtoken.waitingToShow=true;
        if (wtoken.clientHidden) {
          wtoken.clientHidden=false;
          wtoken.sendAppVisibilityToClients();
        }
      }
      if (DEBUG_ADD_REMOVE)       Slog.v(TAG_WM,"String_Node_Str" + wtoken);
      wtoken.mAppStopped=false;
    }
    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) {
        mOpeningApps.add(wtoken);
        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);
  }
}

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 (!mAppTransition.isTransitionSet() && mAppTransition.isReady()) {
        mOpeningApps.add(wtoken);
      }
      wtoken.startingMoved=false;
      if (wtoken.hidden || wtoken.mAppStopped) {
        wtoken.allDrawn=false;
        wtoken.deferClearAllDrawn=false;
        if (wtoken.hidden) {
          wtoken.waitingToShow=true;
        }
        if (wtoken.clientHidden) {
          wtoken.clientHidden=false;
          wtoken.sendAppVisibilityToClients();
        }
      }
      if (DEBUG_ADD_REMOVE)       Slog.v(TAG_WM,"String_Node_Str" + wtoken);
      wtoken.mAppStopped=false;
    }
    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) {
        mOpeningApps.add(wtoken);
        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);
  }
}