Merge pull request #50 from kaajjo/service-patch

fix: use `startForegroundService` instead of `startService`
This commit is contained in:
dovecoteescapee 2024-08-09 01:04:07 +03:00 committed by GitHub
commit 4fdad0cfba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,7 @@ package io.github.dovecoteescapee.byedpi.services
import android.content.Context
import android.content.Intent
import android.util.Log
import androidx.core.content.ContextCompat
import io.github.dovecoteescapee.byedpi.data.Mode
import io.github.dovecoteescapee.byedpi.data.START_ACTION
import io.github.dovecoteescapee.byedpi.data.STOP_ACTION
@ -16,14 +17,14 @@ object ServiceManager {
Log.i(TAG, "Starting VPN")
val intent = Intent(context, ByeDpiVpnService::class.java)
intent.action = START_ACTION
context.startService(intent)
ContextCompat.startForegroundService(context, intent)
}
Mode.Proxy -> {
Log.i(TAG, "Starting proxy")
val intent = Intent(context, ByeDpiProxyService::class.java)
intent.action = START_ACTION
context.startService(intent)
ContextCompat.startForegroundService(context, intent)
}
}
}
@ -35,14 +36,14 @@ object ServiceManager {
Log.i(TAG, "Stopping VPN")
val intent = Intent(context, ByeDpiVpnService::class.java)
intent.action = STOP_ACTION
context.startService(intent)
ContextCompat.startForegroundService(context, intent)
}
Mode.Proxy -> {
Log.i(TAG, "Stopping proxy")
val intent = Intent(context, ByeDpiProxyService::class.java)
intent.action = STOP_ACTION
context.startService(intent)
ContextCompat.startForegroundService(context, intent)
}
}
}