diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/ProcessService.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/ProcessService.kt index e88f7a29..c73fe2b9 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/ProcessService.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/ProcessService.kt @@ -9,7 +9,7 @@ import kotlinx.coroutines.launch class ProcessService { private val TAG = ANG_PACKAGE - private lateinit var process: Process + private var process: Process? = null fun runProcess(context: Context, cmd: MutableList) { Log.d(TAG, cmd.toString()) @@ -24,7 +24,7 @@ class ProcessService { CoroutineScope(Dispatchers.IO).launch { Thread.sleep(50L) Log.d(TAG, "runProcess check") - process.waitFor() + process?.waitFor() Log.d(TAG, "runProcess exited") } Log.d(TAG, process.toString()) @@ -42,4 +42,4 @@ class ProcessService { Log.d(TAG, e.toString()) } } -} \ No newline at end of file +} diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/PluginUtil.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/PluginUtil.kt index 5c68c223..a7566076 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/PluginUtil.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/PluginUtil.kt @@ -14,7 +14,9 @@ object PluginUtil { //private const val HYSTERIA2 = "hysteria2-plugin" private const val HYSTERIA2 = "libhysteria2.so" private const val TAG = ANG_PACKAGE - private lateinit var procService: ProcessService + private val procService: ProcessService by lazy { + ProcessService() + } // fun initPlugin(name: String): PluginManager.InitResult { // return PluginManager.init(name)!! @@ -27,7 +29,6 @@ object PluginUtil { val configFile = genConfigHy2(context, config, domainPort) ?: return val cmd = genCmdHy2(context, configFile) - procService = ProcessService() procService.runProcess(context, cmd) } } @@ -94,4 +95,4 @@ object PluginUtil { Log.d(TAG, e.toString()) } } -} \ No newline at end of file +}