Skip to content

Commit f5a24db

Browse files
committed
[orchestrator] improve start errors handling
1 parent 0d66735 commit f5a24db

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

app/src/main/java/me/capcom/smsgateway/modules/orchestrator/OrchestratorService.kt

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package me.capcom.smsgateway.modules.orchestrator
22

3-
import android.app.ForegroundServiceStartNotAllowedException
43
import android.content.Context
5-
import android.os.Build
64
import me.capcom.smsgateway.helpers.SettingsHelper
75
import me.capcom.smsgateway.modules.gateway.GatewayService
86
import me.capcom.smsgateway.modules.localserver.LocalServerService
@@ -38,18 +36,21 @@ class OrchestratorService(
3836
pingSvc.start(context)
3937
receiverService.start(context)
4038
} catch (e: Throwable) {
41-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
42-
&& e is ForegroundServiceStartNotAllowedException
43-
) {
44-
logsSvc.insert(
45-
LogEntry.Priority.WARN,
46-
MODULE_NAME,
47-
"Can't start foreground services while the app is running in the background"
48-
)
49-
return
50-
}
39+
logsSvc.insert(
40+
LogEntry.Priority.WARN,
41+
MODULE_NAME,
42+
"Can't start foreground services while the app is running in the background"
43+
)
44+
}
5145

52-
throw e
46+
try {
47+
receiverService.start(context)
48+
} catch (e: Throwable) {
49+
logsSvc.insert(
50+
LogEntry.Priority.WARN,
51+
MODULE_NAME,
52+
"Can't register receiver"
53+
)
5354
}
5455
}
5556

0 commit comments

Comments
 (0)