From f3da6a2855ad2a64904fc5ea0de1547208650b0e Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Fri, 15 Jan 2021 15:09:57 +0000 Subject: [PATCH] Clean up some deprecation warnings in SettingsLib Bug: 177652618 Test: Compiles Change-Id: I266d4a038d5f66e0c7e46f6f1a02bc3ee4d84c5b --- .../src/com/android/settingslib/fuelgauge/Estimate.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/fuelgauge/Estimate.kt b/packages/SettingsLib/src/com/android/settingslib/fuelgauge/Estimate.kt index b2e75ea6867fc..cd22247d6142b 100644 --- a/packages/SettingsLib/src/com/android/settingslib/fuelgauge/Estimate.kt +++ b/packages/SettingsLib/src/com/android/settingslib/fuelgauge/Estimate.kt @@ -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(