Loading packages/SystemUI/shared/src/com/android/systemui/shared/clocks/ClockRegistry.kt +15 −2 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ open class ClockRegistry( fun onClockChanged() } var isEnabled: Boolean = false private val gson = Gson() private val availableClocks = mutableMapOf<ClockId, ClockInfo>() private val clockChangeListeners = mutableListOf<ClockChangeListener>() Loading Loading @@ -88,6 +90,12 @@ open class ClockRegistry( init { connectClocks(defaultClockProvider) if (!availableClocks.containsKey(DEFAULT_CLOCK_ID)) { throw IllegalArgumentException( "$defaultClockProvider did not register clock at $DEFAULT_CLOCK_ID" ) } pluginManager.addPluginListener(pluginListener, ClockProviderPlugin::class.java) context.contentResolver.registerContentObserver( Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE), Loading Loading @@ -133,7 +141,12 @@ open class ClockRegistry( } } fun getClocks(): List<ClockMetadata> = availableClocks.map { (_, clock) -> clock.metadata } fun getClocks(): List<ClockMetadata> { if (!isEnabled) { return listOf(availableClocks[DEFAULT_CLOCK_ID]!!.metadata) } return availableClocks.map { (_, clock) -> clock.metadata } } fun getClockThumbnail(clockId: ClockId): Drawable? = availableClocks[clockId]?.provider?.getClockThumbnail(clockId) Loading @@ -148,7 +161,7 @@ open class ClockRegistry( fun createCurrentClock(): Clock { val clockId = currentClockId if (!clockId.isNullOrEmpty()) { if (isEnabled && clockId.isNotEmpty()) { val clock = createClock(clockId) if (clock != null) { return clock Loading packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +5 −1 Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ import com.android.systemui.Dumpable; import com.android.systemui.R; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.flags.Flags; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.plugins.Clock; import com.android.systemui.plugins.statusbar.StatusBarStateController; Loading Loading @@ -118,7 +120,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS SecureSettings secureSettings, @Main Executor uiExecutor, DumpManager dumpManager, ClockEventController clockEventController) { ClockEventController clockEventController, FeatureFlags featureFlags) { super(keyguardClockSwitch); mStatusBarStateController = statusBarStateController; mClockRegistry = clockRegistry; Loading @@ -131,6 +134,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mDumpManager = dumpManager; mClockEventController = clockEventController; mClockRegistry.setEnabled(featureFlags.isEnabled(Flags.LOCKSCREEN_CUSTOM_CLOCKS)); mClockChangedListener = () -> { setClock(mClockRegistry.createCurrentClock()); }; Loading packages/SystemUI/src/com/android/systemui/flags/Flags.java +3 −0 Original line number Diff line number Diff line Loading @@ -81,12 +81,15 @@ public class Flags { public static final ResourceBooleanFlag FACE_SCANNING_ANIM = new ResourceBooleanFlag(205, R.bool.config_enableFaceScanningAnimation); /** * Whether the KeyguardBottomArea(View|Controller) should use the modern architecture or the old * one. */ public static final BooleanFlag MODERN_BOTTOM_AREA = new BooleanFlag(206, false); public static final BooleanFlag LOCKSCREEN_CUSTOM_CLOCKS = new BooleanFlag(207, false); /***************************************/ // 300 - power menu public static final BooleanFlag POWER_MENU_LITE = Loading packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java +5 −1 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import androidx.test.filters.SmallTest; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.plugins.Clock; import com.android.systemui.plugins.statusbar.StatusBarStateController; Loading Loading @@ -102,6 +103,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { private FrameLayout mLargeClockFrame; @Mock private SecureSettings mSecureSettings; @Mock private FeatureFlags mFeatureFlags; private final View mFakeSmartspaceView = new View(mContext); Loading Loading @@ -138,7 +141,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { mSecureSettings, mExecutor, mDumpManager, mClockEventController mClockEventController, mFeatureFlags ); when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE); Loading packages/SystemUI/tests/src/com/android/systemui/shared/clocks/ClockRegistryTest.kt +1 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,7 @@ class ClockRegistryTest : SysuiTestCase() { get() = settingValue set(value) { settingValue = value } } registry.isEnabled = true verify(mockPluginManager) .addPluginListener(captor.capture(), eq(ClockProviderPlugin::class.java)) Loading Loading
packages/SystemUI/shared/src/com/android/systemui/shared/clocks/ClockRegistry.kt +15 −2 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ open class ClockRegistry( fun onClockChanged() } var isEnabled: Boolean = false private val gson = Gson() private val availableClocks = mutableMapOf<ClockId, ClockInfo>() private val clockChangeListeners = mutableListOf<ClockChangeListener>() Loading Loading @@ -88,6 +90,12 @@ open class ClockRegistry( init { connectClocks(defaultClockProvider) if (!availableClocks.containsKey(DEFAULT_CLOCK_ID)) { throw IllegalArgumentException( "$defaultClockProvider did not register clock at $DEFAULT_CLOCK_ID" ) } pluginManager.addPluginListener(pluginListener, ClockProviderPlugin::class.java) context.contentResolver.registerContentObserver( Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE), Loading Loading @@ -133,7 +141,12 @@ open class ClockRegistry( } } fun getClocks(): List<ClockMetadata> = availableClocks.map { (_, clock) -> clock.metadata } fun getClocks(): List<ClockMetadata> { if (!isEnabled) { return listOf(availableClocks[DEFAULT_CLOCK_ID]!!.metadata) } return availableClocks.map { (_, clock) -> clock.metadata } } fun getClockThumbnail(clockId: ClockId): Drawable? = availableClocks[clockId]?.provider?.getClockThumbnail(clockId) Loading @@ -148,7 +161,7 @@ open class ClockRegistry( fun createCurrentClock(): Clock { val clockId = currentClockId if (!clockId.isNullOrEmpty()) { if (isEnabled && clockId.isNotEmpty()) { val clock = createClock(clockId) if (clock != null) { return clock Loading
packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +5 −1 Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ import com.android.systemui.Dumpable; import com.android.systemui.R; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.flags.Flags; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.plugins.Clock; import com.android.systemui.plugins.statusbar.StatusBarStateController; Loading Loading @@ -118,7 +120,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS SecureSettings secureSettings, @Main Executor uiExecutor, DumpManager dumpManager, ClockEventController clockEventController) { ClockEventController clockEventController, FeatureFlags featureFlags) { super(keyguardClockSwitch); mStatusBarStateController = statusBarStateController; mClockRegistry = clockRegistry; Loading @@ -131,6 +134,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mDumpManager = dumpManager; mClockEventController = clockEventController; mClockRegistry.setEnabled(featureFlags.isEnabled(Flags.LOCKSCREEN_CUSTOM_CLOCKS)); mClockChangedListener = () -> { setClock(mClockRegistry.createCurrentClock()); }; Loading
packages/SystemUI/src/com/android/systemui/flags/Flags.java +3 −0 Original line number Diff line number Diff line Loading @@ -81,12 +81,15 @@ public class Flags { public static final ResourceBooleanFlag FACE_SCANNING_ANIM = new ResourceBooleanFlag(205, R.bool.config_enableFaceScanningAnimation); /** * Whether the KeyguardBottomArea(View|Controller) should use the modern architecture or the old * one. */ public static final BooleanFlag MODERN_BOTTOM_AREA = new BooleanFlag(206, false); public static final BooleanFlag LOCKSCREEN_CUSTOM_CLOCKS = new BooleanFlag(207, false); /***************************************/ // 300 - power menu public static final BooleanFlag POWER_MENU_LITE = Loading
packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java +5 −1 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import androidx.test.filters.SmallTest; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.plugins.Clock; import com.android.systemui.plugins.statusbar.StatusBarStateController; Loading Loading @@ -102,6 +103,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { private FrameLayout mLargeClockFrame; @Mock private SecureSettings mSecureSettings; @Mock private FeatureFlags mFeatureFlags; private final View mFakeSmartspaceView = new View(mContext); Loading Loading @@ -138,7 +141,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { mSecureSettings, mExecutor, mDumpManager, mClockEventController mClockEventController, mFeatureFlags ); when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE); Loading
packages/SystemUI/tests/src/com/android/systemui/shared/clocks/ClockRegistryTest.kt +1 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,7 @@ class ClockRegistryTest : SysuiTestCase() { get() = settingValue set(value) { settingValue = value } } registry.isEnabled = true verify(mockPluginManager) .addPluginListener(captor.capture(), eq(ClockProviderPlugin::class.java)) Loading