Skip to content

Commit

Permalink
Merge branch 'compose-dev' into compose/fix/patcher-screen-process-death
Browse files Browse the repository at this point in the history
  • Loading branch information
Axelen123 committed Dec 22, 2024
2 parents c4ef7d3 + 9916e4d commit c7b8617
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.")
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/app/revanced/manager/ui/screen/PatcherScreen.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 },
Expand Down

0 comments on commit c7b8617

Please sign in to comment.