Skip to content
Commit 0ade739a authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[Central Surfaces] Make KeyguardRepository.wakefulness a StateFlow.

In order to remove some CentralSurfaces references (specifically
mWakeUpComingFromTouch), it would be useful to be able to query the
current wakefulness status from KeyguardRepository. However, since
wakefulness is currently just a normal Flow, there's no way to get the
current value.

Converting this flow into a StateFlow gives us a few benefits:
1) Callers can query the flow for the current value instead of needing
   to collect on the flow.
2) Only one callback total is added to WakefulnessLifecycle, instead of
   one callback per flow consumer (14 as of this CL).

I believe this should be a no-op, since the wakefulness flow was already
emitting the current value when the flow starts, which mimicks StateFlow
behavior.

Bug: 284485594
Test: atest KeyguardRepositoryImplTest

Test: manual: verified via local logging that consumers of `wakefulness`
still (1) receive new values at the same times as before; (2) receive
the correct values. Specifically verified:
 - LightRevealScrimRepository.nonBiometricRevealEffect is notified
 whenever wakefulness changes
 - FromDozingTransitionInteractor.listenerForDozingToLockscreen is
 notified whenever wakefulness changes
 - FromPrimaryBouncerTransitionInteractor.listenForPrimaryBouncerToLockscreenOrOccluded
 fetches most recent value whenever primaryBouncerShowing state changes

Change-Id: I792953dd86b367b26540d408c3af9f83c502ea4d
parent 5026a169
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment