Program: 41957
Project: 41957
Buggy source:
private void updateWindow(boolean force){
  if (!mHaveFrame) {
    return;
  }
  ViewRoot viewRoot=(ViewRoot)getRootView().getParent();
  if (viewRoot != null) {
    mTranslator=viewRoot.mTranslator;
  }
  Resources res=getContext().getResources();
  if (mTranslator != null || !res.getCompatibilityInfo().supportsScreen()) {
    mSurface.setCompatibleDisplayMetrics(res.getDisplayMetrics(),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 || mNewSurfaceNeeded;
  final boolean typeChanged=mType != mRequestedType;
  if (force || creating || formatChanged|| sizeChanged|| visibleChanged|| typeChanged|| mLeft != mLocation[0] || mTop != mLocation[1]) {
    if (localLOGV)     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;
      mType=mRequestedType;
      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.memoryType=mRequestedType;
      if (mWindow == null) {
        mWindow=new MyWindow(this);
        mLayout.type=mWindowType;
        mLayout.gravity=Gravity.LEFT | Gravity.TOP;
        mSession.add(mWindow,mLayout,mVisible ? VISIBLE : GONE,mContentInsets);
      }
      if (visibleChanged && (!visible || mNewSurfaceNeeded)) {
        reportSurfaceDestroyed();
      }
      mNewSurfaceNeeded=false;
      mSurfaceLock.lock();
      mDrawingStopped=!visible;
      final int relayoutResult=mSession.relayout(mWindow,mLayout,mWidth,mHeight,visible ? VISIBLE : GONE,false,mWinFrame,mContentInsets,mVisibleInsets,mConfiguration,mSurface);
      if (localLOGV)       Log.i(TAG,"String_Node_Str" + mSurface + "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);
      }
      mSurfaceLock.unlock();
      try {
        if (visible) {
          mDestroyReportNeeded=true;
          SurfaceHolder.Callback callbacks[];
synchronized (mCallbacks) {
            callbacks=new SurfaceHolder.Callback[mCallbacks.size()];
            mCallbacks.toArray(callbacks);
          }
          if (visibleChanged) {
            mIsCreating=true;
            for (            SurfaceHolder.Callback c : callbacks) {
              c.surfaceCreated(mSurfaceHolder);
            }
          }
          if (creating || formatChanged || sizeChanged|| visibleChanged) {
            for (            SurfaceHolder.Callback c : callbacks) {
              c.surfaceChanged(mSurfaceHolder,mFormat,mWidth,mHeight);
            }
          }
        }
 else {
          mSurface.release();
        }
      }
  finally {
        mIsCreating=false;
        if (creating || (relayoutResult & WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) {
          mSession.finishDrawing(mWindow);
        }
      }
    }
 catch (    RemoteException ex) {
    }
    if (localLOGV)     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){
  if (!mHaveFrame) {
    return;
  }
  ViewRoot viewRoot=(ViewRoot)getRootView().getParent();
  if (viewRoot != null) {
    mTranslator=viewRoot.mTranslator;
  }
  Resources res=getContext().getResources();
  if (mTranslator != null || !res.getCompatibilityInfo().supportsScreen()) {
    mSurface.setCompatibleDisplayMetrics(res.getDisplayMetrics(),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 || mNewSurfaceNeeded;
  final boolean typeChanged=mType != mRequestedType;
  if (force || creating || formatChanged|| sizeChanged|| visibleChanged|| typeChanged|| mLeft != mLocation[0] || mTop != mLocation[1] || mUpdateWindowNeeded || mReportDrawNeeded) {
    if (localLOGV)     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;
      mType=mRequestedType;
      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.memoryType=mRequestedType;
      if (mWindow == null) {
        mWindow=new MyWindow(this);
        mLayout.type=mWindowType;
        mLayout.gravity=Gravity.LEFT | Gravity.TOP;
        mSession.add(mWindow,mLayout,mVisible ? VISIBLE : GONE,mContentInsets);
      }
      if (visibleChanged && (!visible || mNewSurfaceNeeded)) {
        reportSurfaceDestroyed();
      }
      mNewSurfaceNeeded=false;
      boolean realSizeChanged;
      boolean reportDrawNeeded;
      mSurfaceLock.lock();
      try {
        mUpdateWindowNeeded=false;
        reportDrawNeeded=mReportDrawNeeded;
        mReportDrawNeeded=false;
        mDrawingStopped=!visible;
        final int relayoutResult=mSession.relayout(mWindow,mLayout,mWidth,mHeight,visible ? VISIBLE : GONE,false,mWinFrame,mContentInsets,mVisibleInsets,mConfiguration,mSurface);
        if ((relayoutResult & WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) {
          mReportDrawNeeded=true;
        }
        if (localLOGV)         Log.i(TAG,"String_Node_Str" + mSurface + "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 {
        if (visible) {
          mDestroyReportNeeded=true;
          SurfaceHolder.Callback callbacks[];
synchronized (mCallbacks) {
            callbacks=new SurfaceHolder.Callback[mCallbacks.size()];
            mCallbacks.toArray(callbacks);
          }
          if (visibleChanged) {
            mIsCreating=true;
            for (            SurfaceHolder.Callback c : callbacks) {
              c.surfaceCreated(mSurfaceHolder);
            }
          }
          if (creating || formatChanged || sizeChanged|| visibleChanged|| realSizeChanged) {
            for (            SurfaceHolder.Callback c : callbacks) {
              c.surfaceChanged(mSurfaceHolder,mFormat,myWidth,myHeight);
            }
          }
        }
 else {
          mSurface.release();
        }
      }
  finally {
        mIsCreating=false;
        if (creating || reportDrawNeeded) {
          mSession.finishDrawing(mWindow);
        }
      }
    }
 catch (    RemoteException ex) {
    }
    if (localLOGV)     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);
  }
}