diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 3acb1c04..9aa00038 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -15,7 +15,6 @@
-
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 0e779df7..b4d1ddbc 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
@@ -9,9 +9,7 @@ import android.content.Intent
import android.content.pm.ServiceInfo
import android.graphics.drawable.Icon
import android.os.Build
-import android.os.PowerManager
import android.util.Log
-import android.view.WindowManager
import androidx.core.content.ContextCompat
import androidx.work.ForegroundInfo
import androidx.work.WorkerParameters
@@ -108,21 +106,9 @@ class PatcherWorker(
Log.d(tag, "Failed to set foreground info:", e)
}
- val wakeLock: PowerManager.WakeLock =
- (applicationContext.getSystemService(Context.POWER_SERVICE) as PowerManager)
- .newWakeLock(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, "$tag::Patcher")
- .apply {
- acquire(10 * 60 * 1000L)
- Log.d(tag, "Acquired wakelock.")
- }
-
val args = workerRepository.claimInput(this)
- return try {
- runPatcher(args)
- } finally {
- wakeLock.release()
- }
+ return runPatcher(args)
}
private suspend fun runPatcher(args: Args): Result {
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 163dfbc6..9e203e12 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.CreateDocument
@@ -25,6 +27,7 @@ import androidx.compose.material3.IconButton
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.Text
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
@@ -85,6 +88,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 },