summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sherry Zhou <yuandizhou@google.com> 2023-11-15 22:55:56 +0000
committer Sherry Zhou <yuandizhou@google.com> 2023-12-01 19:01:40 +0000
commita80d367f5596747ded198f9b45159b48baf574af (patch)
tree652f1bd712c9b6bdd3441cc0073dbbbbf4b54d07
parentb8379d2d3f93dc13798ec859244d80306492c26b (diff)
Add clocks to Aod BurnInLayer
Test: atest KeyguardClockViewBinderTest Bug: 310987145 Flag: LEGACY MIGRATE_CLOCKS_TO_BLUEPRINT DEVELOPMENT Change-Id: Ic40cb502b0a17f2bb7727a022a9f1a4bd9ced9f9
-rw-r--r--packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt5
-rw-r--r--packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockProvider.kt4
-rw-r--r--packages/SystemUI/src/com/android/keyguard/dagger/ClockRegistryModule.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepository.kt57
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt14
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryModule.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt19
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt7
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt87
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardIndicationAreaBinder.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt16
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt16
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt1
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprint.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt41
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt15
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultIndicationAreaSection.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultStatusViewSection.kt5
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt13
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModel.kt31
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt24
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModel.kt23
-rw-r--r--packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java6
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepositoryTest.kt11
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinderTest.kt103
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprintTest.kt2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt5
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt36
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt15
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java3
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/FakeKeyguardDataLayerModule.kt2
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardClockRepository.kt56
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt7
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepositoryKosmos.kt23
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractorKosmos.kt23
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelKosmos.kt31
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelKosmos.kt3
37 files changed, 577 insertions, 142 deletions
diff --git a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt
index 42ba6431822e..53755916f83e 100644
--- a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt
+++ b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt
@@ -53,6 +53,7 @@ class DefaultClockController(
private val resources: Resources,
private val settings: ClockSettings?,
private val hasStepClockAnimation: Boolean = false,
+ private val migratedClocks: Boolean = false,
) : ClockController {
override val smallClock: DefaultClockFaceController
override val largeClock: LargeClockFaceController
@@ -195,6 +196,10 @@ class DefaultClockController(
}
override fun recomputePadding(targetRegion: Rect?) {
+ // TODO(b/310989341): remove after changing migrate_clocks_to_blueprint to aconfig
+ if (migratedClocks) {
+ return
+ }
// We center the view within the targetRegion instead of within the parent
// view by computing the difference and adding that to the padding.
val lp = view.getLayoutParams() as FrameLayout.LayoutParams
diff --git a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockProvider.kt b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockProvider.kt
index dd52e39488ac..f819da5b53de 100644
--- a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockProvider.kt
+++ b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockProvider.kt
@@ -32,7 +32,8 @@ class DefaultClockProvider(
val ctx: Context,
val layoutInflater: LayoutInflater,
val resources: Resources,
- val hasStepClockAnimation: Boolean = false
+ val hasStepClockAnimation: Boolean = false,
+ val migratedClocks: Boolean = false
) : ClockProvider {
override fun getClocks(): List<ClockMetadata> = listOf(ClockMetadata(DEFAULT_CLOCK_ID))
@@ -47,6 +48,7 @@ class DefaultClockProvider(
resources,
settings,
hasStepClockAnimation,
+ migratedClocks,
)
}
diff --git a/packages/SystemUI/src/com/android/keyguard/dagger/ClockRegistryModule.java b/packages/SystemUI/src/com/android/keyguard/dagger/ClockRegistryModule.java
index 9716d98cf5e0..ee35bb9dff84 100644
--- a/packages/SystemUI/src/com/android/keyguard/dagger/ClockRegistryModule.java
+++ b/packages/SystemUI/src/com/android/keyguard/dagger/ClockRegistryModule.java
@@ -20,7 +20,6 @@ import android.content.Context;
import android.content.res.Resources;
import android.view.LayoutInflater;
-import com.android.systemui.res.R;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Application;
import com.android.systemui.dagger.qualifiers.Background;
@@ -30,6 +29,7 @@ import com.android.systemui.flags.Flags;
import com.android.systemui.log.LogBuffer;
import com.android.systemui.log.dagger.KeyguardClockLog;
import com.android.systemui.plugins.PluginManager;
+import com.android.systemui.res.R;
import com.android.systemui.shared.clocks.ClockRegistry;
import com.android.systemui.shared.clocks.DefaultClockProvider;
@@ -67,7 +67,8 @@ public abstract class ClockRegistryModule {
context,
layoutInflater,
resources,
- featureFlags.isEnabled(Flags.STEP_CLOCK_ANIMATION)),
+ featureFlags.isEnabled(Flags.STEP_CLOCK_ANIMATION),
+ featureFlags.isEnabled(Flags.MIGRATE_CLOCKS_TO_BLUEPRINT)),
context.getString(R.string.lockscreen_clock_id_fallback),
logBuffer,
/* keepAllLoaded = */ false,
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepository.kt
index d1c62188d3fc..8d5e6c391e6e 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepository.kt
@@ -19,34 +19,71 @@ package com.android.systemui.keyguard.data.repository
import android.os.UserHandle
import android.provider.Settings
import androidx.annotation.VisibleForTesting
-import com.android.keyguard.KeyguardClockSwitch.SMALL
+import com.android.keyguard.ClockEventController
+import com.android.keyguard.KeyguardClockSwitch.ClockSize
+import com.android.keyguard.KeyguardClockSwitch.LARGE
import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.keyguard.shared.model.SettingsClockSize
+import com.android.systemui.plugins.ClockController
import com.android.systemui.plugins.ClockId
import com.android.systemui.shared.clocks.ClockRegistry
import com.android.systemui.util.settings.SecureSettings
import com.android.systemui.util.settings.SettingsProxyExt.observerFlow
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.MutableStateFlow
+import kotlinx.coroutines.flow.SharingStarted
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.callbackFlow
+import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.onStart
+import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.withContext
+interface KeyguardClockRepository {
+ /** clock size determined by notificationPanelViewController, LARGE or SMALL */
+ val clockSize: StateFlow<Int>
+
+ /** clock size selected in picker, DYNAMIC or SMALL */
+ val selectedClockSize: Flow<SettingsClockSize>
+
+ /** clock id, selected from clock carousel in wallpaper picker */
+ val currentClockId: Flow<ClockId>
+
+ val currentClock: StateFlow<ClockController?>
+
+ val clockEventController: ClockEventController
+ fun setClockSize(@ClockSize size: Int)
+}
+
@SysUISingleton
-class KeyguardClockRepository
+class KeyguardClockRepositoryImpl
@Inject
constructor(
private val secureSettings: SecureSettings,
private val clockRegistry: ClockRegistry,
+ override val clockEventController: ClockEventController,
@Background private val backgroundDispatcher: CoroutineDispatcher,
-) {
+ @Application private val applicationScope: CoroutineScope,
+) : KeyguardClockRepository {
+
+ /** Receive SMALL or LARGE clock should be displayed on keyguard. */
+ private val _clockSize: MutableStateFlow<Int> = MutableStateFlow(LARGE)
+ override val clockSize: StateFlow<Int> = _clockSize.asStateFlow()
- val selectedClockSize: Flow<SettingsClockSize> =
+ override fun setClockSize(size: Int) {
+ _clockSize.value = size
+ }
+
+ override val selectedClockSize: Flow<SettingsClockSize> =
secureSettings
.observerFlow(
names = arrayOf(Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK),
@@ -55,7 +92,7 @@ constructor(
.onStart { emit(Unit) } // Forces an initial update.
.map { getClockSize() }
- val currentClockId: Flow<ClockId> =
+ override val currentClockId: Flow<ClockId> =
callbackFlow {
fun send() {
trySend(clockRegistry.currentClockId)
@@ -72,8 +109,16 @@ constructor(
awaitClose { clockRegistry.unregisterClockChangeListener(listener) }
}
.mapNotNull { it }
+ .distinctUntilChanged()
- val currentClock = currentClockId.map { clockRegistry.createCurrentClock() }
+ override val currentClock: StateFlow<ClockController?> =
+ currentClockId
+ .map { clockRegistry.createCurrentClock() }
+ .stateIn(
+ scope = applicationScope,
+ started = SharingStarted.WhileSubscribed(),
+ initialValue = clockRegistry.createCurrentClock()
+ )
@VisibleForTesting
suspend fun getClockSize(): SettingsClockSize {
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt
index 6ff446edca38..791ac07db5cf 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt
@@ -18,8 +18,6 @@ package com.android.systemui.keyguard.data.repository
import android.graphics.Point
import android.hardware.biometrics.BiometricSourceType
-import com.android.keyguard.KeyguardClockSwitch.ClockSize
-import com.android.keyguard.KeyguardClockSwitch.LARGE
import com.android.keyguard.KeyguardUpdateMonitor
import com.android.keyguard.KeyguardUpdateMonitorCallback
import com.android.systemui.biometrics.AuthController
@@ -192,9 +190,6 @@ interface KeyguardRepository {
/** Observable updated when keyguardDone should be called either now or soon. */
val keyguardDone: Flow<KeyguardDone>
- /** Receive SMALL or LARGE clock should be displayed on keyguard. */
- val clockSize: Flow<Int>
-
/** Receive whether clock should be centered on lockscreen. */
val clockShouldBeCentered: Flow<Boolean>
@@ -247,8 +242,6 @@ interface KeyguardRepository {
suspend fun setKeyguardDone(keyguardDoneType: KeyguardDone)
- fun setClockSize(@ClockSize size: Int)
-
fun setClockShouldBeCentered(shouldBeCentered: Boolean)
}
@@ -293,9 +286,6 @@ constructor(
private val _clockPosition = MutableStateFlow(Position(0, 0))
override val clockPosition = _clockPosition.asStateFlow()
- private val _clockSize = MutableStateFlow(LARGE)
- override val clockSize: Flow<Int> = _clockSize.asStateFlow()
-
private val _clockShouldBeCentered = MutableStateFlow(true)
override val clockShouldBeCentered: Flow<Boolean> = _clockShouldBeCentered.asStateFlow()
@@ -681,10 +671,6 @@ constructor(
_isActiveDreamLockscreenHosted.value = isLockscreenHosted
}
- override fun setClockSize(@ClockSize size: Int) {
- _clockSize.value = size
- }
-
override fun setClockShouldBeCentered(shouldBeCentered: Boolean) {
_clockShouldBeCentered.value = shouldBeCentered
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryModule.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryModule.kt
index 565962394db1..6138330c2e76 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryModule.kt
@@ -74,4 +74,6 @@ interface KeyguardRepositoryModule {
fun bind(impl: BouncerMessageAuditLogger): CoreStartable
@Binds fun trustRepository(impl: TrustRepositoryImpl): TrustRepository
+
+ @Binds fun keyguardClockRepository(impl: KeyguardClockRepositoryImpl): KeyguardClockRepository
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt
index 2f103f612563..3887e69a47a2 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt
@@ -18,6 +18,7 @@
package com.android.systemui.keyguard.domain.interactor
import com.android.keyguard.ClockEventController
+import com.android.keyguard.KeyguardClockSwitch.ClockSize
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.data.repository.KeyguardClockRepository
import com.android.systemui.keyguard.shared.model.SettingsClockSize
@@ -25,6 +26,7 @@ import com.android.systemui.plugins.ClockController
import com.android.systemui.plugins.ClockId
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.StateFlow
private val TAG = KeyguardClockInteractor::class.simpleName
/** Manages keyguard clock for the lockscreen root view. */
@@ -33,7 +35,6 @@ private val TAG = KeyguardClockInteractor::class.simpleName
class KeyguardClockInteractor
@Inject
constructor(
- val eventController: ClockEventController,
private val keyguardClockRepository: KeyguardClockRepository,
) {
@@ -41,11 +42,17 @@ constructor(
val currentClockId: Flow<ClockId> = keyguardClockRepository.currentClockId
- val currentClock: Flow<ClockController> = keyguardClockRepository.currentClock
+ val currentClock: StateFlow<ClockController?> = keyguardClockRepository.currentClock
- var clock: ClockController?
- get() = eventController.clock
- set(value) {
- eventController.clock = value
+ var clock: ClockController? by keyguardClockRepository.clockEventController::clock
+
+ val clockSize: StateFlow<Int> = keyguardClockRepository.clockSize
+ fun setClockSize(@ClockSize size: Int) {
+ keyguardClockRepository.setClockSize(size)
+ }
+
+ val clockEventController: ClockEventController
+ get() {
+ return keyguardClockRepository.clockEventController
}
}
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 e58d7710877b..c0e8e2b60f33 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
@@ -23,7 +23,6 @@ import android.app.StatusBarManager
import android.graphics.Point
import android.util.MathUtils
import com.android.app.animation.Interpolators
-import com.android.keyguard.KeyguardClockSwitch.ClockSize
import com.android.systemui.bouncer.data.repository.KeyguardBouncerRepository
import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging
import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
@@ -243,8 +242,6 @@ constructor(
}
}
- val clockSize: Flow<Int> = repository.clockSize.distinctUntilChanged()
-
val clockShouldBeCentered: Flow<Boolean> = repository.clockShouldBeCentered
/** Whether to animate the next doze mode transition. */
@@ -321,10 +318,6 @@ constructor(
repository.setAnimateDozingTransitions(animate)
}
- fun setClockSize(@ClockSize size: Int) {
- repository.setClockSize(size)
- }
-
fun setClockShouldBeCentered(shouldBeCentered: Boolean) {
repository.setClockShouldBeCentered(shouldBeCentered)
}
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 c688cfff2bf9..48f6092fd570 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
@@ -17,15 +17,16 @@
package com.android.systemui.keyguard.ui.binder
import android.transition.TransitionManager
+import androidx.annotation.VisibleForTesting
+import androidx.constraintlayout.helper.widget.Layer
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.systemui.flags.FeatureFlagsClassic
import com.android.systemui.flags.Flags
-import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
-import com.android.systemui.keyguard.ui.view.layout.items.ClockSection
+import com.android.systemui.keyguard.ui.view.layout.sections.ClockSection
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.plugins.ClockController
@@ -40,13 +41,12 @@ object KeyguardClockViewBinder {
clockSection: ClockSection,
keyguardRootView: ConstraintLayout,
viewModel: KeyguardClockViewModel,
- keyguardBlueprintInteractor: KeyguardBlueprintInteractor,
keyguardClockInteractor: KeyguardClockInteractor,
featureFlags: FeatureFlagsClassic,
) {
keyguardRootView.repeatWhenAttached {
repeatOnLifecycle(Lifecycle.State.CREATED) {
- keyguardClockInteractor.eventController.registerListeners(keyguardRootView)
+ keyguardClockInteractor.clockEventController.registerListeners(keyguardRootView)
}
}
keyguardRootView.repeatWhenAttached {
@@ -54,10 +54,11 @@ object KeyguardClockViewBinder {
launch {
if (!featureFlags.isEnabled(Flags.MIGRATE_CLOCKS_TO_BLUEPRINT)) return@launch
viewModel.currentClock.collect { currentClock ->
- viewModel.clock?.let { clock -> cleanupClockViews(clock, keyguardRootView) }
+ cleanupClockViews(viewModel.clock, keyguardRootView, viewModel.burnInLayer)
viewModel.clock = currentClock
- addClockViews(currentClock, keyguardRootView)
- keyguardBlueprintInteractor.refreshBlueprint()
+ addClockViews(currentClock, keyguardRootView, viewModel.burnInLayer)
+ viewModel.burnInLayer?.updatePostLayout(keyguardRootView)
+ applyConstraints(clockSection, keyguardRootView, true)
}
}
// TODO: Weather clock dozing animation
@@ -71,13 +72,61 @@ object KeyguardClockViewBinder {
}
launch {
if (!featureFlags.isEnabled(Flags.MIGRATE_CLOCKS_TO_BLUEPRINT)) return@launch
- viewModel.clockShouldBeCentered.collect { shouldBeCentered ->
- clockSection.setClockShouldBeCentered(
- viewModel.useLargeClock && shouldBeCentered
- )
+ viewModel.clockShouldBeCentered.collect {
applyConstraints(clockSection, keyguardRootView, true)
}
}
+ launch {
+ if (!featureFlags.isEnabled(Flags.MIGRATE_CLOCKS_TO_BLUEPRINT)) return@launch
+ viewModel.hasCustomWeatherDataDisplay.collect {
+ applyConstraints(clockSection, keyguardRootView, true)
+ }
+ }
+ }
+ }
+ }
+
+ private fun cleanupClockViews(
+ clockController: ClockController?,
+ rootView: ConstraintLayout,
+ burnInLayer: Layer?
+ ) {
+ clockController?.let { clock ->
+ clock.smallClock.layout.views.forEach {
+ burnInLayer?.removeView(it)
+ rootView.removeView(it)
+ }
+ // add large clock to burn in layer only when it will have same transition with other
+ // components in AOD
+ // otherwise, it will have a separate scale transition while other components only have
+ // translate transition
+ if (clock.config.useAlternateSmartspaceAODTransition) {
+ clock.largeClock.layout.views.forEach { burnInLayer?.removeView(it) }
+ }
+ clock.largeClock.layout.views.forEach { rootView.removeView(it) }
+ }
+ }
+
+ @VisibleForTesting
+ fun addClockViews(
+ clockController: ClockController?,
+ rootView: ConstraintLayout,
+ burnInLayer: Layer?
+ ) {
+ clockController?.let { clock ->
+ clock.smallClock.layout.views[0].id = R.id.lockscreen_clock_view
+ if (clock.largeClock.layout.views.size == 1) {
+ clock.largeClock.layout.views[0].id = R.id.lockscreen_clock_view_large
+ }
+ // small clock should either be a single view or container with id
+ // `lockscreen_clock_view`
+ clock.smallClock.layout.views.forEach {
+ rootView.addView(it)
+ burnInLayer?.addView(it)
+ }
+ clock.largeClock.layout.views.forEach { rootView.addView(it) }
+ if (clock.config.useAlternateSmartspaceAODTransition) {
+ clock.largeClock.layout.views.forEach { burnInLayer?.addView(it) }
}
}
}
@@ -92,22 +141,6 @@ object KeyguardClockViewBinder {
if (animated) {
TransitionManager.beginDelayedTransition(rootView)
}
-
constraintSet.applyTo(rootView)
}
-
- private fun cleanupClockViews(clock: ClockController, rootView: ConstraintLayout) {
- clock.smallClock.layout.views.forEach { rootView.removeView(it) }
- clock.largeClock.layout.views.forEach { rootView.removeView(it) }
- }
-
- private fun addClockViews(clock: ClockController, rootView: ConstraintLayout) {
- clock.smallClock.layout.views[0].id = R.id.lockscreen_clock_view
- if (clock.largeClock.layout.views.size == 1) {
- clock.largeClock.layout.views[0].id = R.id.lockscreen_clock_view_large
- }
- // small clock should either be a single view or container with id `lockscreen_clock_view`
- clock.smallClock.layout.views.forEach { rootView.addView(it) }
- clock.largeClock.layout.views.forEach { rootView.addView(it) }
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardIndicationAreaBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardIndicationAreaBinder.kt
index 1a8f62597037..4efd9ef5f21c 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardIndicationAreaBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardIndicationAreaBinder.kt
@@ -23,10 +23,10 @@ import android.widget.TextView
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.systemui.Flags.keyguardBottomAreaRefactor
-import com.android.systemui.res.R
import com.android.systemui.keyguard.ui.viewmodel.KeyguardIndicationAreaViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
+import com.android.systemui.res.R
import com.android.systemui.statusbar.KeyguardIndicationController
import kotlinx.coroutines.DisposableHandle
import kotlinx.coroutines.ExperimentalCoroutinesApi
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 c0d3d336719e..51e1f60acd64 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
@@ -41,6 +41,7 @@ import com.android.systemui.common.shared.model.TintedIcon
import com.android.systemui.common.ui.ConfigurationState
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryHapticsInteractor
import com.android.systemui.flags.FeatureFlagsClassic
+import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel
@@ -140,25 +141,35 @@ object KeyguardRootViewBinder {
}
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
+ // same as translationX
viewModel.translationY.collect { y ->
childViews[burnInLayerId]?.translationY = y
+ childViews[largeClockId]?.translationY = y
}
}
launch {
viewModel.translationX.collect { x ->
childViews[burnInLayerId]?.translationX = x
+ childViews[largeClockId]?.translationX = x
}
}
launch {
viewModel.scale.collect { (scale, scaleClockOnly) ->
if (scaleClockOnly) {
+ // For clocks except weather clock, we have scale transition
+ // besides translate
childViews[largeClockId]?.let {
it.scaleX = scale
it.scaleY = scale
}
} else {
+ // For weather clock, large clock should have only scale
+ // transition with other parts in burnInLayer
childViews[burnInLayerId]?.scaleX = scale
childViews[burnInLayerId]?.scaleY = scale
}
@@ -247,7 +258,10 @@ object KeyguardRootViewBinder {
}
}
}
- viewModel.clockControllerProvider = clockControllerProvider
+
+ if (!featureFlags.isEnabled(Flags.MIGRATE_CLOCKS_TO_BLUEPRINT)) {
+ viewModel.clockControllerProvider = clockControllerProvider
+ }
onLayoutChangeListener = OnLayoutChange(viewModel)
view.addOnLayoutChangeListener(onLayoutChangeListener)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt
index 41a2e509b5d0..954d2cf6ed8a 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.android.systemui.keyguard.ui.binder
import androidx.constraintlayout.widget.ConstraintLayout
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 59c798bfca1e..11872d90cc34 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
@@ -119,7 +119,6 @@ constructor(
private val screenOffAnimationController: ScreenOffAnimationController,
private val shadeInteractor: ShadeInteractor,
) {
-
val hostToken: IBinder? = bundle.getBinder(KEY_HOST_TOKEN)
private val width: Int = bundle.getInt(KEY_VIEW_WIDTH)
private val height: Int = bundle.getInt(KEY_VIEW_HEIGHT)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprint.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprint.kt
index fa27442707a3..1c6a2abdcbe7 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprint.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprint.kt
@@ -21,9 +21,9 @@ import com.android.systemui.communal.ui.view.layout.sections.CommunalTutorialInd
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.shared.model.KeyguardBlueprint
import com.android.systemui.keyguard.shared.model.KeyguardSection
-import com.android.systemui.keyguard.ui.view.layout.items.ClockSection
import com.android.systemui.keyguard.ui.view.layout.sections.AodBurnInSection
import com.android.systemui.keyguard.ui.view.layout.sections.AodNotificationIconsSection
+import com.android.systemui.keyguard.ui.view.layout.sections.ClockSection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultDeviceEntrySection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultIndicationAreaSection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultNotificationStackScrollLayoutSection
@@ -75,10 +75,10 @@ constructor(
defaultStatusBarSection,
defaultNotificationStackScrollLayoutSection,
aodNotificationIconsSection,
+ smartspaceSection,
aodBurnInSection,
communalTutorialIndicatorSection,
clockSection,
- smartspaceSection,
defaultDeviceEntrySection, // Add LAST: Intentionally has z-order above other views.
)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt
index 484d351a362e..df9ae41ed970 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt
@@ -22,8 +22,12 @@ import android.view.View
import androidx.constraintlayout.helper.widget.Layer
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
+import com.android.systemui.flags.FeatureFlagsClassic
+import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl
import com.android.systemui.keyguard.shared.model.KeyguardSection
+import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
+import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.res.R
import javax.inject.Inject
@@ -32,21 +36,31 @@ class AodBurnInSection
@Inject
constructor(
private val context: Context,
+ private val clockViewModel: KeyguardClockViewModel,
+ private val smartspaceViewModel: KeyguardSmartspaceViewModel,
+ private val featureFlags: FeatureFlagsClassic,
) : KeyguardSection() {
+ lateinit var burnInLayer: Layer
override fun addViews(constraintLayout: ConstraintLayout) {
if (!KeyguardShadeMigrationNssl.isEnabled) {
return
}
- val statusView = constraintLayout.requireViewById<View>(R.id.keyguard_status_view)
val nic = constraintLayout.requireViewById<View>(R.id.aod_notification_icon_container)
- val burnInLayer =
+ burnInLayer =
Layer(context).apply {
id = R.id.burn_in_layer
addView(nic)
- addView(statusView)
+ if (!featureFlags.isEnabled(Flags.MIGRATE_CLOCKS_TO_BLUEPRINT)) {
+ val statusView =
+ constraintLayout.requireViewById<View>(R.id.keyguard_status_view)
+ addView(statusView)
+ }
}
+ if (featureFlags.isEnabled(Flags.MIGRATE_CLOCKS_TO_BLUEPRINT)) {
+ addSmartspaceViews(constraintLayout)
+ }
constraintLayout.addView(burnInLayer)
}
@@ -54,6 +68,9 @@ constructor(
if (!KeyguardShadeMigrationNssl.isEnabled) {
return
}
+ if (featureFlags.isEnabled(Flags.MIGRATE_CLOCKS_TO_BLUEPRINT)) {
+ clockViewModel.burnInLayer = burnInLayer
+ }
}
override fun applyConstraints(constraintSet: ConstraintSet) {
@@ -65,4 +82,22 @@ constructor(
override fun removeViews(constraintLayout: ConstraintLayout) {
constraintLayout.removeView(R.id.burn_in_layer)
}
+
+ private fun addSmartspaceViews(constraintLayout: ConstraintLayout) {
+ burnInLayer.apply {
+ if (smartspaceViewModel.isSmartspaceEnabled) {
+ val smartspaceView =
+ constraintLayout.requireViewById<View>(smartspaceViewModel.smartspaceViewId)
+ addView(smartspaceView)
+ if (smartspaceViewModel.isDateWeatherDecoupled) {
+ val dateView =
+ constraintLayout.requireViewById<View>(smartspaceViewModel.dateId)
+ val weatherView =
+ constraintLayout.requireViewById<View>(smartspaceViewModel.weatherId)
+ addView(weatherView)
+ addView(dateView)
+ }
+ }
+ }
+ }
}
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 941c295ab86a..021f06434e80 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
@@ -15,7 +15,7 @@
*
*/
-package com.android.systemui.keyguard.ui.view.layout.items
+package com.android.systemui.keyguard.ui.view.layout.sections
import android.content.Context
import android.view.View
@@ -28,7 +28,6 @@ import androidx.constraintlayout.widget.ConstraintSet.START
import androidx.constraintlayout.widget.ConstraintSet.TOP
import androidx.constraintlayout.widget.ConstraintSet.WRAP_CONTENT
import com.android.systemui.flags.FeatureFlagsClassic
-import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.keyguard.ui.binder.KeyguardClockViewBinder
@@ -39,7 +38,6 @@ import com.android.systemui.plugins.ClockFaceLayout
import com.android.systemui.res.R
import com.android.systemui.statusbar.policy.SplitShadeStateController
import com.android.systemui.util.Utils
-import dagger.Lazy
import javax.inject.Inject
internal fun ConstraintSet.setVisibility(
@@ -60,7 +58,6 @@ constructor(
val smartspaceViewModel: KeyguardSmartspaceViewModel,
private val context: Context,
private val splitShadeStateController: SplitShadeStateController,
- private val keyguardBlueprintInteractor: Lazy<KeyguardBlueprintInteractor>,
private val featureFlags: FeatureFlagsClassic,
) : KeyguardSection() {
override fun addViews(constraintLayout: ConstraintLayout) {}
@@ -70,7 +67,6 @@ constructor(
this,
constraintLayout,
keyguardClockViewModel,
- keyguardBlueprintInteractor.get(),
clockInteractor,
featureFlags
)
@@ -109,15 +105,15 @@ constructor(
return previousValue != largeClockEndGuideline
}
- fun getTargetClockFace(clock: ClockController): ClockFaceLayout =
+ private fun getTargetClockFace(clock: ClockController): ClockFaceLayout =
if (keyguardClockViewModel.useLargeClock) getLargeClockFace(clock)
else getSmallClockFace(clock)
- fun getNonTargetClockFace(clock: ClockController): ClockFaceLayout =
+ private fun getNonTargetClockFace(clock: ClockController): ClockFaceLayout =
if (keyguardClockViewModel.useLargeClock) getSmallClockFace(clock)
else getLargeClockFace(clock)
- fun getLargeClockFace(clock: ClockController): ClockFaceLayout = clock.largeClock.layout
- fun getSmallClockFace(clock: ClockController): ClockFaceLayout = clock.smallClock.layout
+ private fun getLargeClockFace(clock: ClockController): ClockFaceLayout = clock.largeClock.layout
+ private fun getSmallClockFace(clock: ClockController): ClockFaceLayout = clock.smallClock.layout
fun applyDefaultConstraints(constraints: ConstraintSet) {
constraints.apply {
connect(R.id.lockscreen_clock_view_large, START, PARENT_ID, START)
@@ -138,6 +134,7 @@ constructor(
)
}
connect(R.id.lockscreen_clock_view_large, TOP, PARENT_ID, TOP, largeClockTopMargin)
+ constrainHeight(R.id.lockscreen_clock_view_large, WRAP_CONTENT)
constrainWidth(R.id.lockscreen_clock_view_large, WRAP_CONTENT)
constrainWidth(R.id.lockscreen_clock_view, WRAP_CONTENT)
constrainHeight(
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultIndicationAreaSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultIndicationAreaSection.kt
index 8aef7c23b45d..56f717d7e4ef 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultIndicationAreaSection.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultIndicationAreaSection.kt
@@ -22,12 +22,12 @@ import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import com.android.systemui.Flags.keyguardBottomAreaRefactor
-import com.android.systemui.res.R
import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.keyguard.ui.binder.KeyguardIndicationAreaBinder
import com.android.systemui.keyguard.ui.view.KeyguardIndicationArea
import com.android.systemui.keyguard.ui.viewmodel.KeyguardIndicationAreaViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel
+import com.android.systemui.res.R
import com.android.systemui.statusbar.KeyguardIndicationController
import javax.inject.Inject
import kotlinx.coroutines.DisposableHandle
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultStatusViewSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultStatusViewSection.kt
index 4abcca9d1151..851a45f31705 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultStatusViewSection.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultStatusViewSection.kt
@@ -53,7 +53,7 @@ constructor(
private val keyguardViewConfigurator: Lazy<KeyguardViewConfigurator>,
private val notificationPanelViewController: Lazy<NotificationPanelViewController>,
private val keyguardMediaController: KeyguardMediaController,
- private val splitShadeStateController: SplitShadeStateController
+ private val splitShadeStateController: SplitShadeStateController,
) : KeyguardSection() {
private val statusViewId = R.id.keyguard_status_view
@@ -76,6 +76,9 @@ constructor(
keyguardStatusView.findViewById<View>(R.id.left_aligned_notification_icon_container)?.let {
it.setVisibility(View.GONE)
}
+ // Should keep this even if flag, migrating clocks to blueprint, is on
+ // cause some events in clockEventController rely on keyguardStatusViewController
+ // TODO(b/313499340): clean up
constraintLayout.addView(keyguardStatusView)
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt
index 25931a654cd2..a005692c6dbf 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSection.kt
@@ -47,9 +47,9 @@ constructor(
val keyguardUnlockAnimationController: KeyguardUnlockAnimationController,
val featureFlags: FeatureFlagsClassic,
) : KeyguardSection() {
- var smartspaceView: View? = null
- var weatherView: View? = null
- var dateView: View? = null
+ private var smartspaceView: View? = null
+ private var weatherView: View? = null
+ private var dateView: View? = null
override fun addViews(constraintLayout: ConstraintLayout) {
if (!featureFlags.isEnabled(Flags.MIGRATE_CLOCKS_TO_BLUEPRINT)) {
@@ -65,16 +65,11 @@ constructor(
constraintLayout.addView(dateView)
}
}
-
keyguardUnlockAnimationController.lockscreenSmartspace = smartspaceView
}
override fun bindData(constraintLayout: ConstraintLayout) {
- KeyguardSmartspaceViewBinder.bind(
- this,
- constraintLayout,
- keyguardClockViewModel,
- )
+ KeyguardSmartspaceViewBinder.bind(this, constraintLayout, keyguardClockViewModel)
}
override fun applyConstraints(constraintSet: ConstraintSet) {
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModel.kt
index c54f47b48745..7ffa149d7dd9 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModel.kt
@@ -16,6 +16,7 @@
package com.android.systemui.keyguard.ui.viewmodel
+import androidx.constraintlayout.helper.widget.Layer
import com.android.keyguard.KeyguardClockSwitch.LARGE
import com.android.keyguard.KeyguardClockSwitch.SMALL
import com.android.systemui.dagger.SysUISingleton
@@ -29,7 +30,6 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.combine
-import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.stateIn
@SysUISingleton
@@ -40,19 +40,14 @@ constructor(
val keyguardClockInteractor: KeyguardClockInteractor,
@Application private val applicationScope: CoroutineScope,
) {
+ var burnInLayer: Layer? = null
val useLargeClock: Boolean
get() = clockSize.value == LARGE
- var clock: ClockController?
- set(value) {
- keyguardClockInteractor.clock = value
- }
- get() {
- return keyguardClockInteractor.clock
- }
+ var clock: ClockController? by keyguardClockInteractor::clock
val clockSize =
- combine(keyguardClockInteractor.selectedClockSize, keyguardInteractor.clockSize) {
+ combine(keyguardClockInteractor.selectedClockSize, keyguardClockInteractor.clockSize) {
selectedSize,
clockSize ->
if (selectedSize == SettingsClockSize.SMALL) {
@@ -61,7 +56,6 @@ constructor(
clockSize
}
}
- .distinctUntilChanged()
.stateIn(
scope = applicationScope,
started = SharingStarted.WhileSubscribed(),
@@ -72,16 +66,23 @@ constructor(
val hasCustomWeatherDataDisplay =
combine(clockSize, currentClock) { size, clock ->
- (if (size == LARGE) clock.largeClock.config.hasCustomWeatherDataDisplay
- else clock.smallClock.config.hasCustomWeatherDataDisplay)
+ clock?.let {
+ (if (size == LARGE) clock.largeClock.config.hasCustomWeatherDataDisplay
+ else clock.smallClock.config.hasCustomWeatherDataDisplay)
+ }
+ ?: false
}
- .distinctUntilChanged()
.stateIn(
scope = applicationScope,
started = SharingStarted.WhileSubscribed(),
- initialValue = false
+ initialValue = currentClock.value?.largeClock?.config?.hasCustomWeatherDataDisplay
+ ?: false
)
val clockShouldBeCentered: Flow<Boolean> =
- keyguardInteractor.clockShouldBeCentered.distinctUntilChanged()
+ keyguardInteractor.clockShouldBeCentered.stateIn(
+ scope = applicationScope,
+ started = SharingStarted.WhileSubscribed(),
+ initialValue = true
+ )
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt
index f63afebb60ab..af1705369dbb 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt
@@ -21,10 +21,13 @@ import android.content.Context
import android.util.MathUtils
import android.view.View.VISIBLE
import com.android.app.animation.Interpolators
+import com.android.keyguard.KeyguardClockSwitch.LARGE
import com.android.systemui.Flags.newAodTransition
import com.android.systemui.common.shared.model.NotificationContainerBounds
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor
+import com.android.systemui.flags.FeatureFlagsClassic
+import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.domain.interactor.BurnInInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
@@ -68,11 +71,21 @@ constructor(
private val keyguardTransitionInteractor: KeyguardTransitionInteractor,
private val notificationsKeyguardInteractor: NotificationsKeyguardInteractor,
private val burnInInteractor: BurnInInteractor,
+ private val keyguardClockViewModel: KeyguardClockViewModel,
private val goneToAodTransitionViewModel: GoneToAodTransitionViewModel,
private val aodToLockscreenTransitionViewModel: AodToLockscreenTransitionViewModel,
screenOffAnimationController: ScreenOffAnimationController,
+ // TODO(b/310989341): remove after changing migrate_clocks_to_blueprint to aconfig
+ private val featureFlags: FeatureFlagsClassic,
) {
var clockControllerProvider: Provider<ClockController>? = null
+ get() {
+ if (featureFlags.isEnabled(Flags.MIGRATE_CLOCKS_TO_BLUEPRINT)) {
+ return Provider { keyguardClockViewModel.clock }
+ } else {
+ return field
+ }
+ }
/** System insets that keyguard needs to stay out of */
var topInset: Int = 0
@@ -103,7 +116,8 @@ constructor(
return combine(dozingAmount, burnInInteractor.keyguardBurnIn) { dozeAmount, burnIn ->
val interpolation = Interpolators.FAST_OUT_SLOW_IN.getInterpolation(dozeAmount)
val useScaleOnly =
- clockControllerProvider?.get()?.config?.useAlternateSmartspaceAODTransition ?: false
+ (clockControllerProvider?.get()?.config?.useAlternateSmartspaceAODTransition
+ ?: false) && keyguardClockViewModel.clockSize.value == LARGE
if (useScaleOnly) {
BurnInModel(
translationX = 0,
@@ -113,7 +127,12 @@ constructor(
} else {
// Ensure the desired translation doesn't encroach on the top inset
val burnInY = MathUtils.lerp(0, burnIn.translationY, interpolation).toInt()
- val translationY = -(statusViewTop - Math.max(topInset, statusViewTop + burnInY))
+ val translationY =
+ if (featureFlags.isEnabled(Flags.MIGRATE_CLOCKS_TO_BLUEPRINT)) {
+ burnInY
+ } else {
+ -(statusViewTop - Math.max(topInset, statusViewTop + burnInY))
+ }
BurnInModel(
translationX = MathUtils.lerp(0, burnIn.translationX, interpolation).toInt(),
translationY = translationY,
@@ -194,7 +213,6 @@ constructor(
.distinctUntilChanged()
fun onNotificationContainerBoundsChanged(top: Float, bottom: Float) {
-
keyguardInteractor.setNotificationContainerBounds(NotificationContainerBounds(top, bottom))
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModel.kt
index 8e33651ced6a..4541458892bb 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardSmartspaceViewModel.kt
@@ -30,16 +30,21 @@ constructor(val context: Context, smartspaceController: LockscreenSmartspaceCont
val isWeatherEnabled: Boolean = smartspaceController.isWeatherEnabled()
val isDateWeatherDecoupled: Boolean = smartspaceController.isDateWeatherDecoupled()
val smartspaceViewId: Int
- get() {
- return context.resources
- .getIdentifier("bc_smartspace_view", "id", context.packageName)
- .also {
- if (it == 0) {
- Log.d(TAG, "Cannot resolve id bc_smartspace_view")
- }
- }
- }
+ get() = getId("bc_smartspace_view")
+
+ val dateId: Int
+ get() = getId("date_smartspace_view")
+
+ val weatherId: Int
+ get() = getId("weather_smartspace_view")
+ private fun getId(name: String): Int {
+ return context.resources.getIdentifier(name, "id", context.packageName).also {
+ if (it == 0) {
+ Log.d(TAG, "Cannot resolve id $name")
+ }
+ }
+ }
fun getDimen(name: String): Int {
val res = context.packageManager.getResourcesForApplication(context.packageName)
val id = res.getIdentifier(name, "dimen", context.packageName)
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
index 67ec03fc3d0a..30bfe2ab38e1 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
@@ -130,6 +130,7 @@ import com.android.systemui.fragments.FragmentService;
import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
import com.android.systemui.keyguard.KeyguardViewConfigurator;
import com.android.systemui.keyguard.domain.interactor.KeyguardBottomAreaInteractor;
+import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardFaceAuthInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor;
@@ -542,6 +543,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
private final NPVCDownEventState.Buffer mLastDownEvents;
private final KeyguardBottomAreaViewModel mKeyguardBottomAreaViewModel;
private final KeyguardBottomAreaInteractor mKeyguardBottomAreaInteractor;
+ private final KeyguardClockInteractor mKeyguardClockInteractor;
private float mMinExpandHeight;
private boolean mPanelUpdateWhenAnimatorEnds;
private boolean mHasVibratedOnOpen = false;
@@ -760,6 +762,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
SystemClock systemClock,
KeyguardBottomAreaViewModel keyguardBottomAreaViewModel,
KeyguardBottomAreaInteractor keyguardBottomAreaInteractor,
+ KeyguardClockInteractor keyguardClockInteractor,
AlternateBouncerInteractor alternateBouncerInteractor,
DreamingToLockscreenTransitionViewModel dreamingToLockscreenTransitionViewModel,
OccludedToLockscreenTransitionViewModel occludedToLockscreenTransitionViewModel,
@@ -964,6 +967,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
updateUserSwitcherFlags();
mKeyguardBottomAreaViewModel = keyguardBottomAreaViewModel;
mKeyguardBottomAreaInteractor = keyguardBottomAreaInteractor;
+ mKeyguardClockInteractor = keyguardClockInteractor;
KeyguardLongPressViewBinder.bind(
mView.requireViewById(R.id.keyguard_long_press),
keyguardLongPressViewModel,
@@ -1610,7 +1614,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
boolean bypassEnabled = mKeyguardBypassController.getBypassEnabled();
boolean shouldAnimateClockChange = mScreenOffAnimationController.shouldAnimateClockChange();
if (mFeatureFlags.isEnabled(Flags.MIGRATE_CLOCKS_TO_BLUEPRINT)) {
- mKeyguardInteractor.setClockSize(computeDesiredClockSize());
+ mKeyguardClockInteractor.setClockSize(computeDesiredClockSize());
} else {
mKeyguardStatusViewController.displayClock(computeDesiredClockSize(),
shouldAnimateClockChange);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepositoryTest.kt
index bc40c2ddb407..d75cbec8c542 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepositoryTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepositoryTest.kt
@@ -18,6 +18,7 @@ package com.android.systemui.keyguard.data.repository
import android.provider.Settings
import androidx.test.filters.SmallTest
+import com.android.keyguard.ClockEventController
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyguard.shared.model.SettingsClockSize
@@ -47,6 +48,7 @@ class KeyguardClockRepositoryTest : SysuiTestCase() {
private lateinit var underTest: KeyguardClockRepository
private lateinit var fakeSettings: FakeSettings
@Mock private lateinit var clockRegistry: ClockRegistry
+ @Mock private lateinit var clockEventController: ClockEventController
@Before
fun setup() {
@@ -55,7 +57,14 @@ class KeyguardClockRepositoryTest : SysuiTestCase() {
scheduler = TestCoroutineScheduler()
dispatcher = StandardTestDispatcher(scheduler)
scope = TestScope(dispatcher)
- underTest = KeyguardClockRepository(fakeSettings, clockRegistry, dispatcher)
+ underTest =
+ KeyguardClockRepositoryImpl(
+ fakeSettings,
+ clockRegistry,
+ clockEventController,
+ dispatcher,
+ scope.backgroundScope
+ )
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinderTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinderTest.kt
new file mode 100644
index 000000000000..0981c6239cb9
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinderTest.kt
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.keyguard.ui.binder
+
+import android.view.View
+import androidx.constraintlayout.helper.widget.Layer
+import androidx.constraintlayout.widget.ConstraintLayout
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.plugins.ClockConfig
+import com.android.systemui.plugins.ClockController
+import com.android.systemui.plugins.ClockFaceController
+import com.android.systemui.plugins.ClockFaceLayout
+import com.android.systemui.util.mockito.whenever
+import kotlin.test.Test
+import org.junit.Before
+import org.junit.runner.RunWith
+import org.mockito.Mock
+import org.mockito.Mockito.never
+import org.mockito.Mockito.verify
+import org.mockito.MockitoAnnotations
+
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+@kotlinx.coroutines.ExperimentalCoroutinesApi
+class KeyguardClockViewBinderTest : SysuiTestCase() {
+ @Mock private lateinit var rootView: ConstraintLayout
+ @Mock private lateinit var burnInLayer: Layer
+ @Mock private lateinit var clock: ClockController
+ @Mock private lateinit var largeClock: ClockFaceController
+ @Mock private lateinit var smallClock: ClockFaceController
+ @Mock private lateinit var largeClockView: View
+ @Mock private lateinit var smallClockView: View
+ @Mock private lateinit var smallClockFaceLayout: ClockFaceLayout
+ @Mock private lateinit var largeClockFaceLayout: ClockFaceLayout
+
+ @Before
+ fun setup() {
+ MockitoAnnotations.initMocks(this)
+ }
+
+ @Test
+ fun addClockViews_nonWeatherClock() {
+ setupNonWeatherClock()
+ KeyguardClockViewBinder.addClockViews(clock, rootView, burnInLayer)
+ verify(rootView).addView(smallClockView)
+ verify(rootView).addView(largeClockView)
+ verify(burnInLayer).addView(smallClockView)
+ verify(burnInLayer, never()).addView(largeClockView)
+ }
+
+ @Test
+ fun addClockViews_WeatherClock() {
+ setupWeatherClock()
+ KeyguardClockViewBinder.addClockViews(clock, rootView, burnInLayer)
+ verify(rootView).addView(smallClockView)
+ verify(rootView).addView(largeClockView)
+ verify(burnInLayer).addView(smallClockView)
+ verify(burnInLayer).addView(largeClockView)
+ }
+
+ private fun setupWeatherClock() {
+ setupClock()
+ val clockConfig =
+ ClockConfig(
+ id = "WEATHER_CLOCK",
+ name = "",
+ description = "",
+ useAlternateSmartspaceAODTransition = true
+ )
+ whenever(clock.config).thenReturn(clockConfig)
+ }
+
+ private fun setupNonWeatherClock() {
+ setupClock()
+ val clockConfig = ClockConfig(id = "NON_WEATHER_CLOCK", name = "", description = "")
+ whenever(clock.config).thenReturn(clockConfig)
+ }
+
+ private fun setupClock() {
+ whenever(largeClockFaceLayout.views).thenReturn(listOf(largeClockView))
+ whenever(smallClockFaceLayout.views).thenReturn(listOf(smallClockView))
+ whenever(clock.largeClock).thenReturn(largeClock)
+ whenever(clock.smallClock).thenReturn(smallClock)
+ whenever(largeClock.layout).thenReturn(largeClockFaceLayout)
+ whenever(smallClock.layout).thenReturn(smallClockFaceLayout)
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprintTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprintTest.kt
index 740fce988a68..3109e761e423 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprintTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprintTest.kt
@@ -27,9 +27,9 @@ import com.android.systemui.communal.ui.view.layout.sections.CommunalTutorialInd
import com.android.systemui.keyguard.shared.model.KeyguardBlueprint
import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.keyguard.ui.view.KeyguardRootView
-import com.android.systemui.keyguard.ui.view.layout.items.ClockSection
import com.android.systemui.keyguard.ui.view.layout.sections.AodBurnInSection
import com.android.systemui.keyguard.ui.view.layout.sections.AodNotificationIconsSection
+import com.android.systemui.keyguard.ui.view.layout.sections.ClockSection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultDeviceEntrySection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultIndicationAreaSection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultNotificationStackScrollLayoutSection
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt
index 6b85cf719ef5..64a07fa9f723 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSectionTest.kt
@@ -22,9 +22,7 @@ import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.flags.FakeFeatureFlagsClassic
import com.android.systemui.flags.Flags.MIGRATE_CLOCKS_TO_BLUEPRINT
-import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
-import com.android.systemui.keyguard.ui.view.layout.items.ClockSection
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.res.R
@@ -32,7 +30,6 @@ import com.android.systemui.statusbar.policy.SplitShadeStateController
import com.android.systemui.util.Utils
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
-import dagger.Lazy
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -47,7 +44,6 @@ class ClockSectionTest : SysuiTestCase() {
@Mock private lateinit var keyguardClockViewModel: KeyguardClockViewModel
@Mock private lateinit var smartspaceViewModel: KeyguardSmartspaceViewModel
@Mock private lateinit var splitShadeStateController: SplitShadeStateController
- @Mock private lateinit var keyguardBlueprintInteractor: Lazy<KeyguardBlueprintInteractor>
private var featureFlags: FakeFeatureFlagsClassic = FakeFeatureFlagsClassic()
private lateinit var underTest: ClockSection
@@ -94,7 +90,6 @@ class ClockSectionTest : SysuiTestCase() {
smartspaceViewModel,
mContext,
splitShadeStateController,
- keyguardBlueprintInteractor,
featureFlags
)
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt
index 46a7735d92a0..f067871aa0e1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelTest.kt
@@ -25,11 +25,16 @@ import com.android.keyguard.KeyguardClockSwitch.SMALL
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyguard.data.repository.KeyguardClockRepository
+import com.android.systemui.keyguard.data.repository.KeyguardClockRepositoryImpl
import com.android.systemui.keyguard.data.repository.KeyguardRepository
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory
+import com.android.systemui.plugins.ClockController
+import com.android.systemui.plugins.ClockFaceConfig
+import com.android.systemui.plugins.ClockFaceController
import com.android.systemui.shared.clocks.ClockRegistry
+import com.android.systemui.util.mockito.whenever
import com.android.systemui.util.settings.FakeSettings
import com.google.common.truth.Truth.assertThat
import kotlin.test.Test
@@ -50,7 +55,6 @@ class KeyguardClockViewModelTest : SysuiTestCase() {
private lateinit var scheduler: TestCoroutineScheduler
private lateinit var dispatcher: CoroutineDispatcher
private lateinit var scope: TestScope
-
private lateinit var underTest: KeyguardClockViewModel
private lateinit var keyguardInteractor: KeyguardInteractor
private lateinit var keyguardRepository: KeyguardRepository
@@ -58,6 +62,9 @@ class KeyguardClockViewModelTest : SysuiTestCase() {
private lateinit var keyguardClockRepository: KeyguardClockRepository
private lateinit var fakeSettings: FakeSettings
@Mock private lateinit var clockRegistry: ClockRegistry
+ @Mock private lateinit var clock: ClockController
+ @Mock private lateinit var largeClock: ClockFaceController
+ @Mock private lateinit var clockFaceConfig: ClockFaceConfig
@Mock private lateinit var eventController: ClockEventController
@Before
fun setup() {
@@ -70,13 +77,21 @@ class KeyguardClockViewModelTest : SysuiTestCase() {
scheduler = TestCoroutineScheduler()
dispatcher = StandardTestDispatcher(scheduler)
scope = TestScope(dispatcher)
- keyguardClockRepository = KeyguardClockRepository(fakeSettings, clockRegistry, dispatcher)
- keyguardClockInteractor = KeyguardClockInteractor(eventController, keyguardClockRepository)
+ setupMockClock()
+ keyguardClockRepository =
+ KeyguardClockRepositoryImpl(
+ fakeSettings,
+ clockRegistry,
+ eventController,
+ dispatcher,
+ scope.backgroundScope
+ )
+ keyguardClockInteractor = KeyguardClockInteractor(keyguardClockRepository)
underTest =
KeyguardClockViewModel(
keyguardInteractor,
keyguardClockInteractor,
- scope.backgroundScope
+ scope.backgroundScope,
)
}
@@ -86,7 +101,7 @@ class KeyguardClockViewModelTest : SysuiTestCase() {
// When use double line clock is disabled,
// should always return small
fakeSettings.putInt(LOCKSCREEN_USE_DOUBLE_LINE_CLOCK, 0)
- keyguardRepository.setClockSize(LARGE)
+ keyguardClockRepository.setClockSize(LARGE)
val value = collectLastValue(underTest.clockSize)
assertThat(value()).isEqualTo(SMALL)
}
@@ -95,12 +110,19 @@ class KeyguardClockViewModelTest : SysuiTestCase() {
fun testClockSize_dynamicClockSize() =
scope.runTest {
fakeSettings.putInt(LOCKSCREEN_USE_DOUBLE_LINE_CLOCK, 1)
- keyguardRepository.setClockSize(SMALL)
+ keyguardClockRepository.setClockSize(SMALL)
var value = collectLastValue(underTest.clockSize)
assertThat(value()).isEqualTo(SMALL)
- keyguardRepository.setClockSize(LARGE)
+ keyguardClockRepository.setClockSize(LARGE)
value = collectLastValue(underTest.clockSize)
assertThat(value()).isEqualTo(LARGE)
}
+
+ private fun setupMockClock() {
+ whenever(clock.largeClock).thenReturn(largeClock)
+ whenever(largeClock.config).thenReturn(clockFaceConfig)
+ whenever(clockFaceConfig.hasCustomWeatherDataDisplay).thenReturn(false)
+ whenever(clockRegistry.createCurrentClock()).thenReturn(clock)
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt
index a57feda64723..bc60364f27cb 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt
@@ -21,6 +21,7 @@ package com.android.systemui.keyguard.ui.viewmodel
import android.view.View
import androidx.test.filters.SmallTest
+import com.android.keyguard.KeyguardClockSwitch.LARGE
import com.android.systemui.Flags as AConfigFlags
import com.android.systemui.Flags.FLAG_NEW_AOD_TRANSITION
import com.android.systemui.SysUITestComponent
@@ -32,7 +33,9 @@ import com.android.systemui.common.ui.data.repository.FakeConfigurationRepositor
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.deviceentry.data.repository.FakeDeviceEntryRepository
+import com.android.systemui.flags.FakeFeatureFlagsClassic
import com.android.systemui.flags.FakeFeatureFlagsClassicModule
+import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository
import com.android.systemui.keyguard.domain.interactor.BurnInInteractor
@@ -79,13 +82,13 @@ import org.mockito.MockitoAnnotations
@SmallTest
@RunWith(JUnit4::class)
class KeyguardRootViewModelTest : SysuiTestCase() {
-
private lateinit var underTest: KeyguardRootViewModel
private lateinit var testScope: TestScope
private lateinit var repository: FakeKeyguardRepository
private lateinit var keyguardInteractor: KeyguardInteractor
private lateinit var configurationRepository: FakeConfigurationRepository
@Mock private lateinit var burnInInteractor: BurnInInteractor
+ @Mock private lateinit var keyguardClockViewModel: KeyguardClockViewModel
@Mock private lateinit var keyguardTransitionInteractor: KeyguardTransitionInteractor
@Mock private lateinit var goneToAodTransitionViewModel: GoneToAodTransitionViewModel
@Mock
@@ -97,7 +100,9 @@ class KeyguardRootViewModelTest : SysuiTestCase() {
private val enterFromTopAnimationAlpha = MutableStateFlow(0f)
private val goneToAodTransitionStep = MutableSharedFlow<TransitionStep>(replay = 1)
private val dozeAmountTransitionStep = MutableSharedFlow<TransitionStep>(replay = 1)
+ private val clockSize = MutableStateFlow(LARGE)
private val startedKeyguardState = MutableStateFlow(KeyguardState.GONE)
+ private val featureFlags: FakeFeatureFlagsClassic = FakeFeatureFlagsClassic()
@Before
fun setUp() {
@@ -107,7 +112,9 @@ class KeyguardRootViewModelTest : SysuiTestCase() {
mSetFlagsRule.enableFlags(AConfigFlags.FLAG_KEYGUARD_BOTTOM_AREA_REFACTOR)
- val withDeps = KeyguardInteractorFactory.create()
+ featureFlags.set(Flags.MIGRATE_CLOCKS_TO_BLUEPRINT, false)
+
+ val withDeps = KeyguardInteractorFactory.create(featureFlags = featureFlags)
keyguardInteractor = withDeps.keyguardInteractor
repository = withDeps.repository
configurationRepository = withDeps.configurationRepository
@@ -124,6 +131,7 @@ class KeyguardRootViewModelTest : SysuiTestCase() {
whenever(keyguardTransitionInteractor.dozeAmountTransition)
.thenReturn(dozeAmountTransitionStep)
whenever(keyguardTransitionInteractor.startedKeyguardState).thenReturn(startedKeyguardState)
+ whenever(keyguardClockViewModel.clockSize).thenReturn(clockSize)
underTest =
KeyguardRootViewModel(
@@ -139,9 +147,12 @@ class KeyguardRootViewModelTest : SysuiTestCase() {
whenever(isPulseExpanding).thenReturn(emptyFlow())
},
burnInInteractor,
+ keyguardClockViewModel,
goneToAodTransitionViewModel,
aodToLockscreenTransitionViewModel,
screenOffAnimationController = mock(),
+ // TODO(b/310989341): remove after change to aconfig
+ featureFlags
)
underTest.clockControllerProvider = Provider { clockController }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
index 03878b7bcf45..97378c3cc5a9 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
@@ -96,6 +96,7 @@ import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
import com.android.systemui.keyguard.KeyguardViewConfigurator;
import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository;
import com.android.systemui.keyguard.domain.interactor.KeyguardBottomAreaInteractor;
+import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardFaceAuthInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory;
@@ -343,6 +344,7 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase {
protected final int mMaxUdfpsBurnInOffsetY = 5;
protected FakeFeatureFlagsClassic mFeatureFlags = new FakeFeatureFlagsClassic();
protected KeyguardBottomAreaInteractor mKeyguardBottomAreaInteractor;
+ protected KeyguardClockInteractor mKeyguardClockInteractor;
protected FakeKeyguardRepository mFakeKeyguardRepository;
protected KeyguardInteractor mKeyguardInteractor;
protected SceneTestUtils mUtils = new SceneTestUtils(this);
@@ -696,6 +698,7 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase {
systemClock,
mKeyguardBottomAreaViewModel,
mKeyguardBottomAreaInteractor,
+ mKeyguardClockInteractor,
mAlternateBouncerInteractor,
mDreamingToLockscreenTransitionViewModel,
mOccludedToLockscreenTransitionViewModel,
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/FakeKeyguardDataLayerModule.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/FakeKeyguardDataLayerModule.kt
index 6838e7676a23..abbd9be66b17 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/FakeKeyguardDataLayerModule.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/FakeKeyguardDataLayerModule.kt
@@ -16,6 +16,7 @@
package com.android.systemui.keyguard.data
import com.android.systemui.keyguard.data.repository.FakeCommandQueueModule
+import com.android.systemui.keyguard.data.repository.FakeKeyguardClockRepositoryModule
import com.android.systemui.keyguard.data.repository.FakeKeyguardRepositoryModule
import com.android.systemui.keyguard.data.repository.FakeKeyguardSurfaceBehindRepositoryModule
import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepositoryModule
@@ -28,6 +29,7 @@ import dagger.Module
FakeKeyguardRepositoryModule::class,
FakeKeyguardTransitionRepositoryModule::class,
FakeKeyguardSurfaceBehindRepositoryModule::class,
+ FakeKeyguardClockRepositoryModule::class,
]
)
object FakeKeyguardDataLayerModule
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardClockRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardClockRepository.kt
new file mode 100644
index 000000000000..21936c36179c
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardClockRepository.kt
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.keyguard.data.repository
+
+import com.android.keyguard.ClockEventController
+import com.android.keyguard.KeyguardClockSwitch.ClockSize
+import com.android.keyguard.KeyguardClockSwitch.LARGE
+import com.android.systemui.keyguard.shared.model.SettingsClockSize
+import com.android.systemui.plugins.ClockId
+import com.android.systemui.shared.clocks.DEFAULT_CLOCK_ID
+import com.android.systemui.util.mockito.mock
+import dagger.Binds
+import dagger.Module
+import javax.inject.Inject
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+
+class FakeKeyguardClockRepository @Inject constructor() : KeyguardClockRepository {
+ private val _clockSize = MutableStateFlow(LARGE)
+ override val clockSize: StateFlow<Int> = _clockSize
+
+ private val _selectedClockSize = MutableStateFlow(SettingsClockSize.DYNAMIC)
+ override val selectedClockSize = _selectedClockSize
+
+ private val _currentClockId = MutableStateFlow(DEFAULT_CLOCK_ID)
+ override val currentClockId: Flow<ClockId> = _currentClockId
+
+ private val _currentClock = MutableStateFlow(null)
+ override val currentClock = _currentClock
+ override val clockEventController: ClockEventController
+ get() = mock()
+
+ override fun setClockSize(@ClockSize size: Int) {
+ _clockSize.value = size
+ }
+}
+
+@Module
+interface FakeKeyguardClockRepositoryModule {
+ @Binds fun bindFake(fake: FakeKeyguardClockRepository): KeyguardClockRepository
+}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt
index 4068e408f0bd..75fe37eddd70 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt
@@ -18,7 +18,6 @@
package com.android.systemui.keyguard.data.repository
import android.graphics.Point
-import com.android.keyguard.KeyguardClockSwitch.LARGE
import com.android.systemui.common.shared.model.Position
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.shared.model.BiometricUnlockModel
@@ -42,8 +41,6 @@ import kotlinx.coroutines.flow.asStateFlow
class FakeKeyguardRepository @Inject constructor() : KeyguardRepository {
private val _deferKeyguardDone: MutableSharedFlow<KeyguardDone> = MutableSharedFlow()
override val keyguardDone: Flow<KeyguardDone> = _deferKeyguardDone
- private val _clockSize = MutableStateFlow<Int>(LARGE)
- override val clockSize: Flow<Int> = _clockSize
private val _clockShouldBeCentered = MutableStateFlow<Boolean>(true)
override val clockShouldBeCentered: Flow<Boolean> = _clockShouldBeCentered
@@ -187,10 +184,6 @@ class FakeKeyguardRepository @Inject constructor() : KeyguardRepository {
_deferKeyguardDone.emit(timing)
}
- override fun setClockSize(size: Int) {
- _clockSize.value = size
- }
-
override fun setClockShouldBeCentered(shouldBeCentered: Boolean) {
_clockShouldBeCentered.value = shouldBeCentered
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepositoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepositoryKosmos.kt
new file mode 100644
index 000000000000..e6716ba32cda
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/KeyguardClockRepositoryKosmos.kt
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.keyguard.data.repository
+
+import com.android.systemui.kosmos.Kosmos
+
+val Kosmos.keyguardClockRepository: KeyguardClockRepository by
+ Kosmos.Fixture { fakeKeyguardClockRepository }
+val Kosmos.fakeKeyguardClockRepository by Kosmos.Fixture { FakeKeyguardClockRepository() }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractorKosmos.kt
new file mode 100644
index 000000000000..d791e949f853
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractorKosmos.kt
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.keyguard.domain.interactor
+
+import com.android.systemui.keyguard.data.repository.keyguardClockRepository
+import com.android.systemui.kosmos.Kosmos
+
+val Kosmos.keyguardClockInteractor by
+ Kosmos.Fixture { KeyguardClockInteractor(keyguardClockRepository = keyguardClockRepository) }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelKosmos.kt
new file mode 100644
index 000000000000..d8786830f536
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardClockViewModelKosmos.kt
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.keyguard.ui.viewmodel
+
+import com.android.systemui.keyguard.domain.interactor.keyguardClockInteractor
+import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
+import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.applicationCoroutineScope
+
+val Kosmos.keyguardClockViewModel by
+ Kosmos.Fixture {
+ KeyguardClockViewModel(
+ keyguardInteractor = keyguardInteractor,
+ keyguardClockInteractor = keyguardClockInteractor,
+ applicationScope = applicationCoroutineScope,
+ )
+ }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelKosmos.kt
index 663b8450e690..4f807e3ddb64 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelKosmos.kt
@@ -20,6 +20,7 @@ package com.android.systemui.keyguard.ui.viewmodel
import android.content.applicationContext
import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor
+import com.android.systemui.flags.FakeFeatureFlagsClassic
import com.android.systemui.keyguard.domain.interactor.burnInInteractor
import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor
@@ -42,5 +43,7 @@ val Kosmos.keyguardRootViewModel by Fixture {
goneToAodTransitionViewModel = goneToAodTransitionViewModel,
aodToLockscreenTransitionViewModel = aodToLockscreenTransitionViewModel,
screenOffAnimationController = screenOffAnimationController,
+ keyguardClockViewModel = keyguardClockViewModel,
+ featureFlags = FakeFeatureFlagsClassic(),
)
}