From ed4d0867e8eb8755347ea9a4fb570ccfbaf582ab Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Wed, 24 Mar 2021 03:23:11 -0700 Subject: [PATCH] Make sure navigation happens on main thread Fix #4044 --- .../topjohnwu/magisk/core/download/DownloadService.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/core/download/DownloadService.kt b/app/src/main/java/com/topjohnwu/magisk/core/download/DownloadService.kt index 67eed6883..c84c3ed02 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/download/DownloadService.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/download/DownloadService.kt @@ -1,6 +1,5 @@ package com.topjohnwu.magisk.core.download -import android.annotation.SuppressLint import android.app.Notification import android.app.PendingIntent import android.content.Context @@ -15,9 +14,9 @@ import com.topjohnwu.magisk.core.download.Subject.Module import com.topjohnwu.magisk.core.intent import com.topjohnwu.magisk.ui.flash.FlashFragment import com.topjohnwu.magisk.utils.APKInstall +import com.topjohnwu.superuser.internal.UiThreadHandler import kotlin.random.Random.Default.nextInt -@SuppressLint("Registered") open class DownloadService : BaseDownloader() { private val context get() = this @@ -29,9 +28,10 @@ open class DownloadService : BaseDownloader() { private fun Module.onFinish(id: Int) = when (action) { Flash -> { - (ForegroundTracker.foreground as? BaseUIActivity<*, *>) - ?.navigation?.navigate(FlashFragment.install(file, id)) - Unit + UiThreadHandler.run { + (ForegroundTracker.foreground as? BaseUIActivity<*, *>) + ?.navigation?.navigate(FlashFragment.install(file, id)) + } } else -> Unit }