Clean up some deprecation warnings in SettingsLib

Bug: 177652618
Test: Compiles
Change-Id: I266d4a038d5f66e0c7e46f6f1a02bc3ee4d84c5b
This commit is contained in:
Michael Wright
2021-01-15 15:09:57 +00:00
parent c32ef13cc8
commit f3da6a2855

View File

@@ -38,14 +38,13 @@ class Estimate(
* @return An [Estimate] object with the latest battery estimates.
*/
@JvmStatic
@Suppress("DEPRECATION")
fun getCachedEstimateIfAvailable(context: Context): Estimate? {
// if time > 2 min return null or the estimate otherwise
val resolver = context.contentResolver
val lastUpdateTime = Instant.ofEpochMilli(
Settings.Global.getLong(
resolver, Settings.Global.BATTERY_ESTIMATES_LAST_UPDATE_TIME, -1))
val lastUpdateTime = getLastCacheUpdateTime(context)
return if (Duration.between(lastUpdateTime,
Instant.now()).compareTo(Duration.ofMinutes(1)) > 0) {
Instant.now()) > Duration.ofMinutes(1)) {
null
} else Estimate(
Settings.Global.getLong(resolver,
@@ -65,6 +64,7 @@ class Estimate(
* @param estimate the [Estimate] object to store
*/
@JvmStatic
@Suppress("DEPRECATION")
fun storeCachedEstimate(context: Context, estimate: Estimate) {
// store the estimate and update the timestamp
val resolver = context.contentResolver
@@ -82,6 +82,7 @@ class Estimate(
* Returns when the estimate was last updated as an Instant
*/
@JvmStatic
@Suppress("DEPRECATION")
fun getLastCacheUpdateTime(context: Context): Instant {
return Instant.ofEpochMilli(
Settings.Global.getLong(