Enable custom clock feature

- Enable ClockOptionsProvider and the flag let SystemUI(keyguard) have
the ability to apply custom clock
- Remove Analog and Bubble clock from SystemUI

Bug: 146530441
Test: `adb shell content query --uri content://com.android.keyguard.clock/list_options` will list available provider, `adb shell settings put secure lock_screen_custom_clock_face "com.android.keyguard.clock.BubbleClockController"` will not switch to Bubble clock.
Change-Id: Iecfb5e2ea0cc72ca6eb1e16ca0dc0213a3257b6e
This commit is contained in:
Wesley.CW Wang
2020-02-18 15:57:33 +08:00
parent 231f41bfcb
commit 5db44f0ece
4 changed files with 6 additions and 6 deletions

View File

@@ -696,8 +696,7 @@
<provider
android:name="com.android.keyguard.clock.ClockOptionsProvider"
android:authorities="com.android.keyguard.clock"
android:enabled="false"
android:exported="false"
android:exported="true"
android:grantUriPermissions="true">
</provider>

View File

@@ -51,7 +51,7 @@ import javax.inject.Named;
public class KeyguardClockSwitch extends RelativeLayout {
private static final String TAG = "KeyguardClockSwitch";
private static final boolean CUSTOM_CLOCKS_ENABLED = false;
private static final boolean CUSTOM_CLOCKS_ENABLED = true;
/**
* Animation fraction when text is transitioned to/from bold.

View File

@@ -149,8 +149,6 @@ public final class ClockManager {
LayoutInflater layoutInflater = injectionInflater.injectable(LayoutInflater.from(context));
addBuiltinClock(() -> new DefaultClockController(res, layoutInflater, colorExtractor));
addBuiltinClock(() -> new BubbleClockController(res, layoutInflater, colorExtractor));
addBuiltinClock(() -> new AnalogClockController(res, layoutInflater, colorExtractor));
// Store the size of the display for generation of clock preview.
DisplayMetrics dm = res.getDisplayMetrics();
@@ -211,7 +209,8 @@ public final class ClockManager {
return mContentObserver;
}
private void addBuiltinClock(Supplier<ClockPlugin> pluginSupplier) {
@VisibleForTesting
void addBuiltinClock(Supplier<ClockPlugin> pluginSupplier) {
ClockPlugin plugin = pluginSupplier.get();
mPreviewClocks.addClockPlugin(plugin);
mBuiltinClocks.add(pluginSupplier);

View File

@@ -93,6 +93,8 @@ public final class ClockManagerTest extends SysuiTestCase {
mMockPluginManager, mMockColorExtractor, mMockContentResolver,
mMockCurrentUserObserable, mMockSettingsWrapper, mFakeDockManager);
mClockManager.addBuiltinClock(() -> new BubbleClockController(
getContext().getResources(), inflater, mMockColorExtractor));
mClockManager.addOnClockChangedListener(mMockListener1);
mClockManager.addOnClockChangedListener(mMockListener2);
reset(mMockListener1, mMockListener2);