Skip to content

Commit

Permalink
remove wake lock
Browse files Browse the repository at this point in the history
  • Loading branch information
ismartcoding committed Mar 4, 2024
1 parent 942a215 commit c622c7f
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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 = ""
Expand Down Expand Up @@ -112,7 +109,6 @@ class HttpServerService : LifecycleService() {
override fun onDestroy() {
super.onDestroy()
stopForeground(STOP_FOREGROUND_REMOVE)
wakeLock?.release()
}

private suspend fun stopHttpServerAsync() {
Expand Down

0 comments on commit c622c7f

Please sign in to comment.