summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Shawn Lin <shawnlin@google.com> 2021-07-26 08:23:20 +0000
committer shawnlin <shawnlin@google.com> 2021-10-19 14:51:20 +0800
commit16496cb5c1f9d5e745099de153de1ed921aab9ff (patch)
tree5b17abd0afc1340d8f4ef36a16ef7578fc1261ff
parent8172fc3e42e54ac325640afc28fa538a8d8668e8 (diff)
Add APIs to get system bar heights
In multi-display devices, there might be differnt cutout on each display which also causes different status bar height. Now we no longer overlay the status_bar_height dimen and keep it as default value and add APIs to calculate the status bar size. - Add APIs for getting status_bar_height & quick_qs_offset_height in system. - Add APIs for getting split_shade_header_height and qs_header_system_icons_area_height in SystemUI. - Remove all resource overlay for status_bar_height & quick_qs_offset_height. Bug: 186604541 Test: atest SmallClockPositionTest DisplayLayoutTest HideDisplayCutoutOrganizerTest SizeCompatTests NotificationPanelViewControllerTest Change-Id: I5a6dfcc6ff06da8ea0fe119fc9d4c089f13b0dff
-rw-r--r--core/java/com/android/internal/policy/SystemBarUtils.java94
-rw-r--r--core/res/res/values-land/dimens.xml2
-rw-r--r--core/res/res/values/dimens.xml22
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayLayout.java44
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/hidedisplaycutout/HideDisplayCutoutOrganizer.java11
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayLayoutTest.java43
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/hidedisplaycutout/HideDisplayCutoutOrganizerTest.java17
-rw-r--r--packages/SystemUI/res/layout/super_notification_shade.xml1
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java22
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java6
-rw-r--r--packages/SystemUI/src/com/android/keyguard/clock/AnalogClockController.java2
-rw-r--r--packages/SystemUI/src/com/android/keyguard/clock/BubbleClockController.java2
-rw-r--r--packages/SystemUI/src/com/android/keyguard/clock/SmallClockPosition.java13
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSDetail.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java17
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProvider.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java32
-rw-r--r--packages/SystemUI/src/com/android/systemui/util/Utils.java37
-rw-r--r--packages/SystemUI/tests/src/com/android/keyguard/clock/SmallClockPositionTest.kt2
-rw-r--r--packages/overlays/DisplayCutoutEmulationCornerOverlay/res/values-land/config.xml22
-rw-r--r--packages/overlays/DisplayCutoutEmulationCornerOverlay/res/values/config.xml8
-rw-r--r--packages/overlays/DisplayCutoutEmulationDoubleOverlay/res/values-land/config.xml22
-rw-r--r--packages/overlays/DisplayCutoutEmulationDoubleOverlay/res/values/config.xml8
-rw-r--r--packages/overlays/DisplayCutoutEmulationHoleOverlay/res/values-land/config.xml22
-rw-r--r--packages/overlays/DisplayCutoutEmulationHoleOverlay/res/values/config.xml8
-rw-r--r--packages/overlays/DisplayCutoutEmulationNarrowOverlay/res/values-land/config.xml22
-rw-r--r--packages/overlays/DisplayCutoutEmulationNarrowOverlay/res/values/config.xml8
-rw-r--r--packages/overlays/DisplayCutoutEmulationTallOverlay/res/values-land/config.xml22
-rw-r--r--packages/overlays/DisplayCutoutEmulationTallOverlay/res/values/config.xml8
-rw-r--r--packages/overlays/DisplayCutoutEmulationWaterfallOverlay/res/values-land/config.xml22
-rw-r--r--packages/overlays/DisplayCutoutEmulationWaterfallOverlay/res/values/config.xml10
-rw-r--r--packages/overlays/DisplayCutoutEmulationWideOverlay/res/values-land/config.xml22
-rw-r--r--packages/overlays/DisplayCutoutEmulationWideOverlay/res/values/config.xml8
-rw-r--r--packages/overlays/NoCutoutOverlay/res/values/config.xml8
-rw-r--r--services/core/java/com/android/server/wm/DisplayPolicy.java15
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTestsBase.java4
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java5
48 files changed, 301 insertions, 366 deletions
diff --git a/core/java/com/android/internal/policy/SystemBarUtils.java b/core/java/com/android/internal/policy/SystemBarUtils.java
new file mode 100644
index 000000000000..6bf1333097f7
--- /dev/null
+++ b/core/java/com/android/internal/policy/SystemBarUtils.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2021 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 com.android.internal.policy;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Insets;
+import android.util.RotationUtils;
+import android.view.DisplayCutout;
+import android.view.Surface;
+
+import com.android.internal.R;
+
+/**
+ * Utility functions for system bars used by both window manager and System UI.
+ *
+ * @hide
+ */
+public final class SystemBarUtils {
+
+ /**
+ * Gets the status bar height.
+ */
+ public static int getStatusBarHeight(Context context) {
+ return getStatusBarHeight(context.getResources(), context.getDisplay().getCutout());
+ }
+
+ /**
+ * Gets the status bar height with a specific display cutout.
+ */
+ public static int getStatusBarHeight(Resources res, DisplayCutout cutout) {
+ final int defaultSize = res.getDimensionPixelSize(R.dimen.status_bar_height);
+ final int safeInsetTop = cutout == null ? 0 : cutout.getSafeInsetTop();
+ final int waterfallInsetTop = cutout == null ? 0 : cutout.getWaterfallInsets().top;
+ // The status bar height should be:
+ // Max(top cutout size, (status bar default height + waterfall top size))
+ return Math.max(safeInsetTop, defaultSize + waterfallInsetTop);
+ }
+
+ /**
+ * Gets the status bar height for a specific rotation.
+ */
+ public static int getStatusBarHeightForRotation(
+ Context context, @Surface.Rotation int targetRot) {
+ final int rotation = context.getDisplay().getRotation();
+ final DisplayCutout cutout = context.getDisplay().getCutout();
+
+ Insets insets = cutout == null ? Insets.NONE : Insets.of(cutout.getSafeInsets());
+ Insets waterfallInsets = cutout == null ? Insets.NONE : cutout.getWaterfallInsets();
+ // rotate insets to target rotation if needed.
+ if (rotation != targetRot) {
+ if (!insets.equals(Insets.NONE)) {
+ insets = RotationUtils.rotateInsets(
+ insets, RotationUtils.deltaRotation(rotation, targetRot));
+ }
+ if (!waterfallInsets.equals(Insets.NONE)) {
+ waterfallInsets = RotationUtils.rotateInsets(
+ waterfallInsets, RotationUtils.deltaRotation(rotation, targetRot));
+ }
+ }
+ final int defaultSize =
+ context.getResources().getDimensionPixelSize(R.dimen.status_bar_height);
+ // The status bar height should be:
+ // Max(top cutout size, (status bar default height + waterfall top size))
+ return Math.max(insets.top, defaultSize + waterfallInsets.top);
+ }
+
+ /**
+ * Gets the height of area above QQS where battery/time go in notification panel. The height
+ * equals to status bar height if status bar height is bigger than the
+ * {@link R.dimen#quick_qs_offset_height}.
+ */
+ public static int getQuickQsOffsetHeight(Context context) {
+ final int defaultSize = context.getResources().getDimensionPixelSize(
+ R.dimen.quick_qs_offset_height);
+ final int statusBarHeight = getStatusBarHeight(context);
+ // Equals to status bar height if status bar height is bigger.
+ return Math.max(defaultSize, statusBarHeight);
+ }
+}
diff --git a/core/res/res/values-land/dimens.xml b/core/res/res/values-land/dimens.xml
index ca549aeba1f5..f1e5888d61b9 100644
--- a/core/res/res/values-land/dimens.xml
+++ b/core/res/res/values-land/dimens.xml
@@ -27,8 +27,6 @@
<dimen name="password_keyboard_spacebar_vertical_correction">2dip</dimen>
<dimen name="preference_widget_width">72dp</dimen>
- <!-- Height of the status bar -->
- <dimen name="status_bar_height">@dimen/status_bar_height_landscape</dimen>
<!-- Height of area above QQS where battery/time go -->
<dimen name="quick_qs_offset_height">48dp</dimen>
<!-- Default height of an action bar. -->
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index ab923d0b8023..0706d8a8e4c6 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -39,15 +39,21 @@
<!-- Elevation of toast view -->
<dimen name="toast_elevation">2dp</dimen>
- <!-- Height of the status bar -->
- <dimen name="status_bar_height">@dimen/status_bar_height_portrait</dimen>
- <!-- Height of the status bar in portrait. The height should be
- Max((status bar content height + waterfall top size), top cutout size) -->
- <dimen name="status_bar_height_portrait">24dp</dimen>
- <!-- Height of the status bar in landscape. The height should be
- Max((status bar content height + waterfall top size), top cutout size) -->
+ <!-- Height of the status bar.
+ Do not read this dimen directly. Use {@link SystemBarUtils#getStatusBarHeight} instead.
+ -->
+ <dimen name="status_bar_height">24dp</dimen>
+ <!-- Height of the status bar in portrait.
+ Do not read this dimen directly. Use {@link SystemBarUtils#getStatusBarHeight} instead.
+ -->
+ <dimen name="status_bar_height_portrait">@dimen/status_bar_height</dimen>
+ <!-- Height of the status bar in landscape.
+ Do not read this dimen directly. Use {@link SystemBarUtils#getStatusBarHeight} instead.
+ -->
<dimen name="status_bar_height_landscape">@dimen/status_bar_height_portrait</dimen>
- <!-- Height of area above QQS where battery/time go -->
+ <!-- Height of area above QQS where battery/time go.
+ Do not read this dimen directly. Use {@link SystemBarUtils#getQuickQsOffsetHeight} instead.
+ -->
<dimen name="quick_qs_offset_height">48dp</dimen>
<!-- Height of the bottom navigation / system bar. -->
<dimen name="navigation_bar_height">48dp</dimen>
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayLayout.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayLayout.java
index 962aca122b4d..7784665b3031 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayLayout.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayLayout.java
@@ -48,9 +48,11 @@ import android.view.Gravity;
import android.view.InsetsSource;
import android.view.InsetsState;
import android.view.Surface;
-import android.view.WindowInsets;
+
+import androidx.annotation.VisibleForTesting;
import com.android.internal.R;
+import com.android.internal.policy.SystemBarUtils;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -198,12 +200,13 @@ public class DisplayLayout {
recalcInsets(res);
}
- private void recalcInsets(Resources res) {
+ @VisibleForTesting
+ void recalcInsets(Resources res) {
computeNonDecorInsets(res, mRotation, mWidth, mHeight, mCutout, mInsetsState, mUiMode,
mNonDecorInsets, mHasNavigationBar);
mStableInsets.set(mNonDecorInsets);
if (mHasStatusBar) {
- convertNonDecorInsetsToStableInsets(res, mStableInsets, mWidth, mHeight, mHasStatusBar);
+ convertNonDecorInsetsToStableInsets(res, mStableInsets, mCutout, mHasStatusBar);
}
mNavBarFrameHeight = getNavigationBarFrameHeight(res, mWidth > mHeight);
}
@@ -323,12 +326,12 @@ public class DisplayLayout {
/**
* Calculates the stable insets if we already have the non-decor insets.
*/
- private static void convertNonDecorInsetsToStableInsets(Resources res, Rect inOutInsets,
- int displayWidth, int displayHeight, boolean hasStatusBar) {
+ private void convertNonDecorInsetsToStableInsets(Resources res, Rect inOutInsets,
+ DisplayCutout cutout, boolean hasStatusBar) {
if (!hasStatusBar) {
return;
}
- int statusBarHeight = getStatusBarHeight(displayWidth > displayHeight, res);
+ int statusBarHeight = SystemBarUtils.getStatusBarHeight(res, cutout);
inOutInsets.top = Math.max(inOutInsets.top, statusBarHeight);
}
@@ -377,35 +380,6 @@ public class DisplayLayout {
}
}
- /**
- * Calculates the stable insets without running a layout.
- *
- * @param displayRotation the current display rotation
- * @param displayWidth the current display width
- * @param displayHeight the current display height
- * @param displayCutout the current display cutout
- * @param outInsets the insets to return
- */
- static void computeStableInsets(Resources res, int displayRotation, int displayWidth,
- int displayHeight, DisplayCutout displayCutout, InsetsState insetsState, int uiMode,
- Rect outInsets, boolean hasNavigationBar, boolean hasStatusBar) {
- outInsets.setEmpty();
-
- // Navigation bar and status bar.
- computeNonDecorInsets(res, displayRotation, displayWidth, displayHeight, displayCutout,
- insetsState, uiMode, outInsets, hasNavigationBar);
- convertNonDecorInsetsToStableInsets(res, outInsets, displayWidth, displayHeight,
- hasStatusBar);
- }
-
- /** Retrieve the statusbar height from resources. */
- static int getStatusBarHeight(boolean landscape, Resources res) {
- return landscape ? res.getDimensionPixelSize(
- com.android.internal.R.dimen.status_bar_height_landscape)
- : res.getDimensionPixelSize(
- com.android.internal.R.dimen.status_bar_height_portrait);
- }
-
/** Calculate the DisplayCutout for a particular display size/rotation. */
public static DisplayCutout calculateDisplayCutoutForRotation(
DisplayCutout cutout, int rotation, int displayWidth, int displayHeight) {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/hidedisplaycutout/HideDisplayCutoutOrganizer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/hidedisplaycutout/HideDisplayCutoutOrganizer.java
index 75a1ddeccb22..3f7d78dda037 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/hidedisplaycutout/HideDisplayCutoutOrganizer.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/hidedisplaycutout/HideDisplayCutoutOrganizer.java
@@ -39,7 +39,7 @@ import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
-import com.android.internal.R;
+import com.android.internal.policy.SystemBarUtils;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.common.ShellExecutor;
@@ -307,12 +307,9 @@ class HideDisplayCutoutOrganizer extends DisplayAreaOrganizer {
t.apply();
}
- private int getStatusBarHeight() {
- final boolean isLandscape =
- mIsDefaultPortrait ? isDisplaySizeFlipped() : !isDisplaySizeFlipped();
- return mContext.getResources().getDimensionPixelSize(
- isLandscape ? R.dimen.status_bar_height_landscape
- : R.dimen.status_bar_height_portrait);
+ @VisibleForTesting
+ int getStatusBarHeight() {
+ return SystemBarUtils.getStatusBarHeight(mContext);
}
void dump(@NonNull PrintWriter pw) {
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayLayoutTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayLayoutTest.java
index 88e754c58792..0ffa5b35331d 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayLayoutTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayLayoutTest.java
@@ -21,9 +21,14 @@ import static android.view.Surface.ROTATION_0;
import static android.view.Surface.ROTATION_270;
import static android.view.Surface.ROTATION_90;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
+
import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -35,8 +40,12 @@ import android.view.DisplayInfo;
import androidx.test.filters.SmallTest;
import com.android.internal.R;
+import com.android.internal.policy.SystemBarUtils;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
+import org.mockito.MockitoSession;
/**
* Tests for {@link DisplayLayout}.
@@ -46,29 +55,48 @@ import org.junit.Test;
*/
@SmallTest
public class DisplayLayoutTest {
+ private MockitoSession mMockitoSession;
+
+ @Before
+ public void setup() {
+ mMockitoSession = mockitoSession()
+ .initMocks(this)
+ .mockStatic(SystemBarUtils.class)
+ .startMocking();
+ }
+
+ @After
+ public void tearDown() {
+ mMockitoSession.finishMocking();
+ }
@Test
public void testInsets() {
- Resources res = createResources(40, 50, false, 30, 40);
+ Resources res = createResources(40, 50, false);
// Test empty display, no bars or anything
DisplayInfo info = createDisplayInfo(1000, 1500, 0, ROTATION_0);
DisplayLayout dl = new DisplayLayout(info, res, false, false);
+ when(SystemBarUtils.getStatusBarHeight(eq(res), any())).thenReturn(40);
+ dl.recalcInsets(res);
assertEquals(new Rect(0, 0, 0, 0), dl.stableInsets());
assertEquals(new Rect(0, 0, 0, 0), dl.nonDecorInsets());
// Test with bars
dl = new DisplayLayout(info, res, true, true);
+ dl.recalcInsets(res);
assertEquals(new Rect(0, 40, 0, 50), dl.stableInsets());
assertEquals(new Rect(0, 0, 0, 50), dl.nonDecorInsets());
// Test just cutout
info = createDisplayInfo(1000, 1500, 60, ROTATION_0);
dl = new DisplayLayout(info, res, false, false);
+ dl.recalcInsets(res);
assertEquals(new Rect(0, 60, 0, 0), dl.stableInsets());
assertEquals(new Rect(0, 60, 0, 0), dl.nonDecorInsets());
// Test with bars and cutout
dl = new DisplayLayout(info, res, true, true);
+ dl.recalcInsets(res);
assertEquals(new Rect(0, 60, 0, 50), dl.stableInsets());
assertEquals(new Rect(0, 60, 0, 50), dl.nonDecorInsets());
}
@@ -76,27 +104,30 @@ public class DisplayLayoutTest {
@Test
public void testRotate() {
// Basic rotate utility
- Resources res = createResources(40, 50, false, 30, 40);
+ Resources res = createResources(40, 50, false);
DisplayInfo info = createDisplayInfo(1000, 1500, 60, ROTATION_0);
DisplayLayout dl = new DisplayLayout(info, res, true, true);
+ when(SystemBarUtils.getStatusBarHeight(eq(res), any())).thenReturn(40);
+ dl.recalcInsets(res);
assertEquals(new Rect(0, 60, 0, 50), dl.stableInsets());
assertEquals(new Rect(0, 60, 0, 50), dl.nonDecorInsets());
// Rotate to 90
+ when(SystemBarUtils.getStatusBarHeight(eq(res), any())).thenReturn(30);
dl.rotateTo(res, ROTATION_90);
assertEquals(new Rect(60, 30, 0, 40), dl.stableInsets());
assertEquals(new Rect(60, 0, 0, 40), dl.nonDecorInsets());
// Rotate with moving navbar
- res = createResources(40, 50, true, 30, 40);
+ res = createResources(40, 50, true);
dl = new DisplayLayout(info, res, true, true);
+ when(SystemBarUtils.getStatusBarHeight(eq(res), any())).thenReturn(30);
dl.rotateTo(res, ROTATION_270);
assertEquals(new Rect(40, 30, 60, 0), dl.stableInsets());
assertEquals(new Rect(40, 0, 60, 0), dl.nonDecorInsets());
}
- private Resources createResources(
- int navLand, int navPort, boolean navMoves, int statusLand, int statusPort) {
+ private Resources createResources(int navLand, int navPort, boolean navMoves) {
Configuration cfg = new Configuration();
cfg.uiMode = UI_MODE_TYPE_NORMAL;
Resources res = mock(Resources.class);
@@ -108,8 +139,6 @@ public class DisplayLayoutTest {
doReturn(navPort).when(res).getDimensionPixelSize(R.dimen.navigation_bar_height);
doReturn(navLand).when(res).getDimensionPixelSize(R.dimen.navigation_bar_width);
doReturn(navMoves).when(res).getBoolean(R.bool.config_navBarCanMove);
- doReturn(statusLand).when(res).getDimensionPixelSize(R.dimen.status_bar_height_landscape);
- doReturn(statusPort).when(res).getDimensionPixelSize(R.dimen.status_bar_height_portrait);
doReturn(cfg).when(res).getConfiguration();
return res;
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/hidedisplaycutout/HideDisplayCutoutOrganizerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/hidedisplaycutout/HideDisplayCutoutOrganizerTest.java
index 3c124bafc18a..078e2b6cf574 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/hidedisplaycutout/HideDisplayCutoutOrganizerTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/hidedisplaycutout/HideDisplayCutoutOrganizerTest.java
@@ -48,7 +48,6 @@ import android.window.WindowContainerToken;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.SmallTest;
-import com.android.internal.R;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.common.ShellExecutor;
@@ -124,6 +123,7 @@ public class HideDisplayCutoutOrganizerTest {
@Test
public void testEnableHideDisplayCutout() {
+ doReturn(mFakeStatusBarHeightPortrait).when(mOrganizer).getStatusBarHeight();
mOrganizer.enableHideDisplayCutout();
verify(mOrganizer).registerOrganizer(DisplayAreaOrganizer.FEATURE_HIDE_DISPLAY_CUTOUT);
@@ -154,8 +154,7 @@ public class HideDisplayCutoutOrganizerTest {
doReturn(mFakeDefaultBounds).when(mOrganizer).getDisplayBoundsOfNaturalOrientation();
doReturn(mFakeDefaultCutoutInsets).when(mOrganizer)
.getDisplayCutoutInsetsOfNaturalOrientation();
- mContext.getOrCreateTestableResources().addOverride(
- R.dimen.status_bar_height_portrait, mFakeStatusBarHeightPortrait);
+ doReturn(mFakeStatusBarHeightPortrait).when(mOrganizer).getStatusBarHeight();
doReturn(Surface.ROTATION_0).when(mDisplayLayout).rotation();
mOrganizer.enableHideDisplayCutout();
@@ -173,8 +172,7 @@ public class HideDisplayCutoutOrganizerTest {
doReturn(mFakeDefaultBounds).when(mOrganizer).getDisplayBoundsOfNaturalOrientation();
doReturn(mFakeDefaultCutoutInsets).when(mOrganizer)
.getDisplayCutoutInsetsOfNaturalOrientation();
- mContext.getOrCreateTestableResources().addOverride(
- R.dimen.status_bar_height_landscape, mFakeStatusBarHeightLandscape);
+ doReturn(mFakeStatusBarHeightLandscape).when(mOrganizer).getStatusBarHeight();
doReturn(Surface.ROTATION_90).when(mDisplayLayout).rotation();
mOrganizer.enableHideDisplayCutout();
@@ -192,8 +190,7 @@ public class HideDisplayCutoutOrganizerTest {
doReturn(mFakeDefaultBounds).when(mOrganizer).getDisplayBoundsOfNaturalOrientation();
doReturn(mFakeDefaultCutoutInsets).when(mOrganizer)
.getDisplayCutoutInsetsOfNaturalOrientation();
- mContext.getOrCreateTestableResources().addOverride(
- R.dimen.status_bar_height_landscape, mFakeStatusBarHeightLandscape);
+ doReturn(mFakeStatusBarHeightLandscape).when(mOrganizer).getStatusBarHeight();
doReturn(Surface.ROTATION_270).when(mDisplayLayout).rotation();
mOrganizer.enableHideDisplayCutout();
@@ -211,8 +208,7 @@ public class HideDisplayCutoutOrganizerTest {
doReturn(mFakeDefaultBounds).when(mOrganizer).getDisplayBoundsOfNaturalOrientation();
doReturn(mFakeDefaultCutoutInsets).when(mOrganizer)
.getDisplayCutoutInsetsOfNaturalOrientation();
- mContext.getOrCreateTestableResources().addOverride(
- R.dimen.status_bar_height_portrait, mFakeStatusBarHeightPortrait);
+ doReturn(mFakeStatusBarHeightPortrait).when(mOrganizer).getStatusBarHeight();
mOrganizer.enableHideDisplayCutout();
// disable hide display cutout
@@ -230,8 +226,7 @@ public class HideDisplayCutoutOrganizerTest {
doReturn(200).when(mDisplayLayout).height();
doReturn(mFakeDefaultCutoutInsets).when(mOrganizer)
.getDisplayCutoutInsetsOfNaturalOrientation();
- mContext.getOrCreateTestableResources().addOverride(
- R.dimen.status_bar_height_portrait, mFakeStatusBarHeightPortrait);
+ doReturn(mFakeStatusBarHeightPortrait).when(mOrganizer).getStatusBarHeight();
doReturn(Surface.ROTATION_0).when(mDisplayLayout).rotation();
mOrganizer.enableHideDisplayCutout();
assertThat(mOrganizer.mCurrentDisplayBounds).isEqualTo(new Rect(0, 15, 100, 200));
diff --git a/packages/SystemUI/res/layout/super_notification_shade.xml b/packages/SystemUI/res/layout/super_notification_shade.xml
index e02a1767a96c..b28cb2f6f483 100644
--- a/packages/SystemUI/res/layout/super_notification_shade.xml
+++ b/packages/SystemUI/res/layout/super_notification_shade.xml
@@ -81,6 +81,7 @@
<!-- Keyguard messages -->
<LinearLayout
+ android:id="@+id/keyguard_message_area_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java
index 11eeac2272ff..099dd5d82a10 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java
@@ -27,8 +27,10 @@ import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.TextView;
+import com.android.internal.policy.SystemBarUtils;
import com.android.settingslib.Utils;
import com.android.systemui.R;
@@ -55,6 +57,8 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp
private ColorStateList mNextMessageColorState = ColorStateList.valueOf(DEFAULT_COLOR);
private boolean mBouncerVisible;
private boolean mAltBouncerShowing;
+ private ViewGroup mContainer;
+ private int mTopMargin;
public KeyguardMessageArea(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -65,6 +69,24 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp
}
@Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ mContainer = getRootView().findViewById(R.id.keyguard_message_area_container);
+ }
+
+ void onConfigChanged() {
+ final int newTopMargin = SystemBarUtils.getStatusBarHeight(getContext());
+ if (mTopMargin == newTopMargin) {
+ return;
+ }
+ mTopMargin = newTopMargin;
+ ViewGroup.MarginLayoutParams lp =
+ (ViewGroup.MarginLayoutParams) mContainer.getLayoutParams();
+ lp.topMargin = mTopMargin;
+ mContainer.setLayoutParams(lp);
+ }
+
+ @Override
public void setNextMessageColor(ColorStateList colorState) {
mNextMessageColorState = colorState;
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java
index 51ded3fcafdf..05318bb0df78 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java
@@ -17,6 +17,7 @@
package com.android.keyguard;
import android.content.res.ColorStateList;
+import android.content.res.Configuration;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
@@ -48,6 +49,11 @@ public class KeyguardMessageAreaController extends ViewController<KeyguardMessag
private ConfigurationListener mConfigurationListener = new ConfigurationListener() {
@Override
+ public void onConfigChanged(Configuration newConfig) {
+ mView.onConfigChanged();
+ }
+
+ @Override
public void onThemeChanged() {
mView.onThemeChanged();
}
diff --git a/packages/SystemUI/src/com/android/keyguard/clock/AnalogClockController.java b/packages/SystemUI/src/com/android/keyguard/clock/AnalogClockController.java
index 99e122ef74e9..7517deed7cbb 100644
--- a/packages/SystemUI/src/com/android/keyguard/clock/AnalogClockController.java
+++ b/packages/SystemUI/src/com/android/keyguard/clock/AnalogClockController.java
@@ -91,7 +91,7 @@ public class AnalogClockController implements ClockPlugin {
mResources = res;
mLayoutInflater = inflater;
mColorExtractor = colorExtractor;
- mClockPosition = new SmallClockPosition(res);
+ mClockPosition = new SmallClockPosition(inflater.getContext());
}
private void createViews() {
diff --git a/packages/SystemUI/src/com/android/keyguard/clock/BubbleClockController.java b/packages/SystemUI/src/com/android/keyguard/clock/BubbleClockController.java
index fac923c01af5..1add1a3abf5a 100644
--- a/packages/SystemUI/src/com/android/keyguard/clock/BubbleClockController.java
+++ b/packages/SystemUI/src/com/android/keyguard/clock/BubbleClockController.java
@@ -91,7 +91,7 @@ public class BubbleClockController implements ClockPlugin {
mResources = res;
mLayoutInflater = inflater;
mColorExtractor = colorExtractor;
- mClockPosition = new SmallClockPosition(res);
+ mClockPosition = new SmallClockPosition(inflater.getContext());
}
private void createViews() {
diff --git a/packages/SystemUI/src/com/android/keyguard/clock/SmallClockPosition.java b/packages/SystemUI/src/com/android/keyguard/clock/SmallClockPosition.java
index b3040744ce7a..4e51b98b0a4c 100644
--- a/packages/SystemUI/src/com/android/keyguard/clock/SmallClockPosition.java
+++ b/packages/SystemUI/src/com/android/keyguard/clock/SmallClockPosition.java
@@ -16,10 +16,11 @@
package com.android.keyguard.clock;
-import android.content.res.Resources;
+import android.content.Context;
import android.util.MathUtils;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.policy.SystemBarUtils;
import com.android.systemui.R;
/**
@@ -40,11 +41,11 @@ class SmallClockPosition {
*/
private float mDarkAmount;
- SmallClockPosition(Resources res) {
- this(res.getDimensionPixelSize(R.dimen.status_bar_height),
- res.getDimensionPixelSize(R.dimen.keyguard_lock_padding),
- res.getDimensionPixelSize(R.dimen.keyguard_lock_height),
- res.getDimensionPixelSize(R.dimen.burn_in_prevention_offset_y)
+ SmallClockPosition(Context context) {
+ this(SystemBarUtils.getStatusBarHeight(context),
+ context.getResources().getDimensionPixelSize(R.dimen.keyguard_lock_padding),
+ context.getResources().getDimensionPixelSize(R.dimen.keyguard_lock_height),
+ context.getResources().getDimensionPixelSize(R.dimen.burn_in_prevention_offset_y)
);
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java b/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java
index 3fc4f504d007..8588ddfcfa63 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java
@@ -32,6 +32,7 @@ import android.widget.ImageView;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
import com.android.systemui.qs.customize.QSCustomizer;
+import com.android.systemui.util.Utils;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -155,8 +156,7 @@ public class QSContainerImpl extends FrameLayout implements Dumpable {
QuickStatusBarHeaderController quickStatusBarHeaderController) {
mQSPanelContainer.setPaddingRelative(
getPaddingStart(),
- mContext.getResources()
- .getDimensionPixelSize(R.dimen.qs_header_system_icons_area_height),
+ Utils.getQsHeaderSystemIconsAreaHeight(mContext),
getPaddingEnd(),
getPaddingBottom()
);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java b/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java
index 58a942a05cbc..d43404b8781c 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java
@@ -40,6 +40,7 @@ import android.widget.TextView;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.UiEventLogger;
+import com.android.internal.policy.SystemBarUtils;
import com.android.systemui.Dependency;
import com.android.systemui.FontSizeUtils;
import com.android.systemui.R;
@@ -164,8 +165,7 @@ public class QSDetail extends LinearLayout {
public void updateResources() {
updateDetailText();
MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams();
- lp.topMargin = mContext.getResources().getDimensionPixelSize(
- com.android.internal.R.dimen.quick_qs_offset_height);
+ lp.topMargin = SystemBarUtils.getQuickQsOffsetHeight(mContext);
setLayoutParams(lp);
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java b/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java
index a81d3c64d912..071e0535e7c2 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java
@@ -34,6 +34,7 @@ import android.widget.Space;
import androidx.annotation.NonNull;
+import com.android.internal.policy.SystemBarUtils;
import com.android.settingslib.Utils;
import com.android.systemui.R;
import com.android.systemui.battery.BatteryMeterView;
@@ -240,8 +241,7 @@ public class QuickStatusBarHeader extends FrameLayout {
mRoundedCornerPadding = resources.getDimensionPixelSize(
R.dimen.rounded_corner_content_padding);
- int qsOffsetHeight = resources.getDimensionPixelSize(
- com.android.internal.R.dimen.quick_qs_offset_height);
+ int qsOffsetHeight = SystemBarUtils.getQuickQsOffsetHeight(mContext);
mDatePrivacyView.getLayoutParams().height =
Math.max(qsOffsetHeight, mDatePrivacyView.getMinimumHeight());
diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
index 1a6d49070a2f..0a452627427b 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java
@@ -36,6 +36,7 @@ import com.android.systemui.plugins.qs.QS;
import com.android.systemui.plugins.qs.QSContainerController;
import com.android.systemui.qs.QSDetailClipper;
import com.android.systemui.statusbar.phone.LightBarController;
+import com.android.systemui.util.Utils;
/**
* Allows full-screen customization of QS, through show() and hide().
@@ -84,8 +85,7 @@ public class QSCustomizer extends LinearLayout {
void updateResources() {
LayoutParams lp = (LayoutParams) mTransparentView.getLayoutParams();
- lp.height = mContext.getResources()
- .getDimensionPixelSize(R.dimen.qs_header_system_icons_area_height);
+ lp.height = Utils.getQsHeaderSystemIconsAreaHeight(mContext);
mTransparentView.setLayoutParams(lp);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
index 3bd7dd339a9e..790f6f64e245 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
@@ -30,6 +30,7 @@ import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.policy.SystemBarUtils;
import com.android.systemui.R;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
@@ -114,7 +115,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
private void initDimens() {
Resources res = getResources();
- mStatusBarHeight = res.getDimensionPixelOffset(R.dimen.status_bar_height);
+ mStatusBarHeight = SystemBarUtils.getStatusBarHeight(mContext);
mPaddingBetweenElements = res.getDimensionPixelSize(R.dimen.notification_divider_height);
ViewGroup.LayoutParams layoutParams = getLayoutParams();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index c06d877751e1..dd5d7d9e3aba 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -72,6 +72,7 @@ import android.widget.ScrollView;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.graphics.ColorUtils;
import com.android.internal.jank.InteractionJankMonitor;
+import com.android.internal.policy.SystemBarUtils;
import com.android.keyguard.KeyguardSliceView;
import com.android.settingslib.Utils;
import com.android.systemui.Dumpable;
@@ -947,7 +948,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
res.getDimensionPixelSize(R.dimen.notification_divider_height));
mMinTopOverScrollToEscape = res.getDimensionPixelSize(
R.dimen.min_top_overscroll_to_qs);
- mStatusBarHeight = res.getDimensionPixelSize(R.dimen.status_bar_height);
+ mStatusBarHeight = SystemBarUtils.getStatusBarHeight(mContext);
mBottomMargin = res.getDimensionPixelSize(R.dimen.notification_panel_margin_bottom);
mMinimumPaddings = res.getDimensionPixelSize(R.dimen.notification_side_paddings);
mQsTilePadding = res.getDimensionPixelOffset(R.dimen.qs_tile_margin_horizontal);
@@ -958,8 +959,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
mCornerRadius = res.getDimensionPixelSize(R.dimen.notification_corner_radius);
mHeadsUpInset = mStatusBarHeight + res.getDimensionPixelSize(
R.dimen.heads_up_status_bar_padding);
- mQsScrollBoundaryPosition = res.getDimensionPixelSize(
- com.android.internal.R.dimen.quick_qs_offset_height);
+ mQsScrollBoundaryPosition = SystemBarUtils.getQuickQsOffsetHeight(mContext);
}
void updateSidePadding(int viewWidth) {
@@ -1717,7 +1717,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
super.onConfigurationChanged(newConfig);
Resources res = getResources();
updateSplitNotificationShade();
- mStatusBarHeight = res.getDimensionPixelOffset(R.dimen.status_bar_height);
+ mStatusBarHeight = SystemBarUtils.getStatusBarHeight(mContext);
float densityScale = res.getDisplayMetrics().density;
mSwipeHelper.setDensityScale(densityScale);
float pagingTouchSlop = ViewConfiguration.get(getContext()).getScaledPagingTouchSlop();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java
index 7cbe78f16ceb..09ffd65c816a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java
@@ -26,6 +26,7 @@ import android.view.ViewGroup;
import androidx.annotation.VisibleForTesting;
+import com.android.internal.policy.SystemBarUtils;
import com.android.systemui.R;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.statusbar.NotificationShelf;
@@ -77,7 +78,7 @@ public class StackScrollAlgorithm {
R.dimen.notification_divider_height);
mCollapsedSize = res.getDimensionPixelSize(R.dimen.notification_min_height);
mClipNotificationScrollToTop = res.getBoolean(R.bool.config_clipNotificationScrollToTop);
- int statusBarHeight = res.getDimensionPixelSize(R.dimen.status_bar_height);
+ int statusBarHeight = SystemBarUtils.getStatusBarHeight(context);
mHeadsUpInset = statusBarHeight + res.getDimensionPixelSize(
R.dimen.heads_up_status_bar_padding);
mPinnedZTranslationExtra = res.getDimensionPixelSize(
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
index 5f402d0d861d..c81196d7a0f9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
@@ -26,6 +26,7 @@ import android.util.Pools;
import androidx.collection.ArraySet;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.policy.SystemBarUtils;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
@@ -137,9 +138,8 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
private void updateResources() {
Resources resources = mContext.getResources();
- mHeadsUpInset =
- resources.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height)
- + resources.getDimensionPixelSize(R.dimen.heads_up_status_bar_padding);
+ mHeadsUpInset = SystemBarUtils.getStatusBarHeight(mContext)
+ + resources.getDimensionPixelSize(R.dimen.heads_up_status_bar_padding);
}
///////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
index a090ac35070e..b9b663c33a45 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
@@ -30,6 +30,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
+import com.android.internal.policy.SystemBarUtils;
import com.android.keyguard.KeyguardHostViewController;
import com.android.keyguard.KeyguardRootViewController;
import com.android.keyguard.KeyguardSecurityModel;
@@ -467,8 +468,7 @@ public class KeyguardBouncer {
mKeyguardViewController.init();
mContainer.addView(mRoot, mContainer.getChildCount());
- mStatusBarHeight = mRoot.getResources().getDimensionPixelOffset(
- com.android.systemui.R.dimen.status_bar_height);
+ mStatusBarHeight = SystemBarUtils.getStatusBarHeight(mContext);
setVisibility(View.INVISIBLE);
final WindowInsets rootInsets = mRoot.getRootWindowInsets();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
index fe154d232a88..03f3b0cab65c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.phone;
import static com.android.systemui.DejankUtils.whitelistIpcs;
import static com.android.systemui.ScreenDecorations.DisplayCutoutView.boundsFromDirection;
+import static com.android.systemui.util.Utils.getStatusBarHeaderHeightKeyguard;
import android.annotation.ColorInt;
import android.content.Context;
@@ -162,11 +163,8 @@ public class KeyguardStatusBarView extends RelativeLayout {
}
private void updateKeyguardStatusBarHeight() {
- final int waterfallTop =
- mDisplayCutout == null ? 0 : mDisplayCutout.getWaterfallInsets().top;
MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams();
- lp.height = getResources().getDimensionPixelSize(
- R.dimen.status_bar_header_height_keyguard) + waterfallTop;
+ lp.height = getStatusBarHeaderHeightKeyguard(mContext);
setLayoutParams(lp);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
index 54a61402b311..faeeb531d05c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
@@ -94,6 +94,7 @@ import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.policy.ScreenDecorationsUtils;
+import com.android.internal.policy.SystemBarUtils;
import com.android.internal.util.LatencyTracker;
import com.android.keyguard.KeyguardStatusView;
import com.android.keyguard.KeyguardStatusViewController;
@@ -890,10 +891,8 @@ public class NotificationPanelViewController extends PanelViewController {
super.loadDimens();
mFlingAnimationUtils = mFlingAnimationUtilsBuilder.get()
.setMaxLengthSeconds(0.4f).build();
- mStatusBarMinHeight = mResources.getDimensionPixelSize(
- com.android.internal.R.dimen.status_bar_height);
- mStatusBarHeaderHeightKeyguard = mResources.getDimensionPixelSize(
- R.dimen.status_bar_header_height_keyguard);
+ mStatusBarMinHeight = SystemBarUtils.getStatusBarHeight(mView.getContext());
+ mStatusBarHeaderHeightKeyguard = Utils.getStatusBarHeaderHeightKeyguard(mView.getContext());
mQsPeekHeight = mResources.getDimensionPixelSize(R.dimen.qs_peek_height);
mClockPositionAlgorithm.loadDimens(mResources);
mQsFalsingThreshold = mResources.getDimensionPixelSize(R.dimen.qs_falsing_threshold);
@@ -903,8 +902,7 @@ public class NotificationPanelViewController extends PanelViewController {
R.dimen.keyguard_indication_bottom_padding);
mShelfHeight = mResources.getDimensionPixelSize(R.dimen.notification_shelf_height);
mDarkIconSize = mResources.getDimensionPixelSize(R.dimen.status_bar_icon_drawing_size_dark);
- int statusbarHeight = mResources.getDimensionPixelSize(
- com.android.internal.R.dimen.status_bar_height);
+ int statusbarHeight = SystemBarUtils.getStatusBarHeight(mView.getContext());
mHeadsUpInset = statusbarHeight + mResources.getDimensionPixelSize(
R.dimen.heads_up_status_bar_padding);
mDistanceForQSFullShadeTransition = mResources.getDimensionPixelSize(
@@ -973,10 +971,8 @@ public class NotificationPanelViewController extends PanelViewController {
}
public void updateResources() {
- mQuickQsOffsetHeight = mResources.getDimensionPixelSize(
- com.android.internal.R.dimen.quick_qs_offset_height);
- mSplitShadeStatusBarHeight =
- mResources.getDimensionPixelSize(R.dimen.split_shade_header_height);
+ mQuickQsOffsetHeight = SystemBarUtils.getQuickQsOffsetHeight(mView.getContext());
+ mSplitShadeStatusBarHeight = Utils.getSplitShadeStatusBarHeight(mView.getContext());
int qsWidth = mResources.getDimensionPixelSize(R.dimen.qs_panel_width);
int panelWidth = mResources.getDimensionPixelSize(R.dimen.notification_panel_width);
mShouldUseSplitNotificationShade =
@@ -1002,6 +998,7 @@ public class NotificationPanelViewController extends PanelViewController {
constraintSet.connect(
R.id.notification_stack_scroller, START,
R.id.qs_edge_guideline, START);
+ constraintSet.constrainHeight(R.id.split_shade_status_bar, mSplitShadeStatusBarHeight);
} else {
constraintSet.connect(R.id.qs_frame, END, PARENT_ID, END);
constraintSet.connect(R.id.notification_stack_scroller, START, PARENT_ID, START);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index 150d9c8fcce6..bba2d344a241 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -36,6 +36,7 @@ import android.view.WindowInsets;
import android.view.accessibility.AccessibilityEvent;
import android.widget.LinearLayout;
+import com.android.internal.policy.SystemBarUtils;
import com.android.systemui.Dependency;
import com.android.systemui.EventLogTags;
import com.android.systemui.R;
@@ -298,7 +299,7 @@ public class PhoneStatusBarView extends PanelBar {
final int waterfallTopInset =
mDisplayCutout == null ? 0 : mDisplayCutout.getWaterfallInsets().top;
ViewGroup.LayoutParams layoutParams = getLayoutParams();
- mStatusBarHeight = getResources().getDimensionPixelSize(R.dimen.status_bar_height);
+ mStatusBarHeight = SystemBarUtils.getStatusBarHeight(mContext);
layoutParams.height = mStatusBarHeight - waterfallTopInset;
int statusBarPaddingTop = getResources().getDimensionPixelSize(
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProvider.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProvider.kt
index 5bfb2361d4a1..16d7f983d0f3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProvider.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProvider.kt
@@ -25,6 +25,7 @@ import android.view.DisplayCutout
import android.view.View.LAYOUT_DIRECTION_RTL
import android.view.WindowMetrics
import androidx.annotation.VisibleForTesting
+import com.android.internal.policy.SystemBarUtils
import com.android.systemui.Dumpable
import com.android.systemui.R
import com.android.systemui.dagger.SysUISingleton
@@ -174,7 +175,7 @@ class StatusBarContentInsetsProvider @Inject constructor(
targetRotation,
dc,
context.resources.configuration.windowConfiguration.maxBounds,
- rotatedResources.getDimensionPixelSize(R.dimen.status_bar_height),
+ SystemBarUtils.getStatusBarHeight(context),
minLeft,
minRight)
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java
index eb405e9bdea3..b742394b18a5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarTouchableRegionManager.java
@@ -29,6 +29,7 @@ import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnComputeInternalInsetsListener;
import android.view.WindowInsets;
+import com.android.internal.policy.SystemBarUtils;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
import com.android.systemui.ScreenDecorations;
@@ -172,8 +173,7 @@ public final class StatusBarTouchableRegionManager implements Dumpable {
Resources resources = mContext.getResources();
mDisplayCutoutTouchableRegionSize = resources.getDimensionPixelSize(
com.android.internal.R.dimen.display_cutout_touchable_region_size);
- mStatusBarHeight =
- resources.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
+ mStatusBarHeight = SystemBarUtils.getStatusBarHeight(mContext);
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java
index 235a8e85a223..9d2dbc12c97d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java
@@ -40,6 +40,7 @@ import android.view.Surface;
import android.view.ViewGroup;
import android.view.WindowManager;
+import com.android.internal.policy.SystemBarUtils;
import com.android.systemui.R;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
@@ -86,8 +87,7 @@ public class StatusBarWindowController {
mResources = resources;
if (mBarHeight < 0) {
- mBarHeight = mResources.getDimensionPixelSize(
- com.android.internal.R.dimen.status_bar_height);
+ mBarHeight = SystemBarUtils.getStatusBarHeight(mContext);
}
}
@@ -96,12 +96,11 @@ public class StatusBarWindowController {
}
/**
- * Rereads the status_bar_height from configuration and reapplys the current state if the height
+ * Rereads the status bar height and reapplys the current state if the height
* is different.
*/
public void refreshStatusBarHeight() {
- int heightFromConfig = mResources.getDimensionPixelSize(
- com.android.internal.R.dimen.status_bar_height);
+ int heightFromConfig = SystemBarUtils.getStatusBarHeight(mContext);
if (mBarHeight != heightFromConfig) {
mBarHeight = heightFromConfig;
@@ -139,29 +138,20 @@ public class StatusBarWindowController {
private WindowManager.LayoutParams getBarLayoutParamsForRotation(int rotation) {
int height = mBarHeight;
if (INSETS_LAYOUT_GENERALIZATION) {
- Rect displayBounds = mWindowManager.getCurrentWindowMetrics().getBounds();
- int defaultAndUpsideDownHeight;
- int theOtherHeight;
- if (displayBounds.width() > displayBounds.height()) {
- defaultAndUpsideDownHeight = mContext.getResources().getDimensionPixelSize(
- com.android.internal.R.dimen.status_bar_height_landscape);
- theOtherHeight = mContext.getResources().getDimensionPixelSize(
- com.android.internal.R.dimen.status_bar_height_portrait);
- } else {
- defaultAndUpsideDownHeight = mContext.getResources().getDimensionPixelSize(
- com.android.internal.R.dimen.status_bar_height_portrait);
- theOtherHeight = mContext.getResources().getDimensionPixelSize(
- com.android.internal.R.dimen.status_bar_height_landscape);
- }
switch (rotation) {
case ROTATION_UNDEFINED:
case Surface.ROTATION_0:
case Surface.ROTATION_180:
- height = defaultAndUpsideDownHeight;
+ 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 = theOtherHeight;
+ height = SystemBarUtils.getStatusBarHeightForRotation(
+ mContext, Surface.ROTATION_270);
break;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/util/Utils.java b/packages/SystemUI/src/com/android/systemui/util/Utils.java
index a1cdfd8201c7..407dc5e2787a 100644
--- a/packages/SystemUI/src/com/android/systemui/util/Utils.java
+++ b/packages/SystemUI/src/com/android/systemui/util/Utils.java
@@ -24,8 +24,10 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.provider.Settings;
import android.view.ContextThemeWrapper;
+import android.view.DisplayCutout;
import android.view.View;
+import com.android.internal.policy.SystemBarUtils;
import com.android.systemui.R;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.statusbar.CommandQueue;
@@ -186,4 +188,39 @@ public class Utils {
return color;
}
+ /**
+ * Gets the {@link R.dimen#split_shade_header_height}.
+ *
+ * Currently, it's the same as {@link com.android.internal.R.dimen#quick_qs_offset_height}.
+ */
+ public static int getSplitShadeStatusBarHeight(Context context) {
+ return SystemBarUtils.getQuickQsOffsetHeight(context);
+ }
+
+ /**
+ * Gets the {@link R.dimen#qs_header_system_icons_area_height}.
+ *
+ * It's the same as {@link com.android.internal.R.dimen#quick_qs_offset_height} except for
+ * sw600dp-land.
+ */
+ public static int getQsHeaderSystemIconsAreaHeight(Context context) {
+ final Resources res = context.getResources();
+ if (Utils.shouldUseSplitNotificationShade(res)) {
+ return res.getDimensionPixelSize(R.dimen.qs_header_system_icons_area_height);
+ } else {
+ return SystemBarUtils.getQuickQsOffsetHeight(context);
+ }
+ }
+
+ /**
+ * Gets the {@link R.dimen#status_bar_header_height_keyguard}.
+ */
+ public static int getStatusBarHeaderHeightKeyguard(Context context) {
+ final int statusBarHeight = SystemBarUtils.getStatusBarHeight(context);
+ final DisplayCutout cutout = context.getDisplay().getCutout();
+ final int waterfallInsetTop = cutout == null ? 0 : cutout.getWaterfallInsets().top;
+ final int statusBarHeaderHeightKeyguard = context.getResources()
+ .getDimensionPixelSize(R.dimen.status_bar_header_height_keyguard);
+ return Math.max(statusBarHeight, statusBarHeaderHeightKeyguard + waterfallInsetTop);
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/clock/SmallClockPositionTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/clock/SmallClockPositionTest.kt
index 456f32b4bd40..3a27e356ed84 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/clock/SmallClockPositionTest.kt
+++ b/packages/SystemUI/tests/src/com/android/keyguard/clock/SmallClockPositionTest.kt
@@ -43,7 +43,7 @@ class SmallClockPositionTest : SysuiTestCase() {
@Test
fun loadResources() {
// Cover constructor taking Resources object.
- position = SmallClockPosition(context.resources)
+ position = SmallClockPosition(context)
position.setDarkAmount(1f)
assertThat(position.preferredY).isGreaterThan(0)
}
diff --git a/packages/overlays/DisplayCutoutEmulationCornerOverlay/res/values-land/config.xml b/packages/overlays/DisplayCutoutEmulationCornerOverlay/res/values-land/config.xml
deleted file mode 100644
index bd52901cef95..000000000000
--- a/packages/overlays/DisplayCutoutEmulationCornerOverlay/res/values-land/config.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
- ~ Copyright (C) 2018 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
- -->
-
-<resources>
- <!-- Can't link to other dimensions here, but this should be status_bar_height_landscape -->
- <dimen name="quick_qs_offset_height">28dp</dimen>
- <!-- Total height of QQS in landscape; quick_qs_offset_height + 128 -->
- <dimen name="quick_qs_total_height">156dp</dimen>
-</resources> \ No newline at end of file
diff --git a/packages/overlays/DisplayCutoutEmulationCornerOverlay/res/values/config.xml b/packages/overlays/DisplayCutoutEmulationCornerOverlay/res/values/config.xml
index 9254b4d65b50..c340432b9b8c 100644
--- a/packages/overlays/DisplayCutoutEmulationCornerOverlay/res/values/config.xml
+++ b/packages/overlays/DisplayCutoutEmulationCornerOverlay/res/values/config.xml
@@ -44,14 +44,6 @@
-->
<bool name="config_fillMainBuiltInDisplayCutout">true</bool>
- <!-- Height of the status bar -->
- <dimen name="status_bar_height_portrait">48dp</dimen>
- <dimen name="status_bar_height_landscape">28dp</dimen>
- <!-- Height of area above QQS where battery/time go (equal to status bar height if > 48dp) -->
- <dimen name="quick_qs_offset_height">48dp</dimen>
- <!-- Total height of QQS (quick_qs_offset_height + 128) -->
- <dimen name="quick_qs_total_height">176dp</dimen>
-
</resources>
diff --git a/packages/overlays/DisplayCutoutEmulationDoubleOverlay/res/values-land/config.xml b/packages/overlays/DisplayCutoutEmulationDoubleOverlay/res/values-land/config.xml
deleted file mode 100644
index bd52901cef95..000000000000
--- a/packages/overlays/DisplayCutoutEmulationDoubleOverlay/res/values-land/config.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
- ~ Copyright (C) 2018 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
- -->
-
-<resources>
- <!-- Can't link to other dimensions here, but this should be status_bar_height_landscape -->
- <dimen name="quick_qs_offset_height">28dp</dimen>
- <!-- Total height of QQS in landscape; quick_qs_offset_height + 128 -->
- <dimen name="quick_qs_total_height">156dp</dimen>
-</resources> \ No newline at end of file
diff --git a/packages/overlays/DisplayCutoutEmulationDoubleOverlay/res/values/config.xml b/packages/overlays/DisplayCutoutEmulationDoubleOverlay/res/values/config.xml
index 80c997a46264..928d9dfa3ce1 100644
--- a/packages/overlays/DisplayCutoutEmulationDoubleOverlay/res/values/config.xml
+++ b/packages/overlays/DisplayCutoutEmulationDoubleOverlay/res/values/config.xml
@@ -56,14 +56,6 @@
-->
<bool name="config_fillMainBuiltInDisplayCutout">true</bool>
- <!-- Height of the status bar -->
- <dimen name="status_bar_height_portrait">48dp</dimen>
- <dimen name="status_bar_height_landscape">28dp</dimen>
- <!-- Height of area above QQS where battery/time go (equal to status bar height if > 48dp) -->
- <dimen name="quick_qs_offset_height">48dp</dimen>
- <!-- Total height of QQS (quick_qs_offset_height + 128) -->
- <dimen name="quick_qs_total_height">176dp</dimen>
-
</resources>
diff --git a/packages/overlays/DisplayCutoutEmulationHoleOverlay/res/values-land/config.xml b/packages/overlays/DisplayCutoutEmulationHoleOverlay/res/values-land/config.xml
deleted file mode 100644
index 2e971ded2256..000000000000
--- a/packages/overlays/DisplayCutoutEmulationHoleOverlay/res/values-land/config.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
- ~ Copyright (C) 2020 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
- -->
-
-<resources>
- <!-- Can't link to other dimensions here, but this should be status_bar_height_landscape -->
- <dimen name="quick_qs_offset_height">28dp</dimen>
- <!-- Total height of QQS in landscape; quick_qs_offset_height + 128 -->
- <dimen name="quick_qs_total_height">156dp</dimen>
-</resources>
diff --git a/packages/overlays/DisplayCutoutEmulationHoleOverlay/res/values/config.xml b/packages/overlays/DisplayCutoutEmulationHoleOverlay/res/values/config.xml
index 9f558d0e2bd5..62f0535a1746 100644
--- a/packages/overlays/DisplayCutoutEmulationHoleOverlay/res/values/config.xml
+++ b/packages/overlays/DisplayCutoutEmulationHoleOverlay/res/values/config.xml
@@ -48,14 +48,6 @@
-->
<bool name="config_fillMainBuiltInDisplayCutout">true</bool>
- <!-- Height of the status bar -->
- <dimen name="status_bar_height_portrait">136px</dimen>
- <dimen name="status_bar_height_landscape">28dp</dimen>
- <!-- Height of area above QQS where battery/time go (equal to status bar) -->
- <dimen name="quick_qs_offset_height">136px</dimen>
- <!-- Total height of QQS (quick_qs_offset_height + 128) -->
- <dimen name="quick_qs_total_height">488px</dimen>
-
</resources>
diff --git a/packages/overlays/DisplayCutoutEmulationNarrowOverlay/res/values-land/config.xml b/packages/overlays/DisplayCutoutEmulationNarrowOverlay/res/values-land/config.xml
deleted file mode 100644
index bd52901cef95..000000000000
--- a/packages/overlays/DisplayCutoutEmulationNarrowOverlay/res/values-land/config.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
- ~ Copyright (C) 2018 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
- -->
-
-<resources>
- <!-- Can't link to other dimensions here, but this should be status_bar_height_landscape -->
- <dimen name="quick_qs_offset_height">28dp</dimen>
- <!-- Total height of QQS in landscape; quick_qs_offset_height + 128 -->
- <dimen name="quick_qs_total_height">156dp</dimen>
-</resources> \ No newline at end of file
diff --git a/packages/overlays/DisplayCutoutEmulationNarrowOverlay/res/values/config.xml b/packages/overlays/DisplayCutoutEmulationNarrowOverlay/res/values/config.xml
index 6fb3c7f51e26..a9f8b4bc6329 100644
--- a/packages/overlays/DisplayCutoutEmulationNarrowOverlay/res/values/config.xml
+++ b/packages/overlays/DisplayCutoutEmulationNarrowOverlay/res/values/config.xml
@@ -47,14 +47,6 @@
-->
<bool name="config_fillMainBuiltInDisplayCutout">true</bool>
- <!-- Height of the status bar -->
- <dimen name="status_bar_height_portrait">48dp</dimen>
- <dimen name="status_bar_height_landscape">28dp</dimen>
- <!-- Height of area above QQS where battery/time go (equal to status bar height if > 48dp) -->
- <dimen name="quick_qs_offset_height">48dp</dimen>
- <!-- Total height of QQS (quick_qs_offset_height + 128) -->
- <dimen name="quick_qs_total_height">176dp</dimen>
-
</resources>
diff --git a/packages/overlays/DisplayCutoutEmulationTallOverlay/res/values-land/config.xml b/packages/overlays/DisplayCutoutEmulationTallOverlay/res/values-land/config.xml
deleted file mode 100644
index bd52901cef95..000000000000
--- a/packages/overlays/DisplayCutoutEmulationTallOverlay/res/values-land/config.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
- ~ Copyright (C) 2018 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
- -->
-
-<resources>
- <!-- Can't link to other dimensions here, but this should be status_bar_height_landscape -->
- <dimen name="quick_qs_offset_height">28dp</dimen>
- <!-- Total height of QQS in landscape; quick_qs_offset_height + 128 -->
- <dimen name="quick_qs_total_height">156dp</dimen>
-</resources> \ No newline at end of file
diff --git a/packages/overlays/DisplayCutoutEmulationTallOverlay/res/values/config.xml b/packages/overlays/DisplayCutoutEmulationTallOverlay/res/values/config.xml
index 7c29ffb92f4e..be7d0e48fa3f 100644
--- a/packages/overlays/DisplayCutoutEmulationTallOverlay/res/values/config.xml
+++ b/packages/overlays/DisplayCutoutEmulationTallOverlay/res/values/config.xml
@@ -47,14 +47,6 @@
-->
<bool name="config_fillMainBuiltInDisplayCutout">true</bool>
- <!-- Height of the status bar -->
- <dimen name="status_bar_height_portrait">48dp</dimen>
- <dimen name="status_bar_height_landscape">28dp</dimen>
- <!-- Height of area above QQS where battery/time go (equal to status bar height if > 48dp) -->
- <dimen name="quick_qs_offset_height">48dp</dimen>
- <!-- Total height of QQS (quick_qs_offset_height + 128) -->
- <dimen name="quick_qs_total_height">176dp</dimen>
-
</resources>
diff --git a/packages/overlays/DisplayCutoutEmulationWaterfallOverlay/res/values-land/config.xml b/packages/overlays/DisplayCutoutEmulationWaterfallOverlay/res/values-land/config.xml
deleted file mode 100644
index df2f3d19626e..000000000000
--- a/packages/overlays/DisplayCutoutEmulationWaterfallOverlay/res/values-land/config.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
- ~ Copyright (C) 2020 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.
- -->
-
-<resources>
- <!-- Can't link to other dimensions here, but this should be status_bar_height_landscape -->
- <dimen name="quick_qs_offset_height">48dp</dimen>
- <!-- Total height of QQS in landscape; quick_qs_offset_height + 128 -->
- <dimen name="quick_qs_total_height">176dp</dimen>
-</resources> \ No newline at end of file
diff --git a/packages/overlays/DisplayCutoutEmulationWaterfallOverlay/res/values/config.xml b/packages/overlays/DisplayCutoutEmulationWaterfallOverlay/res/values/config.xml
index 8d0227eed875..cc51ebee270c 100644
--- a/packages/overlays/DisplayCutoutEmulationWaterfallOverlay/res/values/config.xml
+++ b/packages/overlays/DisplayCutoutEmulationWaterfallOverlay/res/values/config.xml
@@ -19,16 +19,6 @@
<string translatable="false" name="config_mainBuiltInDisplayCutout"></string>
<string translatable="false" name="config_mainBuiltInDisplayCutoutRectApproximation"></string>
- <!-- Height of the status bar in portrait. The height should be
- Max((status bar content height + waterfall top size), top cutout size) -->
- <dimen name="status_bar_height_portrait">28dp</dimen>
- <!-- Max((28 + 20), 0) = 48 -->
- <dimen name="status_bar_height_landscape">48dp</dimen>
- <!-- Height of area above QQS where battery/time go (equal to status bar height if > 48dp) -->
- <dimen name="quick_qs_offset_height">48dp</dimen>
- <!-- Total height of QQS (quick_qs_offset_height + 128) -->
- <dimen name="quick_qs_total_height">176dp</dimen>
-
<dimen name="waterfall_display_left_edge_size">20dp</dimen>
<dimen name="waterfall_display_top_edge_size">0dp</dimen>
<dimen name="waterfall_display_right_edge_size">20dp</dimen>
diff --git a/packages/overlays/DisplayCutoutEmulationWideOverlay/res/values-land/config.xml b/packages/overlays/DisplayCutoutEmulationWideOverlay/res/values-land/config.xml
deleted file mode 100644
index bd52901cef95..000000000000
--- a/packages/overlays/DisplayCutoutEmulationWideOverlay/res/values-land/config.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
- ~ Copyright (C) 2018 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
- -->
-
-<resources>
- <!-- Can't link to other dimensions here, but this should be status_bar_height_landscape -->
- <dimen name="quick_qs_offset_height">28dp</dimen>
- <!-- Total height of QQS in landscape; quick_qs_offset_height + 128 -->
- <dimen name="quick_qs_total_height">156dp</dimen>
-</resources> \ No newline at end of file
diff --git a/packages/overlays/DisplayCutoutEmulationWideOverlay/res/values/config.xml b/packages/overlays/DisplayCutoutEmulationWideOverlay/res/values/config.xml
index 5fb8b9e241b8..78cc7e04c7a0 100644
--- a/packages/overlays/DisplayCutoutEmulationWideOverlay/res/values/config.xml
+++ b/packages/overlays/DisplayCutoutEmulationWideOverlay/res/values/config.xml
@@ -47,14 +47,6 @@
-->
<bool name="config_fillMainBuiltInDisplayCutout">true</bool>
- <!-- Height of the status bar -->
- <dimen name="status_bar_height_portrait">48dp</dimen>
- <dimen name="status_bar_height_landscape">28dp</dimen>
- <!-- Height of area above QQS where battery/time go (equal to status bar height if > 48dp) -->
- <dimen name="quick_qs_offset_height">48dp</dimen>
- <!-- Total height of QQS (quick_qs_offset_height + 128) -->
- <dimen name="quick_qs_total_height">176dp</dimen>
-
</resources>
diff --git a/packages/overlays/NoCutoutOverlay/res/values/config.xml b/packages/overlays/NoCutoutOverlay/res/values/config.xml
index 91576998cc54..84b91b85350d 100644
--- a/packages/overlays/NoCutoutOverlay/res/values/config.xml
+++ b/packages/overlays/NoCutoutOverlay/res/values/config.xml
@@ -25,12 +25,4 @@
by shrinking the display such that it does not overlap the cutout area. -->
<bool name="config_maskMainBuiltInDisplayCutout">true</bool>
- <!-- Height of the status bar -->
- <dimen name="status_bar_height_portrait">28dp</dimen>
- <dimen name="status_bar_height_landscape">28dp</dimen>
-
- <!-- Height of area above QQS where battery/time go (equal to status bar height if > 48dp) -->
- <dimen name="quick_qs_offset_height">48dp</dimen>
- <!-- Total height of QQS (quick_qs_offset_height + 128) -->
- <dimen name="quick_qs_total_height">176dp</dimen>
</resources>
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index 50c56de49134..6a5a76e455e4 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -156,6 +156,7 @@ import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.policy.GestureNavigationSettingsObserver;
import com.android.internal.policy.ScreenDecorationsUtils;
+import com.android.internal.policy.SystemBarUtils;
import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.ScreenshotHelper;
import com.android.internal.util.function.TriConsumer;
@@ -1330,6 +1331,11 @@ public class DisplayPolicy {
return Math.max(statusBarHeight, displayFrames.mDisplayCutoutSafe.top);
}
+ @VisibleForTesting
+ int getStatusBarHeightForRotation(@Surface.Rotation int rotation) {
+ return SystemBarUtils.getStatusBarHeightForRotation(mUiContext, rotation);
+ }
+
WindowState getStatusBar() {
return mStatusBar != null ? mStatusBar : mStatusBarAlt;
}
@@ -1599,8 +1605,6 @@ public class DisplayPolicy {
// For layout, the status bar is always at the top with our fixed height.
int statusBarBottom = displayFrames.mUnrestricted.top
+ mStatusBarHeightForRotation[displayFrames.mRotation];
- // Make sure the status bar covers the entire cutout height
- statusBarBottom = Math.max(statusBarBottom, displayFrames.mDisplayCutoutSafe.top);
if (displayFrames.mDisplayCutoutSafe.top > displayFrames.mUnrestricted.top) {
// Make sure that the zone we're avoiding for the cutout is at least as tall as the
@@ -2133,10 +2137,11 @@ public class DisplayPolicy {
if (hasStatusBar()) {
mStatusBarHeightForRotation[portraitRotation] =
mStatusBarHeightForRotation[upsideDownRotation] =
- res.getDimensionPixelSize(R.dimen.status_bar_height_portrait);
+ getStatusBarHeightForRotation(portraitRotation);
mStatusBarHeightForRotation[landscapeRotation] =
- mStatusBarHeightForRotation[seascapeRotation] =
- res.getDimensionPixelSize(R.dimen.status_bar_height_landscape);
+ getStatusBarHeightForRotation(landscapeRotation);
+ mStatusBarHeightForRotation[seascapeRotation] =
+ getStatusBarHeightForRotation(seascapeRotation);
mDisplayCutoutTouchableRegionSize = res.getDimensionPixelSize(
R.dimen.display_cutout_touchable_region_size);
} else {
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTestsBase.java
index 3982a83d7778..1d2baab934e5 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTestsBase.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTestsBase.java
@@ -31,6 +31,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.server.wm.utils.CoordinateTransforms.transformPhysicalToLogicalCoordinates;
import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.anyInt;
import android.content.Context;
import android.content.ContextWrapper;
@@ -75,13 +76,12 @@ public class DisplayPolicyTestsBase extends WindowTestsBase {
final TestContextWrapper context = new TestContextWrapper(
mDisplayPolicy.getContext(), mDisplayPolicy.getCurrentUserResources());
final TestableResources resources = context.getResourceMocker();
- resources.addOverride(R.dimen.status_bar_height_portrait, STATUS_BAR_HEIGHT);
- resources.addOverride(R.dimen.status_bar_height_landscape, STATUS_BAR_HEIGHT);
resources.addOverride(R.dimen.navigation_bar_height, NAV_BAR_HEIGHT);
resources.addOverride(R.dimen.navigation_bar_height_landscape, NAV_BAR_HEIGHT);
resources.addOverride(R.dimen.navigation_bar_width, NAV_BAR_HEIGHT);
resources.addOverride(R.dimen.navigation_bar_frame_height_landscape, NAV_BAR_HEIGHT);
resources.addOverride(R.dimen.navigation_bar_frame_height, NAV_BAR_HEIGHT);
+ doReturn(STATUS_BAR_HEIGHT).when(mDisplayPolicy).getStatusBarHeightForRotation(anyInt());
doReturn(resources.getResources()).when(mDisplayPolicy).getCurrentUserResources();
doReturn(true).when(mDisplayPolicy).hasNavigationBar();
doReturn(true).when(mDisplayPolicy).hasStatusBar();
diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
index 6407c92ee2aa..530ee535d529 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
@@ -83,6 +83,8 @@ import android.view.WindowManager;
import androidx.test.filters.MediumTest;
+import com.android.internal.policy.SystemBarUtils;
+
import libcore.junit.util.compat.CoreCompatChangeRule.DisableCompatChanges;
import libcore.junit.util.compat.CoreCompatChangeRule.EnableCompatChanges;
@@ -2126,8 +2128,7 @@ public class SizeCompatTests extends WindowTestsBase {
displayContent.mWmService, mock(Session.class), new TestIWindow(), attrs, token);
token.addWindow(statusBar);
statusBar.setRequestedSize(displayContent.mBaseDisplayWidth,
- displayContent.getDisplayUiContext().getResources().getDimensionPixelSize(
- com.android.internal.R.dimen.status_bar_height));
+ SystemBarUtils.getStatusBarHeight(displayContent.getDisplayUiContext()));
displayPolicy.addWindowLw(statusBar, attrs);
displayPolicy.layoutWindowLw(statusBar, null, displayContent.mDisplayFrames);