Loading packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ClockRegistry.kt +5 −2 Original line number Diff line number Diff line Loading @@ -173,8 +173,10 @@ open class ClockRegistry( { "Skipping initial load of known clock package package: $str1" } ) var isCurrentClock = false var isClockListChanged = false for (metadata in knownClocks) { isCurrentClock = isCurrentClock || currentClockId == metadata.clockId val id = metadata.clockId val info = availableClocks.concurrentGetOrPut(id, ClockInfo(metadata, null, manager)) { Loading Loading @@ -207,8 +209,9 @@ open class ClockRegistry( } verifyLoadedProviders() // Load executed via verifyLoadedProviders return false // Load immediately if it's the current clock, otherwise let verifyLoadedProviders // load and unload clocks as necessary on the background thread. return isCurrentClock } override fun onPluginLoaded( Loading packages/SystemUI/tests/src/com/android/systemui/shared/clocks/ClockRegistryTest.kt +16 −7 Original line number Diff line number Diff line Loading @@ -381,12 +381,15 @@ class ClockRegistryTest : SysuiTestCase() { } @Test fun knownPluginAttached_clockAndListChanged_notLoaded() { val lifecycle1 = FakeLifecycle("Metro", null).apply { mComponentName = ComponentName("com.android.systemui.clocks.metro", "MetroClock") fun knownPluginAttached_clockAndListChanged_loadedCurrent() { val metroLifecycle = FakeLifecycle("Metro", null).apply { mComponentName = ComponentName("com.android.systemui.clocks.metro", "Metro") } val lifecycle2 = FakeLifecycle("BigNum", null).apply { mComponentName = ComponentName("com.android.systemui.clocks.bignum", "BigNumClock") val bignumLifecycle = FakeLifecycle("BigNum", null).apply { mComponentName = ComponentName("com.android.systemui.clocks.bignum", "BigNum") } val calligraphyLifecycle = FakeLifecycle("Calligraphy", null).apply { mComponentName = ComponentName("com.android.systemui.clocks.calligraphy", "Calligraphy") } var changeCallCount = 0 Loading @@ -401,15 +404,21 @@ class ClockRegistryTest : SysuiTestCase() { assertEquals(1, changeCallCount) assertEquals(0, listChangeCallCount) assertEquals(false, pluginListener.onPluginAttached(lifecycle1)) assertEquals(false, pluginListener.onPluginAttached(metroLifecycle)) scheduler.runCurrent() assertEquals(1, changeCallCount) assertEquals(1, listChangeCallCount) assertEquals(false, pluginListener.onPluginAttached(lifecycle2)) assertEquals(false, pluginListener.onPluginAttached(bignumLifecycle)) scheduler.runCurrent() assertEquals(1, changeCallCount) assertEquals(2, listChangeCallCount) // This returns true, but doesn't trigger onCurrentClockChanged yet assertEquals(true, pluginListener.onPluginAttached(calligraphyLifecycle)) scheduler.runCurrent() assertEquals(1, changeCallCount) assertEquals(3, listChangeCallCount) } @Test Loading Loading
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/ClockRegistry.kt +5 −2 Original line number Diff line number Diff line Loading @@ -173,8 +173,10 @@ open class ClockRegistry( { "Skipping initial load of known clock package package: $str1" } ) var isCurrentClock = false var isClockListChanged = false for (metadata in knownClocks) { isCurrentClock = isCurrentClock || currentClockId == metadata.clockId val id = metadata.clockId val info = availableClocks.concurrentGetOrPut(id, ClockInfo(metadata, null, manager)) { Loading Loading @@ -207,8 +209,9 @@ open class ClockRegistry( } verifyLoadedProviders() // Load executed via verifyLoadedProviders return false // Load immediately if it's the current clock, otherwise let verifyLoadedProviders // load and unload clocks as necessary on the background thread. return isCurrentClock } override fun onPluginLoaded( Loading
packages/SystemUI/tests/src/com/android/systemui/shared/clocks/ClockRegistryTest.kt +16 −7 Original line number Diff line number Diff line Loading @@ -381,12 +381,15 @@ class ClockRegistryTest : SysuiTestCase() { } @Test fun knownPluginAttached_clockAndListChanged_notLoaded() { val lifecycle1 = FakeLifecycle("Metro", null).apply { mComponentName = ComponentName("com.android.systemui.clocks.metro", "MetroClock") fun knownPluginAttached_clockAndListChanged_loadedCurrent() { val metroLifecycle = FakeLifecycle("Metro", null).apply { mComponentName = ComponentName("com.android.systemui.clocks.metro", "Metro") } val lifecycle2 = FakeLifecycle("BigNum", null).apply { mComponentName = ComponentName("com.android.systemui.clocks.bignum", "BigNumClock") val bignumLifecycle = FakeLifecycle("BigNum", null).apply { mComponentName = ComponentName("com.android.systemui.clocks.bignum", "BigNum") } val calligraphyLifecycle = FakeLifecycle("Calligraphy", null).apply { mComponentName = ComponentName("com.android.systemui.clocks.calligraphy", "Calligraphy") } var changeCallCount = 0 Loading @@ -401,15 +404,21 @@ class ClockRegistryTest : SysuiTestCase() { assertEquals(1, changeCallCount) assertEquals(0, listChangeCallCount) assertEquals(false, pluginListener.onPluginAttached(lifecycle1)) assertEquals(false, pluginListener.onPluginAttached(metroLifecycle)) scheduler.runCurrent() assertEquals(1, changeCallCount) assertEquals(1, listChangeCallCount) assertEquals(false, pluginListener.onPluginAttached(lifecycle2)) assertEquals(false, pluginListener.onPluginAttached(bignumLifecycle)) scheduler.runCurrent() assertEquals(1, changeCallCount) assertEquals(2, listChangeCallCount) // This returns true, but doesn't trigger onCurrentClockChanged yet assertEquals(true, pluginListener.onPluginAttached(calligraphyLifecycle)) scheduler.runCurrent() assertEquals(1, changeCallCount) assertEquals(3, listChangeCallCount) } @Test Loading