From 249491817179048a2f630a0ef7fe87f9186f5ecb Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Fri, 2 Aug 2024 15:30:27 -0300 Subject: [PATCH] fix(self-updater): export receiver for android 13 and plus --- .../android/updater/GithubSelfUpdaterImpl.java | 8 +++++++- .../android/updater/GithubSelfUpdaterImpl.java | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/mastodon/src/github/java/org/joinmastodon/android/updater/GithubSelfUpdaterImpl.java b/mastodon/src/github/java/org/joinmastodon/android/updater/GithubSelfUpdaterImpl.java index 73ca393d84..1cf492b5f3 100644 --- a/mastodon/src/github/java/org/joinmastodon/android/updater/GithubSelfUpdaterImpl.java +++ b/mastodon/src/github/java/org/joinmastodon/android/updater/GithubSelfUpdaterImpl.java @@ -211,7 +211,13 @@ public void downloadUpdate(){ if(state==UpdateState.DOWNLOADING) throw new IllegalStateException(); DownloadManager dm=MastodonApp.context.getSystemService(DownloadManager.class); - MastodonApp.context.registerReceiver(downloadCompletionReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); + + if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.TIRAMISU){ + MastodonApp.context.registerReceiver(downloadCompletionReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE), Context.RECEIVER_EXPORTED); + }else{ + MastodonApp.context.registerReceiver(downloadCompletionReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); + } + downloadID=dm.enqueue( new DownloadManager.Request(Uri.parse(getPrefs().getString("apkURL", null))) .setDestinationUri(Uri.fromFile(getUpdateApkFile())) diff --git a/mastodon/src/nightly/java/org/joinmastodon/android/updater/GithubSelfUpdaterImpl.java b/mastodon/src/nightly/java/org/joinmastodon/android/updater/GithubSelfUpdaterImpl.java index dc546f21df..ed61487328 100644 --- a/mastodon/src/nightly/java/org/joinmastodon/android/updater/GithubSelfUpdaterImpl.java +++ b/mastodon/src/nightly/java/org/joinmastodon/android/updater/GithubSelfUpdaterImpl.java @@ -206,7 +206,13 @@ public void downloadUpdate(){ if(state==UpdateState.DOWNLOADING) throw new IllegalStateException(); DownloadManager dm=MastodonApp.context.getSystemService(DownloadManager.class); - MastodonApp.context.registerReceiver(downloadCompletionReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); + + if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.TIRAMISU){ + MastodonApp.context.registerReceiver(downloadCompletionReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE), Context.RECEIVER_EXPORTED); + }else{ + MastodonApp.context.registerReceiver(downloadCompletionReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); + } + downloadID=dm.enqueue( new DownloadManager.Request(Uri.parse(getPrefs().getString("apkURL", null))) .setDestinationUri(Uri.fromFile(getUpdateApkFile()))