Merge "Remove the legacy insets mode"
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 27bb9e2..60ddd8a 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -18,7 +18,6 @@
 
 import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
 import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE;
 import static android.view.WindowInsets.Type.navigationBars;
 import static android.view.WindowInsets.Type.statusBars;
 import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
@@ -2201,22 +2200,15 @@
     }
 
     /**
-     * Apply the IME visibility in {@link android.view.ImeInsetsSourceConsumer} when
-     * {@link ViewRootImpl.sNewInsetsMode} is enabled.
+     * Applies the IME visibility in {@link android.view.ImeInsetsSourceConsumer}.
+     *
      * @param setVisible {@code true} to make it visible, false to hide it.
      */
     private void applyVisibilityInInsetsConsumerIfNecessary(boolean setVisible) {
-        if (!isVisibilityAppliedUsingInsetsConsumer()) {
-            return;
-        }
         mPrivOps.applyImeVisibility(setVisible
                 ? mCurShowInputToken : mCurHideInputToken, setVisible);
     }
 
-    private boolean isVisibilityAppliedUsingInsetsConsumer() {
-        return ViewRootImpl.sNewInsetsMode > NEW_INSETS_MODE_NONE;
-    }
-
     private void finishViews(boolean finishingInput) {
         if (mInputViewStarted) {
             if (DEBUG) Log.v(TAG, "CALL: onFinishInputView");
@@ -2241,14 +2233,9 @@
         mWindowVisible = false;
         finishViews(false /* finishingInput */);
         if (mDecorViewVisible) {
-            // When insets API is enabled, it is responsible for client and server side
-            // visibility of IME window.
-            if (isVisibilityAppliedUsingInsetsConsumer()) {
-                if (mInputView != null) {
-                    mInputView.dispatchWindowVisibilityChanged(View.GONE);
-                }
-            } else {
-                mWindow.hide();
+            // It is responsible for client and server side visibility of IME window.
+            if (mInputView != null) {
+                mInputView.dispatchWindowVisibilityChanged(View.GONE);
             }
             mDecorViewVisible = false;
             onWindowHidden();
diff --git a/core/java/android/view/InsetsState.java b/core/java/android/view/InsetsState.java
index 373a096..f462a99 100644
--- a/core/java/android/view/InsetsState.java
+++ b/core/java/android/view/InsetsState.java
@@ -17,10 +17,6 @@
 package android.view;
 
 import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_IME;
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE;
-import static android.view.ViewRootImpl.sNewInsetsMode;
 import static android.view.WindowInsets.Type.MANDATORY_SYSTEM_GESTURES;
 import static android.view.WindowInsets.Type.SYSTEM_GESTURES;
 import static android.view.WindowInsets.Type.displayCutout;
@@ -195,18 +191,6 @@
                 continue;
             }
 
-            boolean skipNonImeInImeMode = ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_IME
-                    && source.getType() != ITYPE_IME;
-            boolean skipSystemBars = ViewRootImpl.sNewInsetsMode != NEW_INSETS_MODE_FULL
-                    && (type == ITYPE_STATUS_BAR || type == ITYPE_NAVIGATION_BAR);
-            boolean skipLegacyTypes = ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_NONE
-                    && (type == ITYPE_STATUS_BAR || type == ITYPE_NAVIGATION_BAR
-                            || type == ITYPE_IME);
-            if (skipSystemBars || skipLegacyTypes || skipNonImeInImeMode) {
-                typeVisibilityMap[indexOf(toPublicType(type))] = source.isVisible();
-                continue;
-            }
-
             processSource(source, relativeFrame, false /* ignoreVisibility */, typeInsetsMap,
                     typeSideMap, typeVisibilityMap);
 
@@ -239,8 +223,7 @@
 
         return new WindowInsets(typeInsetsMap, typeMaxInsetsMap, typeVisibilityMap, isScreenRound,
                 alwaysConsumeSystemBars, cutout, compatInsetsTypes,
-                sNewInsetsMode == NEW_INSETS_MODE_FULL
-                        && (legacySystemUiFlags & SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0);
+                (legacySystemUiFlags & SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0);
     }
 
     public Rect calculateVisibleInsets(Rect frame, @SoftInputModeFlags int softInputMode) {
@@ -250,9 +233,6 @@
             if (source == null) {
                 continue;
             }
-            if (sNewInsetsMode != NEW_INSETS_MODE_FULL && type != ITYPE_IME) {
-                continue;
-            }
 
             // Ignore everything that's not a system bar or IME.
             int publicType = InsetsState.toPublicType(type);
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 92a0f63..e7e28ac 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -17,7 +17,6 @@
 package android.view;
 
 import static android.content.res.Resources.ID_NULL;
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
 import static android.view.accessibility.AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED;
 
 import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DEEP_PRESS;
@@ -5435,8 +5434,7 @@
 
             sAcceptZeroSizeDragShadow = targetSdkVersion < Build.VERSION_CODES.P;
 
-            sBrokenInsetsDispatch = ViewRootImpl.sNewInsetsMode != NEW_INSETS_MODE_FULL
-                    || targetSdkVersion < Build.VERSION_CODES.R;
+            sBrokenInsetsDispatch = targetSdkVersion < Build.VERSION_CODES.R;
 
             sBrokenWindowBackground = targetSdkVersion < Build.VERSION_CODES.Q;
 
@@ -26263,6 +26261,14 @@
     }
 
     /**
+     * This needs to be a better API before it is exposed. For now, only the root view will get
+     * notified.
+     * @hide
+     */
+    public void onSystemBarAppearanceChanged(@WindowInsetsController.Appearance int appearance) {
+    }
+
+    /**
      * Creates an image that the system displays during the drag and drop
      * operation. This is called a &quot;drag shadow&quot;. The default implementation
      * for a DragShadowBuilder based on a View returns an image that has exactly the same
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index e6f89a7..0bbd899 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -221,45 +221,6 @@
     private static final boolean MT_RENDERER_AVAILABLE = true;
 
     /**
-     * If set to 2, the view system will switch from using rectangles retrieved from window to
-     * dispatch to the view hierarchy to using {@link InsetsController}, that derives the insets
-     * directly from the full configuration, enabling richer information about the insets state, as
-     * well as new APIs to control it frame-by-frame, and synchronize animations with it.
-     * <p>
-     * Only set this to 2 once the new insets system is productionized and the old APIs are
-     * fully migrated over.
-     * <p>
-     * If set to 1, this will switch to a mode where we only use the new approach for IME, but not
-     * for the status/navigation bar.
-     */
-    private static final String USE_NEW_INSETS_PROPERTY = "persist.debug.new_insets";
-
-    /**
-     * @see #USE_NEW_INSETS_PROPERTY
-     * @hide
-     */
-    public static final int NEW_INSETS_MODE_NONE = 0;
-
-    /**
-     * @see #USE_NEW_INSETS_PROPERTY
-     * @hide
-     */
-    public static final int NEW_INSETS_MODE_IME = 1;
-
-    /**
-     * @see #USE_NEW_INSETS_PROPERTY
-     * @hide
-     */
-    public static final int NEW_INSETS_MODE_FULL = 2;
-
-    /**
-     * @see #USE_NEW_INSETS_PROPERTY
-     * @hide
-     */
-    public static int sNewInsetsMode =
-            SystemProperties.getInt(USE_NEW_INSETS_PROPERTY, NEW_INSETS_MODE_FULL);
-
-    /**
      * Set this system property to true to force the view hierarchy to render
      * at 60 Hz. This can be used to measure the potential framerate.
      */
@@ -454,8 +415,8 @@
     @UnsupportedAppUsage
     final View.AttachInfo mAttachInfo;
     final SystemUiVisibilityInfo mCompatibleVisibilityInfo;
-    int mDispatchedSystemUiVisibility =
-            ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_FULL ? 0 : -1;
+    int mDispatchedSystemUiVisibility;
+    int mDispatchedSystemBarAppearance;
     InputQueue.Callback mInputQueueCallback;
     InputQueue mInputQueue;
     @UnsupportedAppUsage
@@ -1409,6 +1370,10 @@
             attrs.systemUiVisibility = mWindowAttributes.systemUiVisibility;
             attrs.subtreeSystemUiVisibility = mWindowAttributes.subtreeSystemUiVisibility;
 
+            // Transfer over appearance and behavior values as they carry current state.
+            attrs.insetsFlags.appearance = mWindowAttributes.insetsFlags.appearance;
+            attrs.insetsFlags.behavior = mWindowAttributes.insetsFlags.behavior;
+
             final int changes = mWindowAttributes.copyFrom(attrs);
             if ((changes & WindowManager.LayoutParams.TRANSLUCENT_FLAGS_CHANGED) != 0) {
                 // Recompute system ui visibility.
@@ -1627,9 +1592,6 @@
     }
 
     void notifyInsetsChanged() {
-        if (sNewInsetsMode == NEW_INSETS_MODE_NONE) {
-            return;
-        }
         mApplyInsetsRequested = true;
         requestLayout();
 
@@ -2063,8 +2025,7 @@
      */
     void updateCompatSysUiVisibility(@InternalInsetsType int type, boolean visible,
             boolean hasControl) {
-        if ((type != ITYPE_STATUS_BAR && type != ITYPE_NAVIGATION_BAR)
-                || ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL) {
+        if (type != ITYPE_STATUS_BAR && type != ITYPE_NAVIGATION_BAR) {
             return;
         }
         final SystemUiVisibilityInfo info = mCompatibleVisibilityInfo;
@@ -2089,14 +2050,6 @@
     }
 
     private void handleDispatchSystemUiVisibilityChanged(SystemUiVisibilityInfo args) {
-        if (mSeq != args.seq && sNewInsetsMode != NEW_INSETS_MODE_FULL) {
-            // The sequence has changed, so we need to update our value and make
-            // sure to do a traversal afterward so the window manager is given our
-            // most recent data.
-            mSeq = args.seq;
-            mAttachInfo.mForceReportNewAttributes = true;
-            scheduleTraversals();
-        }
         if (mView == null) return;
         if (args.localChanges != 0) {
             mView.updateLocalSystemUiVisibility(args.localValue, args.localChanges);
@@ -2112,9 +2065,6 @@
 
     @VisibleForTesting
     public static void adjustLayoutParamsForCompatibility(WindowManager.LayoutParams inOutParams) {
-        if (sNewInsetsMode != NEW_INSETS_MODE_FULL) {
-            return;
-        }
         final int sysUiVis = inOutParams.systemUiVisibility | inOutParams.subtreeSystemUiVisibility;
         final int flags = inOutParams.flags;
         final int type = inOutParams.type;
@@ -2179,9 +2129,6 @@
     }
 
     private void controlInsetsForCompatibility(WindowManager.LayoutParams params) {
-        if (sNewInsetsMode != NEW_INSETS_MODE_FULL) {
-            return;
-        }
         final int sysUiVis = params.systemUiVisibility | params.subtreeSystemUiVisibility;
         final int flags = params.flags;
         final boolean matchParent = params.width == MATCH_PARENT && params.height == MATCH_PARENT;
@@ -2629,6 +2576,10 @@
             }
             adjustLayoutParamsForCompatibility(params);
             controlInsetsForCompatibility(params);
+            if (mDispatchedSystemBarAppearance != params.insetsFlags.appearance) {
+                mDispatchedSystemBarAppearance = params.insetsFlags.appearance;
+                mView.onSystemBarAppearanceChanged(mDispatchedSystemBarAppearance);
+            }
         }
 
         if (mFirst || windowShouldResize || viewVisibilityChanged || cutoutChanged || params != null
@@ -3239,14 +3190,12 @@
             hasWindowFocus = mUpcomingWindowFocus;
             inTouchMode = mUpcomingInTouchMode;
         }
-        if (sNewInsetsMode != NEW_INSETS_MODE_NONE) {
-            // TODO (b/131181940): Make sure this doesn't leak Activity with mActivityConfigCallback
-            // config changes.
-            if (hasWindowFocus) {
-                mInsetsController.onWindowFocusGained();
-            } else {
-                mInsetsController.onWindowFocusLost();
-            }
+        // TODO (b/131181940): Make sure this doesn't leak Activity with mActivityConfigCallback
+        // config changes.
+        if (hasWindowFocus) {
+            mInsetsController.onWindowFocusGained();
+        } else {
+            mInsetsController.onWindowFocusLost();
         }
 
         if (mAdded) {
diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java
index 5d53ad7..f57ee65 100644
--- a/core/java/android/view/WindowManagerImpl.java
+++ b/core/java/android/view/WindowManagerImpl.java
@@ -19,7 +19,6 @@
 import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
 import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
 import static android.view.View.SYSTEM_UI_FLAG_VISIBLE;
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
 import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
 import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
 import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
@@ -30,7 +29,6 @@
 import android.compat.annotation.UnsupportedAppUsage;
 import android.content.Context;
 import android.content.res.Configuration;
-import android.graphics.Insets;
 import android.graphics.Rect;
 import android.graphics.Region;
 import android.os.Bundle;
@@ -275,19 +273,10 @@
             final Configuration config = mContext.getResources().getConfiguration();
             final boolean isScreenRound = config.isScreenRound();
             final int windowingMode = config.windowConfiguration.getWindowingMode();
-            if (ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_FULL) {
-                return insetsState.calculateInsets(bounds, null /* ignoringVisibilityState*/,
-                        isScreenRound, alwaysConsumeSystemBars, displayCutout.get(),
-                        SOFT_INPUT_ADJUST_NOTHING, attrs.flags, SYSTEM_UI_FLAG_VISIBLE, attrs.type,
-                        windowingMode, null /* typeSideMap */);
-            } else {
-                return new WindowInsets.Builder()
-                        .setAlwaysConsumeSystemBars(alwaysConsumeSystemBars)
-                        .setRound(isScreenRound)
-                        .setSystemWindowInsets(Insets.of(systemWindowInsets))
-                        .setStableInsets(Insets.of(stableInsets))
-                        .setDisplayCutout(displayCutout.get()).build();
-            }
+            return insetsState.calculateInsets(bounds, null /* ignoringVisibilityState*/,
+                    isScreenRound, alwaysConsumeSystemBars, displayCutout.get(),
+                    SOFT_INPUT_ADJUST_NOTHING, attrs.flags, SYSTEM_UI_FLAG_VISIBLE, attrs.type,
+                    windowingMode, null /* typeSideMap */);
         } catch (RemoteException e) {
             throw e.rethrowFromSystemServer();
         }
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index f6671d8..a3c95a9 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -457,9 +457,7 @@
     private int mRequestUpdateCursorAnchorInfoMonitorMode = REQUEST_UPDATE_CURSOR_ANCHOR_INFO_NONE;
 
     /**
-     * When {@link ViewRootImpl#sNewInsetsMode} is set to
-     * >= {@link ViewRootImpl#NEW_INSETS_MODE_IME}, {@link ImeInsetsSourceConsumer} applies the
-     * IME visibility and listens for other state changes.
+     * Applies the IME visibility and listens for other state changes.
      */
     private ImeInsetsSourceConsumer mImeInsetsConsumer;
 
diff --git a/core/java/android/window/WindowMetricsHelper.java b/core/java/android/window/WindowMetricsHelper.java
index fb8b27e..170ff6f 100644
--- a/core/java/android/window/WindowMetricsHelper.java
+++ b/core/java/android/window/WindowMetricsHelper.java
@@ -16,17 +16,13 @@
 
 package android.window;
 
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
 import static android.view.WindowInsets.Type.displayCutout;
 import static android.view.WindowInsets.Type.navigationBars;
 
 import android.annotation.NonNull;
-import android.graphics.Insets;
 import android.graphics.Point;
 import android.graphics.Rect;
 import android.view.Display;
-import android.view.DisplayCutout;
-import android.view.ViewRootImpl;
 import android.view.WindowInsets;
 import android.view.WindowMetrics;
 
@@ -46,19 +42,8 @@
     public static Rect getBoundsExcludingNavigationBarAndCutout(
             @NonNull WindowMetrics windowMetrics) {
         final WindowInsets windowInsets = windowMetrics.getWindowInsets();
-        Insets insets;
-        if (ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_FULL) {
-            insets = windowInsets.getInsetsIgnoringVisibility(navigationBars() | displayCutout());
-        } else {
-            final Insets stableInsets = windowInsets.getStableInsets();
-            insets = Insets.of(stableInsets.left, 0 /* top */, stableInsets.right,
-                    stableInsets.bottom);
-            final DisplayCutout cutout = windowInsets.getDisplayCutout();
-            insets = (cutout != null) ? Insets.max(insets, Insets.of(cutout.getSafeInsets()))
-                    : insets;
-        }
         final Rect result = new Rect(windowMetrics.getBounds());
-        result.inset(insets);
+        result.inset(windowInsets.getInsetsIgnoringVisibility(navigationBars() | displayCutout()));
         return result;
     }
 }
diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java
index a6c3dd1..1f8a829 100644
--- a/core/java/com/android/internal/policy/DecorView.java
+++ b/core/java/com/android/internal/policy/DecorView.java
@@ -32,6 +32,8 @@
 import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
 import static android.view.Window.DECOR_CAPTION_SHADE_DARK;
 import static android.view.Window.DECOR_CAPTION_SHADE_LIGHT;
+import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
+import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
 import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
 import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
 import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
@@ -97,6 +99,7 @@
 import android.view.WindowCallbacks;
 import android.view.WindowInsets;
 import android.view.WindowInsetsController;
+import android.view.WindowInsetsController.Appearance;
 import android.view.WindowManager;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityManager;
@@ -137,19 +140,16 @@
     private static final int SCRIM_LIGHT = 0xe6ffffff; // 90% white
 
     public static final ColorViewAttributes STATUS_BAR_COLOR_VIEW_ATTRIBUTES =
-            new ColorViewAttributes(SYSTEM_UI_FLAG_FULLSCREEN, FLAG_TRANSLUCENT_STATUS,
+            new ColorViewAttributes(FLAG_TRANSLUCENT_STATUS,
                     Gravity.TOP, Gravity.LEFT, Gravity.RIGHT,
                     Window.STATUS_BAR_BACKGROUND_TRANSITION_NAME,
-                    com.android.internal.R.id.statusBarBackground,
-                    FLAG_FULLSCREEN, ITYPE_STATUS_BAR);
+                    com.android.internal.R.id.statusBarBackground, ITYPE_STATUS_BAR);
 
     public static final ColorViewAttributes NAVIGATION_BAR_COLOR_VIEW_ATTRIBUTES =
-            new ColorViewAttributes(
-                    SYSTEM_UI_FLAG_HIDE_NAVIGATION, FLAG_TRANSLUCENT_NAVIGATION,
+            new ColorViewAttributes(FLAG_TRANSLUCENT_NAVIGATION,
                     Gravity.BOTTOM, Gravity.RIGHT, Gravity.LEFT,
                     Window.NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME,
-                    com.android.internal.R.id.navigationBarBackground,
-                    0 /* hideWindowFlag */, ITYPE_NAVIGATION_BAR);
+                    com.android.internal.R.id.navigationBarBackground, ITYPE_NAVIGATION_BAR);
 
     // This is used to workaround an issue where the PiP shadow can be transparent if the window
     // background is transparent
@@ -1016,6 +1016,11 @@
     }
 
     @Override
+    public void onSystemBarAppearanceChanged(@WindowInsetsController.Appearance int appearance) {
+        updateColorViews(null /* insets */, true /* animate */);
+    }
+
+    @Override
     public WindowInsets onApplyWindowInsets(WindowInsets insets) {
         final WindowManager.LayoutParams attrs = mWindow.getAttributes();
         mFloatingInsets.setEmpty();
@@ -1094,6 +1099,11 @@
                     & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0;
             mLastWindowFlags = attrs.flags;
 
+            final ViewRootImpl viewRoot = getViewRootImpl();
+            final @Appearance int appearance = viewRoot != null
+                    ? viewRoot.mWindowAttributes.insetsFlags.appearance
+                    : controller.getSystemBarsAppearance();
+
             if (insets != null) {
                 final Insets systemBarInsets = insets.getInsets(WindowInsets.Type.systemBars());
                 final Insets stableBarInsets = insets.getInsetsIgnoringVisibility(
@@ -1130,8 +1140,8 @@
             boolean navBarToRightEdge = isNavBarToRightEdge(mLastBottomInset, mLastRightInset);
             boolean navBarToLeftEdge = isNavBarToLeftEdge(mLastBottomInset, mLastLeftInset);
             int navBarSize = getNavBarSize(mLastBottomInset, mLastRightInset, mLastLeftInset);
-            updateColorViewInt(mNavigationColorViewState, sysUiVisibility,
-                    calculateNavigationBarColor(), mWindow.mNavigationBarDividerColor, navBarSize,
+            updateColorViewInt(mNavigationColorViewState, calculateNavigationBarColor(appearance),
+                    mWindow.mNavigationBarDividerColor, navBarSize,
                     navBarToRightEdge || navBarToLeftEdge, navBarToLeftEdge,
                     0 /* sideInset */, animate && !disallowAnimate,
                     mForceWindowDrawsBarBackgrounds, controller);
@@ -1139,9 +1149,8 @@
             mDrawLegacyNavigationBarBackground = mNavigationColorViewState.visible
                     && (mWindow.getAttributes().flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0;
             if (oldDrawLegacy != mDrawLegacyNavigationBarBackground) {
-                ViewRootImpl vri = getViewRootImpl();
-                if (vri != null) {
-                    vri.requestInvalidateRootRenderNode();
+                if (viewRoot != null) {
+                    viewRoot.requestInvalidateRootRenderNode();
                 }
             }
 
@@ -1151,15 +1160,14 @@
                     && mNavigationColorViewState.present;
             int statusBarSideInset = statusBarNeedsRightInset ? mLastRightInset
                     : statusBarNeedsLeftInset ? mLastLeftInset : 0;
-            updateColorViewInt(mStatusColorViewState, sysUiVisibility,
-                    calculateStatusBarColor(), 0, mLastTopInset,
-                    false /* matchVertical */, statusBarNeedsLeftInset, statusBarSideInset,
-                    animate && !disallowAnimate,
+            int statusBarColor = calculateStatusBarColor(appearance);
+            updateColorViewInt(mStatusColorViewState, statusBarColor, 0,
+                    mLastTopInset, false /* matchVertical */, statusBarNeedsLeftInset,
+                    statusBarSideInset, animate && !disallowAnimate,
                     mForceWindowDrawsBarBackgrounds, controller);
 
             if (mHasCaption) {
-                final int captionColor = calculateStatusBarColor();
-                mDecorCaptionView.getCaption().setBackgroundColor(captionColor);
+                mDecorCaptionView.getCaption().setBackgroundColor(statusBarColor);
                 updateDecorCaptionShade();
             }
         }
@@ -1286,29 +1294,30 @@
         return mOriginalBackgroundDrawable;
     }
 
-    private int calculateStatusBarColor() {
+    private int calculateStatusBarColor(@Appearance int appearance) {
         return calculateBarColor(mWindow.getAttributes().flags, FLAG_TRANSLUCENT_STATUS,
                 mSemiTransparentBarColor, mWindow.mStatusBarColor,
-                getWindowSystemUiVisibility(), SYSTEM_UI_FLAG_LIGHT_STATUS_BAR,
+                appearance, APPEARANCE_LIGHT_STATUS_BARS,
                 mWindow.mEnsureStatusBarContrastWhenTransparent);
     }
 
-    private int calculateNavigationBarColor() {
+    private int calculateNavigationBarColor(@Appearance int appearance) {
         return calculateBarColor(mWindow.getAttributes().flags, FLAG_TRANSLUCENT_NAVIGATION,
                 mSemiTransparentBarColor, mWindow.mNavigationBarColor,
-                getWindowSystemUiVisibility(), SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR,
+                appearance, APPEARANCE_LIGHT_NAVIGATION_BARS,
                 mWindow.mEnsureNavigationBarContrastWhenTransparent
                         && getContext().getResources().getBoolean(R.bool.config_navBarNeedsScrim));
     }
 
     public static int calculateBarColor(int flags, int translucentFlag, int semiTransparentBarColor,
-            int barColor, int sysuiVis, int lightSysuiFlag, boolean scrimTransparent) {
+            int barColor, @Appearance int appearance, @Appearance int lightAppearanceFlag,
+            boolean scrimTransparent) {
         if ((flags & translucentFlag) != 0) {
             return semiTransparentBarColor;
         } else if ((flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0) {
             return Color.BLACK;
         } else if (scrimTransparent && Color.alpha(barColor) == 0) {
-            boolean light = (sysuiVis & lightSysuiFlag) != 0;
+            boolean light = (appearance & lightAppearanceFlag) != 0;
             return light ? SCRIM_LIGHT : semiTransparentBarColor;
         } else {
             return barColor;
@@ -1327,7 +1336,6 @@
      * Update a color view
      *
      * @param state the color view to update.
-     * @param sysUiVis the current systemUiVisibility to apply.
      * @param color the current color to apply.
      * @param dividerColor the current divider color to apply.
      * @param size the current size in the non-parent-matching dimension.
@@ -1336,12 +1344,10 @@
      * @param sideMargin sideMargin for the color view.
      * @param animate if true, the change will be animated.
      */
-    private void updateColorViewInt(final ColorViewState state, int sysUiVis, int color,
-            int dividerColor, int size, boolean verticalBar, boolean seascape, int sideMargin,
-            boolean animate, boolean force, WindowInsetsController controller) {
-        state.present = ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL
-                ? state.attributes.isPresent(sysUiVis, mWindow.getAttributes().flags, force)
-                : state.attributes.isPresent(
+    private void updateColorViewInt(final ColorViewState state, int color, int dividerColor,
+            int size, boolean verticalBar, boolean seascape, int sideMargin, boolean animate,
+            boolean force, WindowInsetsController controller) {
+        state.present = state.attributes.isPresent(
                         controller.isRequestedVisible(state.attributes.insetsType),
                         mWindow.getAttributes().flags, force);
         boolean show = state.attributes.isVisible(state.present, color,
@@ -2583,37 +2589,25 @@
     public static class ColorViewAttributes {
 
         final int id;
-        final int systemUiHideFlag;
         final int translucentFlag;
         final int verticalGravity;
         final int horizontalGravity;
         final int seascapeGravity;
         final String transitionName;
-        final int hideWindowFlag;
         final @InternalInsetsType int insetsType;
 
-        private ColorViewAttributes(int systemUiHideFlag, int translucentFlag, int verticalGravity,
-                int horizontalGravity, int seascapeGravity, String transitionName, int id,
-                int hideWindowFlag, @InternalInsetsType int insetsType) {
+        private ColorViewAttributes(int translucentFlag, int verticalGravity, int horizontalGravity,
+                int seascapeGravity, String transitionName, int id,
+                @InternalInsetsType int insetsType) {
             this.id = id;
-            this.systemUiHideFlag = systemUiHideFlag;
             this.translucentFlag = translucentFlag;
             this.verticalGravity = verticalGravity;
             this.horizontalGravity = horizontalGravity;
             this.seascapeGravity = seascapeGravity;
             this.transitionName = transitionName;
-            this.hideWindowFlag = hideWindowFlag;
             this.insetsType = insetsType;
         }
 
-        // TODO(b/118118435): remove after migration
-        public boolean isPresent(int sysUiVis, int windowFlags, boolean force) {
-            return (sysUiVis & systemUiHideFlag) == 0
-                    && (windowFlags & hideWindowFlag) == 0
-                    && ((windowFlags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0
-                    || force);
-        }
-
         public boolean isPresent(boolean requestedVisible, int windowFlags, boolean force) {
             return requestedVisible
                     && ((windowFlags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0 || force);
@@ -2625,12 +2619,6 @@
                     && ((windowFlags & translucentFlag) == 0  || force);
         }
 
-        // TODO(b/118118435): remove after migration
-        public boolean isVisible(int sysUiVis, int color, int windowFlags, boolean force) {
-            final boolean present = isPresent(sysUiVis, windowFlags, force);
-            return isVisible(present, color, windowFlags, force);
-        }
-
         public boolean isVisible(InsetsState state, int color, int windowFlags, boolean force) {
             final boolean present = isPresent(state.getSource(insetsType).isVisible(), windowFlags,
                     force);
diff --git a/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java b/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java
index a2b1e3d..8412e53 100644
--- a/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java
+++ b/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java
@@ -18,7 +18,6 @@
 
 import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
 import static android.view.InsetsState.ITYPE_STATUS_BAR;
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
 import static android.view.WindowInsets.Type.systemBars;
 
 import static org.junit.Assert.assertEquals;
@@ -42,13 +41,10 @@
 import android.view.SurfaceControl.Transaction;
 import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams;
 import android.view.animation.LinearInterpolator;
-import android.view.test.InsetsModeSession;
 
 import androidx.test.runner.AndroidJUnit4;
 
-import org.junit.AfterClass;
 import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
@@ -76,22 +72,11 @@
     private SurfaceControl mTopLeash;
     private SurfaceControl mNavLeash;
     private InsetsState mInsetsState;
-    private static InsetsModeSession sInsetsModeSession;
 
     @Mock Transaction mMockTransaction;
     @Mock InsetsController mMockController;
     @Mock WindowInsetsAnimationControlListener mMockListener;
 
-    @BeforeClass
-    public static void setupOnce() {
-        sInsetsModeSession = new InsetsModeSession(NEW_INSETS_MODE_FULL);
-    }
-
-    @AfterClass
-    public static void tearDownOnce() {
-        sInsetsModeSession.close();
-    }
-
     @Before
     public void setup() {
         MockitoAnnotations.initMocks(this);
diff --git a/core/tests/coretests/src/android/view/InsetsControllerTest.java b/core/tests/coretests/src/android/view/InsetsControllerTest.java
index 88e1f57..cc97eb5 100644
--- a/core/tests/coretests/src/android/view/InsetsControllerTest.java
+++ b/core/tests/coretests/src/android/view/InsetsControllerTest.java
@@ -26,7 +26,6 @@
 import static android.view.InsetsState.ITYPE_IME;
 import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
 import static android.view.InsetsState.ITYPE_STATUS_BAR;
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
 import static android.view.WindowInsets.Type.ime;
 import static android.view.WindowInsets.Type.navigationBars;
 import static android.view.WindowInsets.Type.statusBars;
@@ -63,7 +62,6 @@
 import android.view.WindowManager.BadTokenException;
 import android.view.WindowManager.LayoutParams;
 import android.view.animation.LinearInterpolator;
-import android.view.test.InsetsModeSession;
 import android.widget.TextView;
 
 import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -72,9 +70,7 @@
 import com.android.server.testutils.OffsettableClock;
 import com.android.server.testutils.TestHandler;
 
-import org.junit.AfterClass;
 import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
@@ -102,17 +98,6 @@
     private TestHost mTestHost;
     private TestHandler mTestHandler;
     private OffsettableClock mTestClock;
-    private static InsetsModeSession sInsetsModeSession;
-
-    @BeforeClass
-    public static void setupOnce() {
-        sInsetsModeSession = new InsetsModeSession(NEW_INSETS_MODE_FULL);
-    }
-
-    @AfterClass
-    public static void tearDownOnce() {
-        sInsetsModeSession.close();
-    }
 
     @Before
     public void setup() {
diff --git a/core/tests/coretests/src/android/view/InsetsStateTest.java b/core/tests/coretests/src/android/view/InsetsStateTest.java
index 4306e3e..afab769 100644
--- a/core/tests/coretests/src/android/view/InsetsStateTest.java
+++ b/core/tests/coretests/src/android/view/InsetsStateTest.java
@@ -31,6 +31,7 @@
 import static android.view.WindowInsets.Type.ime;
 import static android.view.WindowInsets.Type.navigationBars;
 import static android.view.WindowInsets.Type.statusBars;
+import static android.view.WindowInsets.Type.systemBars;
 import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
 import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
 import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
@@ -51,7 +52,6 @@
 import android.platform.test.annotations.Presubmit;
 import android.util.SparseIntArray;
 import android.view.WindowInsets.Type;
-import android.view.test.InsetsModeSession;
 
 import androidx.test.runner.AndroidJUnit4;
 
@@ -75,114 +75,96 @@
     private InsetsState mState2 = new InsetsState();
 
     @Test
-    public void testCalculateInsets() throws Exception {
-        try (final InsetsModeSession session =
-                     new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
-            mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
-            mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
-            mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 100, 300));
-            mState.getSource(ITYPE_IME).setVisible(true);
-            SparseIntArray typeSideMap = new SparseIntArray();
-            WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
-                    false, DisplayCutout.NO_CUTOUT, SOFT_INPUT_ADJUST_RESIZE, 0, 0,
-                    TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, typeSideMap);
-            assertEquals(Insets.of(0, 100, 0, 100), insets.getSystemWindowInsets());
-            assertEquals(Insets.of(0, 100, 0, 100), insets.getInsets(Type.all()));
-            assertEquals(ISIDE_TOP, typeSideMap.get(ITYPE_STATUS_BAR));
-            assertEquals(ISIDE_BOTTOM, typeSideMap.get(ITYPE_IME));
-            assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(Type.statusBars()));
-            assertEquals(Insets.of(0, 0, 0, 100), insets.getInsets(Type.ime()));
-        }
+    public void testCalculateInsets() {
+        mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
+        mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
+        mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 100, 300));
+        mState.getSource(ITYPE_IME).setVisible(true);
+        SparseIntArray typeSideMap = new SparseIntArray();
+        WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
+                false, DisplayCutout.NO_CUTOUT, SOFT_INPUT_ADJUST_RESIZE, 0, 0,
+                TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, typeSideMap);
+        assertEquals(Insets.of(0, 100, 0, 100), insets.getSystemWindowInsets());
+        assertEquals(Insets.of(0, 100, 0, 100), insets.getInsets(Type.all()));
+        assertEquals(ISIDE_TOP, typeSideMap.get(ITYPE_STATUS_BAR));
+        assertEquals(ISIDE_BOTTOM, typeSideMap.get(ITYPE_IME));
+        assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(statusBars()));
+        assertEquals(Insets.of(0, 0, 0, 100), insets.getInsets(ime()));
     }
 
     @Test
-    public void testCalculateInsets_imeAndNav() throws Exception{
-        try (final InsetsModeSession session =
-                     new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
-            mState.getSource(ITYPE_NAVIGATION_BAR).setFrame(new Rect(0, 200, 100, 300));
-            mState.getSource(ITYPE_NAVIGATION_BAR).setVisible(true);
-            mState.getSource(ITYPE_IME).setFrame(new Rect(0, 100, 100, 300));
-            mState.getSource(ITYPE_IME).setVisible(true);
-            WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
-                    false, DisplayCutout.NO_CUTOUT, SOFT_INPUT_ADJUST_RESIZE, 0, 0,
-                    TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
-            assertEquals(100, insets.getStableInsetBottom());
-            assertEquals(Insets.of(0, 0, 0, 100), insets.getInsetsIgnoringVisibility(Type.systemBars()));
-            assertEquals(Insets.of(0, 0, 0, 200), insets.getSystemWindowInsets());
-            assertEquals(Insets.of(0, 0, 0, 200), insets.getInsets(Type.all()));
-            assertEquals(Insets.of(0, 0, 0, 100), insets.getInsets(Type.navigationBars()));
-            assertEquals(Insets.of(0, 0, 0, 200), insets.getInsets(Type.ime()));
-        }
+    public void testCalculateInsets_imeAndNav() {
+        mState.getSource(ITYPE_NAVIGATION_BAR).setFrame(new Rect(0, 200, 100, 300));
+        mState.getSource(ITYPE_NAVIGATION_BAR).setVisible(true);
+        mState.getSource(ITYPE_IME).setFrame(new Rect(0, 100, 100, 300));
+        mState.getSource(ITYPE_IME).setVisible(true);
+        WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
+                false, DisplayCutout.NO_CUTOUT, SOFT_INPUT_ADJUST_RESIZE, 0, 0,
+                TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
+        assertEquals(100, insets.getStableInsetBottom());
+        assertEquals(Insets.of(0, 0, 0, 100), insets.getInsetsIgnoringVisibility(systemBars()));
+        assertEquals(Insets.of(0, 0, 0, 200), insets.getSystemWindowInsets());
+        assertEquals(Insets.of(0, 0, 0, 200), insets.getInsets(Type.all()));
+        assertEquals(Insets.of(0, 0, 0, 100), insets.getInsets(navigationBars()));
+        assertEquals(Insets.of(0, 0, 0, 200), insets.getInsets(ime()));
     }
 
     @Test
-    public void testCalculateInsets_navRightStatusTop() throws Exception {
-        try (final InsetsModeSession session =
-                     new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
-            mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
-            mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
-            mState.getSource(ITYPE_NAVIGATION_BAR).setFrame(new Rect(80, 0, 100, 300));
-            mState.getSource(ITYPE_NAVIGATION_BAR).setVisible(true);
-            WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
-                    false, DisplayCutout.NO_CUTOUT, 0, 0, 0, TYPE_APPLICATION,
-                    WINDOWING_MODE_UNDEFINED, null);
-            assertEquals(Insets.of(0, 100, 20, 0), insets.getSystemWindowInsets());
-            assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(Type.statusBars()));
-            assertEquals(Insets.of(0, 0, 20, 0), insets.getInsets(Type.navigationBars()));
-        }
+    public void testCalculateInsets_navRightStatusTop() {
+        mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
+        mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
+        mState.getSource(ITYPE_NAVIGATION_BAR).setFrame(new Rect(80, 0, 100, 300));
+        mState.getSource(ITYPE_NAVIGATION_BAR).setVisible(true);
+        WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
+                false, DisplayCutout.NO_CUTOUT, 0, 0, 0, TYPE_APPLICATION,
+                WINDOWING_MODE_UNDEFINED, null);
+        assertEquals(Insets.of(0, 100, 20, 0), insets.getSystemWindowInsets());
+        assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(statusBars()));
+        assertEquals(Insets.of(0, 0, 20, 0), insets.getInsets(navigationBars()));
     }
 
     @Test
     public void testCalculateInsets_imeIgnoredWithoutAdjustResize() {
-        try (final InsetsModeSession session =
-                     new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
-            mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
-            mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
-            mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 100, 300));
-            mState.getSource(ITYPE_IME).setVisible(true);
-            WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
-                    false, DisplayCutout.NO_CUTOUT, SOFT_INPUT_ADJUST_NOTHING, 0, 0,
-                    TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
-            assertEquals(0, insets.getSystemWindowInsetBottom());
-            assertEquals(100, insets.getInsets(ime()).bottom);
-            assertTrue(insets.isVisible(ime()));
-        }
+        mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
+        mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
+        mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 100, 300));
+        mState.getSource(ITYPE_IME).setVisible(true);
+        WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
+                false, DisplayCutout.NO_CUTOUT, SOFT_INPUT_ADJUST_NOTHING, 0, 0,
+                TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
+        assertEquals(0, insets.getSystemWindowInsetBottom());
+        assertEquals(100, insets.getInsets(ime()).bottom);
+        assertTrue(insets.isVisible(ime()));
     }
 
     @Test
     public void testCalculateInsets_systemUiFlagLayoutStable() {
-        try (final InsetsModeSession session =
-                     new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
-            mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
-            mState.getSource(ITYPE_STATUS_BAR).setVisible(false);
-            mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 100, 300));
-            mState.getSource(ITYPE_IME).setVisible(true);
-            WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
-                    false, DisplayCutout.NO_CUTOUT, SOFT_INPUT_ADJUST_NOTHING, 0,
-                    SYSTEM_UI_FLAG_LAYOUT_STABLE, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
-            assertEquals(100, insets.getSystemWindowInsetTop());
-            insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false, false,
-                    DisplayCutout.NO_CUTOUT, SOFT_INPUT_ADJUST_NOTHING, 0,
-                    0 /* legacySystemUiFlags */, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
-            assertEquals(0, insets.getSystemWindowInsetTop());
-        }
+        mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
+        mState.getSource(ITYPE_STATUS_BAR).setVisible(false);
+        mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 100, 300));
+        mState.getSource(ITYPE_IME).setVisible(true);
+        WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
+                false, DisplayCutout.NO_CUTOUT, SOFT_INPUT_ADJUST_NOTHING, 0,
+                SYSTEM_UI_FLAG_LAYOUT_STABLE, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
+        assertEquals(100, insets.getSystemWindowInsetTop());
+        insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false, false,
+                DisplayCutout.NO_CUTOUT, SOFT_INPUT_ADJUST_NOTHING, 0,
+                0 /* legacySystemUiFlags */, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
+        assertEquals(0, insets.getSystemWindowInsetTop());
     }
 
     @Test
     public void testCalculateInsets_systemUiFlagLayoutStable_windowFlagFullscreen() {
-        try (final InsetsModeSession session =
-                     new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
-            mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
-            mState.getSource(ITYPE_STATUS_BAR).setVisible(false);
-            WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
-                    false, DisplayCutout.NO_CUTOUT, SOFT_INPUT_ADJUST_NOTHING, FLAG_FULLSCREEN,
-                    SYSTEM_UI_FLAG_LAYOUT_STABLE, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
-            assertEquals(0, insets.getSystemWindowInsetTop());
-            insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false, false,
-                    DisplayCutout.NO_CUTOUT, SOFT_INPUT_ADJUST_NOTHING, 0,
-                    0 /* legacySystemUiFlags */, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
-            assertEquals(0, insets.getSystemWindowInsetTop());
-        }
+        mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
+        mState.getSource(ITYPE_STATUS_BAR).setVisible(false);
+        WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
+                false, DisplayCutout.NO_CUTOUT, SOFT_INPUT_ADJUST_NOTHING, FLAG_FULLSCREEN,
+                SYSTEM_UI_FLAG_LAYOUT_STABLE, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
+        assertEquals(0, insets.getSystemWindowInsetTop());
+        insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false, false,
+                DisplayCutout.NO_CUTOUT, SOFT_INPUT_ADJUST_NOTHING, 0,
+                0 /* legacySystemUiFlags */, TYPE_APPLICATION, WINDOWING_MODE_UNDEFINED, null);
+        assertEquals(0, insets.getSystemWindowInsetTop());
     }
 
     @Test
@@ -209,65 +191,53 @@
 
 
     @Test
-    public void testCalculateInsets_captionStatusBarOverlap() throws Exception {
-        try (InsetsModeSession session =
-                     new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
-            mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
-            mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
-            mState.getSource(ITYPE_CAPTION_BAR).setFrame(new Rect(0, 0, 100, 300));
-            mState.getSource(ITYPE_CAPTION_BAR).setVisible(true);
+    public void testCalculateInsets_captionStatusBarOverlap() {
+        mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
+        mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
+        mState.getSource(ITYPE_CAPTION_BAR).setFrame(new Rect(0, 0, 100, 300));
+        mState.getSource(ITYPE_CAPTION_BAR).setVisible(true);
 
-            Rect visibleInsets = mState.calculateVisibleInsets(
-                    new Rect(0, 0, 100, 400), SOFT_INPUT_ADJUST_NOTHING);
-            assertEquals(new Rect(0, 300, 0, 0), visibleInsets);
-        }
+        Rect visibleInsets = mState.calculateVisibleInsets(
+                new Rect(0, 0, 100, 400), SOFT_INPUT_ADJUST_NOTHING);
+        assertEquals(new Rect(0, 300, 0, 0), visibleInsets);
     }
 
     @Test
-    public void testCalculateInsets_captionBarOffset() throws Exception {
-        try (InsetsModeSession session =
-                     new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
-            mState.getSource(ITYPE_CAPTION_BAR).setFrame(new Rect(0, 0, 100, 300));
-            mState.getSource(ITYPE_CAPTION_BAR).setVisible(true);
+    public void testCalculateInsets_captionBarOffset() {
+        mState.getSource(ITYPE_CAPTION_BAR).setFrame(new Rect(0, 0, 100, 300));
+        mState.getSource(ITYPE_CAPTION_BAR).setVisible(true);
 
-            Rect visibleInsets = mState.calculateVisibleInsets(
-                    new Rect(0, 0, 150, 400), SOFT_INPUT_ADJUST_NOTHING);
-            assertEquals(new Rect(0, 300, 0, 0), visibleInsets);
-        }
+        Rect visibleInsets = mState.calculateVisibleInsets(
+                new Rect(0, 0, 150, 400), SOFT_INPUT_ADJUST_NOTHING);
+        assertEquals(new Rect(0, 300, 0, 0), visibleInsets);
     }
 
     @Test
-    public void testCalculateInsets_extraNavRightStatusTop() throws Exception {
-        try (InsetsModeSession session =
-                     new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
-            mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
-            mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
-            mState.getSource(ITYPE_EXTRA_NAVIGATION_BAR).setFrame(new Rect(80, 0, 100, 300));
-            mState.getSource(ITYPE_EXTRA_NAVIGATION_BAR).setVisible(true);
-            WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
-                    false, DisplayCutout.NO_CUTOUT, 0, 0, 0, TYPE_APPLICATION,
-                    WINDOWING_MODE_UNDEFINED, null);
-            assertEquals(Insets.of(0, 100, 20, 0), insets.getSystemWindowInsets());
-            assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(Type.statusBars()));
-            assertEquals(Insets.of(0, 0, 20, 0), insets.getInsets(Type.navigationBars()));
-        }
+    public void testCalculateInsets_extraNavRightStatusTop() {
+        mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
+        mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
+        mState.getSource(ITYPE_EXTRA_NAVIGATION_BAR).setFrame(new Rect(80, 0, 100, 300));
+        mState.getSource(ITYPE_EXTRA_NAVIGATION_BAR).setVisible(true);
+        WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
+                false, DisplayCutout.NO_CUTOUT, 0, 0, 0, TYPE_APPLICATION,
+                WINDOWING_MODE_UNDEFINED, null);
+        assertEquals(Insets.of(0, 100, 20, 0), insets.getSystemWindowInsets());
+        assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(statusBars()));
+        assertEquals(Insets.of(0, 0, 20, 0), insets.getInsets(navigationBars()));
     }
 
     @Test
-    public void testCalculateInsets_navigationRightClimateTop() throws Exception {
-        try (InsetsModeSession session =
-                     new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
-            mState.getSource(ITYPE_CLIMATE_BAR).setFrame(new Rect(0, 0, 100, 100));
-            mState.getSource(ITYPE_CLIMATE_BAR).setVisible(true);
-            mState.getSource(ITYPE_NAVIGATION_BAR).setFrame(new Rect(80, 0, 100, 300));
-            mState.getSource(ITYPE_NAVIGATION_BAR).setVisible(true);
-            WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
-                    false, DisplayCutout.NO_CUTOUT, 0, 0, 0, TYPE_APPLICATION,
-                    WINDOWING_MODE_UNDEFINED, null);
-            assertEquals(Insets.of(0, 100, 20, 0), insets.getSystemWindowInsets());
-            assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(Type.statusBars()));
-            assertEquals(Insets.of(0, 0, 20, 0), insets.getInsets(Type.navigationBars()));
-        }
+    public void testCalculateInsets_navigationRightClimateTop() {
+        mState.getSource(ITYPE_CLIMATE_BAR).setFrame(new Rect(0, 0, 100, 100));
+        mState.getSource(ITYPE_CLIMATE_BAR).setVisible(true);
+        mState.getSource(ITYPE_NAVIGATION_BAR).setFrame(new Rect(80, 0, 100, 300));
+        mState.getSource(ITYPE_NAVIGATION_BAR).setVisible(true);
+        WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), null, false,
+                false, DisplayCutout.NO_CUTOUT, 0, 0, 0, TYPE_APPLICATION,
+                WINDOWING_MODE_UNDEFINED, null);
+        assertEquals(Insets.of(0, 100, 20, 0), insets.getSystemWindowInsets());
+        assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(statusBars()));
+        assertEquals(Insets.of(0, 0, 20, 0), insets.getInsets(navigationBars()));
     }
 
     @Test
@@ -371,59 +341,51 @@
     }
 
     @Test
-    public void testCalculateVisibleInsets() throws Exception {
-        try (final InsetsModeSession session =
-                     new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
-            mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
-            mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
-            mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 100, 300));
-            mState.getSource(ITYPE_IME).setVisible(true);
+    public void testCalculateVisibleInsets() {
+        mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
+        mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
+        mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 100, 300));
+        mState.getSource(ITYPE_IME).setVisible(true);
 
-            // Make sure bottom gestures are ignored
-            mState.getSource(ITYPE_BOTTOM_GESTURES).setFrame(new Rect(0, 100, 100, 300));
-            mState.getSource(ITYPE_BOTTOM_GESTURES).setVisible(true);
-            Rect visibleInsets = mState.calculateVisibleInsets(
-                    new Rect(0, 0, 100, 300), SOFT_INPUT_ADJUST_PAN);
-            assertEquals(new Rect(0, 100, 0, 100), visibleInsets);
-        }
+        // Make sure bottom gestures are ignored
+        mState.getSource(ITYPE_BOTTOM_GESTURES).setFrame(new Rect(0, 100, 100, 300));
+        mState.getSource(ITYPE_BOTTOM_GESTURES).setVisible(true);
+        Rect visibleInsets = mState.calculateVisibleInsets(
+                new Rect(0, 0, 100, 300), SOFT_INPUT_ADJUST_PAN);
+        assertEquals(new Rect(0, 100, 0, 100), visibleInsets);
     }
 
     @Test
