Merge "Override for testing when clock is not set" into tm-qpr-dev

This commit is contained in:
Hawkwood Glazier
2022-11-17 15:43:04 +00:00
committed by Android (Google) Code Review
3 changed files with 12 additions and 3 deletions

View File

@@ -1940,6 +1940,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));
}
}