kunfei 4 лет назад
Родитель
Сommit
05674305a1
1 измененных файлов с 2 добавлено и 9 удалено
  1. 2 9
      app/src/main/java/io/legado/app/service/WebService.kt

+ 2 - 9
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) {
-            wakeLock.acquire()
-        }
+        if (useWakeLock) wakeLock.acquire(10 * 60 * 1000L /*10 minutes*/)
         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) {
-            wakeLock.release()
-        }
+        if (useWakeLock) wakeLock.release()
         networkChangedListener.unRegister()
         networkChangedListener.unRegister()
         isRun = false
         isRun = false
         if (httpServer?.isAlive == true) {
         if (httpServer?.isAlive == true) {