11package com.httpsms.worker
22
33import android.content.Context
4+ import android.os.BatteryManager
45import androidx.work.Worker
56import androidx.work.WorkerParameters
67import com.httpsms.Constants
78import com.httpsms.HttpSmsApiService
89import com.httpsms.Settings
10+ import com.httpsms.utils.Heartbeat
911import timber.log.Timber
1012
1113class HeartbeatWorker (appContext : Context , workerParams : WorkerParameters ) : Worker(appContext, workerParams) {
@@ -30,7 +32,7 @@ class HeartbeatWorker(appContext: Context, workerParams: WorkerParameters) : Wor
3032 return
3133 }
3234
33- HttpSmsApiService .create(applicationContext).storeHeartbeat(Settings .getSIM1PhoneNumber(applicationContext))
35+ HttpSmsApiService .create(applicationContext).storeHeartbeat(Settings .getSIM1PhoneNumber(applicationContext), Settings .isCharging(applicationContext) )
3436 Timber .d(" [SIM1] finished sending heartbeat to server" )
3537
3638 Settings .setHeartbeatTimestampAsync(applicationContext, System .currentTimeMillis())
@@ -43,7 +45,7 @@ class HeartbeatWorker(appContext: Context, workerParams: WorkerParameters) : Wor
4345 return
4446 }
4547
46- HttpSmsApiService .create(applicationContext).storeHeartbeat(Settings .getSIM2PhoneNumber(applicationContext))
48+ HttpSmsApiService .create(applicationContext).storeHeartbeat(Settings .getSIM2PhoneNumber(applicationContext), Settings .isCharging(applicationContext) )
4749 Timber .d(" [SIM2] finished sending heartbeat to server" )
4850
4951 Settings .setHeartbeatTimestampAsync(applicationContext, System .currentTimeMillis())
0 commit comments