mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
Fix crash in ActiveCallManager for lower Android versions.
This commit is contained in:
@@ -11,11 +11,17 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.net.ConnectivityManager
|
||||
import android.os.Build
|
||||
import android.telephony.PhoneStateListener
|
||||
import android.telephony.TelephonyManager
|
||||
import androidx.annotation.MainThread
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import androidx.core.os.bundleOf
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.core.Single
|
||||
import io.reactivex.rxjava3.disposables.Disposable
|
||||
import io.reactivex.rxjava3.kotlin.subscribeBy
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import org.signal.core.util.ThreadUtil
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
@@ -190,6 +196,7 @@ class ActiveCallManager(
|
||||
|
||||
private var hangUpRtcOnDeviceCallAnswered: PhoneStateListener? = null
|
||||
private var notification: Notification? = null
|
||||
private var notificationDisposable: Disposable = Disposable.disposed()
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
@@ -205,6 +212,8 @@ class ActiveCallManager(
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
notificationDisposable.dispose()
|
||||
|
||||
super.onDestroy()
|
||||
|
||||
if (!AndroidTelecomUtil.telecomSupported) {
|
||||
@@ -219,20 +228,37 @@ class ActiveCallManager(
|
||||
return CallNotificationBuilder.getStoppingNotification(this)
|
||||
}
|
||||
|
||||
val recipientId: RecipientId = intent.getParcelableExtra(EXTRA_RECIPIENT_ID)!!
|
||||
val recipient: Recipient = Recipient.resolved(intent.getParcelableExtra(EXTRA_RECIPIENT_ID)!!)
|
||||
val isVideoCall = intent.getBooleanExtra(EXTRA_IS_VIDEO_CALL, false)
|
||||
val requiresAsyncNotificationLoad = Build.VERSION.SDK_INT <= 29
|
||||
|
||||
notification = CallNotificationBuilder.getCallInProgressNotification(
|
||||
this,
|
||||
CallNotificationBuilder.TYPE_ESTABLISHED,
|
||||
Recipient.resolved(recipientId),
|
||||
isVideoCall,
|
||||
false
|
||||
)
|
||||
notification = createNotification(recipient, isVideoCall, skipAvatarLoad = requiresAsyncNotificationLoad)
|
||||
|
||||
if (requiresAsyncNotificationLoad) {
|
||||
notificationDisposable = Single.fromCallable { createNotification(recipient, isVideoCall, skipAvatarLoad = false) }
|
||||
.observeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeBy {
|
||||
notification = it
|
||||
if (NotificationManagerCompat.from(this).activeNotifications.any { n -> n.id == notificationId }) {
|
||||
NotificationManagerCompat.from(application).notify(notificationId, notification!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return notification!!
|
||||
}
|
||||
|
||||
private fun createNotification(recipient: Recipient, isVideoCall: Boolean, skipAvatarLoad: Boolean): Notification {
|
||||
return CallNotificationBuilder.getCallInProgressNotification(
|
||||
this,
|
||||
CallNotificationBuilder.TYPE_ESTABLISHED,
|
||||
recipient,
|
||||
isVideoCall,
|
||||
skipAvatarLoad
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("deprecation")
|
||||
private class HangUpRtcOnPstnCallAnsweredListener : PhoneStateListener() {
|
||||
override fun onCallStateChanged(state: Int, phoneNumber: String) {
|
||||
|
||||
@@ -117,7 +117,7 @@ public final class FeatureFlags {
|
||||
private static final String CALLING_REACTIONS = "android.calling.reactions";
|
||||
private static final String NOTIFICATION_THUMBNAIL_BLOCKLIST = "android.notificationThumbnailProductBlocklist";
|
||||
private static final String CALLING_RAISE_HAND = "android.calling.raiseHand";
|
||||
private static final String USE_ACTIVE_CALL_MANAGER = "android.calling.useActiveCallManager.2";
|
||||
private static final String USE_ACTIVE_CALL_MANAGER = "android.calling.useActiveCallManager.3";
|
||||
private static final String GIF_SEARCH = "global.gifSearch";
|
||||
private static final String AUDIO_REMUXING = "android.media.audioRemux";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user