Merge "Add exception handling to ClockRegistry to prevent crashes" into tm-qpr-dev am: 341b5a877a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19488390 Change-Id: Id68bbefd56b6a79d4a84cfc57ac8e31320b4b232 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -72,18 +72,27 @@ open class ClockRegistry(
|
||||
|
||||
open var currentClockId: ClockId
|
||||
get() {
|
||||
val json = Settings.Secure.getString(
|
||||
context.contentResolver,
|
||||
Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE
|
||||
)
|
||||
return gson.fromJson(json, ClockSetting::class.java)?.clockId ?: DEFAULT_CLOCK_ID
|
||||
return try {
|
||||
val json = Settings.Secure.getString(
|
||||
context.contentResolver,
|
||||
Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE
|
||||
)
|
||||
gson.fromJson(json, ClockSetting::class.java)?.clockId ?: DEFAULT_CLOCK_ID
|
||||
} catch (ex: Exception) {
|
||||
Log.e(TAG, "Failed to parse clock setting", ex)
|
||||
DEFAULT_CLOCK_ID
|
||||
}
|
||||
}
|
||||
set(value) {
|
||||
val json = gson.toJson(ClockSetting(value, System.currentTimeMillis()))
|
||||
Settings.Secure.putString(
|
||||
context.contentResolver,
|
||||
Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE, json
|
||||
)
|
||||
try {
|
||||
val json = gson.toJson(ClockSetting(value, System.currentTimeMillis()))
|
||||
Settings.Secure.putString(
|
||||
context.contentResolver,
|
||||
Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE, json
|
||||
)
|
||||
} catch (ex: Exception) {
|
||||
Log.e(TAG, "Failed to set clock setting", ex)
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
@@ -170,6 +179,6 @@ open class ClockRegistry(
|
||||
|
||||
private data class ClockSetting(
|
||||
val clockId: ClockId,
|
||||
val _applied_timestamp: Long
|
||||
val _applied_timestamp: Long?
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user