Loading packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java +32 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static androidx.constraintlayout.widget.ConstraintSet.END; import static androidx.constraintlayout.widget.ConstraintSet.PARENT_ID; import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_CLOCK_MOVE_ANIMATION; import static com.android.systemui.util.kotlin.JavaAdapterKt.collectFlow; import android.animation.Animator; import android.animation.ValueAnimator; Loading Loading @@ -51,6 +52,10 @@ import com.android.systemui.Dumpable; import com.android.systemui.R; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.flags.Flags; import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; import com.android.systemui.keyguard.shared.model.ScreenModel; import com.android.systemui.keyguard.shared.model.ScreenState; import com.android.systemui.plugins.ClockController; import com.android.systemui.statusbar.notification.AnimatableProperty; import com.android.systemui.statusbar.notification.PropertyAnimator; Loading @@ -62,6 +67,9 @@ import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.util.ViewController; import kotlin.coroutines.CoroutineContext; import kotlin.coroutines.EmptyCoroutineContext; import java.io.PrintWriter; import javax.inject.Inject; Loading Loading @@ -91,6 +99,7 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV private final FeatureFlags mFeatureFlags; private final InteractionJankMonitor mInteractionJankMonitor; private final Rect mClipBounds = new Rect(); private final KeyguardInteractor mKeyguardInteractor; private Boolean mStatusViewCentered = true; Loading Loading @@ -122,6 +131,7 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV KeyguardLogger logger, FeatureFlags featureFlags, InteractionJankMonitor interactionJankMonitor, KeyguardInteractor keyguardInteractor, DumpManager dumpManager) { super(keyguardStatusView); mKeyguardSliceViewController = keyguardSliceViewController; Loading @@ -134,12 +144,34 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV mInteractionJankMonitor = interactionJankMonitor; mFeatureFlags = featureFlags; mDumpManager = dumpManager; mKeyguardInteractor = keyguardInteractor; } @Override public void onInit() { mKeyguardClockSwitchController.init(); mDumpManager.registerDumpable(this); if (mFeatureFlags.isEnabled(Flags.MIGRATE_KEYGUARD_STATUS_VIEW)) { startCoroutines(EmptyCoroutineContext.INSTANCE); } } void startCoroutines(CoroutineContext context) { collectFlow(mView, mKeyguardInteractor.getDozeTimeTick(), (Long millis) -> { dozeTimeTick(); }, context); collectFlow(mView, mKeyguardInteractor.getScreenModel(), (ScreenModel model) -> { if (model.getState() == ScreenState.SCREEN_TURNING_ON) { dozeTimeTick(); } }, context); } public KeyguardStatusView getView() { return mView; } @Override Loading packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +6 −6 Original line number Diff line number Diff line Loading @@ -47,16 +47,15 @@ import com.android.systemui.statusbar.phone.BiometricUnlockController.WakeAndUnl import com.android.systemui.statusbar.phone.DozeParameters import com.android.systemui.statusbar.phone.KeyguardBypassController import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.time.SystemClock import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flowOn Loading Loading @@ -177,7 +176,7 @@ interface KeyguardRepository { val keyguardRootViewVisibility: Flow<KeyguardRootViewVisibilityState> /** Receive an event for doze time tick */ val dozeTimeTick: Flow<Unit> val dozeTimeTick: Flow<Long> /** * Returns `true` if the keyguard is showing; `false` otherwise. Loading Loading @@ -248,6 +247,7 @@ constructor( private val dreamOverlayCallbackController: DreamOverlayCallbackController, @Main private val mainDispatcher: CoroutineDispatcher, @Application private val scope: CoroutineScope, private val systemClock: SystemClock, ) : KeyguardRepository { private val _animateBottomAreaDozingTransitions = MutableStateFlow(false) override val animateBottomAreaDozingTransitions = Loading Loading @@ -398,11 +398,11 @@ constructor( _isDozing.value = isDozing } private val _dozeTimeTick = MutableSharedFlow<Unit>() override val dozeTimeTick = _dozeTimeTick.asSharedFlow() private val _dozeTimeTick = MutableStateFlow<Long>(0) override val dozeTimeTick = _dozeTimeTick.asStateFlow() override fun dozeTimeTick() { _dozeTimeTick.tryEmit(Unit) _dozeTimeTick.value = systemClock.uptimeMillis() } private val _lastDozeTapToWakePosition = MutableStateFlow<Point?>(null) Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/BurnInInteractor.kt +8 −14 Original line number Diff line number Diff line Loading @@ -24,14 +24,11 @@ import com.android.systemui.common.ui.data.repository.ConfigurationRepository import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.doze.util.BurnInHelperWrapper import com.android.systemui.util.time.SystemClock import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.mapLatest import kotlinx.coroutines.flow.stateIn Loading @@ -46,24 +43,17 @@ constructor( private val burnInHelperWrapper: BurnInHelperWrapper, @Application private val scope: CoroutineScope, private val configurationRepository: ConfigurationRepository, private val systemClock: SystemClock, private val keyguardInteractor: KeyguardInteractor, ) { private val _dozeTimeTick = MutableStateFlow<Long>(0) val dozeTimeTick: StateFlow<Long> = _dozeTimeTick.asStateFlow() val udfpsBurnInXOffset: StateFlow<Int> = burnInOffsetDefinedInPixels(R.dimen.udfps_burn_in_offset_x, isXAxis = true) val udfpsBurnInYOffset: StateFlow<Int> = burnInOffsetDefinedInPixels(R.dimen.udfps_burn_in_offset_y, isXAxis = false) val udfpsBurnInProgress: StateFlow<Float> = dozeTimeTick keyguardInteractor.dozeTimeTick .mapLatest { burnInHelperWrapper.burnInProgressOffset() } .stateIn(scope, SharingStarted.Lazily, burnInHelperWrapper.burnInProgressOffset()) fun dozeTimeTick() { _dozeTimeTick.value = systemClock.uptimeMillis() } /** * Use for max burn-in offsets that are NOT specified in pixels. This flow will recalculate the * max burn-in offset on any configuration changes. If the max burn-in offset is specified in Loading @@ -77,7 +67,9 @@ constructor( .flatMapLatest { val maxBurnInOffsetPixels = context.resources.getDimensionPixelSize(maxBurnInOffsetResourceId) dozeTimeTick.mapLatest { calculateOffset(maxBurnInOffsetPixels, isXAxis) } keyguardInteractor.dozeTimeTick.mapLatest { calculateOffset(maxBurnInOffsetPixels, isXAxis) } } .stateIn( scope, Loading @@ -102,7 +94,9 @@ constructor( .flatMapLatest { scale -> val maxBurnInOffsetPixels = context.resources.getDimensionPixelSize(maxBurnInOffsetResourceId) dozeTimeTick.mapLatest { calculateOffset(maxBurnInOffsetPixels, isXAxis, scale) } keyguardInteractor.dozeTimeTick.mapLatest { calculateOffset(maxBurnInOffsetPixels, isXAxis, scale) } } .stateIn( scope, Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +5 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import com.android.systemui.keyguard.shared.model.DozeStateModel import com.android.systemui.keyguard.shared.model.DozeStateModel.Companion.isDozeOff import com.android.systemui.keyguard.shared.model.DozeTransitionModel import com.android.systemui.keyguard.shared.model.KeyguardRootViewVisibilityState import com.android.systemui.keyguard.shared.model.ScreenModel import com.android.systemui.keyguard.shared.model.StatusBarState import com.android.systemui.keyguard.shared.model.WakefulnessModel import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel Loading Loading @@ -87,7 +88,7 @@ constructor( /** Whether the system is in doze mode. */ val isDozing: Flow<Boolean> = repository.isDozing /** Receive an event for doze time tick */ val dozeTimeTick: Flow<Unit> = repository.dozeTimeTick val dozeTimeTick: Flow<Long> = repository.dozeTimeTick /** Whether Always-on Display mode is available. */ val isAodAvailable: Flow<Boolean> = repository.isAodAvailable /** Doze transition information. */ Loading Loading @@ -122,6 +123,9 @@ constructor( /** The device wake/sleep state */ val wakefulnessModel: StateFlow<WakefulnessModel> = repository.wakefulness /** The device screen state */ val screenModel: StateFlow<ScreenModel> = repository.screenModel /** * Dozing and dreaming have overlapping events. If the doze state remains in FINISH, it means * that doze mode is not running and DREAMING is ok to commence. Loading packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +6 −3 Original line number Diff line number Diff line Loading @@ -2820,8 +2820,10 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump @Override public void onScreenTurningOn() { if (!mFeatureFlags.isEnabled(Flags.MIGRATE_KEYGUARD_STATUS_VIEW)) { mKeyguardStatusViewController.dozeTimeTick(); } } private void onMiddleClicked() { switch (mBarState) { Loading Loading @@ -3070,10 +3072,11 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } } @Override public void dozeTimeTick() { mLockIconViewController.dozeTimeTick(); if (!mFeatureFlags.isEnabled(Flags.MIGRATE_KEYGUARD_STATUS_VIEW)) { mKeyguardStatusViewController.dozeTimeTick(); } if (mInterpolatedDarkAmount > 0) { positionClockAndNotifications(); } Loading Loading
packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java +32 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static androidx.constraintlayout.widget.ConstraintSet.END; import static androidx.constraintlayout.widget.ConstraintSet.PARENT_ID; import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_CLOCK_MOVE_ANIMATION; import static com.android.systemui.util.kotlin.JavaAdapterKt.collectFlow; import android.animation.Animator; import android.animation.ValueAnimator; Loading Loading @@ -51,6 +52,10 @@ import com.android.systemui.Dumpable; import com.android.systemui.R; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.flags.Flags; import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; import com.android.systemui.keyguard.shared.model.ScreenModel; import com.android.systemui.keyguard.shared.model.ScreenState; import com.android.systemui.plugins.ClockController; import com.android.systemui.statusbar.notification.AnimatableProperty; import com.android.systemui.statusbar.notification.PropertyAnimator; Loading @@ -62,6 +67,9 @@ import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.util.ViewController; import kotlin.coroutines.CoroutineContext; import kotlin.coroutines.EmptyCoroutineContext; import java.io.PrintWriter; import javax.inject.Inject; Loading Loading @@ -91,6 +99,7 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV private final FeatureFlags mFeatureFlags; private final InteractionJankMonitor mInteractionJankMonitor; private final Rect mClipBounds = new Rect(); private final KeyguardInteractor mKeyguardInteractor; private Boolean mStatusViewCentered = true; Loading Loading @@ -122,6 +131,7 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV KeyguardLogger logger, FeatureFlags featureFlags, InteractionJankMonitor interactionJankMonitor, KeyguardInteractor keyguardInteractor, DumpManager dumpManager) { super(keyguardStatusView); mKeyguardSliceViewController = keyguardSliceViewController; Loading @@ -134,12 +144,34 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV mInteractionJankMonitor = interactionJankMonitor; mFeatureFlags = featureFlags; mDumpManager = dumpManager; mKeyguardInteractor = keyguardInteractor; } @Override public void onInit() { mKeyguardClockSwitchController.init(); mDumpManager.registerDumpable(this); if (mFeatureFlags.isEnabled(Flags.MIGRATE_KEYGUARD_STATUS_VIEW)) { startCoroutines(EmptyCoroutineContext.INSTANCE); } } void startCoroutines(CoroutineContext context) { collectFlow(mView, mKeyguardInteractor.getDozeTimeTick(), (Long millis) -> { dozeTimeTick(); }, context); collectFlow(mView, mKeyguardInteractor.getScreenModel(), (ScreenModel model) -> { if (model.getState() == ScreenState.SCREEN_TURNING_ON) { dozeTimeTick(); } }, context); } public KeyguardStatusView getView() { return mView; } @Override Loading
packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +6 −6 Original line number Diff line number Diff line Loading @@ -47,16 +47,15 @@ import com.android.systemui.statusbar.phone.BiometricUnlockController.WakeAndUnl import com.android.systemui.statusbar.phone.DozeParameters import com.android.systemui.statusbar.phone.KeyguardBypassController import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.time.SystemClock import javax.inject.Inject import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flowOn Loading Loading @@ -177,7 +176,7 @@ interface KeyguardRepository { val keyguardRootViewVisibility: Flow<KeyguardRootViewVisibilityState> /** Receive an event for doze time tick */ val dozeTimeTick: Flow<Unit> val dozeTimeTick: Flow<Long> /** * Returns `true` if the keyguard is showing; `false` otherwise. Loading Loading @@ -248,6 +247,7 @@ constructor( private val dreamOverlayCallbackController: DreamOverlayCallbackController, @Main private val mainDispatcher: CoroutineDispatcher, @Application private val scope: CoroutineScope, private val systemClock: SystemClock, ) : KeyguardRepository { private val _animateBottomAreaDozingTransitions = MutableStateFlow(false) override val animateBottomAreaDozingTransitions = Loading Loading @@ -398,11 +398,11 @@ constructor( _isDozing.value = isDozing } private val _dozeTimeTick = MutableSharedFlow<Unit>() override val dozeTimeTick = _dozeTimeTick.asSharedFlow() private val _dozeTimeTick = MutableStateFlow<Long>(0) override val dozeTimeTick = _dozeTimeTick.asStateFlow() override fun dozeTimeTick() { _dozeTimeTick.tryEmit(Unit) _dozeTimeTick.value = systemClock.uptimeMillis() } private val _lastDozeTapToWakePosition = MutableStateFlow<Point?>(null) Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/BurnInInteractor.kt +8 −14 Original line number Diff line number Diff line Loading @@ -24,14 +24,11 @@ import com.android.systemui.common.ui.data.repository.ConfigurationRepository import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.doze.util.BurnInHelperWrapper import com.android.systemui.util.time.SystemClock import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.mapLatest import kotlinx.coroutines.flow.stateIn Loading @@ -46,24 +43,17 @@ constructor( private val burnInHelperWrapper: BurnInHelperWrapper, @Application private val scope: CoroutineScope, private val configurationRepository: ConfigurationRepository, private val systemClock: SystemClock, private val keyguardInteractor: KeyguardInteractor, ) { private val _dozeTimeTick = MutableStateFlow<Long>(0) val dozeTimeTick: StateFlow<Long> = _dozeTimeTick.asStateFlow() val udfpsBurnInXOffset: StateFlow<Int> = burnInOffsetDefinedInPixels(R.dimen.udfps_burn_in_offset_x, isXAxis = true) val udfpsBurnInYOffset: StateFlow<Int> = burnInOffsetDefinedInPixels(R.dimen.udfps_burn_in_offset_y, isXAxis = false) val udfpsBurnInProgress: StateFlow<Float> = dozeTimeTick keyguardInteractor.dozeTimeTick .mapLatest { burnInHelperWrapper.burnInProgressOffset() } .stateIn(scope, SharingStarted.Lazily, burnInHelperWrapper.burnInProgressOffset()) fun dozeTimeTick() { _dozeTimeTick.value = systemClock.uptimeMillis() } /** * Use for max burn-in offsets that are NOT specified in pixels. This flow will recalculate the * max burn-in offset on any configuration changes. If the max burn-in offset is specified in Loading @@ -77,7 +67,9 @@ constructor( .flatMapLatest { val maxBurnInOffsetPixels = context.resources.getDimensionPixelSize(maxBurnInOffsetResourceId) dozeTimeTick.mapLatest { calculateOffset(maxBurnInOffsetPixels, isXAxis) } keyguardInteractor.dozeTimeTick.mapLatest { calculateOffset(maxBurnInOffsetPixels, isXAxis) } } .stateIn( scope, Loading @@ -102,7 +94,9 @@ constructor( .flatMapLatest { scale -> val maxBurnInOffsetPixels = context.resources.getDimensionPixelSize(maxBurnInOffsetResourceId) dozeTimeTick.mapLatest { calculateOffset(maxBurnInOffsetPixels, isXAxis, scale) } keyguardInteractor.dozeTimeTick.mapLatest { calculateOffset(maxBurnInOffsetPixels, isXAxis, scale) } } .stateIn( scope, Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +5 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import com.android.systemui.keyguard.shared.model.DozeStateModel import com.android.systemui.keyguard.shared.model.DozeStateModel.Companion.isDozeOff import com.android.systemui.keyguard.shared.model.DozeTransitionModel import com.android.systemui.keyguard.shared.model.KeyguardRootViewVisibilityState import com.android.systemui.keyguard.shared.model.ScreenModel import com.android.systemui.keyguard.shared.model.StatusBarState import com.android.systemui.keyguard.shared.model.WakefulnessModel import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel Loading Loading @@ -87,7 +88,7 @@ constructor( /** Whether the system is in doze mode. */ val isDozing: Flow<Boolean> = repository.isDozing /** Receive an event for doze time tick */ val dozeTimeTick: Flow<Unit> = repository.dozeTimeTick val dozeTimeTick: Flow<Long> = repository.dozeTimeTick /** Whether Always-on Display mode is available. */ val isAodAvailable: Flow<Boolean> = repository.isAodAvailable /** Doze transition information. */ Loading Loading @@ -122,6 +123,9 @@ constructor( /** The device wake/sleep state */ val wakefulnessModel: StateFlow<WakefulnessModel> = repository.wakefulness /** The device screen state */ val screenModel: StateFlow<ScreenModel> = repository.screenModel /** * Dozing and dreaming have overlapping events. If the doze state remains in FINISH, it means * that doze mode is not running and DREAMING is ok to commence. Loading
packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +6 −3 Original line number Diff line number Diff line Loading @@ -2820,8 +2820,10 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump @Override public void onScreenTurningOn() { if (!mFeatureFlags.isEnabled(Flags.MIGRATE_KEYGUARD_STATUS_VIEW)) { mKeyguardStatusViewController.dozeTimeTick(); } } private void onMiddleClicked() { switch (mBarState) { Loading Loading @@ -3070,10 +3072,11 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } } @Override public void dozeTimeTick() { mLockIconViewController.dozeTimeTick(); if (!mFeatureFlags.isEnabled(Flags.MIGRATE_KEYGUARD_STATUS_VIEW)) { mKeyguardStatusViewController.dozeTimeTick(); } if (mInterpolatedDarkAmount > 0) { positionClockAndNotifications(); } Loading