Skip to content

Commit b80d59b

Browse files
committed
implemented PR feedback
1 parent a203220 commit b80d59b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

android/src/main/kotlin/com/icapps/background_location_tracker/service/LocationUpdatesService.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import com.icapps.background_location_tracker.utils.Logger
2424
import com.icapps.background_location_tracker.utils.NotificationUtil
2525
import com.icapps.background_location_tracker.utils.SharedPrefsUtil
2626

27+
private const val timeOut = 24 * 60 * 60 * 1000L
28+
2729
internal class LocationUpdatesService : Service() {
2830
private val binder: IBinder = LocalBinder()
2931

@@ -136,13 +138,13 @@ internal class LocationUpdatesService : Service() {
136138
if (!changingConfiguration && SharedPrefsUtil.isTracking(this)) {
137139
Logger.debug(TAG, "Starting foreground service")
138140
if (wakeLock?.isHeld != true) {
139-
wakeLock?.acquire(24 * 60 * 60 * 1000L)
141+
wakeLock?.acquire(timeOut)
140142
}
141143
NotificationUtil.startForeground(this, location)
142144
}
143145
}
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");
146148
}
147149

148150
return true // Ensures onRebind() is called when a client re-binds.
@@ -160,7 +162,7 @@ internal class LocationUpdatesService : Service() {
160162
* [SecurityException].
161163
*/
162164
fun startTracking() {
163-
wakeLock?.acquire(24 * 60 * 60 * 1000L /*24 hours max */)
165+
wakeLock?.acquire(timeOut /*24 hours max */)
164166

165167
Logger.debug(TAG, "Requesting location updates")
166168
SharedPrefsUtil.saveIsTracking(this, true)

0 commit comments

Comments
 (0)