From c622c7f957e4df1d403f1ec2e943544df191122d Mon Sep 17 00:00:00 2001 From: iSmartCoding Date: Mon, 4 Mar 2024 17:11:49 +0800 Subject: [PATCH] remove wake lock --- .../com/ismartcoding/plain/services/HttpServerService.kt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/ismartcoding/plain/services/HttpServerService.kt b/app/src/main/java/com/ismartcoding/plain/services/HttpServerService.kt index acf70e3b..412a744d 100644 --- a/app/src/main/java/com/ismartcoding/plain/services/HttpServerService.kt +++ b/app/src/main/java/com/ismartcoding/plain/services/HttpServerService.kt @@ -1,7 +1,6 @@ package com.ismartcoding.plain.services import android.content.pm.ServiceInfo -import android.os.PowerManager import androidx.core.app.ServiceCompat import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver @@ -19,16 +18,15 @@ import com.ismartcoding.plain.api.HttpClientManager import com.ismartcoding.plain.features.StartHttpServerStateEvent import com.ismartcoding.plain.helpers.NotificationHelper import com.ismartcoding.plain.helpers.UrlHelper -import com.ismartcoding.plain.powerManager import com.ismartcoding.plain.web.HttpServerManager import io.ktor.client.plugins.websocket.ws import io.ktor.client.request.get import io.ktor.client.statement.bodyAsText import io.ktor.http.HttpStatusCode +import kotlinx.coroutines.ExperimentalCoroutinesApi class HttpServerService : LifecycleService() { - private var wakeLock: PowerManager.WakeLock? = null override fun onCreate() { super.onCreate() NotificationHelper.ensureDefaultChannel() @@ -60,11 +58,10 @@ class HttpServerService : LifecycleService() { }) } + @OptIn(ExperimentalCoroutinesApi::class) private suspend fun startHttpServerAsync() { LogCat.d("startHttpServer") try { - wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "${BuildConfig.APPLICATION_ID}:http_server") - wakeLock?.acquire() HttpServerManager.portsInUse.clear() HttpServerManager.stoppedByUser = false HttpServerManager.httpServerError = "" @@ -112,7 +109,6 @@ class HttpServerService : LifecycleService() { override fun onDestroy() { super.onDestroy() stopForeground(STOP_FOREGROUND_REMOVE) - wakeLock?.release() } private suspend fun stopHttpServerAsync() {