Skip to content

Commit

Permalink
Fix startup crash on devices running Android 14
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelvcaetano committed Nov 11, 2023
1 parent 638abbc commit 3dcd62c
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.content.Intent
import android.content.IntentFilter
import android.database.ContentObserver
import android.net.Uri
import android.os.Build
import androidx.core.content.getSystemService
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
Expand All @@ -32,7 +33,18 @@ class GitHubUpdateInstallManager(private val context: Context) : UpdateInstallMa
private var pendingDownloadId: Long? = null

init {
context.registerReceiver(downloadCompleteReceiver, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE))
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.registerReceiver(
downloadCompleteReceiver,
IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE),
Context.RECEIVER_EXPORTED,
)
} else {
context.registerReceiver(
downloadCompleteReceiver,
IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE),
)
}
}

override fun downloadAndInstallUpdate(update: AppUpdate): Flow<DownloadProgress> = flow {
Expand Down

0 comments on commit 3dcd62c

Please sign in to comment.