-    public void testCalculateVisibleInsets_adjustNothing() throws Exception {
-        try (final InsetsModeSession session =
-                     new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
-            mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
-            mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
-            mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 100, 300));
-            mState.getSource(ITYPE_IME).setVisible(true);
+    public void testCalculateVisibleInsets_adjustNothing() {
+        mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
+        mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
+        mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 100, 300));
+        mState.getSource(ITYPE_IME).setVisible(true);
 
-            // Make sure bottom gestures are ignored
-            mState.getSource(ITYPE_BOTTOM_GESTURES).setFrame(new Rect(0, 100, 100, 300));
-            mState.getSource(ITYPE_BOTTOM_GESTURES).setVisible(true);
-            Rect visibleInsets = mState.calculateVisibleInsets(
-                    new Rect(0, 0, 100, 300), SOFT_INPUT_ADJUST_NOTHING);
-            assertEquals(new Rect(0, 100, 0, 0), visibleInsets);
-        }
+        // Make sure bottom gestures are ignored
+        mState.getSource(ITYPE_BOTTOM_GESTURES).setFrame(new Rect(0, 100, 100, 300));
+        mState.getSource(ITYPE_BOTTOM_GESTURES).setVisible(true);
+        Rect visibleInsets = mState.calculateVisibleInsets(
+                new Rect(0, 0, 100, 300), SOFT_INPUT_ADJUST_NOTHING);
+        assertEquals(new Rect(0, 100, 0, 0), visibleInsets);
     }
 
     @Test
