mirror of
https://github.com/openlibrecommunity/olcng.git
synced 2026-07-03 14:05:17 +02:00
fix(service): handle missing service reference and notify UI on shutdown
This commit is contained in:
@@ -96,6 +96,11 @@ object V2RayServiceManager {
|
||||
}
|
||||
|
||||
try {
|
||||
if (serviceControl?.get() == null) {
|
||||
Log.w(AppConfig.TAG, "StartCore-Manager: Service not running, resetting UI state")
|
||||
MessageUtil.sendMsg2UI(context, AppConfig.MSG_STATE_STOP_SUCCESS, "")
|
||||
return
|
||||
}
|
||||
MessageUtil.sendMsg2Service(context, AppConfig.MSG_STATE_STOP, "")
|
||||
} finally {
|
||||
synchronized(operationLock) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import xyz.zarazaex.olc.handler.MmkvManager
|
||||
import xyz.zarazaex.olc.handler.NotificationManager
|
||||
import xyz.zarazaex.olc.handler.SettingsManager
|
||||
import xyz.zarazaex.olc.handler.V2RayServiceManager
|
||||
import xyz.zarazaex.olc.util.MessageUtil
|
||||
import xyz.zarazaex.olc.util.MyContextWrapper
|
||||
import xyz.zarazaex.olc.util.Utils
|
||||
import java.lang.ref.SoftReference
|
||||
@@ -94,6 +95,7 @@ class V2RayVpnService : VpnService(), ServiceControl {
|
||||
super.onDestroy()
|
||||
Log.i(AppConfig.TAG, "StartCore-VPN: Service destroyed")
|
||||
NotificationManager.cancelNotification()
|
||||
MessageUtil.sendMsg2UI(this, AppConfig.MSG_STATE_STOP_SUCCESS, "")
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
|
||||
Reference in New Issue
Block a user