diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/ActiveCallManager.kt b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/ActiveCallManager.kt index 4753906de6..95b6f7bb03 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/ActiveCallManager.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/ActiveCallManager.kt @@ -35,6 +35,7 @@ import org.thoughtcrime.securesms.permissions.Permissions import org.thoughtcrime.securesms.recipients.Recipient import org.thoughtcrime.securesms.recipients.RecipientId import org.thoughtcrime.securesms.service.SafeForegroundService +import org.thoughtcrime.securesms.util.DeviceProperties import org.thoughtcrime.securesms.util.TelephonyUtil import org.thoughtcrime.securesms.webrtc.CallNotificationBuilder import org.thoughtcrime.securesms.webrtc.UncaughtExceptionHandlerManager @@ -147,6 +148,8 @@ class ActiveCallManager( private var previousNotificationDisposable = Disposable.disposed() init { + Log.i(TAG, "init(bkgRestricted: ${DeviceProperties.isBackgroundRestricted()})") + registerUncaughtExceptionHandler() registerNetworkReceiver() @@ -266,6 +269,8 @@ class ActiveCallManager( /** Foreground service started only after a call is established */ class ActiveCallForegroundService : SafeForegroundService() { companion object { + private const val TAG = "ActiveCallService" + private const val EXTRA_RECIPIENT_ID = "RECIPIENT_ID" private const val EXTRA_IS_VIDEO_CALL = "IS_VIDEO_CALL" private const val EXTRA_TYPE = "TYPE" diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/DeviceProperties.java b/app/src/main/java/org/thoughtcrime/securesms/util/DeviceProperties.java index 8722a14082..e43eb4f134 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/DeviceProperties.java +++ b/app/src/main/java/org/thoughtcrime/securesms/util/DeviceProperties.java @@ -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); diff --git a/app/src/main/java/org/thoughtcrime/securesms/webrtc/CallNotificationBuilder.java b/app/src/main/java/org/thoughtcrime/securesms/webrtc/CallNotificationBuilder.java index a28d58bb7d..4791f7aec2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/webrtc/CallNotificationBuilder.java +++ b/app/src/main/java/org/thoughtcrime/securesms/webrtc/CallNotificationBuilder.java @@ -20,6 +20,7 @@ import org.thoughtcrime.securesms.notifications.NotificationChannels; import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.service.webrtc.ActiveCallManager; import org.thoughtcrime.securesms.util.ConversationUtil; +import org.thoughtcrime.securesms.util.DeviceProperties; /** * Manages the state of the WebRtc items in the Android notification bar. @@ -232,6 +233,6 @@ public class CallNotificationBuilder { } private static boolean deviceVersionSupportsIncomingCallStyle() { - return Build.VERSION.SDK_INT >= API_LEVEL_CALL_STYLE; + return Build.VERSION.SDK_INT >= API_LEVEL_CALL_STYLE && !DeviceProperties.isBackgroundRestricted(); } }