-    public void testCalculateUncontrollableInsets() throws Exception {
-        try (InsetsModeSession session = new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
-            mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 200, 100));
-            mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
-            mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 200, 300));
-            mState.getSource(ITYPE_IME).setVisible(true);
-            mState.getSource(ITYPE_NAVIGATION_BAR).setFrame(new Rect(100, 0, 200, 300));
-            mState.getSource(ITYPE_NAVIGATION_BAR).setVisible(true);
+    public void testCalculateUncontrollableInsets() {
+        mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 200, 100));
+        mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
+        mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 200, 300));
+        mState.getSource(ITYPE_IME).setVisible(true);
+        mState.getSource(ITYPE_NAVIGATION_BAR).setFrame(new Rect(100, 0, 200, 300));
+        mState.getSource(ITYPE_NAVIGATION_BAR).setVisible(true);
 
-            mState.setDisplayFrame(new Rect(0, 0, 200, 300));
-            assertEquals(0,
-                    mState.calculateUncontrollableInsetsFromFrame(new Rect(0, 0, 200, 300)));
-            assertEquals(statusBars() | ime(),
-                    mState.calculateUncontrollableInsetsFromFrame(new Rect(0, 50, 200, 250)));
-            assertEquals(navigationBars(),
-                    mState.calculateUncontrollableInsetsFromFrame(new Rect(50, 0, 150, 300)));
-        }
+        mState.setDisplayFrame(new Rect(0, 0, 200, 300));
+        assertEquals(0,
+                mState.calculateUncontrollableInsetsFromFrame(new Rect(0, 0, 200, 300)));
+        assertEquals(statusBars() | ime(),
+                mState.calculateUncontrollableInsetsFromFrame(new Rect(0, 50, 200, 250)));
+        assertEquals(navigationBars(),
+                mState.calculateUncontrollableInsetsFromFrame(new Rect(50, 0, 150, 300)));
     }
 
     private void assertEqualsAndHashCode() {
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
index 4115829..b62ea6b 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java
@@ -15,8 +15,6 @@
  */
 package com.android.keyguard;
 
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
-import static android.view.ViewRootImpl.sNewInsetsMode;
 import static android.view.WindowInsets.Type.ime;
 import static android.view.WindowInsets.Type.systemBars;
 import static android.view.WindowInsetsAnimation.Callback.DISPATCH_MODE_STOP;
@@ -401,14 +399,9 @@
     public WindowInsets onApplyWindowInsets(WindowInsets insets) {
 
         // Consume bottom insets because we're setting the padding locally (for IME and navbar.)
-        int inset;
-        if (sNewInsetsMode == NEW_INSETS_MODE_FULL) {
-            int bottomInset = insets.getInsetsIgnoringVisibility(systemBars()).bottom;
-            int imeInset = insets.getInsets(ime()).bottom;
-            inset = max(bottomInset, imeInset);
-        } else {
-            inset = insets.getSystemWindowInsetBottom();
-        }
+        int bottomInset = insets.getInsetsIgnoringVisibility(systemBars()).bottom;
+        int imeInset = insets.getInsets(ime()).bottom;
+        int inset = max(bottomInset, imeInset);
         setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), inset);
         return insets.inset(0, 0, 0, inset);
     }
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
index f98bb33..ec60cbd 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java
@@ -16,15 +16,12 @@
 
 package com.android.systemui.bubbles;
 
