Skip to content
This repository was archived by the owner on Dec 18, 2022. It is now read-only.

Commit 28eef94

Browse files
authored
Merge pull request #85 from 05nelsonm/mn/bug-fix/background-manager-rebind
BugFix: background manager rebind
2 parents eaf4f4c + 8492117 commit 28eef94

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

topl-service/src/main/java/io/matthewnelson/topl_service/lifecycle/BackgroundManager.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,16 @@ class BackgroundManager internal constructor(
320320
private fun applicationMovedToBackground() {
321321
taskIsInForeground = false
322322
if (!ServiceActionProcessor.wasLastAcceptedServiceActionStop()) {
323-
// System automatically unbinds when app is sent to the background. This prevents
324-
// it so that we maintain a started, bound service.
325-
BaseService.bindService(
326-
BaseService.getAppContext(),
327-
serviceClass,
328-
bindServiceFlag = bindServiceFlag
329-
)
330-
TorServiceConnection.serviceBinder?.executeBackgroundPolicyJob(policy, executionDelay)
323+
TorServiceConnection.serviceBinder?.let { binder ->
324+
// System automatically unbinds when app is sent to the background. This prevents
325+
// it so that we maintain a started, bound service.
326+
BaseService.bindService(
327+
BaseService.getAppContext(),
328+
serviceClass,
329+
bindServiceFlag = bindServiceFlag
330+
)
331+
binder.executeBackgroundPolicyJob(policy, executionDelay)
332+
}
331333
}
332334
}
333335
}

topl-service/src/main/java/io/matthewnelson/topl_service/service/components/binding/BaseServiceBinder.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@
6666
* */
6767
package io.matthewnelson.topl_service.service.components.binding
6868

69-
import android.app.Activity
70-
import android.app.Application
7169
import android.os.Binder
72-
import android.os.Bundle
7370
import io.matthewnelson.topl_core.broadcaster.BroadcastLogger
7471
import io.matthewnelson.topl_service.service.BaseService
7572
import io.matthewnelson.topl_service.lifecycle.BackgroundManager
@@ -78,9 +75,7 @@ import io.matthewnelson.topl_service.service.components.actions.ServiceActions.S
7875
import io.matthewnelson.topl_service.util.ServiceConsts.BackgroundPolicy
7976
import kotlinx.coroutines.Job
8077
import kotlinx.coroutines.delay
81-
import kotlinx.coroutines.isActive
8278
import kotlinx.coroutines.launch
83-
import net.freehaven.tor.control.TorControlCommands
8479

8580

8681
internal abstract class BaseServiceBinder(private val torService: BaseService): Binder() {

topl-service/src/main/java/io/matthewnelson/topl_service/util/ServiceConsts.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ package io.matthewnelson.topl_service.util
6969
import androidx.annotation.IntDef
7070
import androidx.annotation.StringDef
7171
import io.matthewnelson.topl_core_base.BaseConsts
72-
import io.matthewnelson.topl_service.service.components.actions.ServiceActions
7372

7473
abstract class ServiceConsts: BaseConsts() {
7574

0 commit comments

Comments
 (0)