Loading packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/autoaddable/CastAutoAddableTest.kt +31 −11 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.systemui.qs.pipeline.domain.model.AutoAddSignal import com.android.systemui.qs.pipeline.shared.TileSpec import com.android.systemui.qs.tiles.CastTile import com.android.systemui.statusbar.policy.CastController import com.android.systemui.statusbar.policy.CastDevice import com.android.systemui.util.mockito.capture import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat Loading Loading @@ -73,9 +74,12 @@ class CastAutoAddableTest : SysuiTestCase() { @Test fun onCastDevicesChanged_deviceNotConnectedOrConnecting_noSignal() = runTest { val device = CastController.CastDevice().apply { state = CastController.CastDevice.STATE_DISCONNECTED } CastDevice( id = "id", name = null, state = CastDevice.CastState.Disconnected, origin = CastDevice.CastOrigin.MediaProjection, ) whenever(castController.castDevices).thenReturn(listOf(device)) val signal by collectLastValue(underTest.autoAddSignal(0)) Loading @@ -91,11 +95,19 @@ class CastAutoAddableTest : SysuiTestCase() { @Test fun onCastDevicesChanged_someDeviceConnecting_addSignal() = runTest { val disconnectedDevice = CastController.CastDevice().apply { state = CastController.CastDevice.STATE_DISCONNECTED } CastDevice( id = "id", name = null, state = CastDevice.CastState.Disconnected, origin = CastDevice.CastOrigin.MediaProjection, ) val connectingDevice = CastController.CastDevice().apply { state = CastController.CastDevice.STATE_CONNECTING } CastDevice( id = "id", name = null, state = CastDevice.CastState.Connecting, origin = CastDevice.CastOrigin.MediaProjection, ) whenever(castController.castDevices) .thenReturn(listOf(disconnectedDevice, connectingDevice)) Loading @@ -112,11 +124,19 @@ class CastAutoAddableTest : SysuiTestCase() { @Test fun onCastDevicesChanged_someDeviceConnected_addSignal() = runTest { val disconnectedDevice = CastController.CastDevice().apply { state = CastController.CastDevice.STATE_DISCONNECTED } CastDevice( id = "id", name = null, state = CastDevice.CastState.Disconnected, origin = CastDevice.CastOrigin.MediaProjection, ) val connectedDevice = CastController.CastDevice().apply { state = CastController.CastDevice.STATE_CONNECTED } CastDevice( id = "id", name = null, state = CastDevice.CastState.Connected, origin = CastDevice.CastOrigin.MediaProjection, ) whenever(castController.castDevices).thenReturn(listOf(disconnectedDevice, connectedDevice)) val signal by collectLastValue(underTest.autoAddSignal(0)) Loading packages/SystemUI/src/com/android/systemui/qs/pipeline/domain/autoaddable/CastAutoAddable.kt +1 −6 Original line number Diff line number Diff line Loading @@ -41,12 +41,7 @@ constructor( override fun ProducerScope<AutoAddSignal>.getCallback(): CastController.Callback { return CastController.Callback { val isCasting = controller.castDevices.any { it.state == CastController.CastDevice.STATE_CONNECTED || it.state == CastController.CastDevice.STATE_CONNECTING } if (isCasting) { if (controller.castDevices.any { it.isCasting }) { sendAdd() } } Loading packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java +6 −7 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ import com.android.systemui.statusbar.phone.SystemUIDialog; import com.android.systemui.statusbar.pipeline.shared.data.model.DefaultConnectionModel; import com.android.systemui.statusbar.pipeline.shared.data.repository.ConnectivityRepository; import com.android.systemui.statusbar.policy.CastController; import com.android.systemui.statusbar.policy.CastController.CastDevice; import com.android.systemui.statusbar.policy.CastDevice; import com.android.systemui.statusbar.policy.HotspotController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.util.DialogKt; Loading Loading @@ -193,14 +193,13 @@ public class CastTile extends QSTileImpl<BooleanState> { // case where multiple devices were active :-/. private boolean willPopDialog() { List<CastDevice> activeDevices = getActiveDevices(); return activeDevices.isEmpty() || (activeDevices.get(0).tag instanceof RouteInfo); return activeDevices.isEmpty() || (activeDevices.get(0).getTag() instanceof RouteInfo); } private List<CastDevice> getActiveDevices() { ArrayList<CastDevice> activeDevices = new ArrayList<>(); for (CastDevice device : mController.getCastDevices()) { if (device.state == CastDevice.STATE_CONNECTED || device.state == CastDevice.STATE_CONNECTING) { if (device.isCasting()) { activeDevices.add(device); } } Loading Loading @@ -276,7 +275,7 @@ public class CastTile extends QSTileImpl<BooleanState> { // We always choose the first device that's in the CONNECTED state in the case where // multiple devices are CONNECTED at the same time. for (CastDevice device : devices) { if (device.state == CastDevice.STATE_CONNECTED) { if (device.getState() == CastDevice.CastState.Connected) { state.value = true; state.secondaryLabel = getDeviceName(device); state.stateDescription = state.stateDescription + "," Loading @@ -284,7 +283,7 @@ public class CastTile extends QSTileImpl<BooleanState> { R.string.accessibility_cast_name, state.label); connecting = false; break; } else if (device.state == CastDevice.STATE_CONNECTING) { } else if (device.getState() == CastDevice.CastState.Connecting) { connecting = true; } } Loading Loading @@ -315,7 +314,7 @@ public class CastTile extends QSTileImpl<BooleanState> { } private String getDeviceName(CastDevice device) { return device.name != null ? device.name return device.getName() != null ? device.getName() : mContext.getString(R.string.quick_settings_cast_device_default_name); } Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/AutoTileManager.java +2 −3 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ import com.android.systemui.qs.external.CustomTile; import com.android.systemui.qs.pipeline.shared.QSPipelineFlagsRepository; import com.android.systemui.res.R; import com.android.systemui.statusbar.policy.CastController; import com.android.systemui.statusbar.policy.CastController.CastDevice; import com.android.systemui.statusbar.policy.CastDevice; import com.android.systemui.statusbar.policy.DataSaverController; import com.android.systemui.statusbar.policy.DataSaverController.Listener; import com.android.systemui.statusbar.policy.DeviceControlsController; Loading Loading @@ -430,8 +430,7 @@ public class AutoTileManager implements UserAwareController { boolean isCasting = false; for (CastDevice device : mCastController.getCastDevices()) { if (device.state == CastDevice.STATE_CONNECTED || device.state == CastDevice.STATE_CONNECTING) { if (device.isCasting()) { isCasting = true; break; } Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +2 −3 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.phone.ui.StatusBarIconController; import com.android.systemui.statusbar.policy.BluetoothController; import com.android.systemui.statusbar.policy.CastController; import com.android.systemui.statusbar.policy.CastController.CastDevice; import com.android.systemui.statusbar.policy.CastDevice; import com.android.systemui.statusbar.policy.DataSaverController; import com.android.systemui.statusbar.policy.DataSaverController.Listener; import com.android.systemui.statusbar.policy.DeviceProvisionedController; Loading Loading @@ -521,8 +521,7 @@ public class PhoneStatusBarPolicy private void updateCast() { boolean isCasting = false; for (CastDevice device : mCast.getCastDevices()) { if (device.state == CastDevice.STATE_CONNECTING || device.state == CastDevice.STATE_CONNECTED) { if (device.isCasting()) { isCasting = true; break; } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/domain/autoaddable/CastAutoAddableTest.kt +31 −11 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.systemui.qs.pipeline.domain.model.AutoAddSignal import com.android.systemui.qs.pipeline.shared.TileSpec import com.android.systemui.qs.tiles.CastTile import com.android.systemui.statusbar.policy.CastController import com.android.systemui.statusbar.policy.CastDevice import com.android.systemui.util.mockito.capture import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat Loading Loading @@ -73,9 +74,12 @@ class CastAutoAddableTest : SysuiTestCase() { @Test fun onCastDevicesChanged_deviceNotConnectedOrConnecting_noSignal() = runTest { val device = CastController.CastDevice().apply { state = CastController.CastDevice.STATE_DISCONNECTED } CastDevice( id = "id", name = null, state = CastDevice.CastState.Disconnected, origin = CastDevice.CastOrigin.MediaProjection, ) whenever(castController.castDevices).thenReturn(listOf(device)) val signal by collectLastValue(underTest.autoAddSignal(0)) Loading @@ -91,11 +95,19 @@ class CastAutoAddableTest : SysuiTestCase() { @Test fun onCastDevicesChanged_someDeviceConnecting_addSignal() = runTest { val disconnectedDevice = CastController.CastDevice().apply { state = CastController.CastDevice.STATE_DISCONNECTED } CastDevice( id = "id", name = null, state = CastDevice.CastState.Disconnected, origin = CastDevice.CastOrigin.MediaProjection, ) val connectingDevice = CastController.CastDevice().apply { state = CastController.CastDevice.STATE_CONNECTING } CastDevice( id = "id", name = null, state = CastDevice.CastState.Connecting, origin = CastDevice.CastOrigin.MediaProjection, ) whenever(castController.castDevices) .thenReturn(listOf(disconnectedDevice, connectingDevice)) Loading @@ -112,11 +124,19 @@ class CastAutoAddableTest : SysuiTestCase() { @Test fun onCastDevicesChanged_someDeviceConnected_addSignal() = runTest { val disconnectedDevice = CastController.CastDevice().apply { state = CastController.CastDevice.STATE_DISCONNECTED } CastDevice( id = "id", name = null, state = CastDevice.CastState.Disconnected, origin = CastDevice.CastOrigin.MediaProjection, ) val connectedDevice = CastController.CastDevice().apply { state = CastController.CastDevice.STATE_CONNECTED } CastDevice( id = "id", name = null, state = CastDevice.CastState.Connected, origin = CastDevice.CastOrigin.MediaProjection, ) whenever(castController.castDevices).thenReturn(listOf(disconnectedDevice, connectedDevice)) val signal by collectLastValue(underTest.autoAddSignal(0)) Loading
packages/SystemUI/src/com/android/systemui/qs/pipeline/domain/autoaddable/CastAutoAddable.kt +1 −6 Original line number Diff line number Diff line Loading @@ -41,12 +41,7 @@ constructor( override fun ProducerScope<AutoAddSignal>.getCallback(): CastController.Callback { return CastController.Callback { val isCasting = controller.castDevices.any { it.state == CastController.CastDevice.STATE_CONNECTED || it.state == CastController.CastDevice.STATE_CONNECTING } if (isCasting) { if (controller.castDevices.any { it.isCasting }) { sendAdd() } } Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java +6 −7 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ import com.android.systemui.statusbar.phone.SystemUIDialog; import com.android.systemui.statusbar.pipeline.shared.data.model.DefaultConnectionModel; import com.android.systemui.statusbar.pipeline.shared.data.repository.ConnectivityRepository; import com.android.systemui.statusbar.policy.CastController; import com.android.systemui.statusbar.policy.CastController.CastDevice; import com.android.systemui.statusbar.policy.CastDevice; import com.android.systemui.statusbar.policy.HotspotController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.util.DialogKt; Loading Loading @@ -193,14 +193,13 @@ public class CastTile extends QSTileImpl<BooleanState> { // case where multiple devices were active :-/. private boolean willPopDialog() { List<CastDevice> activeDevices = getActiveDevices(); return activeDevices.isEmpty() || (activeDevices.get(0).tag instanceof RouteInfo); return activeDevices.isEmpty() || (activeDevices.get(0).getTag() instanceof RouteInfo); } private List<CastDevice> getActiveDevices() { ArrayList<CastDevice> activeDevices = new ArrayList<>(); for (CastDevice device : mController.getCastDevices()) { if (device.state == CastDevice.STATE_CONNECTED || device.state == CastDevice.STATE_CONNECTING) { if (device.isCasting()) { activeDevices.add(device); } } Loading Loading @@ -276,7 +275,7 @@ public class CastTile extends QSTileImpl<BooleanState> { // We always choose the first device that's in the CONNECTED state in the case where // multiple devices are CONNECTED at the same time. for (CastDevice device : devices) { if (device.state == CastDevice.STATE_CONNECTED) { if (device.getState() == CastDevice.CastState.Connected) { state.value = true; state.secondaryLabel = getDeviceName(device); state.stateDescription = state.stateDescription + "," Loading @@ -284,7 +283,7 @@ public class CastTile extends QSTileImpl<BooleanState> { R.string.accessibility_cast_name, state.label); connecting = false; break; } else if (device.state == CastDevice.STATE_CONNECTING) { } else if (device.getState() == CastDevice.CastState.Connecting) { connecting = true; } } Loading Loading @@ -315,7 +314,7 @@ public class CastTile extends QSTileImpl<BooleanState> { } private String getDeviceName(CastDevice device) { return device.name != null ? device.name return device.getName() != null ? device.getName() : mContext.getString(R.string.quick_settings_cast_device_default_name); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/AutoTileManager.java +2 −3 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ import com.android.systemui.qs.external.CustomTile; import com.android.systemui.qs.pipeline.shared.QSPipelineFlagsRepository; import com.android.systemui.res.R; import com.android.systemui.statusbar.policy.CastController; import com.android.systemui.statusbar.policy.CastController.CastDevice; import com.android.systemui.statusbar.policy.CastDevice; import com.android.systemui.statusbar.policy.DataSaverController; import com.android.systemui.statusbar.policy.DataSaverController.Listener; import com.android.systemui.statusbar.policy.DeviceControlsController; Loading Loading @@ -430,8 +430,7 @@ public class AutoTileManager implements UserAwareController { boolean isCasting = false; for (CastDevice device : mCastController.getCastDevices()) { if (device.state == CastDevice.STATE_CONNECTED || device.state == CastDevice.STATE_CONNECTING) { if (device.isCasting()) { isCasting = true; break; } Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +2 −3 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.phone.ui.StatusBarIconController; import com.android.systemui.statusbar.policy.BluetoothController; import com.android.systemui.statusbar.policy.CastController; import com.android.systemui.statusbar.policy.CastController.CastDevice; import com.android.systemui.statusbar.policy.CastDevice; import com.android.systemui.statusbar.policy.DataSaverController; import com.android.systemui.statusbar.policy.DataSaverController.Listener; import com.android.systemui.statusbar.policy.DeviceProvisionedController; Loading Loading @@ -521,8 +521,7 @@ public class PhoneStatusBarPolicy private void updateCast() { boolean isCasting = false; for (CastDevice device : mCast.getCastDevices()) { if (device.state == CastDevice.STATE_CONNECTING || device.state == CastDevice.STATE_CONNECTED) { if (device.isCasting()) { isCasting = true; break; } Loading