diff options
| author | 2023-03-06 10:34:36 -0500 | |
|---|---|---|
| committer | 2023-03-20 19:17:03 +0000 | |
| commit | 220ea0932c737e1bcc26bff9ceb9e4f03c340560 (patch) | |
| tree | e0ee625b0038c36ce1125c7d61260880a3869696 | |
| parent | e50a62e38e611435e5448d56f0a090cd7112bb0b (diff) | |
Fix || for != in QSTileViewImpl
The block to change colors should only be ran if the colors actually
need to change. The condition was wrongly written, but because those
variables are boolean, the only effect it had was that it would be
called more often (sometimes when colors didn't need to change).
Test: atest QSTileViewImpl
Fixes: 271835100
Change-Id: Idd160b31b72cb18b8d90aa48133dc425a414c697
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt | 2 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt index de1137e48074..5eea6c2803d3 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt @@ -490,7 +490,7 @@ open class QSTileViewImpl @JvmOverloads constructor( } // Colors - if (state.state != lastState || state.disabledByPolicy || lastDisabledByPolicy) { + if (state.state != lastState || state.disabledByPolicy != lastDisabledByPolicy) { singleAnimator.cancel() mQsLogger?.logTileBackgroundColorUpdateIfInternetTile( state.spec, diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt index d3ec1dd8bfb2..28aeba461c50 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt @@ -317,6 +317,26 @@ class QSTileViewImplTest : SysuiTestCase() { } @Test + fun testDisableByPolicyThenRemoved_changesColor() { + val stateActive = QSTile.State() + stateActive.state = Tile.STATE_ACTIVE + + val stateDisabledByPolicy = stateActive.copy() + stateDisabledByPolicy.disabledByPolicy = true + + tileView.changeState(stateActive) + val activeColors = tileView.getCurrentColors() + + tileView.changeState(stateDisabledByPolicy) + // It has unavailable colors + assertThat(tileView.getCurrentColors()).isNotEqualTo(activeColors) + + // When we get back to not disabled by policy tile, it should go back to active colors + tileView.changeState(stateActive) + assertThat(tileView.getCurrentColors()).containsExactlyElementsIn(activeColors) + } + + @Test fun testDisabledByPolicy_secondaryLabelText() { val testA11yLabel = "TEST_LABEL" context.orCreateTestableResources |