Merge "Add Flag for Custom Clocks" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
79dac2d234
@@ -54,6 +54,8 @@ open class ClockRegistry(
|
|||||||
fun onClockChanged()
|
fun onClockChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isEnabled: Boolean = false
|
||||||
|
|
||||||
private val gson = Gson()
|
private val gson = Gson()
|
||||||
private val availableClocks = mutableMapOf<ClockId, ClockInfo>()
|
private val availableClocks = mutableMapOf<ClockId, ClockInfo>()
|
||||||
private val clockChangeListeners = mutableListOf<ClockChangeListener>()
|
private val clockChangeListeners = mutableListOf<ClockChangeListener>()
|
||||||
@@ -97,6 +99,12 @@ open class ClockRegistry(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
connectClocks(defaultClockProvider)
|
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)
|
pluginManager.addPluginListener(pluginListener, ClockProviderPlugin::class.java)
|
||||||
context.contentResolver.registerContentObserver(
|
context.contentResolver.registerContentObserver(
|
||||||
Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE),
|
Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE),
|
||||||
@@ -142,7 +150,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? =
|
fun getClockThumbnail(clockId: ClockId): Drawable? =
|
||||||
availableClocks[clockId]?.provider?.getClockThumbnail(clockId)
|
availableClocks[clockId]?.provider?.getClockThumbnail(clockId)
|
||||||
@@ -157,7 +170,7 @@ open class ClockRegistry(
|
|||||||
|
|
||||||
fun createCurrentClock(): Clock {
|
fun createCurrentClock(): Clock {
|
||||||
val clockId = currentClockId
|
val clockId = currentClockId
|
||||||
if (!clockId.isNullOrEmpty()) {
|
if (isEnabled && clockId.isNotEmpty()) {
|
||||||
val clock = createClock(clockId)
|
val clock = createClock(clockId)
|
||||||
if (clock != null) {
|
if (clock != null) {
|
||||||
return clock
|
return clock
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ import com.android.systemui.Dumpable;
|
|||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.dump.DumpManager;
|
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.keyguard.KeyguardUnlockAnimationController;
|
||||||
import com.android.systemui.plugins.Clock;
|
import com.android.systemui.plugins.Clock;
|
||||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||||
@@ -118,7 +120,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
|
|||||||
SecureSettings secureSettings,
|
SecureSettings secureSettings,
|
||||||
@Main Executor uiExecutor,
|
@Main Executor uiExecutor,
|
||||||
DumpManager dumpManager,
|
DumpManager dumpManager,
|
||||||
ClockEventController clockEventController) {
|
ClockEventController clockEventController,
|
||||||
|
FeatureFlags featureFlags) {
|
||||||
super(keyguardClockSwitch);
|
super(keyguardClockSwitch);
|
||||||
mStatusBarStateController = statusBarStateController;
|
mStatusBarStateController = statusBarStateController;
|
||||||
mClockRegistry = clockRegistry;
|
mClockRegistry = clockRegistry;
|
||||||
@@ -131,6 +134,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
|
|||||||
mDumpManager = dumpManager;
|
mDumpManager = dumpManager;
|
||||||
mClockEventController = clockEventController;
|
mClockEventController = clockEventController;
|
||||||
|
|
||||||
|
mClockRegistry.setEnabled(featureFlags.isEnabled(Flags.LOCKSCREEN_CUSTOM_CLOCKS));
|
||||||
mClockChangedListener = () -> {
|
mClockChangedListener = () -> {
|
||||||
setClock(mClockRegistry.createCurrentClock());
|
setClock(mClockRegistry.createCurrentClock());
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -87,12 +87,15 @@ public class Flags {
|
|||||||
|
|
||||||
public static final ResourceBooleanFlag FACE_SCANNING_ANIM =
|
public static final ResourceBooleanFlag FACE_SCANNING_ANIM =
|
||||||
new ResourceBooleanFlag(205, R.bool.config_enableFaceScanningAnimation);
|
new ResourceBooleanFlag(205, R.bool.config_enableFaceScanningAnimation);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the KeyguardBottomArea(View|Controller) should use the modern architecture or the old
|
* Whether the KeyguardBottomArea(View|Controller) should use the modern architecture or the old
|
||||||
* one.
|
* one.
|
||||||
*/
|
*/
|
||||||
public static final BooleanFlag MODERN_BOTTOM_AREA = new BooleanFlag(206, false);
|
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
|
// 300 - power menu
|
||||||
public static final BooleanFlag POWER_MENU_LITE =
|
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.R;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.dump.DumpManager;
|
import com.android.systemui.dump.DumpManager;
|
||||||
|
import com.android.systemui.flags.FeatureFlags;
|
||||||
import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
|
import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
|
||||||
import com.android.systemui.plugins.Clock;
|
import com.android.systemui.plugins.Clock;
|
||||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||||
@@ -102,6 +103,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
|
|||||||
private FrameLayout mLargeClockFrame;
|
private FrameLayout mLargeClockFrame;
|
||||||
@Mock
|
@Mock
|
||||||
private SecureSettings mSecureSettings;
|
private SecureSettings mSecureSettings;
|
||||||
|
@Mock
|
||||||
|
private FeatureFlags mFeatureFlags;
|
||||||
|
|
||||||
private final View mFakeSmartspaceView = new View(mContext);
|
private final View mFakeSmartspaceView = new View(mContext);
|
||||||
|
|
||||||
@@ -138,7 +141,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
|
|||||||
mSecureSettings,
|
mSecureSettings,
|
||||||
mExecutor,
|
mExecutor,
|
||||||
mDumpManager,
|
mDumpManager,
|
||||||
mClockEventController
|
mClockEventController,
|
||||||
|
mFeatureFlags
|
||||||
);
|
);
|
||||||
|
|
||||||
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE);
|
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE);
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ class ClockRegistryTest : SysuiTestCase() {
|
|||||||
get() = settingValue
|
get() = settingValue
|
||||||
set(value) { settingValue = value }
|
set(value) { settingValue = value }
|
||||||
}
|
}
|
||||||
|
registry.isEnabled = true
|
||||||
|
|
||||||
verify(mockPluginManager)
|
verify(mockPluginManager)
|
||||||
.addPluginListener(captor.capture(), eq(ClockProviderPlugin::class.java))
|
.addPluginListener(captor.capture(), eq(ClockProviderPlugin::class.java))
|
||||||
|
|||||||
Reference in New Issue
Block a user