Add Flag for Custom Clocks
Test: Manual Bug: 229771520 Change-Id: Ic06481b3da589ab6f27ae4ff79bd39a45dee3711
This commit is contained in:
@@ -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>()
|
||||
@@ -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),
|
||||
@@ -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)
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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());
|
||||
};
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
|
||||
@@ -138,7 +141,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
|
||||
mSecureSettings,
|
||||
mExecutor,
|
||||
mDumpManager,
|
||||
mClockEventController
|
||||
mClockEventController,
|
||||
mFeatureFlags
|
||||
);
|
||||
|
||||
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE);
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user