This repository was archived by the owner on Dec 18, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
topl-service/src/main/java/io/matthewnelson/topl_service/lifecycle Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -151,9 +151,9 @@ class BackgroundManager internal constructor(
151151 class Builder {
152152
153153 @BackgroundPolicy
154- internal lateinit var chosenPolicy: String
154+ private lateinit var chosenPolicy: String
155155 private var executionDelay: Long = 30_000L
156- internal var killAppIfTaskIsRemoved = false
156+ private var killAppIfTaskIsRemoved = false
157157
158158 /* *
159159 * Stops [TorService] after being in the background for the declared [secondsFrom5To45].
@@ -221,7 +221,16 @@ class BackgroundManager internal constructor(
221221 *
222222 * @param [policyBuilder] The [BackgroundManager.Builder] to be built during initialization
223223 * */
224- class Policy (internal val policyBuilder : Builder ) {
224+ class Policy internal constructor (private val policyBuilder : Builder ) {
225+
226+ internal fun configurationIsCompliant (stopServiceOnTaskRemoved : Boolean ): Boolean {
227+ return if (stopServiceOnTaskRemoved) {
228+ policyBuilder.chosenPolicy == BackgroundPolicy .RUN_IN_FOREGROUND &&
229+ policyBuilder.killAppIfTaskIsRemoved
230+ } else {
231+ true
232+ }
233+ }
225234
226235 /* *
227236 * Only available internally, so this is where we intercept for integration testing.
You can’t perform that action at this time.
0 commit comments