pull/2498/head
kunfei 2 years ago
parent ebe681d7e3
commit d07fdeec9a
  1. 11
      app/src/main/java/io/legado/app/service/WebService.kt

@ -1,6 +1,5 @@
package io.legado.app.service package io.legado.app.service
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Build import android.os.Build
@ -18,7 +17,6 @@ import io.legado.app.web.HttpServer
import io.legado.app.web.WebSocketServer import io.legado.app.web.WebSocketServer
import splitties.init.appCtx import splitties.init.appCtx
import splitties.systemservices.powerManager import splitties.systemservices.powerManager
import java.io.IOException import java.io.IOException
class WebService : BaseService() { class WebService : BaseService() {
@ -56,12 +54,9 @@ class WebService : BaseService() {
NetworkChangedListener(this) NetworkChangedListener(this)
} }
@SuppressLint("WakelockTimeout")
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
if (useWakeLock) { if (useWakeLock) wakeLock.acquire(10 * 60 * 1000L /*10 minutes*/)
wakeLock.acquire()
}
isRun = true isRun = true
notificationContent = getString(R.string.service_starting) notificationContent = getString(R.string.service_starting)
upNotification() upNotification()
@ -94,9 +89,7 @@ class WebService : BaseService() {
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
if (useWakeLock) { if (useWakeLock) wakeLock.release()
wakeLock.release()
}
networkChangedListener.unRegister() networkChangedListener.unRegister()
isRun = false isRun = false
if (httpServer?.isAlive == true) { if (httpServer?.isAlive == true) {

Loading…
Cancel
Save