-import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
 import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
 import static android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
 import static android.graphics.PixelFormat.TRANSPARENT;
 import static android.view.Display.INVALID_DISPLAY;
 import static android.view.InsetsState.ITYPE_IME;
 import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
-import static android.view.ViewRootImpl.sNewInsetsMode;
 import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
 import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
 import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
@@ -48,7 +45,6 @@
 import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.graphics.Color;
-import android.graphics.Insets;
 import android.graphics.Outline;
 import android.graphics.Point;
 import android.graphics.Rect;
@@ -471,11 +467,7 @@
         mKeyboardVisible = false;
         mNeedsNewHeight = false;
         if (mActivityView != null) {
-            if (sNewInsetsMode == NEW_INSETS_MODE_FULL) {
-                setImeWindowToDisplay(0, 0);
-            } else {
-                mActivityView.setForwardedInsets(Insets.of(0, 0, 0, 0));
-            }
+            setImeWindowToDisplay(0, 0);
         }
         if (DEBUG_BUBBLE_EXPANDED_VIEW) {
             Log.d(TAG, "onDetachedFromWindow: bubble=" + getBubbleKey());
@@ -525,13 +517,7 @@
                     insets.getDisplayCutout() != null
                             ? insets.getDisplayCutout().getSafeInsetBottom()
                             : 0);
