[SB][Screen Chips] Always maintain media projection callback order.
This fixes b/352483752. In this bug, an #onRecordingSessionSet event
came in, and then an #onStop event came in very soon after. Because
onRecordingSessionSet has to do some background work before emitting but
onStop doesn't, the repository was actually emitting the stopped event
*first* and the session event *second*, even though the callback events
came in the opposite order.
This CL instead has all callback events immediately emit, and then uses
a `mapLatest` to perform that extra background work for
onRecordingSessionSet. The `mapLatest` will ensure that if an onStop
event comes in while we're still performing background work for
onRecordingSessionSet, that background work will get cancelled and only
the stop event will be emitted.
Fixes: 352483752
Bug: 332662551
Flag: com.android.systemui.status_bar_screen_sharing_chips
Flag: com.android.systemui.pss_task_switcher
(Note on flag stanzas: This repository is used by two features, each
guarded by one of those flags)
Test: atest MediaProjectionManagerRepositoryTest (verified new test
failed before changes, and passes after)
Change-Id: I15d09beec744515c09a49122d4ece37cc4007ca9
3 files changed