Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 48156c7f authored by Yunfan Chen's avatar Yunfan Chen
Browse files

Cleanup non-flexible insets logic

This CL removes the old non-flexible insets logic, as well as the flags
to control the two solutions.

Besides, this CL removed the old logic in calculating nav bar position
which is in effect even after the flexible flag is on when the
navigation bar doesn't exists. Adjusted TestDisplayContent to make tests
working with the modification.

Bug: 161689946
Test: m checkbuild
Test: atest DisplayPolicyTests
Test: atest ActivityRecordTests
Change-Id: I04af809b5ff1ea43772a41d36ed6d97fb80ee02e
parent 2f8ddace
Loading
Loading
Loading
Loading
+0 −15
Original line number Original line Diff line number Diff line
@@ -294,21 +294,6 @@ public final class ViewRootImpl implements ViewParent,
     */
     */
    private static final int SCROLL_CAPTURE_REQUEST_TIMEOUT_MILLIS = 2500;
    private static final int SCROLL_CAPTURE_REQUEST_TIMEOUT_MILLIS = 2500;


    /**
     * If set to {@code true}, the new logic to layout system bars as normal window and to use
     * layout result to get insets will be applied. Otherwise, the old hard-coded window logic will
     * be applied.
     */
    private static final String USE_FLEXIBLE_INSETS = "persist.debug.flexible_insets";

    /**
     * A flag to indicate to use the new generalized insets window logic, or the old hard-coded
     * insets window layout logic.
     * {@hide}
     */
    public static final boolean INSETS_LAYOUT_GENERALIZATION =
            SystemProperties.getBoolean(USE_FLEXIBLE_INSETS, true);

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    static final ThreadLocal<HandlerActionQueue> sRunQueues = new ThreadLocal<HandlerActionQueue>();
    static final ThreadLocal<HandlerActionQueue> sRunQueues = new ThreadLocal<HandlerActionQueue>();


+40 −45
Original line number Original line Diff line number Diff line
@@ -30,7 +30,6 @@ import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_NAVIGAT
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
import static android.view.InsetsState.containsType;
import static android.view.InsetsState.containsType;
import static android.view.ViewRootImpl.INSETS_LAYOUT_GENERALIZATION;
import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS;
import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS;
import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_NAVIGATION_BARS;
import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_NAVIGATION_BARS;
import static android.view.WindowInsetsController.APPEARANCE_SEMI_TRANSPARENT_NAVIGATION_BARS;
import static android.view.WindowInsetsController.APPEARANCE_SEMI_TRANSPARENT_NAVIGATION_BARS;
@@ -131,10 +130,10 @@ import com.android.systemui.navigationbar.gestural.QuickswitchOrientedNavHandle;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.Recents;
import com.android.systemui.shared.rotation.RotationButton;
import com.android.systemui.shared.rotation.RotationButtonController;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.shared.recents.utilities.Utilities;
import com.android.systemui.shared.recents.utilities.Utilities;
import com.android.systemui.shared.rotation.RotationButton;
import com.android.systemui.shared.rotation.RotationButtonController;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.statusbar.AutoHideUiElement;
import com.android.systemui.statusbar.AutoHideUiElement;
@@ -1606,7 +1605,6 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
        int height = WindowManager.LayoutParams.MATCH_PARENT;
        int height = WindowManager.LayoutParams.MATCH_PARENT;
        int insetsHeight = -1;
        int insetsHeight = -1;
        int gravity = Gravity.BOTTOM;
        int gravity = Gravity.BOTTOM;
        if (INSETS_LAYOUT_GENERALIZATION) {
        boolean navBarCanMove = true;
        boolean navBarCanMove = true;
        if (mWindowManager != null && mWindowManager.getCurrentWindowMetrics() != null) {
        if (mWindowManager != null && mWindowManager.getCurrentWindowMetrics() != null) {
            Rect displaySize = mWindowManager.getCurrentWindowMetrics().getBounds();
            Rect displaySize = mWindowManager.getCurrentWindowMetrics().getBounds();
@@ -1641,7 +1639,6 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
                    break;
                    break;
            }
            }
        }
        }
        }
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                width,
                width,
                height,
                height,
@@ -1653,14 +1650,12 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
                        | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH
                        | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH
                        | WindowManager.LayoutParams.FLAG_SLIPPERY,
                        | WindowManager.LayoutParams.FLAG_SLIPPERY,
                PixelFormat.TRANSLUCENT);
                PixelFormat.TRANSLUCENT);
        if (INSETS_LAYOUT_GENERALIZATION) {
        lp.gravity = gravity;
        lp.gravity = gravity;
        if (insetsHeight != -1) {
        if (insetsHeight != -1) {
            lp.providedInternalInsets = Insets.of(0, height - insetsHeight, 0, 0);
            lp.providedInternalInsets = Insets.of(0, height - insetsHeight, 0, 0);
        } else {
        } else {
            lp.providedInternalInsets = Insets.NONE;
            lp.providedInternalInsets = Insets.NONE;
        }
        }
        }
        lp.token = new Binder();
        lp.token = new Binder();
        lp.accessibilityTitle = mContext.getString(R.string.nav_bar);
        lp.accessibilityTitle = mContext.getString(R.string.nav_bar);
        lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC;
        lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC;
+1 −21
Original line number Original line Diff line number Diff line
@@ -16,8 +16,6 @@


package com.android.systemui.statusbar.phone;
package com.android.systemui.statusbar.phone;