-            final int insetsBottom = Math.max(activityViewBottom - keyboardTop, 0);
-
-            if (sNewInsetsMode == NEW_INSETS_MODE_FULL) {
-                setImeWindowToDisplay(getWidth(), insetsBottom);
-            } else {
-                mActivityView.setForwardedInsets(Insets.of(0, 0, 0, insetsBottom));
-            }
+            setImeWindowToDisplay(getWidth(), Math.max(activityViewBottom - keyboardTop, 0));
         }
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
index 51209d1..9e2e57e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -16,8 +16,6 @@
 
 package com.android.systemui.statusbar.phone;
 
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
-import static android.view.ViewRootImpl.sNewInsetsMode;
 import static android.view.WindowInsets.Type.navigationBars;
 
 import static com.android.systemui.plugins.ActivityStarter.OnDismissAction;
@@ -803,12 +801,8 @@
     private Runnable mMakeNavigationBarVisibleRunnable = new Runnable() {
         @Override
         public void run() {
-            if (ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_FULL) {
-                mStatusBar.getNotificationShadeWindowView().getWindowInsetsController()
-                        .show(navigationBars());
-            } else {
-                mStatusBar.getNavigationBarView().getRootView().setVisibility(View.VISIBLE);
-            }
+            mStatusBar.getNotificationShadeWindowView().getWindowInsetsController()
+                    .show(navigationBars());
         }
     };
 
