Skip to content

Commit

Permalink
Fixes crash when service is on the background
Browse files Browse the repository at this point in the history
  • Loading branch information
kelsos committed Nov 19, 2020
1 parent 1b0022b commit 7227ec3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def gitHash() {
return "git -C ${rootDir} rev-parse --short HEAD".execute().text.trim()
}

def version = "1.2.0-beta1"
def version_code = 116
def version = "1.2.0"
def version_code = 117

android {
compileSdkVersion 30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class RemoteService : Service(), ForegroundHooks {
@Inject
lateinit var notificationService: NotificationService

private lateinit var threadPoolExecutor: ExecutorService
private var threadPoolExecutor: ExecutorService? = null
private lateinit var scope: Scope

override fun onBind(intent: Intent?): IBinder {
Expand All @@ -56,8 +56,9 @@ class RemoteService : Service(), ForegroundHooks {
CommandRegistration.register(remoteController, scope)
threadPoolExecutor = Executors.newSingleThreadExecutor {
Thread(it, "message-thread")
}.apply {
execute(remoteController)
}
threadPoolExecutor.execute(remoteController)

remoteController.executeCommand(MessageEvent(UserInputEventType.StartConnection))
discovery.startDiscovery()
Expand All @@ -71,7 +72,7 @@ class RemoteService : Service(), ForegroundHooks {
remoteController.executeCommand(MessageEvent(UserInputEventType.CancelNotification))
remoteController.executeCommand(MessageEvent(UserInputEventType.TerminateConnection))
CommandRegistration.unregister(remoteController)
threadPoolExecutor.shutdownNow()
threadPoolExecutor?.shutdownNow()
Timber.d("Background Service::Destroyed")
Toothpick.closeScope(this)
}
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/raw/changelog.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog>
<version
release="Nov 19,2020"
version="1.2.0">
<bug>Fixes a background crash with the application service.</bug>
</version>
<version
release="Nov 07,2020"
version="1.2.0-beta1">
Expand Down

0 comments on commit 7227ec3

Please sign in to comment.