Program: 195162
Project: 195162
Buggy source:
@Override public void setSystemUiVisibility(int vis,int mask){
  final int oldVal=mSystemUiVisibility;
  final int newVal=(oldVal & ~mask) | (vis & mask);
  final int diff=newVal ^ oldVal;
  if (DEBUG)   Log.d(TAG,String.format("String_Node_Str",Integer.toHexString(vis),Integer.toHexString(mask),Integer.toHexString(oldVal),Integer.toHexString(newVal),Integer.toHexString(diff)));
  if (diff != 0) {
    final boolean wasRecentsVisible=(mSystemUiVisibility & View.RECENT_APPS_VISIBLE) > 0;
    mSystemUiVisibility=newVal;
    if ((diff & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
      final boolean lightsOut=(vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0;
      if (lightsOut) {
        animateCollapsePanels();
      }
      setAreThereNotifications();
    }
    final int sbMode=computeBarMode(oldVal,newVal,mStatusBarView.getBarTransitions(),View.STATUS_BAR_TRANSIENT,View.STATUS_BAR_TRANSLUCENT);
    final int nbMode=mNavigationBarView == null ? -1 : computeBarMode(oldVal,newVal,mNavigationBarView.getBarTransitions(),View.NAVIGATION_BAR_TRANSIENT,View.NAVIGATION_BAR_TRANSLUCENT);
    final boolean sbModeChanged=sbMode != -1;
    final boolean nbModeChanged=nbMode != -1;
    boolean checkBarModes=false;
    if (sbModeChanged && sbMode != mStatusBarMode) {
      mStatusBarMode=sbMode;
      checkBarModes=true;
    }
    if (nbModeChanged && nbMode != mNavigationBarMode) {
      mNavigationBarMode=nbMode;
      checkBarModes=true;
    }
    if (checkBarModes) {
      checkBarModes();
    }
    if (sbModeChanged || nbModeChanged) {
      if (mStatusBarMode == MODE_SEMI_TRANSPARENT || mNavigationBarMode == MODE_SEMI_TRANSPARENT) {
        scheduleAutohide();
      }
 else {
        cancelAutohide();
      }
    }
    if ((vis & View.STATUS_BAR_UNHIDE) != 0) {
      mSystemUiVisibility&=~View.STATUS_BAR_UNHIDE;
    }
    if ((vis & View.NAVIGATION_BAR_UNHIDE) != 0) {
      mSystemUiVisibility&=~View.NAVIGATION_BAR_UNHIDE;
    }
    if ((diff & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) != 0 || sbModeChanged) {
      boolean isTransparentBar=(mStatusBarMode == MODE_TRANSPARENT || mStatusBarMode == MODE_LIGHTS_OUT_TRANSPARENT);
      boolean allowLight=isTransparentBar && !mBatteryController.isPowerSave();
      boolean light=(vis & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) != 0;
      mIconController.setIconsDark(allowLight && light);
    }
    if (wasRecentsVisible) {
      mSystemUiVisibility|=View.RECENT_APPS_VISIBLE;
    }
    notifyUiVisibilityChanged(mSystemUiVisibility);
  }
}

Fixed version (ground truth):
@Override public void setSystemUiVisibility(int vis,int mask){
  final int oldVal=mSystemUiVisibility;
  final int newVal=(oldVal & ~mask) | (vis & mask);
  final int diff=newVal ^ oldVal;
  if (DEBUG)   Log.d(TAG,String.format("String_Node_Str",Integer.toHexString(vis),Integer.toHexString(mask),Integer.toHexString(oldVal),Integer.toHexString(newVal),Integer.toHexString(diff)));
  if (diff != 0) {
    final boolean wasRecentsVisible=(mSystemUiVisibility & View.RECENT_APPS_VISIBLE) > 0;
    mSystemUiVisibility=newVal;
    if ((diff & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
      final boolean lightsOut=(vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0;
      if (lightsOut) {
        animateCollapsePanels();
      }
      setAreThereNotifications();
    }
    if ((vis & View.STATUS_BAR_UNHIDE) != 0) {
      mSystemUiVisibility&=~View.STATUS_BAR_UNHIDE;
      mNoAnimationOnNextBarModeChange=true;
    }
    final int sbMode=computeBarMode(oldVal,newVal,mStatusBarView.getBarTransitions(),View.STATUS_BAR_TRANSIENT,View.STATUS_BAR_TRANSLUCENT);
    final int nbMode=mNavigationBarView == null ? -1 : computeBarMode(oldVal,newVal,mNavigationBarView.getBarTransitions(),View.NAVIGATION_BAR_TRANSIENT,View.NAVIGATION_BAR_TRANSLUCENT);
    final boolean sbModeChanged=sbMode != -1;
    final boolean nbModeChanged=nbMode != -1;
    boolean checkBarModes=false;
    if (sbModeChanged && sbMode != mStatusBarMode) {
      mStatusBarMode=sbMode;
      checkBarModes=true;
    }
    if (nbModeChanged && nbMode != mNavigationBarMode) {
      mNavigationBarMode=nbMode;
      checkBarModes=true;
    }
    if (checkBarModes) {
      checkBarModes();
    }
    if (sbModeChanged || nbModeChanged) {
      if (mStatusBarMode == MODE_SEMI_TRANSPARENT || mNavigationBarMode == MODE_SEMI_TRANSPARENT) {
        scheduleAutohide();
      }
 else {
        cancelAutohide();
      }
    }
    if ((vis & View.NAVIGATION_BAR_UNHIDE) != 0) {
      mSystemUiVisibility&=~View.NAVIGATION_BAR_UNHIDE;
    }
    if ((diff & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) != 0 || sbModeChanged) {
      boolean isTransparentBar=(mStatusBarMode == MODE_TRANSPARENT || mStatusBarMode == MODE_LIGHTS_OUT_TRANSPARENT);
      boolean allowLight=isTransparentBar && !mBatteryController.isPowerSave();
      boolean light=(vis & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) != 0;
      mIconController.setIconsDark(allowLight && light);
    }
    if (wasRecentsVisible) {
      mSystemUiVisibility|=View.RECENT_APPS_VISIBLE;
    }
    notifyUiVisibilityChanged(mSystemUiVisibility);
  }
}