@@ -876,12 +870,8 @@
                 }
             } else {
                 mContainer.removeCallbacks(mMakeNavigationBarVisibleRunnable);
-                if (sNewInsetsMode == NEW_INSETS_MODE_FULL) {
-                    mStatusBar.getNotificationShadeWindowView().getWindowInsetsController()
-                            .hide(navigationBars());
-                } else {
-                    mStatusBar.getNavigationBarView().getRootView().setVisibility(View.GONE);
-                }
+                mStatusBar.getNotificationShadeWindowView().getWindowInsetsController()
+                        .hide(navigationBars());
             }
         }
     }
diff --git a/services/core/java/com/android/server/wm/InsetsPolicy.java b/services/core/java/com/android/server/wm/InsetsPolicy.java
index 18a2503..0c9c87a 100644
--- a/services/core/java/com/android/server/wm/InsetsPolicy.java
+++ b/services/core/java/com/android/server/wm/InsetsPolicy.java
@@ -41,7 +41,6 @@
 import android.view.InsetsState.InternalInsetsType;
 import android.view.SurfaceControl;
 import android.view.SyncRtSurfaceTransactionApplier;
-import android.view.ViewRootImpl;
 import android.view.WindowInsetsAnimation;
 import android.view.WindowInsetsAnimation.Bounds;
 import android.view.WindowInsetsAnimationControlListener;
