Skip to content

Commit

Permalink
Fix service restart for Android 10 and below
Browse files Browse the repository at this point in the history
  • Loading branch information
reconman committed Aug 19, 2024
1 parent 9691afe commit 102018a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ScreenshotServiceHolder @Inject constructor(
val mediaProjection =
mediaProjectionManager.getMediaProjection(Activity.RESULT_OK, token)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
// not allowed to reuse tokens on Android 14
ScriptRunnerService.mediaProjectionToken = null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class ScriptRunnerNotification @Inject constructor(
fun show(useRootForScreenshots: Boolean) {
val builder = startBuildNotification()

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
var foregroundServiceType = ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
if (!useRootForScreenshots) {
foregroundServiceType = foregroundServiceType.or(ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,12 @@ private fun toggleOverlayService(
if (vm.prefs.wantsMediaProjectionToken) {
if (ScriptRunnerService.mediaProjectionToken == null) {
startMediaProjection()
return
}
} else {
ScriptRunnerService.startService(context)
}

// if we already have a token or are using root mode
ScriptRunnerService.startService(context)
}
}

Expand Down

0 comments on commit 102018a

Please sign in to comment.