From 8b396f3bba2c8df095a3f3984cdaaeed9b5faaa4 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 4 Apr 2023 18:05:43 -0700 Subject: [PATCH] Fix logic error releasing wakelock. --- .../main/java/net/voussoir/trkpt/TrackerService.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/net/voussoir/trkpt/TrackerService.kt b/app/src/main/java/net/voussoir/trkpt/TrackerService.kt index eb88029..52179c5 100644 --- a/app/src/main/java/net/voussoir/trkpt/TrackerService.kt +++ b/app/src/main/java/net/voussoir/trkpt/TrackerService.kt @@ -219,14 +219,17 @@ class TrackerService: Service() location_interval = Keys.LOCATION_INTERVAL_DEAD } - if ( + val should_wakelock = ( (gpsLocationListenerRegistered || networkLocationListenerRegistered) && trackingState == Keys.STATE_TRACKING_ACTIVE && - interval == Keys.LOCATION_INTERVAL_FULL_POWER && - !wakelock.isHeld + interval == Keys.LOCATION_INTERVAL_FULL_POWER ) + if (should_wakelock) { - wakelock.acquire() + if (! wakelock.isHeld) + { + wakelock.acquire() + } } else if (wakelock.isHeld) {