Track charging sessions and daily consumption history
This commit is contained in:
@@ -131,6 +131,7 @@ public class AbrpUploadService extends Service {
|
||||
private EnergyTelemetryReader energyReader;
|
||||
private ConsumptionTracker consumptionTracker;
|
||||
private ConsumptionCloudClient consumptionCloudClient;
|
||||
private ChargeSessionTracker chargeSessionTracker;
|
||||
/**
|
||||
* Keeps the unit on the phone hotspot without a trip into Settings. Attempted on the
|
||||
* upload tick because that is exactly when being offline costs something, and it is
|
||||
@@ -198,6 +199,7 @@ public class AbrpUploadService extends Service {
|
||||
energyReader = new EnergyTelemetryReader(getApplicationContext());
|
||||
consumptionTracker = ConsumptionTracker.get(this);
|
||||
consumptionCloudClient = new ConsumptionCloudClient(getApplicationContext());
|
||||
chargeSessionTracker = ChargeSessionTracker.get(getApplicationContext());
|
||||
wifi = new WifiAutoConnect(getApplicationContext());
|
||||
// The head unit's own weather service, bound for one reason: ENV_OUTSIDE_TEMPERATURE
|
||||
// is not implemented on this vehicle, so the car cannot say how warm it is outside
|
||||
@@ -326,7 +328,8 @@ public class AbrpUploadService extends Service {
|
||||
long sampleMs = System.currentTimeMillis();
|
||||
EnergySnapshot vehicle = energyReader.read(sampleMs);
|
||||
consumptionTracker.sample(vehicle);
|
||||
consumptionCloudClient.syncIfDue(consumptionTracker.cloudSnapshot(), sampleMs);
|
||||
chargeSessionTracker.sample(vehicle);
|
||||
consumptionCloudClient.syncIfDue(consumptionTracker, chargeSessionTracker, sampleMs);
|
||||
|
||||
// Keep local consumption history alive while another app owns the ABRP feed.
|
||||
if (!settings.abrpUploadEnabled) {
|
||||
|
||||
Reference in New Issue
Block a user