Skip to content

Commit

Permalink
Don't reuse MediaProjection tokens on Android 14
Browse files Browse the repository at this point in the history
  • Loading branch information
reconman committed Aug 15, 2024
1 parent e603d01 commit daba563
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.github.fate_grand_automata.runner
import android.app.Activity
import android.content.Intent
import android.media.projection.MediaProjectionManager
import android.os.Build
import dagger.hilt.android.scopes.ServiceScoped
import io.github.fate_grand_automata.imaging.MediaProjectionScreenshotService
import io.github.fate_grand_automata.root.RootScreenshotService
Expand Down Expand Up @@ -55,6 +56,11 @@ class ScreenshotServiceHolder @Inject constructor(
val mediaProjection =
mediaProjectionManager.getMediaProjection(Activity.RESULT_OK, token)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
// not allowed to reuse tokens on Android 14
ScriptRunnerService.mediaProjectionToken = null
}

val scaledSize = size * (scale ?: 1.0)
val scaledDensity = (landscapeMetrics.densityDpi / (scale ?: 1.0)).roundToInt()

Expand Down

0 comments on commit daba563

Please sign in to comment.