Program: 2282
Project: 2282
Buggy source:
private void updateWindow(boolean force,boolean redrawNeeded){
  if (!mHaveFrame) {
    return;
  }
  ViewRootImpl viewRoot=getViewRootImpl();
  if (viewRoot != null) {
    mTranslator=viewRoot.mTranslator;
  }
  if (mTranslator != null) {
    mSurface.setCompatibilityTranslator(mTranslator);
  }
  int myWidth=mRequestedWidth;
  if (myWidth <= 0)   myWidth=getWidth();
  int myHeight=mRequestedHeight;
  if (myHeight <= 0)   myHeight=getHeight();
  getLocationInWindow(mLocation);
  final boolean creating=mWindow == null;
  final boolean formatChanged=mFormat != mRequestedFormat;
  final boolean sizeChanged=mWidth != myWidth || mHeight != myHeight;
  final boolean visibleChanged=mVisible != mRequestedVisible;
  if (force || creating || formatChanged|| sizeChanged|| visibleChanged|| mLeft != mLocation[0] || mTop != mLocation[1] || mUpdateWindowNeeded || mReportDrawNeeded || redrawNeeded) {
    if (DEBUG)     Log.i(TAG,"String_Node_Str" + creating + "String_Node_Str"+ formatChanged+ "String_Node_Str"+ sizeChanged+ "String_Node_Str"+ visibleChanged+ "String_Node_Str"+ (mLeft != mLocation[0])+ "String_Node_Str"+ (mTop != mLocation[1]));
    try {
      final boolean visible=mVisible=mRequestedVisible;
      mLeft=mLocation[0];
      mTop=mLocation[1];
      mWidth=myWidth;
      mHeight=myHeight;
      mFormat=mRequestedFormat;
      mLayout.x=mLeft;
      mLayout.y=mTop;
      mLayout.width=getWidth();
      mLayout.height=getHeight();
      if (mTranslator != null) {
        mTranslator.translateLayoutParamsInAppWindowToScreen(mLayout);
      }
      mLayout.format=mRequestedFormat;
      mLayout.flags|=WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS| WindowManager.LayoutParams.FLAG_SCALED| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
      if (!getContext().getResources().getCompatibilityInfo().supportsScreen()) {
        mLayout.flags|=WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW;
      }
      if (mWindow == null) {
        Display display=getDisplay();
        mWindow=new MyWindow(this);
        mLayout.type=mWindowType;
        mLayout.gravity=Gravity.START | Gravity.TOP;
        mSession.addToDisplayWithoutInputChannel(mWindow,mWindow.mSeq,mLayout,mVisible ? VISIBLE : GONE,display.getDisplayId(),mContentInsets);
      }
      boolean realSizeChanged;
      boolean reportDrawNeeded;
      int relayoutResult;
      mSurfaceLock.lock();
      try {
        mUpdateWindowNeeded=false;
        reportDrawNeeded=mReportDrawNeeded;
        mReportDrawNeeded=false;
        mDrawingStopped=!visible;
        if (DEBUG)         Log.i(TAG,"String_Node_Str" + mSurface);
        relayoutResult=mSession.relayout(mWindow,mWindow.mSeq,mLayout,mWidth,mHeight,visible ? VISIBLE : GONE,WindowManagerGlobal.RELAYOUT_DEFER_SURFACE_DESTROY,mWinFrame,mOverscanInsets,mContentInsets,mVisibleInsets,mConfiguration,mNewSurface);
        if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0) {
          mReportDrawNeeded=true;
        }
        if (DEBUG)         Log.i(TAG,"String_Node_Str" + mNewSurface + "String_Node_Str"+ visible+ "String_Node_Str"+ mWinFrame);
        mSurfaceFrame.left=0;
        mSurfaceFrame.top=0;
        if (mTranslator == null) {
          mSurfaceFrame.right=mWinFrame.width();
          mSurfaceFrame.bottom=mWinFrame.height();
        }
 else {
          float appInvertedScale=mTranslator.applicationInvertedScale;
          mSurfaceFrame.right=(int)(mWinFrame.width() * appInvertedScale + 0.5f);
          mSurfaceFrame.bottom=(int)(mWinFrame.height() * appInvertedScale + 0.5f);
        }
        final int surfaceWidth=mSurfaceFrame.right;
        final int surfaceHeight=mSurfaceFrame.bottom;
        realSizeChanged=mLastSurfaceWidth != surfaceWidth || mLastSurfaceHeight != surfaceHeight;
        mLastSurfaceWidth=surfaceWidth;
        mLastSurfaceHeight=surfaceHeight;
      }
  finally {
        mSurfaceLock.unlock();
      }
      try {
        redrawNeeded|=creating | reportDrawNeeded;
        SurfaceHolder.Callback callbacks[]=null;
        final boolean surfaceChanged=(relayoutResult & WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED) != 0;
        if (mSurfaceCreated && (surfaceChanged || (!visible && visibleChanged))) {
          mSurfaceCreated=false;
          if (mSurface.isValid()) {
            if (DEBUG)             Log.i(TAG,"String_Node_Str");
            callbacks=getSurfaceCallbacks();
            for (            SurfaceHolder.Callback c : callbacks) {
              c.surfaceDestroyed(mSurfaceHolder);
            }
          }
        }
        mSurface.transferFrom(mNewSurface);
        if (visible && mSurface.isValid()) {
          if (!mSurfaceCreated && (surfaceChanged || visibleChanged)) {
            mSurfaceCreated=true;
            mIsCreating=true;
            if (DEBUG)             Log.i(TAG,"String_Node_Str");
            if (callbacks == null) {
              callbacks=getSurfaceCallbacks();
            }
            for (            SurfaceHolder.Callback c : callbacks) {
              c.surfaceCreated(mSurfaceHolder);
            }
          }
          if (creating || formatChanged || sizeChanged|| visibleChanged|| realSizeChanged) {
            if (DEBUG)             Log.i(TAG,"String_Node_Str" + mFormat + "String_Node_Str"+ myWidth+ "String_Node_Str"+ myHeight);
            if (callbacks == null) {
              callbacks=getSurfaceCallbacks();
            }
            for (            SurfaceHolder.Callback c : callbacks) {
              c.surfaceChanged(mSurfaceHolder,mFormat,myWidth,myHeight);
            }
          }
          if (redrawNeeded) {
            if (DEBUG)             Log.i(TAG,"String_Node_Str");
            if (callbacks == null) {
              callbacks=getSurfaceCallbacks();
            }
            for (            SurfaceHolder.Callback c : callbacks) {
              if (c instanceof SurfaceHolder.Callback2) {
                ((SurfaceHolder.Callback2)c).surfaceRedrawNeeded(mSurfaceHolder);
              }
            }
          }
        }
      }
  finally {
        mIsCreating=false;
        if (redrawNeeded) {
          if (DEBUG)           Log.i(TAG,"String_Node_Str");
          mSession.finishDrawing(mWindow);
        }
        mSession.performDeferredDestroy(mWindow);
      }
    }
 catch (    RemoteException ex) {
    }
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + mLayout.x + "String_Node_Str"+ mLayout.y+ "String_Node_Str"+ mLayout.width+ "String_Node_Str"+ mLayout.height+ "String_Node_Str"+ mSurfaceFrame);
  }
}

