From 04d27ab984ce55c5adf058efa5348e35bf6ffa3b Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 2 Apr 2023 16:16:59 -0700 Subject: [PATCH] Double the give up time during sleep. If you're gonna die in your sleep, you may as well sleep in. --- app/src/main/java/net/voussoir/trkpt/TrackerService.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/net/voussoir/trkpt/TrackerService.kt b/app/src/main/java/net/voussoir/trkpt/TrackerService.kt index b794c5c..8e0ccb4 100644 --- a/app/src/main/java/net/voussoir/trkpt/TrackerService.kt +++ b/app/src/main/java/net/voussoir/trkpt/TrackerService.kt @@ -714,15 +714,17 @@ class TrackerService: Service() handler.postDelayed(this, WATCHDOG_INTERVAL) val now = System.currentTimeMillis() last_watchdog = now + + val struggletime = if (location_interval == Keys.LOCATION_INTERVAL_SLEEP) (TIME_UNTIL_GIVE_UP * 2) else TIME_UNTIL_GIVE_UP if ( allow_sleep && has_motion_sensor && !device_is_charging && trackingState == Keys.STATE_TRACKING_ACTIVE && location_interval != Keys.LOCATION_INTERVAL_GIVE_UP && - (now - listeners_enabled_at) > TIME_UNTIL_GIVE_UP && - (now - currentBestLocation.time) > TIME_UNTIL_GIVE_UP && - (now - last_significant_motion) > TIME_UNTIL_GIVE_UP + (now - listeners_enabled_at) > struggletime && + (now - currentBestLocation.time) > struggletime && + (now - last_significant_motion) > struggletime ) { reset_location_listeners(Keys.LOCATION_INTERVAL_GIVE_UP)