void startDimming( final WindowStateAnimator winAnimator, final float target, final int width, final int height) { if (mDimAnimator == null) { mDimAnimator = new DimAnimator(mService.mFxSession); } // Only set dim params on the highest dimmed layer. final WindowStateAnimator dimWinAnimator = mDimParams == null ? null : mDimParams.mDimWinAnimator; // Don't turn on for an unshown surface, or for any layer but the highest dimmed one. if (winAnimator.mSurfaceShown && (dimWinAnimator == null || !dimWinAnimator.mSurfaceShown || dimWinAnimator.mAnimLayer < winAnimator.mAnimLayer)) { /** * Author: Onskreen Date: 21/12/2012 * * <p>Sets the dimming rect and position as per panel(main or either of cornerstone panels)'s * current position in which this window is running. */ if (winAnimator.mWin != null) { if (winAnimator.mWin.mAppToken != null) { IBinder token = winAnimator.mWin.mAppToken.token; if (token != null) { WindowPanel wp = mService.findWindowPanel(token); if (wp != null) { Rect dimRect = new Rect(); dimRect.set(wp.getPos()); mDimAnimator.mDimX = dimRect.left; mDimAnimator.mDimY = dimRect.top; mService.mH.sendMessage( mService.mH.obtainMessage( SET_DIM_PARAMETERS, new DimAnimator.Parameters( winAnimator, dimRect.width(), dimRect.height(), target))); } else { mService.mH.sendMessage( mService.mH.obtainMessage( SET_DIM_PARAMETERS, new DimAnimator.Parameters(winAnimator, width, height, target))); } } else { mService.mH.sendMessage( mService.mH.obtainMessage( SET_DIM_PARAMETERS, new DimAnimator.Parameters(winAnimator, width, height, target))); } } else { mService.mH.sendMessage( mService.mH.obtainMessage( SET_DIM_PARAMETERS, new DimAnimator.Parameters(winAnimator, width, height, target))); } } else { mService.mH.sendMessage( mService.mH.obtainMessage( SET_DIM_PARAMETERS, new DimAnimator.Parameters(winAnimator, width, height, target))); } } }