Use the field isFullChargeCycleStart in database to get the last full

charge cycle start and remove the unused SharedPreference.

Test: make RunSettingsRoboTests + manual
Bug: 253553141
Change-Id: I74ef71775fa5d4871077f6d5573467aa5843bc6b
This commit is contained in:
Kuan Wang
2022-11-17 21:33:40 +08:00
parent bf26483af5
commit 2b93d40683
14 changed files with 159 additions and 255 deletions

View File

@@ -41,9 +41,11 @@ public interface BatteryStateDao {
@Query("SELECT * FROM BatteryState WHERE timestamp > :timestamp ORDER BY timestamp DESC")
List<BatteryState> getAllAfter(long timestamp);
/** Gets the {@link Cursor} of all recorded data from a specific timestamp. */
@Query("SELECT * FROM BatteryState WHERE timestamp >= :timestamp ORDER BY timestamp DESC")
Cursor getCursorAfter(long timestamp);
/** Gets the {@link Cursor} of all recorded data since last full charge within 7 days. */
@Query("SELECT * FROM BatteryState WHERE timestamp >= :timestampSixDaysAgo AND timestamp >= "
+ "(SELECT MAX(timestamp) FROM BatteryState WHERE isFullChargeCycleStart = 1)"
+ " ORDER BY timestamp ASC")
Cursor getCursorSinceLastFullCharge(long timestampSixDaysAgo);
/** Get the count of distinct timestamp after a specific timestamp. */
@Query("SELECT COUNT(DISTINCT timestamp) FROM BatteryState WHERE timestamp > :timestamp")