@@ -139,9 +138,6 @@
                 getFakeControlTarget(focusedWin, statusControlTarget),
                 navControlTarget,
                 getFakeControlTarget(focusedWin, navControlTarget));
-        if (ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL) {
-            return;
-        }
         mStatusBar.updateVisibility(statusControlTarget, ITYPE_STATUS_BAR);
         mNavBar.updateVisibility(navControlTarget, ITYPE_NAVIGATION_BAR);
         mPolicy.updateHideNavInputEventReceiver();
diff --git a/services/core/java/com/android/server/wm/InsetsSourceProvider.java b/services/core/java/com/android/server/wm/InsetsSourceProvider.java
index e00c9e7..a7f32c0 100644
--- a/services/core/java/com/android/server/wm/InsetsSourceProvider.java
+++ b/services/core/java/com/android/server/wm/InsetsSourceProvider.java
@@ -19,10 +19,6 @@
 import static android.view.InsetsState.ITYPE_IME;
 import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
 import static android.view.InsetsState.ITYPE_STATUS_BAR;
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_IME;
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE;
-import static android.view.ViewRootImpl.sNewInsetsMode;
 
 import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_IME;
 import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_INSETS_CONTROL;
@@ -93,13 +89,14 @@
         mFakeControl = new InsetsSourceControl(source.getType(), null /* leash */,
                 new Point());
 
-        final int type = source.getType();
-        if (type == ITYPE_STATUS_BAR || type == ITYPE_NAVIGATION_BAR) {
-            mControllable = sNewInsetsMode == NEW_INSETS_MODE_FULL;
-        } else if (type == ITYPE_IME) {
-            mControllable = sNewInsetsMode >= NEW_INSETS_MODE_IME;
-        } else {
-            mControllable = false;
+        switch (source.getType()) {
+            case ITYPE_STATUS_BAR:
+            case ITYPE_NAVIGATION_BAR:
+            case ITYPE_IME:
+                mControllable = true;
+                break;
+            default:
+                mControllable = false;
         }
     }
 
@@ -395,7 +392,7 @@
     }
 
     boolean isClientVisible() {
-        return sNewInsetsMode == NEW_INSETS_MODE_NONE || mClientVisible;
+        return mClientVisible;
     }
 
     /**
diff --git a/services/core/java/com/android/server/wm/InsetsStateController.java b/services/core/java/com/android/server/wm/InsetsStateController.java
index 5520ad3..c0bdbff 100644
--- a/services/core/java/com/android/server/wm/InsetsStateController.java
+++ b/services/core/java/com/android/server/wm/InsetsStateController.java
@@ -24,8 +24,6 @@
 import static android.view.InsetsState.ITYPE_INVALID;
 import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
 import static android.view.InsetsState.ITYPE_STATUS_BAR;
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
-import static android.view.ViewRootImpl.sNewInsetsMode;
 import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
 import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
 import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
@@ -382,9 +380,6 @@
      */
     void onControlFakeTargetChanged(@InternalInsetsType int type,
             @Nullable InsetsControlTarget fakeTarget) {
-        if (sNewInsetsMode != NEW_INSETS_MODE_FULL) {
-            return;
-        }
         final InsetsControlTarget previous = mTypeFakeControlTargetMap.get(type);
         if (fakeTarget == previous) {
             return;
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotController.java b/services/core/java/com/android/server/wm/TaskSnapshotController.java
index f39fa1b..b475846d6 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotController.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotController.java
@@ -487,7 +487,7 @@
         mergeInsetsSources(insetsState, mainWindow.getRequestedInsetsState());
         final Rect systemBarInsets = getSystemBarInsets(mainWindow.getFrame(), insetsState);
         final SystemBarBackgroundPainter decorPainter = new SystemBarBackgroundPainter(attrs.flags,
-                attrs.privateFlags, attrs.systemUiVisibility, task.getTaskDescription(),
+                attrs.privateFlags, attrs.insetsFlags.appearance, task.getTaskDescription(),
                 mHighResTaskSnapshotScale, insetsState);
         final int taskWidth = task.getBounds().width();
         final int taskHeight = task.getBounds().height();
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotSurface.java b/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
index 100f1bf..c4ca989 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
@@ -19,8 +19,8 @@
 import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
 import static android.graphics.Color.WHITE;
 import static android.graphics.Color.alpha;
-import static android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
-import static android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
+import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
+import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
 import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
 import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
 import static android.view.WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES;
@@ -75,7 +75,6 @@
 import android.view.SurfaceSession;
 import android.view.View;
 import android.view.ViewGroup.LayoutParams;
-import android.view.ViewRootImpl;
 import android.view.WindowManager;
 import android.view.WindowManagerGlobal;
 import android.window.ClientWindowFrames;
@@ -167,7 +166,7 @@
         final TaskDescription taskDescription = new TaskDescription();
         taskDescription.setBackgroundColor(WHITE);
         final WindowState topFullscreenOpaqueWindow;
-        final int sysUiVis;
+        final int appearance;
         final int windowFlags;
         final int windowPrivateFlags;
         final int currentOrientation;
@@ -204,8 +203,8 @@
                         topFullscreenActivity, false /* checkOpening */);
             }
 
-            sysUiVis = topFullscreenOpaqueWindow.getSystemUiVisibility();
             WindowManager.LayoutParams attrs = topFullscreenOpaqueWindow.mAttrs;
+            appearance = attrs.insetsFlags.appearance;
             windowFlags = attrs.flags;
             windowPrivateFlags = attrs.privateFlags;
 
@@ -221,11 +220,8 @@
             layoutParams.token = activity.token;
             layoutParams.width = LayoutParams.MATCH_PARENT;
             layoutParams.height = LayoutParams.MATCH_PARENT;
-            layoutParams.systemUiVisibility = sysUiVis;
-            layoutParams.insetsFlags.behavior
-                    = topFullscreenOpaqueWindow.mAttrs.insetsFlags.behavior;
-            layoutParams.insetsFlags.appearance
-                    = topFullscreenOpaqueWindow.mAttrs.insetsFlags.appearance;
+            layoutParams.insetsFlags.appearance = appearance;
+            layoutParams.insetsFlags.behavior = attrs.insetsFlags.behavior;
             layoutParams.layoutInDisplayCutoutMode = attrs.layoutInDisplayCutoutMode;
             layoutParams.setFitInsetsTypes(attrs.getFitInsetsTypes());
             layoutParams.setFitInsetsSides(attrs.getFitInsetsSides());
