Commit ed4d0867 authored by topjohnwu's avatar topjohnwu

Make sure navigation happens on main thread

Fix #4044
parent 1c71e024
package com.topjohnwu.magisk.core.download package com.topjohnwu.magisk.core.download
import android.annotation.SuppressLint
import android.app.Notification import android.app.Notification
import android.app.PendingIntent import android.app.PendingIntent
import android.content.Context import android.content.Context
...@@ -15,9 +14,9 @@ import com.topjohnwu.magisk.core.download.Subject.Module ...@@ -15,9 +14,9 @@ import com.topjohnwu.magisk.core.download.Subject.Module
import com.topjohnwu.magisk.core.intent import com.topjohnwu.magisk.core.intent
import com.topjohnwu.magisk.ui.flash.FlashFragment import com.topjohnwu.magisk.ui.flash.FlashFragment
import com.topjohnwu.magisk.utils.APKInstall import com.topjohnwu.magisk.utils.APKInstall
import com.topjohnwu.superuser.internal.UiThreadHandler
import kotlin.random.Random.Default.nextInt import kotlin.random.Random.Default.nextInt
@SuppressLint("Registered")
open class DownloadService : BaseDownloader() { open class DownloadService : BaseDownloader() {
private val context get() = this private val context get() = this
...@@ -29,9 +28,10 @@ open class DownloadService : BaseDownloader() { ...@@ -29,9 +28,10 @@ open class DownloadService : BaseDownloader() {
private fun Module.onFinish(id: Int) = when (action) { private fun Module.onFinish(id: Int) = when (action) {
Flash -> { Flash -> {
(ForegroundTracker.foreground as? BaseUIActivity<*, *>) UiThreadHandler.run {
?.navigation?.navigate(FlashFragment.install(file, id)) (ForegroundTracker.foreground as? BaseUIActivity<*, *>)
Unit ?.navigation?.navigate(FlashFragment.install(file, id))
}
} }
else -> Unit else -> Unit
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment