05nelsonm / kmp-tor

Kotlin Multiplatform Library for embedding Tor into your applications
Apache License 2.0
33 stars 5 forks source link

`TorService.TaskReturnMonitor` does not work in headless mode #472

Closed 05nelsonm closed 3 weeks ago

05nelsonm commented 3 weeks ago

If the app is started in some other manner than the launch activity (e.g. receives an Intent from a BroadcastReceiver and starts Tor), then there is no task removal to trigger exitProcess.

Application.ActivityLifecycleCallbacks must be registered upon initialiaztion of TorServiceConfig.Initializer in order to catch the first Activity.onCreate (before Application.onCreate finishes). In the event there is no Activity (i.e. headless mode), then when TorService.onDestroy executes it should register as not having a task associated with it and call exitProcess.

Part of #423

05nelsonm commented 3 weeks ago

Actually, the current implementation is the same functionality as 1.x.x. It should remain that way as to not modify behavior.