@@ -261,7 +257,7 @@
             // Local call.
         }
         final TaskSnapshotSurface snapshotSurface = new TaskSnapshotSurface(service, window,
-                surfaceControl, snapshot, layoutParams.getTitle(), taskDescription, sysUiVis,
+                surfaceControl, snapshot, layoutParams.getTitle(), taskDescription, appearance,
                 windowFlags, windowPrivateFlags, taskBounds, currentOrientation, activityType,
                 insetsState);
         window.setOuter(snapshotSurface);
@@ -282,7 +278,7 @@
     @VisibleForTesting
     TaskSnapshotSurface(WindowManagerService service, Window window, SurfaceControl surfaceControl,
             TaskSnapshot snapshot, CharSequence title, TaskDescription taskDescription,
-            int sysUiVis, int windowFlags, int windowPrivateFlags, Rect taskBounds,
+            int appearance, int windowFlags, int windowPrivateFlags, Rect taskBounds,
             int currentOrientation, int activityType, InsetsState insetsState) {
         mService = service;
         mSurface = service.mSurfaceFactory.get();
@@ -296,7 +292,7 @@
         mBackgroundPaint.setColor(backgroundColor != 0 ? backgroundColor : WHITE);
         mTaskBounds = taskBounds;
         mSystemBarBackgroundPainter = new SystemBarBackgroundPainter(windowFlags,
-                windowPrivateFlags, sysUiVis, taskDescription, 1f, insetsState);
+                windowPrivateFlags, appearance, taskDescription, 1f, insetsState);
         mStatusBarColor = taskDescription.getStatusBarColor();
         mOrientationOnCreation = currentOrientation;
         mActivityType = activityType;
@@ -554,28 +550,26 @@
         private final int mNavigationBarColor;
         private final int mWindowFlags;
         private final int mWindowPrivateFlags;
-        private final int mSysUiVis;
         private final float mScale;
         private final InsetsState mInsetsState;
         private final Rect mSystemBarInsets = new Rect();
 
-        SystemBarBackgroundPainter(int windowFlags, int windowPrivateFlags, int sysUiVis,
+        SystemBarBackgroundPainter(int windowFlags, int windowPrivateFlags, int appearance,
                 TaskDescription taskDescription, float scale, InsetsState insetsState) {
             mWindowFlags = windowFlags;
             mWindowPrivateFlags = windowPrivateFlags;
-            mSysUiVis = sysUiVis;
             mScale = scale;
             final Context context = ActivityThread.currentActivityThread().getSystemUiContext();
             final int semiTransparent = context.getColor(
                     R.color.system_bar_background_semi_transparent);
             mStatusBarColor = DecorView.calculateBarColor(windowFlags, FLAG_TRANSLUCENT_STATUS,
-                    semiTransparent, taskDescription.getStatusBarColor(), sysUiVis,
-                    SYSTEM_UI_FLAG_LIGHT_STATUS_BAR,
+                    semiTransparent, taskDescription.getStatusBarColor(), appearance,
+                    APPEARANCE_LIGHT_STATUS_BARS,
                     taskDescription.getEnsureStatusBarContrastWhenTransparent());
             mNavigationBarColor = DecorView.calculateBarColor(windowFlags,
                     FLAG_TRANSLUCENT_NAVIGATION, semiTransparent,
-                    taskDescription.getNavigationBarColor(), sysUiVis,
-                    SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR,
+                    taskDescription.getNavigationBarColor(), appearance,
+                    APPEARANCE_LIGHT_NAVIGATION_BARS,
                     taskDescription.getEnsureNavigationBarContrastWhenTransparent()
                             && context.getResources().getBoolean(R.bool.config_navBarNeedsScrim));
             mStatusBarPaint.setColor(mStatusBarColor);
@@ -590,11 +584,8 @@
         int getStatusBarColorViewHeight() {
             final boolean forceBarBackground =
                     (mWindowPrivateFlags & PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS) != 0;
-            if (ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL
-                    ? STATUS_BAR_COLOR_VIEW_ATTRIBUTES.isVisible(
-                            mSysUiVis, mStatusBarColor, mWindowFlags, forceBarBackground)
-                    : STATUS_BAR_COLOR_VIEW_ATTRIBUTES.isVisible(
-                            mInsetsState, mStatusBarColor, mWindowFlags, forceBarBackground)) {
+            if (STATUS_BAR_COLOR_VIEW_ATTRIBUTES.isVisible(
+                    mInsetsState, mStatusBarColor, mWindowFlags, forceBarBackground)) {
                 return (int) (mSystemBarInsets.top * mScale);
             } else {
                 return 0;
@@ -604,11 +595,8 @@
         private boolean isNavigationBarColorViewVisible() {
             final boolean forceBarBackground =
                     (mWindowPrivateFlags & PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS) != 0;
-            return ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL
-                    ? NAVIGATION_BAR_COLOR_VIEW_ATTRIBUTES.isVisible(
-                            mSysUiVis, mNavigationBarColor, mWindowFlags, forceBarBackground)
-                    : NAVIGATION_BAR_COLOR_VIEW_ATTRIBUTES.isVisible(
-                            mInsetsState, mNavigationBarColor, mWindowFlags, forceBarBackground);
+            return NAVIGATION_BAR_COLOR_VIEW_ATTRIBUTES.isVisible(
+                    mInsetsState, mNavigationBarColor, mWindowFlags, forceBarBackground);
         }
 
         void drawDecors(Canvas c, @Nullable Rect alreadyDrawnFrame) {
diff --git a/services/tests/wmtests/src/com/android/server/wm/InsetsPolicyTest.java b/services/tests/wmtests/src/com/android/server/wm/InsetsPolicyTest.java
index 608305c..821480d 100644
--- a/services/tests/wmtests/src/com/android/server/wm/InsetsPolicyTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/InsetsPolicyTest.java
@@ -22,7 +22,6 @@
 import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
 import static android.view.InsetsState.ITYPE_STATUS_BAR;
 import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
 import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
 import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR;
 import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION;
@@ -45,13 +44,10 @@
 import android.platform.test.annotations.Presubmit;
 import android.view.InsetsSourceControl;
 import android.view.InsetsState;
-import android.view.test.InsetsModeSession;
 
 import androidx.test.filters.SmallTest;
 
-import org.junit.AfterClass;
 import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -59,19 +55,6 @@
 @Presubmit
 @RunWith(WindowTestRunner.class)
 public class InsetsPolicyTest extends WindowTestsBase {
-    private static InsetsModeSession sInsetsModeSession;
-
-    @BeforeClass
-    public static void setUpOnce() {
-        // To let the insets provider control the insets visibility, the insets mode has to be
-        // NEW_INSETS_MODE_FULL.
-        sInsetsModeSession = new InsetsModeSession(NEW_INSETS_MODE_FULL);
-    }
-
-    @AfterClass
-    public static void tearDownOnce() {
-        sInsetsModeSession.close();
-    }
 
     @Before
     public void setup() {
diff --git a/services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java
index 59f8cc8..4a49743 100644
--- a/services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/InsetsStateControllerTest.java
@@ -23,7 +23,6 @@
 import static android.view.InsetsState.ITYPE_IME;
 import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
 import static android.view.InsetsState.ITYPE_STATUS_BAR;
-import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
 import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
 import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
@@ -43,15 +42,11 @@
 
 import android.graphics.Rect;
 import android.platform.test.annotations.Presubmit;
-import android.util.IntArray;
 import android.view.InsetsSourceControl;
 import android.view.InsetsState;
-import android.view.test.InsetsModeSession;
 
 import androidx.test.filters.SmallTest;
 
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -59,19 +54,6 @@
 @Presubmit
 @RunWith(WindowTestRunner.class)
 public class InsetsStateControllerTest extends WindowTestsBase {
-    private static InsetsModeSession sInsetsModeSession;
-
-    @BeforeClass
-    public static void setUpOnce() {
-        // To let the insets provider control the insets visibility, the insets mode has to be
-        // NEW_INSETS_MODE_FULL.
-        sInsetsModeSession = new InsetsModeSession(NEW_INSETS_MODE_FULL);
-    }
-
-    @AfterClass
-    public static void tearDownOnce() {
-        sInsetsModeSession.close();
-    }
 
     @Test
     public void testStripForDispatch_notOwn() {
diff --git a/tests/utils/testutils/java/android/view/test/InsetsModeSession.java b/tests/utils/testutils/java/android/view/test/InsetsModeSession.java
deleted file mode 100644
index e05fdce..0000000
--- a/tests/utils/testutils/java/android/view/test/InsetsModeSession.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.view.test;
-
-import android.view.ViewRootImpl;
-
-/**
- * Session to set insets mode for {@link ViewRootImpl#sNewInsetsMode}.
- */
-public class InsetsModeSession implements AutoCloseable {
-
-    private int mOldMode;
-
-    public InsetsModeSession(int flag) {
-        mOldMode = ViewRootImpl.sNewInsetsMode;
-        ViewRootImpl.sNewInsetsMode = flag;
-    }
-
-    @Override
-    public void close() {
-        ViewRootImpl.sNewInsetsMode = mOldMode;
-    }
-}