Skip to content

Commit

Permalink
Fix BroadcastReceiver ANR
Browse files Browse the repository at this point in the history
  • Loading branch information
FranAguilera committed Dec 18, 2024
1 parent 02d0d8b commit c908c11
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ class ScreenOffTrigger(
context: Context,
intent: Intent
) {
if (intent.action == ACTION_SCREEN_OFF) {
if (currentJob == null) {
val job =
analysisClient.newJob(JobContext(ScreenOffTrigger::class))
currentJob = job
analysisExecutor.execute {
analysisExecutor.execute {
if (intent.action == ACTION_SCREEN_OFF) {
if (currentJob == null) {
val job =
analysisClient.newJob(JobContext(ScreenOffTrigger::class))
currentJob = job
val result = job.execute()
currentJob = null
analysisCallback(result)
}
} else {
currentJob?.cancel("screen on again")
currentJob = null
}
} else {
currentJob?.cancel("screen on again")
currentJob = null
}
}
}
Expand Down

0 comments on commit c908c11

Please sign in to comment.