From 8a1bdc4bc265772387ed561ccfa5bc34e087a3ec Mon Sep 17 00:00:00 2001 From: Oscar Mira Date: Wed, 4 Sep 2024 13:44:10 +0200 Subject: [PATCH] Fix API 34 compatibility --- app/src/main/AndroidManifest.xml | 10 ++--- .../securesms/service/WipeMemoryService.java | 7 ++++ libnetcipher/build.gradle | 2 +- .../netcipher/proxy/OrbotHelper.java | 39 ++----------------- 4 files changed, 17 insertions(+), 41 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 23508d808f..31abecc782 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1085,11 +1085,6 @@ android:name=".service.KeyCachingService" android:foregroundServiceType="remoteMessaging"/> - - + + diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/WipeMemoryService.java b/app/src/main/java/org/thoughtcrime/securesms/service/WipeMemoryService.java index 17a23ff6d1..07b3da38ce 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/WipeMemoryService.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/WipeMemoryService.java @@ -182,6 +182,13 @@ public class WipeMemoryService extends IntentService { super.onLowMemory(); } + @Override + public void onTimeout(int startId) { + notifyLowMemory(); + Log.i(TAG, "onTimeout()"); + super.onTimeout(startId); + } + private void notifyLowMemory() { lowMemory = true; } diff --git a/libnetcipher/build.gradle b/libnetcipher/build.gradle index 310b0c1da6..17e4b8a3db 100644 --- a/libnetcipher/build.gradle +++ b/libnetcipher/build.gradle @@ -21,6 +21,6 @@ android { dependencies { implementation project(':core-util') - implementation libs.androidx.annotation + implementation libs.androidx.fragment lintChecks project(':lintchecks') } diff --git a/libnetcipher/src/main/java/info/guardianproject/netcipher/proxy/OrbotHelper.java b/libnetcipher/src/main/java/info/guardianproject/netcipher/proxy/OrbotHelper.java index b90a70c83d..6a768d4223 100644 --- a/libnetcipher/src/main/java/info/guardianproject/netcipher/proxy/OrbotHelper.java +++ b/libnetcipher/src/main/java/info/guardianproject/netcipher/proxy/OrbotHelper.java @@ -31,6 +31,7 @@ import android.os.Looper; import android.text.TextUtils; import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; import org.signal.core.util.logging.Log; @@ -511,8 +512,9 @@ public class OrbotHelper implements ProxyHelper { if (orbot != null) { isInstalled = true; handler.postDelayed(onStatusTimeout, statusTimeoutMs); - context.registerReceiver(orbotStatusReceiver, - new IntentFilter(OrbotHelper.ACTION_STATUS)); + ContextCompat.registerReceiver(context, orbotStatusReceiver, + new IntentFilter(OrbotHelper.ACTION_STATUS), + ContextCompat.RECEIVER_EXPORTED); context.sendBroadcast(orbot); } else { isInstalled = false; @@ -525,39 +527,6 @@ public class OrbotHelper implements ProxyHelper { return (isInstalled); } - /** - * Given that init() returned false, calling installOrbot() - * will trigger an attempt to install Orbot from an available - * distribution channel (e.g., the Play Store). Only call this - * if the user is expecting it, such as in response to tapping - * a dialog button or an action bar item. - *

- * Note that installation may take a long time, even if - * the user is proceeding with the installation, due to network - * speeds, waiting for user input, and so on. Either specify - * a long timeout, or consider the timeout to be merely advisory - * and use some other user input to cause you to try - * init() again after, presumably, Orbot has been installed - * and configured by the user. - *

- * If the user does install Orbot, we will attempt init() - * again automatically. Hence, you will probably need user input - * to tell you when the user has gotten Orbot up and going. - * - * @param host the Activity that is triggering this work - */ - public void installOrbot(Activity host) { - handler.postDelayed(onInstallTimeout, installTimeoutMs); - - IntentFilter filter = - new IntentFilter(Intent.ACTION_PACKAGE_ADDED); - - filter.addDataScheme("package"); - - context.registerReceiver(orbotInstallReceiver, filter); - host.startActivity(OrbotHelper.getOrbotInstallIntent(context)); - } - private BroadcastReceiver orbotStatusReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) {