Program: 22970
Project: 22970
Buggy source:
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,"String_Node_Str" + token);
      return;
    }
    if (DEBUG_APP_TRANSITIONS || DEBUG_ORIENTATION) {
      RuntimeException e=new RuntimeException();
      if (!HIDE_STACK_CRAWLS)       e.fillInStackTrace();
      Slog.v(TAG,"String_Node_Str" + token + "String_Node_Str"+ visible+ "String_Node_Str"+ mNextAppTransition+ "String_Node_Str"+ wtoken.hidden+ "String_Node_Str"+ wtoken.hiddenRequested,e);
    }
    if (!mDisplayFrozen && mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
      if (wtoken.hiddenRequested != visible) {
        return;
      }
      wtoken.hiddenRequested=!visible;
      if (DEBUG_APP_TRANSITIONS)       Slog.v(TAG,"String_Node_Str" + wtoken);
      wtoken.setDummyAnimation();
      mOpeningApps.remove(wtoken);
      mClosingApps.remove(wtoken);
      wtoken.waitingToShow=wtoken.waitingToHide=false;
      wtoken.inPendingTransaction=true;
      if (visible) {
        mOpeningApps.add(wtoken);
        wtoken.startingDisplayed=false;
        wtoken.startingMoved=false;
        if (wtoken.hidden) {
          wtoken.allDrawn=false;
          wtoken.waitingToShow=true;
          if (wtoken.clientHidden) {
            wtoken.clientHidden=false;
            wtoken.sendAppVisibilityToClients();
          }
        }
      }
 else {
        mClosingApps.add(wtoken);
        if (!wtoken.hidden) {
          wtoken.waitingToHide=true;
        }
      }
      return;
    }
    final long origId=Binder.clearCallingIdentity();
    setTokenVisibilityLocked(wtoken,null,visible,WindowManagerPolicy.TRANSIT_UNSET,true);
    wtoken.updateReportedVisibilityLocked();
    Binder.restoreCallingIdentity(origId);
  }
}

Fixed version (ground truth):
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,"String_Node_Str" + token);
      return;
    }
    if (DEBUG_APP_TRANSITIONS || DEBUG_ORIENTATION) {
      RuntimeException e=new RuntimeException();
      if (!HIDE_STACK_CRAWLS)       e.fillInStackTrace();
      Slog.v(TAG,"String_Node_Str" + token + "String_Node_Str"+ visible+ "String_Node_Str"+ mNextAppTransition+ "String_Node_Str"+ wtoken.hidden+ "String_Node_Str"+ wtoken.hiddenRequested,e);
    }
    if (!mDisplayFrozen && mPolicy.isScreenOn() && mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
      if (wtoken.hiddenRequested != visible) {
        return;
      }
      wtoken.hiddenRequested=!visible;
      if (DEBUG_APP_TRANSITIONS)       Slog.v(TAG,"String_Node_Str" + wtoken);
      wtoken.setDummyAnimation();
      mOpeningApps.remove(wtoken);
      mClosingApps.remove(wtoken);
      wtoken.waitingToShow=wtoken.waitingToHide=false;
      wtoken.inPendingTransaction=true;
      if (visible) {
        mOpeningApps.add(wtoken);
        wtoken.startingDisplayed=false;
        wtoken.startingMoved=false;
        if (wtoken.hidden) {
          wtoken.allDrawn=false;
          wtoken.waitingToShow=true;
          if (wtoken.clientHidden) {
            wtoken.clientHidden=false;
            wtoken.sendAppVisibilityToClients();
          }
        }
      }
 else {
        mClosingApps.add(wtoken);
        if (!wtoken.hidden) {
          wtoken.waitingToHide=true;
        }
      }
      return;
    }
    final long origId=Binder.clearCallingIdentity();
    setTokenVisibilityLocked(wtoken,null,visible,WindowManagerPolicy.TRANSIT_UNSET,true);
    wtoken.updateReportedVisibilityLocked();
    Binder.restoreCallingIdentity(origId);
  }
}