Program: 193244
Project: 193244
Buggy source:
void updateSurfaceWindowCrop(final boolean recoveringMemory){
  final WindowState w=mWin;
  final DisplayContent displayContent=w.getDisplayContent();
  if (displayContent == null) {
    return;
  }
  final DisplayInfo displayInfo=displayContent.getDisplayInfo();
  if (!w.isDefaultDisplay()) {
    w.mSystemDecorRect.set(0,0,w.mCompatFrame.width(),w.mCompatFrame.height());
    w.mSystemDecorRect.intersect(-w.mCompatFrame.left,-w.mCompatFrame.top,displayInfo.logicalWidth - w.mCompatFrame.left,displayInfo.logicalHeight - w.mCompatFrame.top);
  }
 else   if (w.mLayer >= mService.mSystemDecorLayer) {
    w.mSystemDecorRect.set(0,0,w.mCompatFrame.width(),w.mCompatFrame.height());
  }
 else   if (w.mDecorFrame.isEmpty()) {
    w.mSystemDecorRect.set(0,0,w.mCompatFrame.width(),w.mCompatFrame.height());
  }
 else   if (w.mAttrs.type == LayoutParams.TYPE_WALLPAPER && mAnimator.mAnimating) {
    mTmpClipRect.set(w.mSystemDecorRect);
    applyDecorRect(w.mDecorFrame);
    w.mSystemDecorRect.union(mTmpClipRect);
  }
 else {
    applyDecorRect(w.mDecorFrame);
  }
  final boolean fullscreen=w.isFullscreen(displayInfo.appWidth,displayInfo.appHeight);
  final boolean isFreeformResizing=w.isDragResizing() && w.getResizeMode() == DRAG_RESIZE_MODE_FREEFORM;
  final Rect clipRect=mTmpClipRect;
  if (isFreeformResizing) {
    clipRect.set(0,0,displayInfo.logicalWidth,displayInfo.logicalHeight);
  }
 else {
    clipRect.set((mHasClipRect && !fullscreen) ? mClipRect : w.mSystemDecorRect);
  }
  final WindowManager.LayoutParams attrs=w.mAttrs;
  clipRect.left-=attrs.surfaceInsets.left;
  clipRect.top-=attrs.surfaceInsets.top;
  clipRect.right+=attrs.surfaceInsets.right;
  clipRect.bottom+=attrs.surfaceInsets.bottom;
  if (mHasClipRect && fullscreen) {
    clipRect.intersect(mClipRect);
  }
  clipRect.offset(attrs.surfaceInsets.left,attrs.surfaceInsets.top);
  if (!(mAnimator.mAnimating && w.inDockedWorkspace())) {
    adjustCropToStackBounds(w,clipRect,isFreeformResizing);
  }
  w.transformFromScreenToSurfaceSpace(clipRect);
  if (!clipRect.equals(mLastClipRect)) {
    mLastClipRect.set(clipRect);
    mSurfaceController.setCropInTransaction(clipRect,recoveringMemory);
  }
}

Fixed version (ground truth):
void updateSurfaceWindowCrop(final boolean recoveringMemory){
  final WindowState w=mWin;
  final DisplayContent displayContent=w.getDisplayContent();
  if (displayContent == null) {
    return;
  }
  final DisplayInfo displayInfo=displayContent.getDisplayInfo();
  if (!w.isDefaultDisplay()) {
    w.mSystemDecorRect.set(0,0,w.mCompatFrame.width(),w.mCompatFrame.height());
    w.mSystemDecorRect.intersect(-w.mCompatFrame.left,-w.mCompatFrame.top,displayInfo.logicalWidth - w.mCompatFrame.left,displayInfo.logicalHeight - w.mCompatFrame.top);
  }
 else   if (w.mLayer >= mService.mSystemDecorLayer) {
    w.mSystemDecorRect.set(0,0,w.mCompatFrame.width(),w.mCompatFrame.height());
  }
 else   if (w.mDecorFrame.isEmpty()) {
    w.mSystemDecorRect.set(0,0,w.mCompatFrame.width(),w.mCompatFrame.height());
  }
 else   if (w.mAttrs.type == LayoutParams.TYPE_WALLPAPER && mAnimator.isAnimating()) {
    mTmpClipRect.set(w.mSystemDecorRect);
    applyDecorRect(w.mDecorFrame);
    w.mSystemDecorRect.union(mTmpClipRect);
  }
 else {
    applyDecorRect(w.mDecorFrame);
  }
  final boolean fullscreen=w.isFullscreen(displayInfo.appWidth,displayInfo.appHeight);
  final boolean isFreeformResizing=w.isDragResizing() && w.getResizeMode() == DRAG_RESIZE_MODE_FREEFORM;
  final Rect clipRect=mTmpClipRect;
  if (isFreeformResizing) {
    clipRect.set(0,0,displayInfo.logicalWidth,displayInfo.logicalHeight);
  }
 else {
    clipRect.set((mHasClipRect && !fullscreen) ? mClipRect : w.mSystemDecorRect);
  }
  final WindowManager.LayoutParams attrs=w.mAttrs;
  clipRect.left-=attrs.surfaceInsets.left;
  clipRect.top-=attrs.surfaceInsets.top;
  clipRect.right+=attrs.surfaceInsets.right;
  clipRect.bottom+=attrs.surfaceInsets.bottom;
  if (mHasClipRect && fullscreen) {
    clipRect.intersect(mClipRect);
  }
  clipRect.offset(attrs.surfaceInsets.left,attrs.surfaceInsets.top);
  adjustCropToStackBounds(w,clipRect,isFreeformResizing);
  w.transformFromScreenToSurfaceSpace(clipRect);
  if (!clipRect.equals(mLastClipRect)) {
    mLastClipRect.set(clipRect);
    mSurfaceController.setCropInTransaction(clipRect,recoveringMemory);
  }
}