@@ -24,6 +24,8 @@ import com.icapps.background_location_tracker.utils.Logger
24
24
import com.icapps.background_location_tracker.utils.NotificationUtil
25
25
import com.icapps.background_location_tracker.utils.SharedPrefsUtil
26
26
27
+ private const val timeOut = 24 * 60 * 60 * 1000L
28
+
27
29
internal class LocationUpdatesService : Service () {
28
30
private val binder: IBinder = LocalBinder ()
29
31
@@ -136,13 +138,13 @@ internal class LocationUpdatesService : Service() {
136
138
if (! changingConfiguration && SharedPrefsUtil .isTracking(this )) {
137
139
Logger .debug(TAG , " Starting foreground service" )
138
140
if (wakeLock?.isHeld != true ) {
139
- wakeLock?.acquire(24 * 60 * 60 * 1000L )
141
+ wakeLock?.acquire(timeOut )
140
142
}
141
143
NotificationUtil .startForeground(this , location)
142
144
}
143
145
}
144
- catch (e: Exception ) {
145
- Logger .error(e.message ? : " " ," onUnbind failed to execute" , );
146
+ catch (e: Throwable ) {
147
+ Logger .error(e.message ? : " " ," onUnbind failed to execute" );
146
148
}
147
149
148
150
return true // Ensures onRebind() is called when a client re-binds.
@@ -160,7 +162,7 @@ internal class LocationUpdatesService : Service() {
160
162
* [SecurityException].
161
163
*/
162
164
fun startTracking () {
163
- wakeLock?.acquire(24 * 60 * 60 * 1000L /* 24 hours max */ )
165
+ wakeLock?.acquire(timeOut /* 24 hours max */ )
164
166
165
167
Logger .debug(TAG , " Requesting location updates" )
166
168
SharedPrefsUtil .saveIsTracking(this , true )
0 commit comments