Skip to content

Commit 7227ec3

Browse files
committed
Fixes crash when service is on the background
1 parent 1b0022b commit 7227ec3

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def gitHash() {
2424
return "git -C ${rootDir} rev-parse --short HEAD".execute().text.trim()
2525
}
2626

27-
def version = "1.2.0-beta1"
28-
def version_code = 116
27+
def version = "1.2.0"
28+
def version_code = 117
2929

3030
android {
3131
compileSdkVersion 30

app/src/main/kotlin/com/kelsos/mbrc/controller/RemoteService.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class RemoteService : Service(), ForegroundHooks {
3636
@Inject
3737
lateinit var notificationService: NotificationService
3838

39-
private lateinit var threadPoolExecutor: ExecutorService
39+
private var threadPoolExecutor: ExecutorService? = null
4040
private lateinit var scope: Scope
4141

4242
override fun onBind(intent: Intent?): IBinder {
@@ -56,8 +56,9 @@ class RemoteService : Service(), ForegroundHooks {
5656
CommandRegistration.register(remoteController, scope)
5757
threadPoolExecutor = Executors.newSingleThreadExecutor {
5858
Thread(it, "message-thread")
59+
}.apply {
60+
execute(remoteController)
5961
}
60-
threadPoolExecutor.execute(remoteController)
6162

6263
remoteController.executeCommand(MessageEvent(UserInputEventType.StartConnection))
6364
discovery.startDiscovery()
@@ -71,7 +72,7 @@ class RemoteService : Service(), ForegroundHooks {
7172
remoteController.executeCommand(MessageEvent(UserInputEventType.CancelNotification))
7273
remoteController.executeCommand(MessageEvent(UserInputEventType.TerminateConnection))
7374
CommandRegistration.unregister(remoteController)
74-
threadPoolExecutor.shutdownNow()
75+
threadPoolExecutor?.shutdownNow()
7576
Timber.d("Background Service::Destroyed")
7677
Toothpick.closeScope(this)
7778
}

app/src/main/res/raw/changelog.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<changelog>
3+
<version
4+
release="Nov 19,2020"
5+
version="1.2.0">
6+
<bug>Fixes a background crash with the application service.</bug>
7+
</version>
38
<version
49
release="Nov 07,2020"
510
version="1.2.0-beta1">

0 commit comments

Comments
 (0)