From 8e65abd2586fb351fdf6a98fd772bfb715fec434 Mon Sep 17 00:00:00 2001 From: jacquarg Date: Fri, 26 Jul 2024 17:06:00 +0200 Subject: [PATCH] feat:2376: Fix registerReceiver for Android 14 compatibility. --- build.gradle | 4 +--- .../java/org/torproject/android/service/OrbotService.java | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index dc9a986..de111fe 100644 --- a/build.gradle +++ b/build.gradle @@ -4,11 +4,9 @@ apply from : '../dependencies.gradle' apply from : '../exportdependencies/publish.gradle' android { - ndkVersion '21.3.6528147' - defaultConfig { minSdkVersion 24 - targetSdkVersion 33 + targetSdkVersion 34 } buildTypes { diff --git a/src/main/java/org/torproject/android/service/OrbotService.java b/src/main/java/org/torproject/android/service/OrbotService.java index f1b86e9..16a4107 100644 --- a/src/main/java/org/torproject/android/service/OrbotService.java +++ b/src/main/java/org/torproject/android/service/OrbotService.java @@ -87,6 +87,7 @@ import IPtProxy.IPtProxy; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import androidx.core.app.NotificationCompat; +import androidx.core.content.ContextCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager; @SuppressWarnings("StringConcatenationInsideStringBufferAppend") @@ -574,7 +575,7 @@ public class OrbotService extends VpnService implements OrbotConstants { filter.addAction(LOCAL_ACTION_NOTIFICATION_START); mActionBroadcastReceiver = new ActionBroadcastReceiver(); - registerReceiver(mActionBroadcastReceiver, filter); + ContextCompat.registerReceiver(this, mActionBroadcastReceiver, filter, ContextCompat.RECEIVER_NOT_EXPORTED); mIsServiceRunningBroadcastReceiver = new IsServiceRunningBroadcastReceiver(); LocalBroadcastManager.getInstance(this).registerReceiver( -- GitLab