diff --git a/app/src/main/java/app/revanced/manager/patcher/worker/PatcherWorker.kt b/app/src/main/java/app/revanced/manager/patcher/worker/PatcherWorker.kt index 0e63fbbd7c..5096170caa 100644 --- a/app/src/main/java/app/revanced/manager/patcher/worker/PatcherWorker.kt +++ b/app/src/main/java/app/revanced/manager/patcher/worker/PatcherWorker.kt @@ -13,7 +13,6 @@ import android.os.Build import android.os.Parcelable import android.os.PowerManager import android.util.Log -import android.view.WindowManager import androidx.activity.result.ActivityResult import androidx.core.content.ContextCompat import androidx.work.ForegroundInfo @@ -122,7 +121,7 @@ class PatcherWorker( val wakeLock: PowerManager.WakeLock = (applicationContext.getSystemService(Context.POWER_SERVICE) as PowerManager) - .newWakeLock(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, "$tag::Patcher") + .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "$tag::Patcher") .apply { acquire(10 * 60 * 1000L) Log.d(tag, "Acquired wakelock.") diff --git a/app/src/main/java/app/revanced/manager/ui/screen/PatcherScreen.kt b/app/src/main/java/app/revanced/manager/ui/screen/PatcherScreen.kt index e193d6fa85..d2195e9683 100644 --- a/app/src/main/java/app/revanced/manager/ui/screen/PatcherScreen.kt +++ b/app/src/main/java/app/revanced/manager/ui/screen/PatcherScreen.kt @@ -1,5 +1,7 @@ package app.revanced.manager.ui.screen +import android.app.Activity +import android.view.WindowManager import androidx.activity.compose.BackHandler import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts @@ -15,6 +17,7 @@ import androidx.compose.material.icons.outlined.PostAdd import androidx.compose.material.icons.outlined.Save import androidx.compose.material3.* import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState @@ -65,6 +68,16 @@ fun PatcherScreen( } } + if (patcherSucceeded == null) { + DisposableEffect(Unit) { + val window = (context as Activity).window + window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) + onDispose { + window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) + } + } + } + if (showInstallPicker) InstallPickerDialog( onDismiss = { showInstallPicker = false },