Update WebService.kt
This commit is contained in:
1 parent
7eda2f7ee5
commit
345ca5a963
1 file changed
+14
-1
@@ -33,6 +33,8 @@ import splitties.init.appCtx
|
|||||||
import splitties.systemservices.powerManager
|
import splitties.systemservices.powerManager
|
||||||
import splitties.systemservices.wifiManager
|
import splitties.systemservices.wifiManager
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
// ——————【新增引用】——————
|
||||||
|
import io.legado.app.utils.putPrefBoolean
|
||||||
|
|
||||||
class WebService : BaseService() {
|
class WebService : BaseService() {
|
||||||
|
|
||||||
@@ -41,6 +43,9 @@ class WebService : BaseService() {
|
|||||||
var hostAddress = ""
|
var hostAddress = ""
|
||||||
|
|
||||||
fun start(context: Context) {
|
fun start(context: Context) {
|
||||||
|
// ——————【修改开始】记录开启状态——————
|
||||||
|
appCtx.putPrefBoolean("web_service_auto", true)
|
||||||
|
// ——————【修改结束】——————
|
||||||
context.startService<WebService>()
|
context.startService<WebService>()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,6 +55,9 @@ class WebService : BaseService() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun stop(context: Context) {
|
fun stop(context: Context) {
|
||||||
|
// ——————【修改开始】记录关闭状态——————
|
||||||
|
appCtx.putPrefBoolean("web_service_auto", false)
|
||||||
|
// ——————【修改结束】——————
|
||||||
context.stopService<WebService>()
|
context.stopService<WebService>()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +124,12 @@ class WebService : BaseService() {
|
|||||||
@SuppressLint("WakelockTimeout")
|
@SuppressLint("WakelockTimeout")
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
when (intent?.action) {
|
when (intent?.action) {
|
||||||
IntentAction.stop -> stopSelf()
|
IntentAction.stop -> {
|
||||||
|
// ——————【修改开始】通知栏点击停止时,也记录关闭状态——————
|
||||||
|
appCtx.putPrefBoolean("web_service_auto", false)
|
||||||
|
stopSelf()
|
||||||
|
// ——————【修改结束】——————
|
||||||
|
}
|
||||||
"copyHostAddress" -> sendToClip(hostAddress)
|
"copyHostAddress" -> sendToClip(hostAddress)
|
||||||
"serve" -> if (useWakeLock) {
|
"serve" -> if (useWakeLock) {
|
||||||
wakeLock.acquire()
|
wakeLock.acquire()
|
||||||
|
|||||||
Reference in new issue
Block a user