From 57fbc043070a4caba938f8fd360c5cc25f2b54b3 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Tue, 2 May 2023 15:54:58 +0800 Subject: [PATCH] Do not set different gravity for non-moveable nav bar Some tests assume that if the bar cannot move, it should be always at the bottom. Otherwise the tests may fail by Gravity.RIGHT on a default landscape display. Bug: 267792420 Test: adb shell wm size 2200x1800 atest DisplayPolicyInsetsTests Change-Id: Ieea801ceb8082349858a3fa8c4d324b6ad6278fb --- .../src/com/android/server/wm/WindowTestsBase.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java index 07244a4f24785..0fcf987c2bb1d 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java @@ -359,9 +359,12 @@ class WindowTestsBase extends SystemServiceTestsBase { new InsetsFrameProvider(owner, 0, WindowInsets.Type.tappableElement()), new InsetsFrameProvider(owner, 0, WindowInsets.Type.mandatorySystemGestures()) }; - for (int rot = Surface.ROTATION_0; rot <= Surface.ROTATION_270; rot++) { - mNavBarWindow.mAttrs.paramsForRotation[rot] = - getNavBarLayoutParamsForRotation(rot, owner); + // If the navigation bar cannot move then it is always at the bottom. + if (mDisplayContent.getDisplayPolicy().navigationBarCanMove()) { + for (int rot = Surface.ROTATION_0; rot <= Surface.ROTATION_270; rot++) { + mNavBarWindow.mAttrs.paramsForRotation[rot] = + getNavBarLayoutParamsForRotation(rot, owner); + } } } if (addAll || ArrayUtils.contains(requestedWindows, W_DOCK_DIVIDER)) {