diff options
| author | 2024-04-09 21:52:57 +0000 | |
|---|---|---|
| committer | 2024-04-09 21:52:57 +0000 | |
| commit | 6d6097a3d050868e8ed13cd91d93d0ef604b249c (patch) | |
| tree | 32a57b8e4f358edb5903a591df087c87196ce7e8 | |
| parent | 7cf3c29d5fda3c7a21dc0d0551ee59143fa8cc5d (diff) | |
| parent | 8e1cb133681fbf98fec45419478d400e8dbc7701 (diff) | |
Merge "Revert "Remove dozeui binder call"" into main
21 files changed, 76 insertions, 173 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/BottomAreaSection.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/BottomAreaSection.kt index 467dbca759c8..97d5b41000de 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/BottomAreaSection.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/BottomAreaSection.kt @@ -32,7 +32,6 @@ import androidx.core.content.res.ResourcesCompat import com.android.compose.animation.scene.ElementKey import com.android.compose.animation.scene.SceneScope import com.android.systemui.animation.view.LaunchableImageView -import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.keyguard.ui.binder.KeyguardIndicationAreaBinder import com.android.systemui.keyguard.ui.binder.KeyguardQuickAffordanceViewBinder import com.android.systemui.keyguard.ui.view.KeyguardIndicationArea @@ -44,7 +43,6 @@ import com.android.systemui.res.R import com.android.systemui.statusbar.KeyguardIndicationController import com.android.systemui.statusbar.VibratorHelper import javax.inject.Inject -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.DisposableHandle import kotlinx.coroutines.flow.Flow @@ -56,7 +54,6 @@ constructor( private val vibratorHelper: VibratorHelper, private val indicationController: KeyguardIndicationController, private val indicationAreaViewModel: KeyguardIndicationAreaViewModel, - @Main private val mainImmediateDispatcher: CoroutineDispatcher, ) { /** * Renders a single lockscreen shortcut. @@ -164,7 +161,6 @@ constructor( transitionAlpha, falsingManager, vibratorHelper, - mainImmediateDispatcher, ) { indicationController.showTransientIndication(it) } diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/LockSection.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/LockSection.kt index 48684a02bd19..9f02201f1d81 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/LockSection.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/LockSection.kt @@ -34,7 +34,6 @@ import com.android.keyguard.LockIconView import com.android.keyguard.LockIconViewController import com.android.systemui.biometrics.AuthController import com.android.systemui.dagger.qualifiers.Application -import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor import com.android.systemui.flags.FeatureFlagsClassic import com.android.systemui.flags.Flags @@ -51,14 +50,12 @@ import com.android.systemui.shade.NotificationPanelView import com.android.systemui.statusbar.VibratorHelper import dagger.Lazy import javax.inject.Inject -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope class LockSection @Inject constructor( @Application private val applicationScope: CoroutineScope, - @Main private val mainImmediateDispatcher: CoroutineDispatcher, private val windowManager: WindowManager, private val authController: AuthController, private val featureFlags: FeatureFlagsClassic, @@ -96,7 +93,6 @@ constructor( deviceEntryBackgroundViewModel.get(), falsingManager.get(), vibratorHelper.get(), - mainImmediateDispatcher, ) } } else { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt index 6d7a0a96a71b..eec74efd4751 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt @@ -214,16 +214,14 @@ class KeyguardInteractorTest : SysuiTestCase() { ) repository.setStatusBarState(StatusBarState.KEYGUARD) - // User begins to swipe up - shadeRepository.setLegacyShadeExpansion(0.99f) + shadeRepository.setLegacyShadeExpansion(1f) // When not dismissable, no alpha value (null) should emit repository.setKeyguardDismissible(false) assertThat(dismissAlpha).isNull() repository.setKeyguardDismissible(true) - shadeRepository.setLegacyShadeExpansion(0.98f) - assertThat(dismissAlpha).isGreaterThan(0.5f) + assertThat(dismissAlpha).isGreaterThan(0.95f) } @Test diff --git a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt index eca932c531b2..c9789e8109cb 100644 --- a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +++ b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt @@ -31,7 +31,6 @@ import android.view.ViewTreeObserver.OnGlobalLayoutListener import androidx.annotation.VisibleForTesting import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle -import com.android.app.tracing.coroutines.launch import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.customization.R import com.android.systemui.dagger.qualifiers.Background @@ -66,7 +65,6 @@ import java.util.Locale import java.util.TimeZone import java.util.concurrent.Executor import javax.inject.Inject -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.DisposableHandle import kotlinx.coroutines.Job @@ -74,6 +72,7 @@ import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.merge +import kotlinx.coroutines.launch /** * Controller for a Clock provided by the registry and used on the keyguard. Instantiated by @@ -91,7 +90,6 @@ constructor( @DisplaySpecific private val resources: Resources, private val context: Context, @Main private val mainExecutor: DelayableExecutor, - @Main private val mainImmediateDispatcher: CoroutineDispatcher, @Background private val bgExecutor: Executor, private val clockBuffers: ClockMessageBuffers, private val featureFlags: FeatureFlagsClassic, @@ -426,7 +424,7 @@ constructor( keyguardUpdateMonitor.registerCallback(keyguardUpdateMonitorCallback) zenModeController.addCallback(zenModeCallback) disposableHandle = - parent.repeatWhenAttached(mainImmediateDispatcher) { + parent.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.CREATED) { listenForDozing(this) if (MigrateClocksToBlueprint.isEnabled) { @@ -532,14 +530,12 @@ constructor( @VisibleForTesting internal fun listenForDozeAmount(scope: CoroutineScope): Job { - return scope.launch("$TAG#listenForDozeAmount") { - keyguardInteractor.dozeAmount.collect { handleDoze(it) } - } + return scope.launch { keyguardInteractor.dozeAmount.collect { handleDoze(it) } } } @VisibleForTesting internal fun listenForDozeAmountTransition(scope: CoroutineScope): Job { - return scope.launch("$TAG#listenForDozeAmountTransition") { + return scope.launch { merge( keyguardTransitionInteractor.aodToLockscreenTransition.map { step -> step.copy(value = 1f - step.value) @@ -557,7 +553,7 @@ constructor( */ @VisibleForTesting internal fun listenForAnyStateToAodTransition(scope: CoroutineScope): Job { - return scope.launch("$TAG#listenForAnyStateToAodTransition") { + return scope.launch { keyguardTransitionInteractor .transitionStepsToState(AOD) .filter { it.transitionState == TransitionState.STARTED } @@ -579,7 +575,7 @@ constructor( @VisibleForTesting internal fun listenForDozing(scope: CoroutineScope): Job { - return scope.launch("$TAG#listenForDozing") { + return scope.launch { combine( keyguardInteractor.dozeAmount, keyguardInteractor.isDozing, @@ -644,7 +640,7 @@ constructor( } companion object { - private const val TAG = "ClockEventController" - private const val DOZE_TICKRATE_THRESHOLD = 0.99f + private val TAG = ClockEventController::class.simpleName!! + private val DOZE_TICKRATE_THRESHOLD = 0.99f } } diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java index 9a9e698e0138..424bd0a3e23b 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java @@ -209,15 +209,6 @@ public class DozeLog implements Dumpable { } /** - * Logs cancelation requests for time ticks - * @param isPending is an unschedule request pending? - * @param isTimeTickScheduled is a time tick request scheduled - */ - public void tracePendingUnscheduleTimeTick(boolean isPending, boolean isTimeTickScheduled) { - mLogger.logPendingUnscheduleTimeTick(isPending, isTimeTickScheduled); - } - - /** * Appends keyguard visibility change event to the logs * @param showing whether the keyguard is now showing */ diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeLogger.kt b/packages/SystemUI/src/com/android/systemui/doze/DozeLogger.kt index 9d6693efffa3..75b8e513c14a 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeLogger.kt @@ -162,15 +162,6 @@ class DozeLogger @Inject constructor( }) } - fun logPendingUnscheduleTimeTick(isPending: Boolean, isTimeTickScheduled: Boolean) { - buffer.log(TAG, INFO, { - bool1 = isPending - bool2 = isTimeTickScheduled - }, { - "Pending unschedule time tick, isPending=$bool1, isTimeTickScheduled:$bool2" - }) - } - fun logDozeStateChanged(state: DozeMachine.State) { buffer.log(TAG, INFO, { str1 = state.name diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeUi.java b/packages/SystemUI/src/com/android/systemui/doze/DozeUi.java index 1a855d735a02..34a80e867153 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeUi.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeUi.java @@ -26,12 +26,11 @@ import android.os.SystemClock; import android.text.format.Formatter; import android.util.Log; -import com.android.systemui.dagger.qualifiers.Background; +import com.android.systemui.DejankUtils; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.doze.dagger.DozeScope; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.util.AlarmTimeout; -import com.android.systemui.util.concurrency.DelayableExecutor; import com.android.systemui.util.wakelock.WakeLock; import java.util.Calendar; @@ -53,19 +52,14 @@ public class DozeUi implements DozeMachine.Part { private final boolean mCanAnimateTransition; private final DozeParameters mDozeParameters; private final DozeLog mDozeLog; - private final DelayableExecutor mBgExecutor; - private Runnable mCancelRunnable = null; private long mLastTimeTickElapsed = 0; // If time tick is scheduled and there's not a pending runnable to cancel: - private volatile boolean mTimeTickScheduled; + private boolean mTimeTickScheduled; private final Runnable mCancelTimeTickerRunnable = new Runnable() { @Override public void run() { - mDozeLog.tracePendingUnscheduleTimeTick(false, mTimeTickScheduled); - if (!mTimeTickScheduled) { - mTimeTicker.cancel(); - } + mTimeTicker.cancel(); } }; @@ -73,13 +67,11 @@ public class DozeUi implements DozeMachine.Part { public DozeUi(Context context, AlarmManager alarmManager, WakeLock wakeLock, DozeHost host, @Main Handler handler, DozeParameters params, - @Background DelayableExecutor bgExecutor, DozeLog dozeLog) { mContext = context; mWakeLock = wakeLock; mHost = host; mHandler = handler; - mBgExecutor = bgExecutor; mCanAnimateTransition = !params.getDisplayNeedsBlanking(); mDozeParameters = params; mTimeTicker = new AlarmTimeout(alarmManager, this::onTimeTick, "doze_time_tick", handler); @@ -174,6 +166,7 @@ public class DozeUi implements DozeMachine.Part { return; } mTimeTickScheduled = true; + DejankUtils.removeCallbacks(mCancelTimeTickerRunnable); long time = System.currentTimeMillis(); long delta = roundToNextMinute(time) - System.currentTimeMillis(); @@ -189,8 +182,7 @@ public class DozeUi implements DozeMachine.Part { return; } mTimeTickScheduled = false; - mDozeLog.tracePendingUnscheduleTimeTick(true, mTimeTickScheduled); - mBgExecutor.execute(mCancelTimeTickerRunnable); + DejankUtils.postAfterTraversal(mCancelTimeTickerRunnable); } private void verifyLastTimeTick() { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt index e6e6ff6dcadb..c32c226441fe 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt @@ -41,7 +41,6 @@ import com.android.keyguard.dagger.KeyguardStatusViewComponent import com.android.systemui.CoreStartable import com.android.systemui.common.ui.ConfigurationState import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.deviceentry.domain.interactor.DeviceEntryHapticsInteractor import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor @@ -73,7 +72,6 @@ import com.android.systemui.statusbar.phone.ScreenOffAnimationController import com.android.systemui.temporarydisplay.chipbar.ChipbarCoordinator import dagger.Lazy import javax.inject.Inject -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.DisposableHandle import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -110,7 +108,6 @@ constructor( private val keyguardBlueprintViewBinder: KeyguardBlueprintViewBinder, private val clockInteractor: KeyguardClockInteractor, private val keyguardViewMediator: KeyguardViewMediator, - @Main private val mainImmediateDispatcher: CoroutineDispatcher, ) : CoreStartable { private var rootViewHandle: DisposableHandle? = null @@ -214,7 +211,6 @@ constructor( vibratorHelper, falsingManager, keyguardViewMediator, - mainImmediateDispatcher, ) } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt index 2182fe378d2f..e384bfb7a36e 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt @@ -49,7 +49,6 @@ import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.data.repository.ShadeRepository import com.android.systemui.statusbar.CommandQueue import com.android.systemui.statusbar.notification.stack.domain.interactor.SharedNotificationContainerInteractor -import com.android.systemui.util.kotlin.Utils.Companion.sample as sampleCombine import com.android.systemui.util.kotlin.sample import javax.inject.Inject import javax.inject.Provider @@ -280,16 +279,12 @@ constructor( * signal should be sent directly to transitions. */ val dismissAlpha: Flow<Float?> = - shadeRepository.legacyShadeExpansion - .filter { it < 1f } - .sampleCombine( + combine( + shadeRepository.legacyShadeExpansion, statusBarState, keyguardTransitionInteractor.currentKeyguardState, isKeyguardDismissible, - ) - .map { - (legacyShadeExpansion, statusBarState, currentKeyguardState, isKeyguardDismissible) - -> + ) { legacyShadeExpansion, statusBarState, currentKeyguardState, isKeyguardDismissible -> if ( statusBarState == StatusBarState.KEYGUARD && isKeyguardDismissible && diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt index e423fe0bd8a0..f46a207b273a 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt @@ -25,7 +25,6 @@ import android.view.View import androidx.core.view.isInvisible import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle -import com.android.app.tracing.coroutines.launch import com.android.systemui.common.ui.view.LongPressHandlingView import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor import com.android.systemui.keyguard.ui.view.DeviceEntryIconView @@ -35,15 +34,13 @@ import com.android.systemui.keyguard.ui.viewmodel.DeviceEntryIconViewModel import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.plugins.FalsingManager import com.android.systemui.statusbar.VibratorHelper -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.launch @ExperimentalCoroutinesApi object DeviceEntryIconViewBinder { - private const val TAG = "DeviceEntryIconViewBinder" - /** * Updates UI for: * - device entry containing view (parent view for the below views) @@ -61,7 +58,6 @@ object DeviceEntryIconViewBinder { bgViewModel: DeviceEntryBackgroundViewModel, falsingManager: FalsingManager, vibratorHelper: VibratorHelper, - mainImmediateDispatcher: CoroutineDispatcher, ) { DeviceEntryUdfpsRefactor.isUnexpectedlyInLegacyMode() val longPressHandlingView = view.longPressHandlingView @@ -77,33 +73,31 @@ object DeviceEntryIconViewBinder { view, HapticFeedbackConstants.CONFIRM, ) - applicationScope.launch("$TAG#viewModel.onLongPress") { - viewModel.onLongPress() - } + applicationScope.launch { viewModel.onLongPress() } } } - view.repeatWhenAttached(mainImmediateDispatcher) { + view.repeatWhenAttached { // Repeat on CREATED so that the view will always observe the entire // GONE => AOD transition (even though the view may not be visible until the middle // of the transition. repeatOnLifecycle(Lifecycle.State.CREATED) { - launch("$TAG#viewModel.isVisible") { + launch { viewModel.isVisible.collect { isVisible -> longPressHandlingView.isInvisible = !isVisible } } - launch("$TAG#viewModel.isLongPressEnabled") { + launch { viewModel.isLongPressEnabled.collect { isEnabled -> longPressHandlingView.setLongPressHandlingEnabled(isEnabled) } } - launch("$TAG#viewModel.accessibilityDelegateHint") { + launch { viewModel.accessibilityDelegateHint.collect { hint -> view.accessibilityHintType = hint } } - launch("$TAG#viewModel.useBackgroundProtection") { + launch { viewModel.useBackgroundProtection.collect { useBackgroundProtection -> if (useBackgroundProtection) { bgView.visibility = View.VISIBLE @@ -112,7 +106,7 @@ object DeviceEntryIconViewBinder { } } } - launch("$TAG#viewModel.burnInOffsets") { + launch { viewModel.burnInOffsets.collect { burnInOffsets -> view.translationX = burnInOffsets.x.toFloat() view.translationY = burnInOffsets.y.toFloat() @@ -120,17 +114,15 @@ object DeviceEntryIconViewBinder { } } - launch("$TAG#viewModel.deviceEntryViewAlpha") { - viewModel.deviceEntryViewAlpha.collect { alpha -> view.alpha = alpha } - } + launch { viewModel.deviceEntryViewAlpha.collect { alpha -> view.alpha = alpha } } } } - fgIconView.repeatWhenAttached(mainImmediateDispatcher) { + fgIconView.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.STARTED) { // Start with an empty state fgIconView.setImageState(StateSet.NOTHING, /* merge */ false) - launch("$TAG#fgViewModel.viewModel") { + launch { fgViewModel.viewModel.collect { viewModel -> fgIconView.setImageState( view.getIconState(viewModel.type, viewModel.useAodVariant), @@ -150,10 +142,8 @@ object DeviceEntryIconViewBinder { bgView.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.CREATED) { - launch("$TAG#bgViewModel.alpha") { - bgViewModel.alpha.collect { alpha -> bgView.alpha = alpha } - } - launch("$TAG#bgViewModel.color") { + launch { bgViewModel.alpha.collect { alpha -> bgView.alpha = alpha } } + launch { bgViewModel.color.collect { color -> bgView.imageTintList = ColorStateList.valueOf(color) } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt index 1b06a69213b9..6255f0d44609 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt @@ -26,7 +26,6 @@ import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintSet import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle -import com.android.app.tracing.coroutines.launch import com.android.keyguard.KeyguardClockSwitch.LARGE import com.android.keyguard.KeyguardClockSwitch.SMALL import com.android.systemui.keyguard.MigrateClocksToBlueprint @@ -38,10 +37,10 @@ import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.plugins.clocks.ClockController import com.android.systemui.shared.clocks.DEFAULT_CLOCK_ID -import kotlinx.coroutines.DisposableHandle +import kotlinx.coroutines.launch object KeyguardClockViewBinder { - private const val TAG = "KeyguardClockViewBinder" + private val TAG = KeyguardClockViewBinder::class.simpleName!! // When changing to new clock, we need to remove old clock views from burnInLayer private var lastClock: ClockController? = null @JvmStatic @@ -51,12 +50,15 @@ object KeyguardClockViewBinder { viewModel: KeyguardClockViewModel, keyguardClockInteractor: KeyguardClockInteractor, blueprintInteractor: KeyguardBlueprintInteractor, - ): DisposableHandle { - keyguardClockInteractor.clockEventController.registerListeners(keyguardRootView) - - return keyguardRootView.repeatWhenAttached { + ) { + keyguardRootView.repeatWhenAttached { + repeatOnLifecycle(Lifecycle.State.CREATED) { + keyguardClockInteractor.clockEventController.registerListeners(keyguardRootView) + } + } + keyguardRootView.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.CREATED) { - launch("$TAG#viewModel.currentClock") { + launch { if (!MigrateClocksToBlueprint.isEnabled) return@launch viewModel.currentClock.collect { currentClock -> cleanupClockViews(currentClock, keyguardRootView, viewModel.burnInLayer) @@ -65,14 +67,14 @@ object KeyguardClockViewBinder { applyConstraints(clockSection, keyguardRootView, true) } } - launch("$TAG#viewModel.clockSize") { + launch { if (!MigrateClocksToBlueprint.isEnabled) return@launch viewModel.clockSize.collect { updateBurnInLayer(keyguardRootView, viewModel) blueprintInteractor.refreshBlueprint(Type.ClockSize) } } - launch("$TAG#viewModel.clockShouldBeCentered") { + launch { if (!MigrateClocksToBlueprint.isEnabled) return@launch viewModel.clockShouldBeCentered.collect { clockShouldBeCentered -> viewModel.currentClock.value?.let { @@ -89,7 +91,7 @@ object KeyguardClockViewBinder { } } } - launch("$TAG#viewModel.isAodIconsVisible") { + launch { if (!MigrateClocksToBlueprint.isEnabled) return@launch viewModel.isAodIconsVisible.collect { isAodIconsVisible -> viewModel.currentClock.value?.let { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt index 6c21e6cdb3bc..abd79ab793d5 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt @@ -30,7 +30,6 @@ import androidx.core.view.isVisible import androidx.core.view.updateLayoutParams import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle -import com.android.app.tracing.coroutines.launch import com.android.settingslib.Utils import com.android.systemui.animation.Expandable import com.android.systemui.animation.view.LaunchableImageView @@ -42,11 +41,11 @@ import com.android.systemui.plugins.FalsingManager import com.android.systemui.res.R import com.android.systemui.statusbar.VibratorHelper import com.android.systemui.util.doOnEnd -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.map +import kotlinx.coroutines.launch /** This is only for a SINGLE Quick affordance */ object KeyguardQuickAffordanceViewBinder { @@ -54,7 +53,6 @@ object KeyguardQuickAffordanceViewBinder { private const val EXIT_DOZE_BUTTON_REVEAL_ANIMATION_DURATION_MS = 250L private const val SCALE_SELECTED_BUTTON = 1.23f private const val DIM_ALPHA = 0.3f - private const val TAG = "KeyguardQuickAffordanceViewBinder" /** * Defines interface for an object that acts as the binding between the view and its view-model. @@ -76,15 +74,14 @@ object KeyguardQuickAffordanceViewBinder { alpha: Flow<Float>, falsingManager: FalsingManager?, vibratorHelper: VibratorHelper?, - mainImmediateDispatcher: CoroutineDispatcher, messageDisplayer: (Int) -> Unit, ): Binding { val button = view as ImageView val configurationBasedDimensions = MutableStateFlow(loadFromResources(view)) val disposableHandle = - view.repeatWhenAttached(mainImmediateDispatcher) { + view.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.STARTED) { - launch("$TAG#viewModel.collect") { + launch { viewModel.collect { buttonModel -> updateButton( view = button, @@ -96,7 +93,7 @@ object KeyguardQuickAffordanceViewBinder { } } - launch("$TAG#updateButtonAlpha") { + launch { updateButtonAlpha( view = button, viewModel = viewModel, @@ -104,7 +101,7 @@ object KeyguardQuickAffordanceViewBinder { ) } - launch("$TAG#configurationBasedDimensions") { + launch { configurationBasedDimensions.collect { dimensions -> button.updateLayoutParams<ViewGroup.LayoutParams> { width = dimensions.buttonSizePx.width diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt index 44fd58267250..5ee35e4f8eb6 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt @@ -33,7 +33,6 @@ import android.view.WindowInsets import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle import com.android.app.animation.Interpolators -import com.android.app.tracing.coroutines.launch import com.android.internal.jank.InteractionJankMonitor import com.android.internal.jank.InteractionJankMonitor.CUJ_SCREEN_OFF_SHOW_AOD import com.android.systemui.Flags.newAodTransition @@ -73,7 +72,6 @@ import com.android.systemui.util.ui.isAnimating import com.android.systemui.util.ui.stopAnimating import com.android.systemui.util.ui.value import kotlin.math.min -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.DisposableHandle import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.coroutineScope @@ -81,6 +79,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.update +import kotlinx.coroutines.launch /** Bind occludingAppDeviceEntryMessageViewModel to run whenever the keyguard view is attached. */ @OptIn(ExperimentalCoroutinesApi::class) @@ -101,7 +100,6 @@ object KeyguardRootViewBinder { vibratorHelper: VibratorHelper?, falsingManager: FalsingManager?, keyguardViewMediator: KeyguardViewMediator?, - mainImmediateDispatcher: CoroutineDispatcher, ): DisposableHandle { val disposables = DisposableHandles() val childViews = mutableMapOf<Int, View>() @@ -125,9 +123,9 @@ object KeyguardRootViewBinder { ) disposables += - view.repeatWhenAttached(mainImmediateDispatcher) { + view.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.CREATED) { - launch("$TAG#occludingAppDeviceEntryMessageViewModel.message") { + launch { occludingAppDeviceEntryMessageViewModel.message.collect { biometricMessage -> if (biometricMessage?.message != null) { @@ -146,7 +144,7 @@ object KeyguardRootViewBinder { if ( KeyguardBottomAreaRefactor.isEnabled || DeviceEntryUdfpsRefactor.isEnabled ) { - launch("$TAG#viewModel.alpha") { + launch { viewModel.alpha(viewState).collect { alpha -> view.alpha = alpha if (KeyguardBottomAreaRefactor.isEnabled) { @@ -158,21 +156,21 @@ object KeyguardRootViewBinder { } if (MigrateClocksToBlueprint.isEnabled) { - launch("$TAG#viewModel.burnInLayerVisibility") { + launch { viewModel.burnInLayerVisibility.collect { visibility -> childViews[burnInLayerId]?.visibility = visibility childViews[aodNotificationIconContainerId]?.visibility = visibility } } - launch("$TAG#viewModel.burnInLayerAlpha") { + launch { viewModel.burnInLayerAlpha.collect { alpha -> childViews[statusViewId]?.alpha = alpha childViews[aodNotificationIconContainerId]?.alpha = alpha } } - launch("$TAG#viewModel.topClippingBounds") { + launch { val clipBounds = Rect() viewModel.topClippingBounds.collect { clipTop -> if (clipTop == null) { @@ -189,13 +187,13 @@ object KeyguardRootViewBinder { } } - launch("$TAG#viewModel.lockscreenStateAlpha") { + launch { viewModel.lockscreenStateAlpha(viewState).collect { alpha -> childViews[statusViewId]?.alpha = alpha } } - launch("$TAG#viewModel.translationY") { + launch { // When translation happens in burnInLayer, it won't be weather clock // large clock isn't added to burnInLayer due to its scale transition // so we also need to add translation to it here @@ -207,7 +205,7 @@ object KeyguardRootViewBinder { } } - launch("$TAG#viewModel.translationX") { + launch { viewModel.translationX.collect { state -> val px = state.value ?: return@collect when { @@ -234,7 +232,7 @@ object KeyguardRootViewBinder { } } - launch("$TAG#viewModel.scale") { + launch { viewModel.scale.collect { scaleViewModel -> if (scaleViewModel.scaleClockOnly) { // For clocks except weather clock, we have scale transition @@ -265,7 +263,7 @@ object KeyguardRootViewBinder { } if (NotificationIconContainerRefactor.isEnabled) { - launch("$TAG#viewModel.isNotifIconContainerVisible") { + launch { val iconsAppearTranslationPx = configuration .getDimensionPixelSize(R.dimen.shelf_appear_translation) @@ -282,7 +280,7 @@ object KeyguardRootViewBinder { } interactionJankMonitor?.let { jankMonitor -> - launch("$TAG#viewModel.goneToAodTransition") { + launch { viewModel.goneToAodTransition.collect { when (it.transitionState) { TransitionState.STARTED -> { @@ -308,7 +306,7 @@ object KeyguardRootViewBinder { } } - launch("$TAG#shadeInteractor.isAnyFullyExpanded") { + launch { shadeInteractor.isAnyFullyExpanded.collect { isFullyAnyExpanded -> view.visibility = if (isFullyAnyExpanded) { @@ -319,12 +317,10 @@ object KeyguardRootViewBinder { } } - launch("$TAG#burnInParams.collect") { - burnInParams.collect { viewModel.updateBurnInParams(it) } - } + launch { burnInParams.collect { viewModel.updateBurnInParams(it) } } if (deviceEntryHapticsInteractor != null && vibratorHelper != null) { - launch("$TAG#deviceEntryHapticsInteractor.playSuccessHaptic") { + launch { deviceEntryHapticsInteractor.playSuccessHaptic.collect { vibratorHelper.performHapticFeedback( view, @@ -334,7 +330,7 @@ object KeyguardRootViewBinder { } } - launch("$TAG#deviceEntryHapticsInteractor.playErrorHaptic") { + launch { deviceEntryHapticsInteractor.playErrorHaptic.collect { vibratorHelper.performHapticFeedback( view, @@ -589,5 +585,4 @@ object KeyguardRootViewBinder { private const val ID = "occluding_app_device_entry_unlock_msg" private const val AOD_ICONS_APPEAR_DURATION: Long = 200 - private const val TAG = "KeyguardRootViewBinder" } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt index ce1aed08ab49..d35f3eb1360b 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt @@ -387,7 +387,6 @@ constructor( null, // device entry haptics not required for preview mode null, // falsing manager not required for preview mode null, // keyguard view mediator is not required for preview mode - mainDispatcher, ) } rootView.addView( @@ -454,7 +453,6 @@ constructor( alpha = flowOf(1f), falsingManager = falsingManager, vibratorHelper = vibratorHelper, - mainImmediateDispatcher = mainDispatcher, ) { message -> indicationController.showTransientIndication(message) } @@ -469,7 +467,6 @@ constructor( alpha = flowOf(1f), falsingManager = falsingManager, vibratorHelper = vibratorHelper, - mainImmediateDispatcher = mainDispatcher, ) { message -> indicationController.showTransientIndication(message) } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AlignShortcutsToUdfpsSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AlignShortcutsToUdfpsSection.kt index 5404729d1819..2e9663897f89 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AlignShortcutsToUdfpsSection.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AlignShortcutsToUdfpsSection.kt @@ -36,7 +36,6 @@ import com.android.systemui.res.R import com.android.systemui.statusbar.KeyguardIndicationController import com.android.systemui.statusbar.VibratorHelper import javax.inject.Inject -import kotlinx.coroutines.CoroutineDispatcher class AlignShortcutsToUdfpsSection @Inject @@ -48,7 +47,6 @@ constructor( private val falsingManager: FalsingManager, private val indicationController: KeyguardIndicationController, private val vibratorHelper: VibratorHelper, - @Main private val mainImmediateDispatcher: CoroutineDispatcher, ) : BaseShortcutSection() { override fun addViews(constraintLayout: ConstraintLayout) { if (KeyguardBottomAreaRefactor.isEnabled) { @@ -66,7 +64,6 @@ constructor( keyguardQuickAffordancesCombinedViewModel.transitionAlpha, falsingManager, vibratorHelper, - mainImmediateDispatcher, ) { indicationController.showTransientIndication(it) } @@ -77,7 +74,6 @@ constructor( keyguardQuickAffordancesCombinedViewModel.transitionAlpha, falsingManager, vibratorHelper, - mainImmediateDispatcher, ) { indicationController.showTransientIndication(it) } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt index e0bf8152d11f..78a1fcfe4258 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt @@ -45,7 +45,6 @@ import com.android.systemui.res.R import com.android.systemui.shared.R as sharedR import dagger.Lazy import javax.inject.Inject -import kotlinx.coroutines.DisposableHandle internal fun ConstraintSet.setVisibility( views: Iterable<View>, @@ -66,23 +65,19 @@ constructor( val smartspaceViewModel: KeyguardSmartspaceViewModel, val blueprintInteractor: Lazy<KeyguardBlueprintInteractor>, ) : KeyguardSection() { - private var handle: DisposableHandle? = null - override fun addViews(constraintLayout: ConstraintLayout) {} override fun bindData(constraintLayout: ConstraintLayout) { if (!MigrateClocksToBlueprint.isEnabled) { return } - handle?.dispose() - handle = - KeyguardClockViewBinder.bind( - this, - constraintLayout, - keyguardClockViewModel, - clockInteractor, - blueprintInteractor.get() - ) + KeyguardClockViewBinder.bind( + this, + constraintLayout, + keyguardClockViewModel, + clockInteractor, + blueprintInteractor.get() + ) } override fun applyConstraints(constraintSet: ConstraintSet) { @@ -94,13 +89,7 @@ constructor( } } - override fun removeViews(constraintLayout: ConstraintLayout) { - if (!MigrateClocksToBlueprint.isEnabled) { - return - } - handle?.dispose() - handle = null - } + override fun removeViews(constraintLayout: ConstraintLayout) {} private fun buildConstraints( clock: ClockController, diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntrySection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntrySection.kt index 865e989c5b68..29041d1665c3 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntrySection.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntrySection.kt @@ -30,7 +30,6 @@ import com.android.keyguard.LockIconView import com.android.keyguard.LockIconViewController import com.android.systemui.biometrics.AuthController import com.android.systemui.dagger.qualifiers.Application -import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags @@ -48,7 +47,6 @@ import com.android.systemui.shade.NotificationPanelView import com.android.systemui.statusbar.VibratorHelper import dagger.Lazy import javax.inject.Inject -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -69,7 +67,6 @@ constructor( private val deviceEntryBackgroundViewModel: Lazy<DeviceEntryBackgroundViewModel>, private val falsingManager: Lazy<FalsingManager>, private val vibratorHelper: Lazy<VibratorHelper>, - @Main private val mainImmediateDispatcher: CoroutineDispatcher, ) : KeyguardSection() { private val deviceEntryIconViewId = R.id.device_entry_icon_view @@ -107,7 +104,6 @@ constructor( deviceEntryBackgroundViewModel.get(), falsingManager.get(), vibratorHelper.get(), - mainImmediateDispatcher, ) } } else { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultShortcutsSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultShortcutsSection.kt index 27ca5cdbad17..45b82576c6c4 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultShortcutsSection.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultShortcutsSection.kt @@ -35,7 +35,6 @@ import com.android.systemui.res.R import com.android.systemui.statusbar.KeyguardIndicationController import com.android.systemui.statusbar.VibratorHelper import javax.inject.Inject -import kotlinx.coroutines.CoroutineDispatcher class DefaultShortcutsSection @Inject @@ -47,7 +46,6 @@ constructor( private val falsingManager: FalsingManager, private val indicationController: KeyguardIndicationController, private val vibratorHelper: VibratorHelper, - @Main private val mainImmediateDispatcher: CoroutineDispatcher, ) : BaseShortcutSection() { override fun addViews(constraintLayout: ConstraintLayout) { if (KeyguardBottomAreaRefactor.isEnabled) { @@ -65,7 +63,6 @@ constructor( keyguardQuickAffordancesCombinedViewModel.transitionAlpha, falsingManager, vibratorHelper, - mainImmediateDispatcher, ) { indicationController.showTransientIndication(it) } @@ -76,7 +73,6 @@ constructor( keyguardQuickAffordancesCombinedViewModel.transitionAlpha, falsingManager, vibratorHelper, - mainImmediateDispatcher, ) { indicationController.showTransientIndication(it) } diff --git a/packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt index 9a833114ab72..f1ad355fc296 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt @@ -142,7 +142,6 @@ class ClockEventControllerTest : SysuiTestCase() { context.resources, context, mainExecutor, - IMMEDIATE, bgExecutor, clockBuffers, withDeps.featureFlags, diff --git a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeUiTest.java b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeUiTest.java index e7caf000ef67..7311f4a5ef71 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeUiTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeUiTest.java @@ -41,8 +41,6 @@ import androidx.test.runner.AndroidJUnit4; import com.android.systemui.DejankUtils; import com.android.systemui.SysuiTestCase; import com.android.systemui.statusbar.phone.DozeParameters; -import com.android.systemui.util.concurrency.FakeExecutor; -import com.android.systemui.util.time.FakeSystemClock; import com.android.systemui.util.wakelock.WakeLockFake; import org.junit.After; @@ -71,7 +69,6 @@ public class DozeUiTest extends SysuiTestCase { private Handler mHandler; private HandlerThread mHandlerThread; private DozeUi mDozeUi; - private FakeExecutor mFakeExecutor; @Before public void setUp() throws Exception { @@ -83,9 +80,9 @@ public class DozeUiTest extends SysuiTestCase { mHandlerThread.start(); mWakeLock = new WakeLockFake(); mHandler = mHandlerThread.getThreadHandler(); - mFakeExecutor = new FakeExecutor(new FakeSystemClock()); + mDozeUi = new DozeUi(mContext, mAlarmManager, mWakeLock, mHost, mHandler, - mDozeParameters, mFakeExecutor, mDozeLog); + mDozeParameters, mDozeLog); mDozeUi.setDozeMachine(mMachine); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntrySectionTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntrySectionTest.kt index b5f668cef08c..4f2b690f9fcd 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntrySectionTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntrySectionTest.kt @@ -38,7 +38,6 @@ import com.android.systemui.shade.NotificationPanelView import com.android.systemui.statusbar.VibratorHelper import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.TestScope @@ -86,7 +85,6 @@ class DefaultDeviceEntrySectionTest : SysuiTestCase() { { mock(DeviceEntryBackgroundViewModel::class.java) }, { falsingManager }, { mock(VibratorHelper::class.java) }, - mock(CoroutineDispatcher::class.java), ) } |