import static android.app.WindowConfiguration.ROTATION_UNDEFINED;
import static android.view.ViewRootImpl.INSETS_LAYOUT_GENERALIZATION;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR;
@@ -136,25 +134,7 @@ public class StatusBarWindowController {
    }
    }


    private WindowManager.LayoutParams getBarLayoutParamsForRotation(int rotation) {
    private WindowManager.LayoutParams getBarLayoutParamsForRotation(int rotation) {
        int height = mBarHeight;
        int height = SystemBarUtils.getStatusBarHeightForRotation(mContext, rotation);
        if (INSETS_LAYOUT_GENERALIZATION) {
            switch (rotation) {
                case ROTATION_UNDEFINED:
                case Surface.ROTATION_0:
                case Surface.ROTATION_180:
                    height = SystemBarUtils.getStatusBarHeightForRotation(
                            mContext, Surface.ROTATION_0);
                    break;
                case Surface.ROTATION_90:
                    height = SystemBarUtils.getStatusBarHeightForRotation(
                            mContext, Surface.ROTATION_90);
                    break;
                case Surface.ROTATION_270:
                    height = SystemBarUtils.getStatusBarHeightForRotation(
                            mContext, Surface.ROTATION_270);
                    break;
            }
        }
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.MATCH_PARENT,
                height,
                height,
+1 −1
Original line number Original line Diff line number Diff line
@@ -9032,7 +9032,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                final int dh = rotated ? display.mBaseDisplayWidth : display.mBaseDisplayHeight;
                final int dh = rotated ? display.mBaseDisplayWidth : display.mBaseDisplayHeight;
                final DisplayCutout cutout = display.calculateDisplayCutoutForRotation(rotation)
                final DisplayCutout cutout = display.calculateDisplayCutoutForRotation(rotation)
                        .getDisplayCutout();
                        .getDisplayCutout();
                policy.getNonDecorInsetsLw(rotation, dw, dh, cutout, mNonDecorInsets[rotation]);
                policy.getNonDecorInsetsLw(rotation, cutout, mNonDecorInsets[rotation]);
                mStableInsets[rotation].set(mNonDecorInsets[rotation]);
                mStableInsets[rotation].set(mNonDecorInsets[rotation]);
                policy.convertNonDecorInsetsToStableInsets(mStableInsets[rotation], rotation);
                policy.convertNonDecorInsetsToStableInsets(mStableInsets[rotation], rotation);


+5 −5
Original line number Original line Diff line number Diff line
@@ -2027,7 +2027,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp


        final int appWidth = mDisplayPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode,
        final int appWidth = mDisplayPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode,
                displayCutout);
                displayCutout);
        final int appHeight = mDisplayPolicy.getNonDecorDisplayHeight(dw, dh, rotation, uiMode,
        final int appHeight = mDisplayPolicy.getNonDecorDisplayHeight(dh, rotation,
                displayCutout);
                displayCutout);
        mDisplayInfo.rotation = rotation;
        mDisplayInfo.rotation = rotation;
        mDisplayInfo.logicalWidth = dw;
        mDisplayInfo.logicalWidth = dw;
@@ -2165,9 +2165,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            int rotation, int uiMode, DisplayCutout displayCutout) {
            int rotation, int uiMode, DisplayCutout displayCutout) {
        final int appWidth = mDisplayPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode,
        final int appWidth = mDisplayPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode,
                displayCutout);
                displayCutout);
        final int appHeight = mDisplayPolicy.getNonDecorDisplayHeight(dw, dh, rotation, uiMode,
        final int appHeight = mDisplayPolicy.getNonDecorDisplayHeight(dh, rotation,
                displayCutout);
                displayCutout);
        mDisplayPolicy.getNonDecorInsetsLw(rotation, dw, dh, displayCutout, mTmpRect);
        mDisplayPolicy.getNonDecorInsetsLw(rotation, displayCutout, mTmpRect);
        final int leftInset = mTmpRect.left;
        final int leftInset = mTmpRect.left;
        final int topInset = mTmpRect.top;
        final int topInset = mTmpRect.top;
        // AppBounds at the root level should mirror the app screen size.
        // AppBounds at the root level should mirror the app screen size.
@@ -2321,7 +2321,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                rotation).getDisplayCutout();
                rotation).getDisplayCutout();
        dm.noncompatWidthPixels = mDisplayPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode,
        dm.noncompatWidthPixels = mDisplayPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode,
                displayCutout);
                displayCutout);
        dm.noncompatHeightPixels = mDisplayPolicy.getNonDecorDisplayHeight(dw, dh, rotation, uiMode,
        dm.noncompatHeightPixels = mDisplayPolicy.getNonDecorDisplayHeight(dh, rotation,
                displayCutout);
                displayCutout);
        float scale = CompatibilityInfo.computeCompatibleScaling(dm, null);
        float scale = CompatibilityInfo.computeCompatibleScaling(dm, null);
        int size = (int)(((dm.noncompatWidthPixels / scale) / dm.density) + .5f);
        int size = (int)(((dm.noncompatWidthPixels / scale) / dm.density) + .5f);
@@ -2375,7 +2375,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp


        // Get the app screen size at this rotation.
        // Get the app screen size at this rotation.
        int w = mDisplayPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode, displayCutout);
        int w = mDisplayPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode, displayCutout);
        int h = mDisplayPolicy.getNonDecorDisplayHeight(dw, dh, rotation, uiMode, displayCutout);
        int h = mDisplayPolicy.getNonDecorDisplayHeight(dh, rotation, displayCutout);


        // Compute the screen layout size class for this rotation.
        // Compute the screen layout size class for this rotation.
        int longSize = w;
        int longSize = w;
Loading