From 1a9ac28e32620ae4f7ede18ac8222af348df8605 Mon Sep 17 00:00:00 2001 From: Shawn Lee Date: Fri, 26 May 2023 10:16:58 -0700 Subject: [PATCH] Adds mobile indicators to QQS header when multiple SIMs are in use Current behavior hides mobile indicators from shade header when multiple SIMs are active, only showing them in the ShadeCarrierGroup which is only visible in full QS. This adds the mobile indicators to the shade header when in QQS, and removes them when in QS. The transition here is not ideal - it just uses the default animations for adding/removing icons from the shade header - this is due to MotionLayout calculating the size the icon container should lerp to before the mobile icons are added to it. Bug: 278726045 Test: verified single-sim and multi-sim behavior Change-Id: I16e8f0265369d2f9be62174e30817bda537f9970 --- .../systemui/shade/ShadeHeaderController.kt | 15 +++++++++++---- .../statusbar/phone/StatusIconContainer.java | 10 +++++++++- .../systemui/shade/ShadeHeaderControllerTest.kt | 11 +++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt index 3af75cef3d4c9..8789a8b3b7f4d 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt @@ -195,7 +195,9 @@ constructor( set(value) { if (visible && field != value) { field = value + iconContainer.setQsExpansionTransitioning(value > 0f && value < 1.0f) updatePosition() + updateIgnoredSlots() } } @@ -216,6 +218,8 @@ constructor( view.onApplyWindowInsets(insets) } + private var singleCarrier = false + private val demoModeReceiver = object : DemoMode { override fun demoCommands() = listOf(DemoMode.COMMAND_CLOCK) @@ -479,17 +483,20 @@ constructor( private fun updateListeners() { mShadeCarrierGroupController.setListening(visible) if (visible) { - updateSingleCarrier(mShadeCarrierGroupController.isSingleCarrier) + singleCarrier = mShadeCarrierGroupController.isSingleCarrier + updateIgnoredSlots() mShadeCarrierGroupController.setOnSingleCarrierChangedListener { - updateSingleCarrier(it) + singleCarrier = it + updateIgnoredSlots() } } else { mShadeCarrierGroupController.setOnSingleCarrierChangedListener(null) } } - private fun updateSingleCarrier(singleCarrier: Boolean) { - if (singleCarrier) { + private fun updateIgnoredSlots() { + // switching from QQS to QS state halfway through the transition + if (singleCarrier || qsExpandedFraction < 0.5) { iconContainer.removeIgnoredSlots(carrierIconSlots) } else { iconContainer.addIgnoredSlots(carrierIconSlots) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusIconContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusIconContainer.java index 26c17674ab101..a696a98b24065 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusIconContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusIconContainer.java @@ -64,6 +64,7 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout { private boolean mNeedsUnderflow; // Individual StatusBarIconViews draw their etc dots centered in this width private int mIconDotFrameWidth; + private boolean mQsExpansionTransitioning; private boolean mShouldRestrictIcons = true; // Used to count which states want to be visible during layout private ArrayList mLayoutStates = new ArrayList<>(); @@ -87,6 +88,10 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout { super.onFinishInflate(); } + public void setQsExpansionTransitioning(boolean expansionTransitioning) { + mQsExpansionTransitioning = expansionTransitioning; + } + public void setShouldRestrictIcons(boolean should) { mShouldRestrictIcons = should; } @@ -397,6 +402,7 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout { StatusIconState vs = getViewStateFromChild(child); if (vs != null) { vs.applyToView(child); + vs.qsExpansionTransitioning = mQsExpansionTransitioning; } } } @@ -431,6 +437,7 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout { /// StatusBarIconView.STATE_* public int visibleState = STATE_ICON; public boolean justAdded = true; + public boolean qsExpansionTransitioning = false; // How far we are from the end of the view actually is the most relevant for animation float distanceToViewEnd = -1; @@ -473,12 +480,13 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout { } icon.setVisibleState(visibleState, animateVisibility); - if (animationProperties != null) { + if (animationProperties != null && !qsExpansionTransitioning) { animateTo(view, animationProperties); } else { super.applyToView(view); } + qsExpansionTransitioning = false; justAdded = false; distanceToViewEnd = currentDistanceToEnd; diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeHeaderControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeHeaderControllerTest.kt index 2da2e9238d0ad..f542ab0995176 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeHeaderControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeHeaderControllerTest.kt @@ -237,10 +237,21 @@ class ShadeHeaderControllerTest : SysuiTestCase() { whenever(mShadeCarrierGroupController.isSingleCarrier).thenReturn(false) makeShadeVisible() + shadeHeaderController.qsExpandedFraction = 1.0f verify(statusIcons).addIgnoredSlots(carrierIconSlots) } + @Test + fun dualCarrier_enablesCarrierIconsInStatusIcons_qsExpanded() { + whenever(mShadeCarrierGroupController.isSingleCarrier).thenReturn(false) + + makeShadeVisible() + shadeHeaderController.qsExpandedFraction = 0.0f + + verify(statusIcons, times(2)).removeIgnoredSlots(carrierIconSlots) + } + @Test fun disableQS_notDisabled_visible() { makeShadeVisible()