Fix state exception by always starting call service in foreground.

This commit is contained in:
Cody Henthorne
2021-04-02 14:59:15 -04:00
parent c4d317b33e
commit f332cbf1bc
11 changed files with 70 additions and 18 deletions

View File

@@ -11,6 +11,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import androidx.core.app.NotificationCompat;
import org.thoughtcrime.securesms.MainActivity;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.WebRtcCallActivity;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
@@ -79,6 +80,24 @@ public class CallNotificationBuilder {
}
}
public static @NonNull Notification getStoppingNotification(@NonNull Context context) {
Intent contentIntent = new Intent(context, MainActivity.class);
contentIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, contentIntent, 0);
return new NotificationCompat.Builder(context, NotificationChannels.OTHER).setSmallIcon(R.drawable.ic_call_secure_white_24dp)
.setContentIntent(pendingIntent)
.setOngoing(true)
.setContentTitle(context.getString(R.string.NotificationBarManager__stopping_signal_call_service))
.setPriority(NotificationCompat.PRIORITY_MIN)
.build();
}
public static int getStoppingNotificationId() {
return WEBRTC_NOTIFICATION;
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public static boolean isWebRtcNotification(int notificationId) {
return notificationId == WEBRTC_NOTIFICATION || notificationId == WEBRTC_NOTIFICATION_RINGING;