Override for testing when clock is not set

Bug: 259097187
Test: Manually verified default clock was correctly used
Change-Id: I4fe2572aa95edf34cb7e6a4745e7dda35776c8f0
This commit is contained in:
Hawkwood Glazier
2022-11-09 20:11:09 +00:00
parent d825147525
commit c2b519b890
3 changed files with 12 additions and 3 deletions

View File

@@ -1932,6 +1932,9 @@
<!-- SysUI Tuner: Summary of no shortcut being selected [CHAR LIMIT=60] -->
<string name="lockscreen_none">None</string>
<!-- ClockId to use when none is set by user -->
<string name="lockscreen_clock_id_fallback" translatable="false">DEFAULT</string>
<!-- SysUI Tuner: Format string for describing launching an app [CHAR LIMIT=60] -->
<string name="tuner_launch_app">Launch <xliff:g id="app" example="Settings">%1$s</xliff:g></string>

View File

@@ -41,6 +41,7 @@ open class ClockRegistry(
val isEnabled: Boolean,
userHandle: Int,
defaultClockProvider: ClockProvider,
val fallbackClockId: ClockId = DEFAULT_CLOCK_ID,
) {
// Usually this would be a typealias, but a SAM provides better java interop
fun interface ClockChangeListener {
@@ -69,10 +70,13 @@ open class ClockRegistry(
context.contentResolver,
Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE
)
ClockSetting.deserialize(json)?.clockId ?: DEFAULT_CLOCK_ID
if (json == null || json.isEmpty()) {
return fallbackClockId
}
ClockSetting.deserialize(json).clockId
} catch (ex: Exception) {
Log.e(TAG, "Failed to parse clock setting", ex)
DEFAULT_CLOCK_ID
fallbackClockId
}
}
set(value) {

View File

@@ -20,6 +20,7 @@ import android.content.Context;
import android.os.Handler;
import android.os.UserHandle;
import com.android.systemui.R;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Application;
import com.android.systemui.dagger.qualifiers.Main;
@@ -50,6 +51,7 @@ public abstract class ClockRegistryModule {
handler,
featureFlags.isEnabled(Flags.LOCKSCREEN_CUSTOM_CLOCKS),
UserHandle.USER_ALL,
defaultClockProvider);
defaultClockProvider,
context.getString(R.string.lockscreen_clock_id_fallback));
}
}