Merge "Select the default clock if current clock id was not found" into udc-qpr-dev am: 6bcdc99328

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/ThemePicker/+/24443680

Change-Id: I2563871ad3b791b38638139a36936ef5a2923a10
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/customization/picker/clock/data/repository/ClockPickerRepositoryImpl.kt b/src/com/android/customization/picker/clock/data/repository/ClockPickerRepositoryImpl.kt
index aeed45e..004103f 100644
--- a/src/com/android/customization/picker/clock/data/repository/ClockPickerRepositoryImpl.kt
+++ b/src/com/android/customization/picker/clock/data/repository/ClockPickerRepositoryImpl.kt
@@ -53,11 +53,12 @@
     override val allClocks: Flow<List<ClockMetadataModel>> =
         callbackFlow {
                 fun send() {
+                    val activeClockId = registry.activeClockId
                     val allClocks =
-                        registry
-                            .getClocks()
-                            .filter { "NOT_IN_USE" !in it.clockId }
-                            .map { it.toModel(isSelected = it.clockId == registry.currentClockId) }
+                        registry.getClocks().map {
+                            it.toModel(isSelected = it.clockId == activeClockId)
+                        }
+
                     trySend(allClocks)
                 }
 
@@ -84,12 +85,12 @@
     override val selectedClock: Flow<ClockMetadataModel> =
         callbackFlow {
                 fun send() {
-                    val currentClockId = registry.currentClockId
+                    val activeClockId = registry.activeClockId
                     val metadata = registry.settings?.metadata
                     val model =
                         registry
                             .getClocks()
-                            .find { clockMetadata -> clockMetadata.clockId == currentClockId }
+                            .find { clockMetadata -> clockMetadata.clockId == activeClockId }
                             ?.toModel(
                                 isSelected = true,
                                 selectedColorId = metadata?.getSelectedColorId(),