Fix API 34 compatibility

This commit is contained in:
Oscar Mira 2024-09-04 13:44:10 +02:00
parent d7e9fa7721
commit 8a1bdc4bc2
No known key found for this signature in database
GPG key ID: B371B98C5DC32237
4 changed files with 17 additions and 41 deletions

View file

@ -1085,11 +1085,6 @@
android:name=".service.KeyCachingService"
android:foregroundServiceType="remoteMessaging"/>
<service
android:enabled="true"
android:exported="false"
android:name=".service.WipeMemoryService" />
<service
android:enabled="true"
android:name=".messages.IncomingMessageObserver$ForegroundService"
@ -1168,6 +1163,11 @@
<!-- MOLLY: FcmReceiveService moved to gms/AndroidManifest.xml -->
<service
android:name=".service.WipeMemoryService"
android:exported="false"
android:foregroundServiceType="remoteMessaging" />
<receiver android:name=".notifications.MarkReadReceiver"
android:enabled="true"
android:exported="false">

View file

@ -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;
}

View file

@ -21,6 +21,6 @@ android {
dependencies {
implementation project(':core-util')
implementation libs.androidx.annotation
implementation libs.androidx.fragment
lintChecks project(':lintchecks')
}

View file

@ -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.
* <p>
* 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.
* <p>
* 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) {