diff options
6 files changed, 96 insertions, 3 deletions
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig index 2ad7192a3248..6a4f92c92d6f 100644 --- a/packages/SystemUI/aconfig/systemui.aconfig +++ b/packages/SystemUI/aconfig/systemui.aconfig @@ -227,6 +227,17 @@ flag { } flag { + name: "truncated_status_bar_icons_fix" + namespace: "systemui" + description: "Fixes the status bar icons being trunacted due to the status bar window height " + "not being updated after certain rotations" + bug: "323299264" + metadata { + purpose: PURPOSE_BUGFIX + } +} + +flag { name: "compose_bouncer" namespace: "systemui" description: "Use the new compose bouncer in SystemUI" diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java index 1a34cc4fc3a9..91157d7ebb20 100644 --- a/packages/SystemUI/src/com/android/systemui/Dependency.java +++ b/packages/SystemUI/src/com/android/systemui/Dependency.java @@ -59,6 +59,7 @@ import com.android.systemui.statusbar.phone.SystemUIDialogManager; import com.android.systemui.statusbar.policy.BluetoothController; import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.systemui.statusbar.policy.FlashlightController; +import com.android.systemui.statusbar.window.StatusBarWindowController; import com.android.systemui.tuner.TunablePadding.TunablePaddingService; import com.android.systemui.tuner.TunerService; @@ -172,6 +173,7 @@ public class Dependency { @Inject Lazy<SystemUIDialogManager> mSystemUIDialogManagerLazy; @Inject Lazy<DialogLaunchAnimator> mDialogLaunchAnimatorLazy; @Inject Lazy<UserTracker> mUserTrackerLazy; + @Inject Lazy<StatusBarWindowController> mStatusBarWindowControllerLazy; @Inject public Dependency() { @@ -226,6 +228,7 @@ public class Dependency { mProviders.put(SystemUIDialogManager.class, mSystemUIDialogManagerLazy::get); mProviders.put(DialogLaunchAnimator.class, mDialogLaunchAnimatorLazy::get); mProviders.put(UserTracker.class, mUserTrackerLazy::get); + mProviders.put(StatusBarWindowController.class, mStatusBarWindowControllerLazy::get); Dependency.setInstance(this); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index 209936108f6b..3eb41f8fb89b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -29,6 +29,7 @@ import static androidx.lifecycle.Lifecycle.State.RESUMED; import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME; import static com.android.systemui.Flags.lightRevealMigration; import static com.android.systemui.Flags.predictiveBackSysui; +import static com.android.systemui.Flags.truncatedStatusBarIconsFix; import static com.android.systemui.charging.WirelessChargingAnimation.UNKNOWN_BATTERY_LEVEL; import static com.android.systemui.statusbar.NotificationLockscreenUserManager.PERMISSION_SELF; import static com.android.systemui.statusbar.StatusBarState.SHADE; @@ -1905,10 +1906,11 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mQSPanelController.updateResources(); } - if (mStatusBarWindowController != null) { - mStatusBarWindowController.refreshStatusBarHeight(); + if (!truncatedStatusBarIconsFix()) { + if (mStatusBarWindowController != null) { + mStatusBarWindowController.refreshStatusBarHeight(); + } } - if (mShadeSurface != null) { mShadeSurface.updateResources(); } 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 cb7bc256504e..45bdae83bbd9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java @@ -17,6 +17,8 @@ package com.android.systemui.statusbar.phone; +import static com.android.systemui.Flags.truncatedStatusBarIconsFix; + import android.annotation.Nullable; import android.content.Context; import android.content.res.Configuration; @@ -41,6 +43,7 @@ import com.android.systemui.plugins.DarkIconDispatcher; import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver; import com.android.systemui.statusbar.phone.userswitcher.StatusBarUserSwitcherContainer; import com.android.systemui.statusbar.policy.Clock; +import com.android.systemui.statusbar.window.StatusBarWindowController; import com.android.systemui.user.ui.binder.StatusBarUserChipViewBinder; import com.android.systemui.user.ui.viewmodel.StatusBarUserChipViewModel; import com.android.systemui.util.leak.RotationUtils; @@ -50,6 +53,7 @@ import java.util.Objects; public class PhoneStatusBarView extends FrameLayout { private static final String TAG = "PhoneStatusBarView"; private final StatusBarContentInsetsProvider mContentInsetsProvider; + private final StatusBarWindowController mStatusBarWindowController; private DarkReceiver mBattery; private Clock mClock; @@ -72,6 +76,7 @@ public class PhoneStatusBarView extends FrameLayout { public PhoneStatusBarView(Context context, AttributeSet attrs) { super(context, attrs); mContentInsetsProvider = Dependency.get(StatusBarContentInsetsProvider.class); + mStatusBarWindowController = Dependency.get(StatusBarWindowController.class); } void setTouchEventHandler(Gefingerpoken handler) { @@ -101,6 +106,9 @@ public class PhoneStatusBarView extends FrameLayout { Dependency.get(DarkIconDispatcher.class).addDarkReceiver(mClock); if (updateDisplayParameters()) { updateLayoutForCutout(); + if (truncatedStatusBarIconsFix()) { + updateWindowHeight(); + } } } @@ -124,6 +132,9 @@ public class PhoneStatusBarView extends FrameLayout { if (updateDisplayParameters()) { updateLayoutForCutout(); requestLayout(); + if (truncatedStatusBarIconsFix()) { + updateWindowHeight(); + } } } @@ -279,4 +290,8 @@ public class PhoneStatusBarView extends FrameLayout { insets.right, getPaddingBottom()); } + + private void updateWindowHeight() { + mStatusBarWindowController.refreshStatusBarHeight(); + } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java index b048949e0e76..fe299179d28f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java @@ -1053,6 +1053,24 @@ public class CentralSurfacesImplTest extends SysuiTestCase { verify(mBubbles).onStatusBarVisibilityChanged(true); } + @Test + public void updateResources_flagEnabled_doesNotUpdateStatusBarWindowHeight() { + mSetFlagsRule.enableFlags(com.android.systemui.Flags.FLAG_TRUNCATED_STATUS_BAR_ICONS_FIX); + + mCentralSurfaces.updateResources(); + + verify(mStatusBarWindowController, never()).refreshStatusBarHeight(); + } + + @Test + public void updateResources_flagDisabled_updatesStatusBarWindowHeight() { + mSetFlagsRule.disableFlags(com.android.systemui.Flags.FLAG_TRUNCATED_STATUS_BAR_ICONS_FIX); + + mCentralSurfaces.updateResources(); + + verify(mStatusBarWindowController).refreshStatusBarHeight(); + } + /** * Configures the appropriate mocks and then calls {@link CentralSurfacesImpl#updateIsKeyguard} * to reconfigure the keyguard to reflect the requested showing/occluded states. diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewTest.kt index 65d71f8b4540..6eb1c1a9f12c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewTest.kt @@ -29,16 +29,20 @@ import android.view.RoundedCorners import android.view.WindowInsets import android.widget.FrameLayout import androidx.test.filters.SmallTest +import com.android.systemui.Flags import com.android.systemui.Gefingerpoken import com.android.systemui.SysuiTestCase import com.android.systemui.plugins.DarkIconDispatcher import com.android.systemui.res.R +import com.android.systemui.statusbar.window.StatusBarWindowController import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Test +import org.mockito.Mockito.never import org.mockito.Mockito.spy +import org.mockito.Mockito.verify @SmallTest @RunWithLooper(setAsMainLooper = true) @@ -47,6 +51,7 @@ class PhoneStatusBarViewTest : SysuiTestCase() { private lateinit var view: PhoneStatusBarView private val contentInsetsProvider = mock<StatusBarContentInsetsProvider>() + private val windowController = mock<StatusBarWindowController>() @Before fun setUp() { @@ -55,8 +60,11 @@ class PhoneStatusBarViewTest : SysuiTestCase() { contentInsetsProvider ) mDependency.injectTestDependency(DarkIconDispatcher::class.java, mock<DarkIconDispatcher>()) + mDependency.injectTestDependency(StatusBarWindowController::class.java, windowController) view = spy(createStatusBarView()) whenever(view.rootWindowInsets).thenReturn(emptyWindowInsets()) + whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) + .thenReturn(Insets.NONE) } @Test @@ -110,6 +118,42 @@ class PhoneStatusBarViewTest : SysuiTestCase() { } @Test + fun onAttachedToWindow_flagEnabled_updatesWindowHeight() { + mSetFlagsRule.enableFlags(Flags.FLAG_TRUNCATED_STATUS_BAR_ICONS_FIX) + + view.onAttachedToWindow() + + verify(windowController).refreshStatusBarHeight() + } + + @Test + fun onAttachedToWindow_flagDisabled_doesNotUpdateWindowHeight() { + mSetFlagsRule.disableFlags(Flags.FLAG_TRUNCATED_STATUS_BAR_ICONS_FIX) + + view.onAttachedToWindow() + + verify(windowController, never()).refreshStatusBarHeight() + } + + @Test + fun onConfigurationChanged_flagEnabled_updatesWindowHeight() { + mSetFlagsRule.enableFlags(Flags.FLAG_TRUNCATED_STATUS_BAR_ICONS_FIX) + + view.onConfigurationChanged(Configuration()) + + verify(windowController).refreshStatusBarHeight() + } + + @Test + fun onConfigurationChanged_flagDisabled_doesNotUpdateWindowHeight() { + mSetFlagsRule.disableFlags(Flags.FLAG_TRUNCATED_STATUS_BAR_ICONS_FIX) + + view.onConfigurationChanged(Configuration()) + + verify(windowController, never()).refreshStatusBarHeight() + } + + @Test fun onAttachedToWindow_updatesLeftTopRightPaddingsBasedOnInsets() { val insets = Insets.of(/* left = */ 10, /* top = */ 20, /* right = */ 30, /* bottom = */ 40) whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation()) |