[SB][Screen Chips] Show cast chip even if audio-only casting.
When casting to another device, you can either cast your screen, or just your audio. - When casting just audio, only MediaRouter APIs fire. - When casting screen, both MediaRouter APIs and MediaProjection APIs fire. Previously, we were only listening to MediaProjection APIs, so we weren't showing the cast chip if you're just casting audio. This CL adds listening to MediaRouter events so that we also show the cast chip if you're casting just audio. This gets tricky when casting your screen though, because both the MediaProjection APIs and the MediaRouter APIs fire when screen casting but they fire at different times (see b/269975671): - The MediaRouter APIs fire as soon as you select a device to cast to, even if you haven't confirmed you want to start casting. - The MediaProjection APIs only fire once you've confirmed casting should start. This CL also includes disambiguation logic between these two API surfaces. Key changes: 1) Adds new MediaRouterRepository, which listens to the existing CastController for MediaRouter events. 2) Adds new MediaRouterChipInteractor, which filters those media router events down to just active casts. 3) Updates CastToOtherDeviceChipViewModel to listen to the new interactor and use either MediaRouter or MediaProjection as the datasource, depending on what's available. 2) Updates the stop dialog to have screen-specific strings or generic strings, depending on whether MediaProjection is active. Bug: 332662551 Flag: com.android.systemui.status_bar_screen_sharing_chips Test: Cast to an audio-only device -> verify cast chip appears. Tap chip -> verify dialog text is audio-specific. Tap "Stop casting" in dialog -> verify casting stops. Test: Cast to an audio-only device, then also start sharing your screen to an app -> verify the cast-to-other-device chip is replaced by the share-to-app chip. Tap chip -> verify dialog is about sharing, not casting. Stop sharing to app -> verify cast-to-other-device chip re-appears. Tap chip -> verify dialog is about casting. Test: Cast screen to a device -> verify cast chip appears. Verify timer doesn't reset between selecting the device and starting casting. Tap chip -> verify dialog text is screen-specific. Tap "Stop casting" in dialog -> verify casting stops. Test: atest MediaRouterRepositoryTest MediaRouterChipInteractorTest CastToOtherDeviceChipViewModelTest Change-Id: I4a1c6ea9e1089d3780b6e0a5d6cb88675e6a7aa0
Loading
Please register or sign in to comment