v7/appcompat/src/main/java/androidx/appcompat/app/AppCompatDelegateImpl.java
int updateStatusGuard(int insetTop) {
        boolean showStatusGuard = false;
        // Show the status guard when the non-overlay contextual action bar is showing
        if (mActionModeView != null) {
            if (mActionModeView.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
                ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams)
                        mActionModeView.getLayoutParams();
                boolean mlpChanged = false;

                if (mActionModeView.isShown()) {
                    if (mTempRect1 == null) {
                        mTempRect1 = new Rect();
                        mTempRect2 = new Rect();
                    }
                    final Rect insets = mTempRect1;
                    final Rect localInsets = mTempRect2;
                    insets.set(0, insetTop, 0, 0);

                    ViewUtils.computeFitSystemWindows(mSubDecor, insets, localInsets);
                    final int newMargin = localInsets.top == 0 ? insetTop : 0;
                    if (mlp.topMargin != newMargin) {
                        mlpChanged = true;
                        mlp.topMargin = insetTop;

                        if (mStatusGuard == null) {
                            mStatusGuard = new View(mContext);
                            mStatusGuard.setBackgroundColor(mContext.getResources()
                                    .getColor(R.color.abc_input_method_navigation_guard));
                            mSubDecor.addView(mStatusGuard, -1,
                                    new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                                            insetTop));
                        } else {
                            ViewGroup.LayoutParams lp = mStatusGuard.getLayoutParams();
                            if (lp.height != insetTop) {
                                lp.height = insetTop;
                                mStatusGuard.setLayoutParams(lp);
                            }
                        }
                    }

                    // The action mode's theme may differ from the app, so
                    // always show the status guard above it.
                    showStatusGuard = mStatusGuard != null;

                    // We only need to consume the insets if the action
                    // mode is overlaid on the app content (e.g. it's
                    // sitting in a FrameLayout, see
                    // screen_simple_overlay_action_mode.xml).
                    if (!mOverlayActionMode && showStatusGuard) {
                        insetTop = 0;
                    }
                } else {
                    // reset top margin
                    if (mlp.topMargin != 0) {
                        mlpChanged = true;
                        mlp.topMargin = 0;
                    }
                }
                if (mlpChanged) {
                    mActionModeView.setLayoutParams(mlp);
                }
            }
        }
        if (mStatusGuard != null) {
            mStatusGuard.setVisibility(showStatusGuard ? View.VISIBLE : View.GONE);
        }

        return insetTop;
    }
/**
     * Updates the status bar guard
     *
     * @param insetTop the current top system window inset
     * @return the new top system window inset
     */
Updates the status bar guard
@param insetTop the current top system window inset
@return the new top system window inset
Updates the status bar guard @param insetTop the current top system window inset @return the new top system window inset
int updateStatusGuard(int insetTop) {
        boolean showStatusGuard = false;
        if (mActionModeView != null) {
            if (mActionModeView.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
                ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams)
                        mActionModeView.getLayoutParams();
                boolean mlpChanged = false;
                if (mActionModeView.isShown()) {
                    if (mTempRect1 == null) {
                        mTempRect1 = new Rect();
                        mTempRect2 = new Rect();
                    }
                    final Rect insets = mTempRect1;
                    final Rect localInsets = mTempRect2;
                    insets.set(0, insetTop, 0, 0);
                    ViewUtils.computeFitSystemWindows(mSubDecor, insets, localInsets);
                    final int newMargin = localInsets.top == 0 ? insetTop : 0;
                    if (mlp.topMargin != newMargin) {
                        mlpChanged = true;
                        mlp.topMargin = insetTop;
                        if (mStatusGuard == null) {
                            mStatusGuard = new View(mContext);
                            mStatusGuard.setBackgroundColor(mContext.getResources()
                                    .getColor(R.color.abc_input_method_navigation_guard));
                            mSubDecor.addView(mStatusGuard, -1,
                                    new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                                            insetTop));
                        } else {
                            ViewGroup.LayoutParams lp = mStatusGuard.getLayoutParams();
                            if (lp.height != insetTop) {
                                lp.height = insetTop;
                                mStatusGuard.setLayoutParams(lp);
                            }
                        }
                    }
                    showStatusGuard = mStatusGuard != null;
                    if (!mOverlayActionMode && showStatusGuard) {
                        insetTop = 0;
                    }
                } else {
                    if (mlp.topMargin != 0) {
                        mlpChanged = true;
                        mlp.topMargin = 0;
                    }
                }
                if (mlpChanged) {
                    mActionModeView.setLayoutParams(mlp);
                }
            }
        }
        if (mStatusGuard != null) {
            mStatusGuard.setVisibility(showStatusGuard ? View.VISIBLE : View.GONE);
        }
        return insetTop;
    }
int updateStatusGuard ( int insetTop ) { boolean showStatusGuard = false ; if ( mActionModeView != null ) { if ( mActionModeView . getLayoutParams ( ) instanceof ViewGroup . MarginLayoutParams ) { ViewGroup . MarginLayoutParams mlp = ( ViewGroup . MarginLayoutParams ) mActionModeView . getLayoutParams ( ) ; boolean mlpChanged = false ; if ( mActionModeView . isShown ( ) ) { if ( mTempRect1 == null ) { mTempRect1 = new Rect ( ) ; mTempRect2 = new Rect ( ) ; } final Rect insets = mTempRect1 ; final Rect localInsets = mTempRect2 ; insets . set ( 0 , insetTop , 0 , 0 ) ; ViewUtils . computeFitSystemWindows ( mSubDecor , insets , localInsets ) ; final int newMargin = localInsets . top == 0 ? insetTop : 0 ; if ( mlp . topMargin != newMargin ) { mlpChanged = true ; mlp . topMargin = insetTop ; if ( mStatusGuard == null ) { mStatusGuard = new View ( mContext ) ; mStatusGuard . setBackgroundColor ( mContext . getResources ( ) . getColor ( R . color . abc_input_method_navigation_guard ) ) ; mSubDecor . addView ( mStatusGuard , - 1 , new ViewGroup . LayoutParams ( ViewGroup . LayoutParams . MATCH_PARENT , insetTop ) ) ; } else { ViewGroup . LayoutParams lp = mStatusGuard . getLayoutParams ( ) ; if ( lp . height != insetTop ) { lp . height = insetTop ; mStatusGuard . setLayoutParams ( lp ) ; } } } showStatusGuard = mStatusGuard != null ; if ( ! mOverlayActionMode && showStatusGuard ) { insetTop = 0 ; } } else { if ( mlp . topMargin != 0 ) { mlpChanged = true ; mlp . topMargin = 0 ; } } if ( mlpChanged ) { mActionModeView . setLayoutParams ( mlp ) ; } } } if ( mStatusGuard != null ) { mStatusGuard . setVisibility ( showStatusGuard ? View . VISIBLE : View . GONE ) ; } return insetTop ; }
Updates the status bar guard
 @param insetTop the current top system window inset
 @return the new top system window inset
Updates the status bar guard @param insetTop the current top system window inset @return the new top system window inset
// Show the status guard when the non-overlay contextual action bar is showing // The action mode's theme may differ from the app, so // always show the status guard above it. // We only need to consume the insets if the action // mode is overlaid on the app content (e.g. it's // sitting in a FrameLayout, see // screen_simple_overlay_action_mode.xml). // reset top margin