Prevent calls crashing due to background restrictions.

This commit is contained in:
Cody Henthorne
2025-01-10 13:51:53 -05:00
committed by Greyson Parrelli
parent a63fd5a584
commit 919648b94b
3 changed files with 15 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
/**
* Easy access to various properties of the device, typically to make performance-related decisions.
@@ -65,6 +66,13 @@ public final class DeviceProperties {
return info;
}
public static boolean isBackgroundRestricted() {
if (Build.VERSION.SDK_INT >= 28) {
return isBackgroundRestricted(AppDependencies.getApplication());
}
return false;
}
@RequiresApi(28)
public static boolean isBackgroundRestricted(@NonNull Context context) {
ActivityManager activityManager = ServiceUtil.getActivityManager(context);