6666* */
6767package io.matthewnelson.topl_service.lifecycle
6868
69+ import android.content.Context
6970import androidx.lifecycle.Lifecycle
7071import androidx.lifecycle.LifecycleObserver
7172import androidx.lifecycle.OnLifecycleEvent
@@ -117,15 +118,15 @@ import io.matthewnelson.topl_service.util.ServiceConsts
117118 * @param [executionDelay] Length of time before the policy gets executed *after* the application
118119 * is sent to the background.
119120 * @param [serviceClass] The Service class being managed
120- * @param [serviceConnection ] The ServiceConnection being used to bind with
121+ * @param [bindServiceFlag ] The flag to be used when binding to the service
121122 * @see [io.matthewnelson.topl_service.service.components.binding.BaseServiceBinder.executeBackgroundPolicyJob]
122123 * @see [io.matthewnelson.topl_service.service.components.binding.BaseServiceBinder.cancelExecuteBackgroundPolicyJob]
123124 * */
124125class BackgroundManager internal constructor(
125126 @BackgroundPolicy private val policy : String ,
126127 private val executionDelay : Long ,
127128 private val serviceClass : Class <* >,
128- private val serviceConnection : TorServiceConnection
129+ private val bindServiceFlag : Int
129130): ServiceConsts(), LifecycleObserver {
130131
131132
@@ -213,8 +214,8 @@ class BackgroundManager internal constructor(
213214 * test classes get initialized so they aren't overwritten by production classes.
214215 * */
215216 internal fun build (
216- serviceClass : Class <* >,
217- serviceConnection : TorServiceConnection
217+ serviceClass : Class <* > = TorService : :class.java ,
218+ bindServiceFlag : Int = Context . BIND_AUTO_CREATE
218219 ) {
219220
220221 // Only initialize it once. Reflection has issues here
@@ -227,7 +228,7 @@ class BackgroundManager internal constructor(
227228 policyBuilder.chosenPolicy,
228229 policyBuilder.executionDelay,
229230 serviceClass,
230- serviceConnection
231+ bindServiceFlag
231232 )
232233 }
233234 }
@@ -261,8 +262,9 @@ class BackgroundManager internal constructor(
261262 BaseService .startService(
262263 BaseService .getAppContext(),
263264 serviceClass,
264- serviceConnection,
265- includeIntentActionStart = false
265+ TorServiceConnection .torServiceConnection,
266+ includeIntentActionStart = false ,
267+ bindServiceFlag = bindServiceFlag
266268 )
267269 }
268270 }
0 commit comments