Loading packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java +35 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ package com.android.systemui.qs.tileimpl; import static com.android.systemui.Flags.FLAG_QS_NEW_TILES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.mockito.ArgumentMatchers.any; Loading @@ -21,11 +23,16 @@ import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; import android.graphics.drawable.AnimatedVectorDrawable; import android.graphics.drawable.Drawable; import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.service.quicksettings.Tile; import android.testing.UiThreadTest; import android.widget.ImageView; Loading @@ -47,7 +54,6 @@ import org.mockito.Mockito; @UiThreadTest @SmallTest public class QSIconViewImplTest extends SysuiTestCase { private QSIconViewImpl mIconView; @Before Loading Loading @@ -106,6 +112,34 @@ public class QSIconViewImplTest extends SysuiTestCase { verify(iv).setImageTintList(argThat(stateList -> stateList.getColors()[0] == desiredColor)); } @EnableFlags(FLAG_QS_NEW_TILES) @Test public void testIconPreloaded_withFlagOn_immediatelyLoadsAll3TintColors() { Context ctx = spy(mContext); QSIconViewImpl iconView = new QSIconViewImpl(ctx); verify(ctx, times(3)).obtainStyledAttributes(any()); iconView.getColor(new State()); // this should not increase the call count verify(ctx, times(3)).obtainStyledAttributes(any()); } @DisableFlags(FLAG_QS_NEW_TILES) @Test public void testIconPreloaded_withFlagOff_loadsOneTintColorAfterIconColorIsRead() { Context ctx = spy(mContext); QSIconViewImpl iconView = new QSIconViewImpl(ctx); verify(ctx, never()).obtainStyledAttributes(any()); // none of the colors are preloaded iconView.getColor(new State()); verify(ctx, times(1)).obtainStyledAttributes(any()); } @Test public void testStateSetCorrectly_toString() { ImageView iv = mock(ImageView.class); Loading packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java +4 −1 Original line number Diff line number Diff line Loading @@ -184,7 +184,10 @@ public interface QSTile { } } /** Get the text for secondaryLabel. */ /** * If the current secondaryLabel value is not empty, ignore the given input and return * the current value. Otherwise return current value. */ public CharSequence getSecondaryLabel(CharSequence stateText) { // Use a local reference as the value might change from other threads CharSequence localSecondaryLabel = secondaryLabel; Loading packages/SystemUI/src/com/android/systemui/qs/logging/QSLogger.kt +37 −23 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import com.android.systemui.log.core.LogLevel.VERBOSE import com.android.systemui.log.dagger.QSConfigLog import com.android.systemui.log.dagger.QSLog import com.android.systemui.plugins.qs.QSTile import com.android.systemui.plugins.qs.QSTile.State import com.android.systemui.statusbar.StatusBarState import com.google.errorprone.annotations.CompileTimeConstant import javax.inject.Inject Loading @@ -57,6 +58,7 @@ constructor( fun d(@CompileTimeConstant msg: String, arg: Any) { buffer.log(TAG, DEBUG, { str1 = arg.toString() }, { "$msg: $str1" }) } fun i(@CompileTimeConstant msg: String, arg: Any) { buffer.log(TAG, INFO, { str1 = arg.toString() }, { "$msg: $str1" }) } Loading @@ -73,7 +75,19 @@ constructor( str1 = tileSpec str2 = reason }, { "[$str1] Tile destroyed. Reason: $str2" } { "[$str1] Tile destroyed. Reason: $str2" }, ) } fun logStateChanged(tileSpec: String, state: State) { buffer.log( TAG, DEBUG, { str1 = tileSpec str2 = state.toString() }, { "[$str1] Tile state=$str2" }, ) } Loading @@ -85,7 +99,7 @@ constructor( bool1 = listening str1 = tileSpec }, { "[$str1] Tile listening=$bool1" } { "[$str1] Tile listening=$bool1" }, ) } Loading @@ -98,7 +112,7 @@ constructor( str1 = containerName str2 = allSpecs }, { "Tiles listening=$bool1 in $str1. $str2" } { "Tiles listening=$bool1 in $str1. $str2" }, ) } Loading @@ -112,7 +126,7 @@ constructor( str2 = StatusBarState.toString(statusBarState) str3 = toStateString(state) }, { "[$str1][$int1] Tile clicked. StatusBarState=$str2. TileState=$str3" } { "[$str1][$int1] Tile clicked. StatusBarState=$str2. TileState=$str3" }, ) } Loading @@ -124,7 +138,7 @@ constructor( str1 = tileSpec int1 = eventId }, { "[$str1][$int1] Tile handling click." } { "[$str1][$int1] Tile handling click." }, ) } Loading @@ -138,7 +152,7 @@ constructor( str2 = StatusBarState.toString(statusBarState) str3 = toStateString(state) }, { "[$str1][$int1] Tile secondary clicked. StatusBarState=$str2. TileState=$str3" } { "[$str1][$int1] Tile secondary clicked. StatusBarState=$str2. TileState=$str3" }, ) } Loading @@ -150,7 +164,7 @@ constructor( str1 = tileSpec int1 = eventId }, { "[$str1][$int1] Tile handling secondary click." } { "[$str1][$int1] Tile handling secondary click." }, ) } Loading @@ -164,7 +178,7 @@ constructor( str2 = StatusBarState.toString(statusBarState) str3 = toStateString(state) }, { "[$str1][$int1] Tile long clicked. StatusBarState=$str2. TileState=$str3" } { "[$str1][$int1] Tile long clicked. StatusBarState=$str2. TileState=$str3" }, ) } Loading @@ -176,7 +190,7 @@ constructor( str1 = tileSpec int1 = eventId }, { "[$str1][$int1] Tile handling long click." } { "[$str1][$int1] Tile handling long click." }, ) } Loading @@ -189,7 +203,7 @@ constructor( int1 = lastType str2 = callback }, { "[$str1] mLastTileState=$int1, Callback=$str2." } { "[$str1] mLastTileState=$int1, Callback=$str2." }, ) } Loading @@ -198,7 +212,7 @@ constructor( tileSpec: String, state: Int, disabledByPolicy: Boolean, color: Int color: Int, ) { // This method is added to further debug b/250618218 which has only been observed from the // InternetTile, so we are only logging the background color change for the InternetTile Loading @@ -215,7 +229,7 @@ constructor( bool1 = disabledByPolicy int2 = color }, { "[$str1] state=$int1, disabledByPolicy=$bool1, color=$int2." } { "[$str1] state=$int1, disabledByPolicy=$bool1, color=$int2." }, ) } Loading @@ -229,7 +243,7 @@ constructor( str3 = state.icon?.toString() int1 = state.state }, { "[$str1] Tile updated. Label=$str2. State=$int1. Icon=$str3." } { "[$str1] Tile updated. Label=$str2. State=$int1. Icon=$str3." }, ) } Loading @@ -241,7 +255,7 @@ constructor( str1 = containerName bool1 = expanded }, { "$str1 expanded=$bool1" } { "$str1 expanded=$bool1" }, ) } Loading @@ -253,7 +267,7 @@ constructor( str1 = containerName int1 = orientation }, { "onViewAttached: $str1 orientation $int1" } { "onViewAttached: $str1 orientation $int1" }, ) } Loading @@ -265,7 +279,7 @@ constructor( str1 = containerName int1 = orientation }, { "onViewDetached: $str1 orientation $int1" } { "onViewDetached: $str1 orientation $int1" }, ) } Loading @@ -276,7 +290,7 @@ constructor( newShouldUseSplitShade: Boolean, oldScreenLayout: Int, newScreenLayout: Int, containerName: String containerName: String, ) { configChangedBuffer.log( TAG, Loading @@ -297,7 +311,7 @@ constructor( "screen layout=${toScreenLayoutString(long1.toInt())} " + "(was ${toScreenLayoutString(long2.toInt())}), " + "splitShade=$bool2 (was $bool1)" } }, ) } Loading @@ -305,7 +319,7 @@ constructor( after: Boolean, before: Boolean, force: Boolean, containerName: String containerName: String, ) { buffer.log( TAG, Loading @@ -316,7 +330,7 @@ constructor( bool2 = before bool3 = force }, { "change tile layout: $str1 horizontal=$bool1 (was $bool2), force? $bool3" } { "change tile layout: $str1 horizontal=$bool1 (was $bool2), force? $bool3" }, ) } Loading @@ -328,7 +342,7 @@ constructor( int1 = tilesPerPageCount int2 = totalTilesCount }, { "Distributing tiles: [tilesPerPageCount=$int1] [totalTilesCount=$int2]" } { "Distributing tiles: [tilesPerPageCount=$int1] [totalTilesCount=$int2]" }, ) } Loading @@ -340,7 +354,7 @@ constructor( str1 = tileName int1 = pageIndex }, { "Adding $str1 to page number $int1" } { "Adding $str1 to page number $int1" }, ) } Loading @@ -361,7 +375,7 @@ constructor( str1 = viewName str2 = toVisibilityString(visibility) }, { "$str1 visibility: $str2" } { "$str1 visibility: $str2" }, ) } Loading packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java +29 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ package com.android.systemui.qs.tileimpl; import static com.android.systemui.Flags.qsNewTiles; import static com.android.systemui.Flags.removeUpdateListenerInQsIconViewImpl; import android.animation.Animator; Loading Loading @@ -66,12 +67,22 @@ public class QSIconViewImpl extends QSIconView { private ValueAnimator mColorAnimator = new ValueAnimator(); private int mColorUnavailable; private int mColorInactive; private int mColorActive; public QSIconViewImpl(Context context) { super(context); final Resources res = context.getResources(); mIconSizePx = res.getDimensionPixelSize(R.dimen.qs_icon_size); if (qsNewTiles()) { // pre-load icon tint colors mColorUnavailable = Utils.getColorAttrDefaultColor(context, R.attr.outline); mColorInactive = Utils.getColorAttrDefaultColor(context, R.attr.onShadeInactiveVariant); mColorActive = Utils.getColorAttrDefaultColor(context, R.attr.onShadeActive); } mIcon = createIcon(); addView(mIcon); mColorAnimator.setDuration(QS_ANIM_LENGTH); Loading Loading @@ -195,8 +206,12 @@ public class QSIconViewImpl extends QSIconView { } protected int getColor(QSTile.State state) { if (qsNewTiles()) { return getCachedIconColorForState(state); } else { return getIconColorForState(getContext(), state); } } private void animateGrayScale(int fromColor, int toColor, ImageView iv, final Runnable endRunnable) { Loading Loading @@ -267,6 +282,19 @@ public class QSIconViewImpl extends QSIconView { } } private int getCachedIconColorForState(QSTile.State state) { if (state.disabledByPolicy || state.state == Tile.STATE_UNAVAILABLE) { return mColorUnavailable; } else if (state.state == Tile.STATE_INACTIVE) { return mColorInactive; } else if (state.state == Tile.STATE_ACTIVE) { return mColorActive; } else { Log.e("QSIconView", "Invalid state " + state); return 0; } } private static class EndRunnableAnimatorListener extends AnimatorListenerAdapter { private Runnable mRunnable; Loading packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt +0 −1 Original line number Diff line number Diff line Loading @@ -643,7 +643,6 @@ constructor( } // HANDLE STATE CHANGES RELATED METHODS protected open fun handleStateChanged(state: QSTile.State) { val allowAnimations = animationsEnabled() isClickable = state.state != Tile.STATE_UNAVAILABLE Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java +35 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ package com.android.systemui.qs.tileimpl; import static com.android.systemui.Flags.FLAG_QS_NEW_TILES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.mockito.ArgumentMatchers.any; Loading @@ -21,11 +23,16 @@ import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; import android.graphics.drawable.AnimatedVectorDrawable; import android.graphics.drawable.Drawable; import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.service.quicksettings.Tile; import android.testing.UiThreadTest; import android.widget.ImageView; Loading @@ -47,7 +54,6 @@ import org.mockito.Mockito; @UiThreadTest @SmallTest public class QSIconViewImplTest extends SysuiTestCase { private QSIconViewImpl mIconView; @Before Loading Loading @@ -106,6 +112,34 @@ public class QSIconViewImplTest extends SysuiTestCase { verify(iv).setImageTintList(argThat(stateList -> stateList.getColors()[0] == desiredColor)); } @EnableFlags(FLAG_QS_NEW_TILES) @Test public void testIconPreloaded_withFlagOn_immediatelyLoadsAll3TintColors() { Context ctx = spy(mContext); QSIconViewImpl iconView = new QSIconViewImpl(ctx); verify(ctx, times(3)).obtainStyledAttributes(any()); iconView.getColor(new State()); // this should not increase the call count verify(ctx, times(3)).obtainStyledAttributes(any()); } @DisableFlags(FLAG_QS_NEW_TILES) @Test public void testIconPreloaded_withFlagOff_loadsOneTintColorAfterIconColorIsRead() { Context ctx = spy(mContext); QSIconViewImpl iconView = new QSIconViewImpl(ctx); verify(ctx, never()).obtainStyledAttributes(any()); // none of the colors are preloaded iconView.getColor(new State()); verify(ctx, times(1)).obtainStyledAttributes(any()); } @Test public void testStateSetCorrectly_toString() { ImageView iv = mock(ImageView.class); Loading
packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java +4 −1 Original line number Diff line number Diff line Loading @@ -184,7 +184,10 @@ public interface QSTile { } } /** Get the text for secondaryLabel. */ /** * If the current secondaryLabel value is not empty, ignore the given input and return * the current value. Otherwise return current value. */ public CharSequence getSecondaryLabel(CharSequence stateText) { // Use a local reference as the value might change from other threads CharSequence localSecondaryLabel = secondaryLabel; Loading
packages/SystemUI/src/com/android/systemui/qs/logging/QSLogger.kt +37 −23 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import com.android.systemui.log.core.LogLevel.VERBOSE import com.android.systemui.log.dagger.QSConfigLog import com.android.systemui.log.dagger.QSLog import com.android.systemui.plugins.qs.QSTile import com.android.systemui.plugins.qs.QSTile.State import com.android.systemui.statusbar.StatusBarState import com.google.errorprone.annotations.CompileTimeConstant import javax.inject.Inject Loading @@ -57,6 +58,7 @@ constructor( fun d(@CompileTimeConstant msg: String, arg: Any) { buffer.log(TAG, DEBUG, { str1 = arg.toString() }, { "$msg: $str1" }) } fun i(@CompileTimeConstant msg: String, arg: Any) { buffer.log(TAG, INFO, { str1 = arg.toString() }, { "$msg: $str1" }) } Loading @@ -73,7 +75,19 @@ constructor( str1 = tileSpec str2 = reason }, { "[$str1] Tile destroyed. Reason: $str2" } { "[$str1] Tile destroyed. Reason: $str2" }, ) } fun logStateChanged(tileSpec: String, state: State) { buffer.log( TAG, DEBUG, { str1 = tileSpec str2 = state.toString() }, { "[$str1] Tile state=$str2" }, ) } Loading @@ -85,7 +99,7 @@ constructor( bool1 = listening str1 = tileSpec }, { "[$str1] Tile listening=$bool1" } { "[$str1] Tile listening=$bool1" }, ) } Loading @@ -98,7 +112,7 @@ constructor( str1 = containerName str2 = allSpecs }, { "Tiles listening=$bool1 in $str1. $str2" } { "Tiles listening=$bool1 in $str1. $str2" }, ) } Loading @@ -112,7 +126,7 @@ constructor( str2 = StatusBarState.toString(statusBarState) str3 = toStateString(state) }, { "[$str1][$int1] Tile clicked. StatusBarState=$str2. TileState=$str3" } { "[$str1][$int1] Tile clicked. StatusBarState=$str2. TileState=$str3" }, ) } Loading @@ -124,7 +138,7 @@ constructor( str1 = tileSpec int1 = eventId }, { "[$str1][$int1] Tile handling click." } { "[$str1][$int1] Tile handling click." }, ) } Loading @@ -138,7 +152,7 @@ constructor( str2 = StatusBarState.toString(statusBarState) str3 = toStateString(state) }, { "[$str1][$int1] Tile secondary clicked. StatusBarState=$str2. TileState=$str3" } { "[$str1][$int1] Tile secondary clicked. StatusBarState=$str2. TileState=$str3" }, ) } Loading @@ -150,7 +164,7 @@ constructor( str1 = tileSpec int1 = eventId }, { "[$str1][$int1] Tile handling secondary click." } { "[$str1][$int1] Tile handling secondary click." }, ) } Loading @@ -164,7 +178,7 @@ constructor( str2 = StatusBarState.toString(statusBarState) str3 = toStateString(state) }, { "[$str1][$int1] Tile long clicked. StatusBarState=$str2. TileState=$str3" } { "[$str1][$int1] Tile long clicked. StatusBarState=$str2. TileState=$str3" }, ) } Loading @@ -176,7 +190,7 @@ constructor( str1 = tileSpec int1 = eventId }, { "[$str1][$int1] Tile handling long click." } { "[$str1][$int1] Tile handling long click." }, ) } Loading @@ -189,7 +203,7 @@ constructor( int1 = lastType str2 = callback }, { "[$str1] mLastTileState=$int1, Callback=$str2." } { "[$str1] mLastTileState=$int1, Callback=$str2." }, ) } Loading @@ -198,7 +212,7 @@ constructor( tileSpec: String, state: Int, disabledByPolicy: Boolean, color: Int color: Int, ) { // This method is added to further debug b/250618218 which has only been observed from the // InternetTile, so we are only logging the background color change for the InternetTile Loading @@ -215,7 +229,7 @@ constructor( bool1 = disabledByPolicy int2 = color }, { "[$str1] state=$int1, disabledByPolicy=$bool1, color=$int2." } { "[$str1] state=$int1, disabledByPolicy=$bool1, color=$int2." }, ) } Loading @@ -229,7 +243,7 @@ constructor( str3 = state.icon?.toString() int1 = state.state }, { "[$str1] Tile updated. Label=$str2. State=$int1. Icon=$str3." } { "[$str1] Tile updated. Label=$str2. State=$int1. Icon=$str3." }, ) } Loading @@ -241,7 +255,7 @@ constructor( str1 = containerName bool1 = expanded }, { "$str1 expanded=$bool1" } { "$str1 expanded=$bool1" }, ) } Loading @@ -253,7 +267,7 @@ constructor( str1 = containerName int1 = orientation }, { "onViewAttached: $str1 orientation $int1" } { "onViewAttached: $str1 orientation $int1" }, ) } Loading @@ -265,7 +279,7 @@ constructor( str1 = containerName int1 = orientation }, { "onViewDetached: $str1 orientation $int1" } { "onViewDetached: $str1 orientation $int1" }, ) } Loading @@ -276,7 +290,7 @@ constructor( newShouldUseSplitShade: Boolean, oldScreenLayout: Int, newScreenLayout: Int, containerName: String containerName: String, ) { configChangedBuffer.log( TAG, Loading @@ -297,7 +311,7 @@ constructor( "screen layout=${toScreenLayoutString(long1.toInt())} " + "(was ${toScreenLayoutString(long2.toInt())}), " + "splitShade=$bool2 (was $bool1)" } }, ) } Loading @@ -305,7 +319,7 @@ constructor( after: Boolean, before: Boolean, force: Boolean, containerName: String containerName: String, ) { buffer.log( TAG, Loading @@ -316,7 +330,7 @@ constructor( bool2 = before bool3 = force }, { "change tile layout: $str1 horizontal=$bool1 (was $bool2), force? $bool3" } { "change tile layout: $str1 horizontal=$bool1 (was $bool2), force? $bool3" }, ) } Loading @@ -328,7 +342,7 @@ constructor( int1 = tilesPerPageCount int2 = totalTilesCount }, { "Distributing tiles: [tilesPerPageCount=$int1] [totalTilesCount=$int2]" } { "Distributing tiles: [tilesPerPageCount=$int1] [totalTilesCount=$int2]" }, ) } Loading @@ -340,7 +354,7 @@ constructor( str1 = tileName int1 = pageIndex }, { "Adding $str1 to page number $int1" } { "Adding $str1 to page number $int1" }, ) } Loading @@ -361,7 +375,7 @@ constructor( str1 = viewName str2 = toVisibilityString(visibility) }, { "$str1 visibility: $str2" } { "$str1 visibility: $str2" }, ) } Loading
packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java +29 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ package com.android.systemui.qs.tileimpl; import static com.android.systemui.Flags.qsNewTiles; import static com.android.systemui.Flags.removeUpdateListenerInQsIconViewImpl; import android.animation.Animator; Loading Loading @@ -66,12 +67,22 @@ public class QSIconViewImpl extends QSIconView { private ValueAnimator mColorAnimator = new ValueAnimator(); private int mColorUnavailable; private int mColorInactive; private int mColorActive; public QSIconViewImpl(Context context) { super(context); final Resources res = context.getResources(); mIconSizePx = res.getDimensionPixelSize(R.dimen.qs_icon_size); if (qsNewTiles()) { // pre-load icon tint colors mColorUnavailable = Utils.getColorAttrDefaultColor(context, R.attr.outline); mColorInactive = Utils.getColorAttrDefaultColor(context, R.attr.onShadeInactiveVariant); mColorActive = Utils.getColorAttrDefaultColor(context, R.attr.onShadeActive); } mIcon = createIcon(); addView(mIcon); mColorAnimator.setDuration(QS_ANIM_LENGTH); Loading Loading @@ -195,8 +206,12 @@ public class QSIconViewImpl extends QSIconView { } protected int getColor(QSTile.State state) { if (qsNewTiles()) { return getCachedIconColorForState(state); } else { return getIconColorForState(getContext(), state); } } private void animateGrayScale(int fromColor, int toColor, ImageView iv, final Runnable endRunnable) { Loading Loading @@ -267,6 +282,19 @@ public class QSIconViewImpl extends QSIconView { } } private int getCachedIconColorForState(QSTile.State state) { if (state.disabledByPolicy || state.state == Tile.STATE_UNAVAILABLE) { return mColorUnavailable; } else if (state.state == Tile.STATE_INACTIVE) { return mColorInactive; } else if (state.state == Tile.STATE_ACTIVE) { return mColorActive; } else { Log.e("QSIconView", "Invalid state " + state); return 0; } } private static class EndRunnableAnimatorListener extends AnimatorListenerAdapter { private Runnable mRunnable; Loading
packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt +0 −1 Original line number Diff line number Diff line Loading @@ -643,7 +643,6 @@ constructor( } // HANDLE STATE CHANGES RELATED METHODS protected open fun handleStateChanged(state: QSTile.State) { val allowAnimations = animationsEnabled() isClickable = state.state != Tile.STATE_UNAVAILABLE Loading