Loading packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/CastTileTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.qs.tiles; import static com.android.systemui.flags.Flags.SIGNAL_CALLBACK_DEPRECATION; import static com.google.common.truth.Truth.assertThat; import static junit.framework.Assert.assertTrue; import static junit.framework.TestCase.assertEquals; Loading Loading @@ -544,6 +546,13 @@ public class CastTileTest extends SysuiTestCase { mCastTile.getDetailsViewModel(Assert::assertNotNull); } @Test public void testStateInactive_emptyStateDescription() { createAndStartTileOldImpl(); enableWifiAndProcessMessages(); assertThat(mCastTile.getState().stateDescription.isEmpty()).isTrue(); } /** * For simplicity, let this method still set the field even though that's kind of gross */ Loading packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java +8 −5 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.os.Handler; import android.os.Looper; import android.provider.Settings; import android.service.quicksettings.Tile; import android.text.TextUtils; import android.util.Log; import android.widget.Button; Loading Loading @@ -301,7 +302,7 @@ public class CastTile extends QSTileImpl<BooleanState> { protected void handleUpdateState(BooleanState state, Object arg) { state.label = mContext.getString(R.string.quick_settings_cast_title); state.contentDescription = state.label; state.stateDescription = ""; ArrayList<CharSequence> stateDescriptionParts = new ArrayList<>(); state.value = false; final List<CastDevice> devices = mController.getCastDevices(); boolean connecting = false; Loading @@ -311,9 +312,8 @@ public class CastTile extends QSTileImpl<BooleanState> { if (device.getState() == CastDevice.CastState.Connected) { state.value = true; state.secondaryLabel = getDeviceName(device); state.stateDescription = state.stateDescription + "," + mContext.getString( R.string.accessibility_cast_name, state.label); stateDescriptionParts .add(mContext.getString(R.string.accessibility_cast_name, state.label)); connecting = false; break; } else if (device.getState() == CastDevice.CastState.Connecting) { Loading @@ -338,7 +338,10 @@ public class CastTile extends QSTileImpl<BooleanState> { state.secondaryLabel = noWifi; state.forceExpandIcon = false; } state.stateDescription = state.stateDescription + ", " + state.secondaryLabel; if (!TextUtils.isEmpty(state.secondaryLabel)) { stateDescriptionParts.add(state.secondaryLabel); } state.stateDescription = String.join(", ", stateDescriptionParts); } @Override Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/CastTileTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.qs.tiles; import static com.android.systemui.flags.Flags.SIGNAL_CALLBACK_DEPRECATION; import static com.google.common.truth.Truth.assertThat; import static junit.framework.Assert.assertTrue; import static junit.framework.TestCase.assertEquals; Loading Loading @@ -544,6 +546,13 @@ public class CastTileTest extends SysuiTestCase { mCastTile.getDetailsViewModel(Assert::assertNotNull); } @Test public void testStateInactive_emptyStateDescription() { createAndStartTileOldImpl(); enableWifiAndProcessMessages(); assertThat(mCastTile.getState().stateDescription.isEmpty()).isTrue(); } /** * For simplicity, let this method still set the field even though that's kind of gross */ Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java +8 −5 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.os.Handler; import android.os.Looper; import android.provider.Settings; import android.service.quicksettings.Tile; import android.text.TextUtils; import android.util.Log; import android.widget.Button; Loading Loading @@ -301,7 +302,7 @@ public class CastTile extends QSTileImpl<BooleanState> { protected void handleUpdateState(BooleanState state, Object arg) { state.label = mContext.getString(R.string.quick_settings_cast_title); state.contentDescription = state.label; state.stateDescription = ""; ArrayList<CharSequence> stateDescriptionParts = new ArrayList<>(); state.value = false; final List<CastDevice> devices = mController.getCastDevices(); boolean connecting = false; Loading @@ -311,9 +312,8 @@ public class CastTile extends QSTileImpl<BooleanState> { if (device.getState() == CastDevice.CastState.Connected) { state.value = true; state.secondaryLabel = getDeviceName(device); state.stateDescription = state.stateDescription + "," + mContext.getString( R.string.accessibility_cast_name, state.label); stateDescriptionParts .add(mContext.getString(R.string.accessibility_cast_name, state.label)); connecting = false; break; } else if (device.getState() == CastDevice.CastState.Connecting) { Loading @@ -338,7 +338,10 @@ public class CastTile extends QSTileImpl<BooleanState> { state.secondaryLabel = noWifi; state.forceExpandIcon = false; } state.stateDescription = state.stateDescription + ", " + state.secondaryLabel; if (!TextUtils.isEmpty(state.secondaryLabel)) { stateDescriptionParts.add(state.secondaryLabel); } state.stateDescription = String.join(", ", stateDescriptionParts); } @Override Loading