Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b84fde6 authored by Salvador Martinez's avatar Salvador Martinez
Browse files

Add function to query last estimate time to Estimate

This just adds a centralized place to query for the last update
time so that people don't implement it with different defaults
or something like that.

Test: in sister CL
Bug: 132751712
Change-Id: I10769eaa2e4c2ec613397988a264228a9474d1d6
parent c3bfdf52
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -77,5 +77,17 @@ class Estimate(
            Settings.Global.putLong(resolver, Settings.Global.BATTERY_ESTIMATES_LAST_UPDATE_TIME,
                    System.currentTimeMillis())
        }

        /**
         * Returns when the estimate was last updated as an Instant
         */
        @JvmStatic
        fun getLastCacheUpdateTime(context: Context): Instant {
            return Instant.ofEpochMilli(
                    Settings.Global.getLong(
                            context.contentResolver,
                            Settings.Global.BATTERY_ESTIMATES_LAST_UPDATE_TIME,
                            -1))
        }
    }
}