Fixed version (ground truth):
private void updateWindow(boolean force,boolean redrawNeeded){
  if (!mHaveFrame) {
    return;
  }
  ViewRootImpl viewRoot=getViewRootImpl();
  if (viewRoot != null) {
    mTranslator=viewRoot.mTranslator;
  }
  if (mTranslator != null) {
    mSurface.setCompatibilityTranslator(mTranslator);
  }
  int myWidth=mRequestedWidth;
  if (myWidth <= 0)   myWidth=getWidth();
  int myHeight=mRequestedHeight;
  if (myHeight <= 0)   myHeight=getHeight();
  getLocationInWindow(mLocation);
  final boolean creating=mWindow == null;
  final boolean formatChanged=mFormat != mRequestedFormat;
  final boolean sizeChanged=mWidth != myWidth || mHeight != myHeight;
  final boolean visibleChanged=mVisible != mRequestedVisible;
  if (force || creating || formatChanged|| sizeChanged|| visibleChanged|| mLeft != mLocation[0] || mTop != mLocation[1] || mUpdateWindowNeeded || mReportDrawNeeded || redrawNeeded) {
    if (DEBUG)     Log.i(TAG,"String_Node_Str" + creating + "String_Node_Str"+ formatChanged+ "String_Node_Str"+ sizeChanged+ "String_Node_Str"+ visibleChanged+ "String_Node_Str"+ (mLeft != mLocation[0])+ "String_Node_Str"+ (mTop != mLocation[1]));
    try {
      final boolean visible=mVisible=mRequestedVisible;
      mLeft=mLocation[0];
      mTop=mLocation[1];
      mWidth=myWidth;
      mHeight=myHeight;
      mFormat=mRequestedFormat;
      mLayout.x=mLeft;
      mLayout.y=mTop;
      mLayout.width=getWidth();
      mLayout.height=getHeight();
      if (mTranslator != null) {
        mTranslator.translateLayoutParamsInAppWindowToScreen(mLayout);
      }
      mLayout.format=mRequestedFormat;
      mLayout.flags|=WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS| WindowManager.LayoutParams.FLAG_SCALED| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
      if (!getContext().getResources().getCompatibilityInfo().supportsScreen()) {
        mLayout.flags|=WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW;
      }
      mLayout.privateFlags|=WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
      if (mWindow == null) {
        Display display=getDisplay();
        mWindow=new MyWindow(this);
        mLayout.type=mWindowType;
        mLayout.gravity=Gravity.START | Gravity.TOP;
        mSession.addToDisplayWithoutInputChannel(mWindow,mWindow.mSeq,mLayout,mVisible ? VISIBLE : GONE,display.getDisplayId(),mContentInsets);
      }
      boolean realSizeChanged;
      boolean reportDrawNeeded;
      int relayoutResult;
      mSurfaceLock.lock();
      try {
        mUpdateWindowNeeded=false;
        reportDrawNeeded=mReportDrawNeeded;
        mReportDrawNeeded=false;
        mDrawingStopped=!visible;
        if (DEBUG)         Log.i(TAG,"String_Node_Str" + mSurface);
        relayoutResult=mSession.relayout(mWindow,mWindow.mSeq,mLayout,mWidth,mHeight,visible ? VISIBLE : GONE,WindowManagerGlobal.RELAYOUT_DEFER_SURFACE_DESTROY,mWinFrame,mOverscanInsets,mContentInsets,mVisibleInsets,mConfiguration,mNewSurface);
        if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0) {
          mReportDrawNeeded=true;
        }
        if (DEBUG)         Log.i(TAG,"String_Node_Str" + mNewSurface + "String_Node_Str"+ visible+ "String_Node_Str"+ mWinFrame);
        mSurfaceFrame.left=0;
        mSurfaceFrame.top=0;
        if (mTranslator == null) {
          mSurfaceFrame.right=mWinFrame.width();
          mSurfaceFrame.bottom=mWinFrame.height();
        }
 else {
          float appInvertedScale=mTranslator.applicationInvertedScale;
          mSurfaceFrame.right=(int)(mWinFrame.width() * appInvertedScale + 0.5f);
          mSurfaceFrame.bottom=(int)(mWinFrame.height() * appInvertedScale + 0.5f);
        }
        final int surfaceWidth=mSurfaceFrame.right;
        final int surfaceHeight=mSurfaceFrame.bottom;
        realSizeChanged=mLastSurfaceWidth != surfaceWidth || mLastSurfaceHeight != surfaceHeight;
        mLastSurfaceWidth=surfaceWidth;
        mLastSurfaceHeight=surfaceHeight;
      }
  finally {
        mSurfaceLock.unlock();
      }
      try {
        redrawNeeded|=creating | reportDrawNeeded;
        SurfaceHolder.Callback callbacks[]=null;
        final boolean surfaceChanged=(relayoutResult & WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED) != 0;
        if (mSurfaceCreated && (surfaceChanged || (!visible && visibleChanged))) {
          mSurfaceCreated=false;
          if (mSurface.isValid()) {
            if (DEBUG)             Log.i(TAG,"String_Node_Str");
            callbacks=getSurfaceCallbacks();
            for (            SurfaceHolder.Callback c : callbacks) {
              c.surfaceDestroyed(mSurfaceHolder);
            }
          }
        }
        mSurface.transferFrom(mNewSurface);
        if (visible && mSurface.isValid()) {
          if (!mSurfaceCreated && (surfaceChanged || visibleChanged)) {
            mSurfaceCreated=true;
            mIsCreating=true;
            if (DEBUG)             Log.i(TAG,"String_Node_Str");
            if (callbacks == null) {
              callbacks=getSurfaceCallbacks();
            }
            for (            SurfaceHolder.Callback c : callbacks) {
              c.surfaceCreated(mSurfaceHolder);
            }
          }
          if (creating || formatChanged || sizeChanged|| visibleChanged|| realSizeChanged) {
            if (DEBUG)             Log.i(TAG,"String_Node_Str" + mFormat + "String_Node_Str"+ myWidth+ "String_Node_Str"+ myHeight);
            if (callbacks == null) {
              callbacks=getSurfaceCallbacks();
            }
            for (            SurfaceHolder.Callback c : callbacks) {
              c.surfaceChanged(mSurfaceHolder,mFormat,myWidth,myHeight);
            }
          }
          if (redrawNeeded) {
            if (DEBUG)             Log.i(TAG,"String_Node_Str");
            if (callbacks == null) {
              callbacks=getSurfaceCallbacks();
            }
            for (            SurfaceHolder.Callback c : callbacks) {
              if (c instanceof SurfaceHolder.Callback2) {
                ((SurfaceHolder.Callback2)c).surfaceRedrawNeeded(mSurfaceHolder);
              }
            }
          }
        }
      }
  finally {
        mIsCreating=false;
        if (redrawNeeded) {
          if (DEBUG)           Log.i(TAG,"String_Node_Str");
          mSession.finishDrawing(mWindow);
        }
        mSession.performDeferredDestroy(mWindow);
      }
    }
 catch (    RemoteException ex) {
    }
    if (DEBUG)     Log.v(TAG,"String_Node_Str" + mLayout.x + "String_Node_Str"+ mLayout.y+ "String_Node_Str"+ mLayout.width+ "String_Node_Str"+ mLayout.height+ "String_Node_Str"+ mSurfaceFrame);
  }
}