Stop using internal context of VectorLocal in CallHeadsUpActionReceiver...

This commit is contained in:
Benoit Marty 2020-08-24 15:08:52 +02:00
parent 69e9a79ac1
commit efa3aa5cf8
2 changed files with 8 additions and 16 deletions

View File

@ -21,8 +21,6 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import im.vector.app.core.di.HasVectorInjector import im.vector.app.core.di.HasVectorInjector
import im.vector.app.features.call.WebRtcPeerConnectionManager import im.vector.app.features.call.WebRtcPeerConnectionManager
import im.vector.app.features.notifications.NotificationUtils
import im.vector.app.features.settings.VectorLocale.context
import timber.log.Timber import timber.log.Timber
class CallHeadsUpActionReceiver : BroadcastReceiver() { class CallHeadsUpActionReceiver : BroadcastReceiver() {
@ -32,20 +30,14 @@ class CallHeadsUpActionReceiver : BroadcastReceiver() {
const val CALL_ACTION_REJECT = 0 const val CALL_ACTION_REJECT = 0
} }
private lateinit var peerConnectionManager: WebRtcPeerConnectionManager
private lateinit var notificationUtils: NotificationUtils
init {
val appContext = context.applicationContext
if (appContext is HasVectorInjector) {
peerConnectionManager = appContext.injector().webRtcPeerConnectionManager()
notificationUtils = appContext.injector().notificationUtils()
}
}
override fun onReceive(context: Context, intent: Intent?) { override fun onReceive(context: Context, intent: Intent?) {
val peerConnectionManager = (context.applicationContext as? HasVectorInjector)
?.injector()
?.webRtcPeerConnectionManager()
?: return
when (intent?.getIntExtra(EXTRA_CALL_ACTION_KEY, 0)) { when (intent?.getIntExtra(EXTRA_CALL_ACTION_KEY, 0)) {
CALL_ACTION_REJECT -> onCallRejectClicked() CALL_ACTION_REJECT -> onCallRejectClicked(peerConnectionManager)
} }
// Not sure why this should be needed // Not sure why this should be needed
@ -56,7 +48,7 @@ class CallHeadsUpActionReceiver : BroadcastReceiver() {
// context.stopService(Intent(context, CallHeadsUpService::class.java)) // context.stopService(Intent(context, CallHeadsUpService::class.java))
} }
private fun onCallRejectClicked() { private fun onCallRejectClicked(peerConnectionManager: WebRtcPeerConnectionManager) {
Timber.d("onCallRejectClicked") Timber.d("onCallRejectClicked")
peerConnectionManager.endCall() peerConnectionManager.endCall()
} }

View File

@ -52,7 +52,7 @@ object VectorLocale {
var applicationLocale = defaultLocale var applicationLocale = defaultLocale
private set private set
lateinit var context: Context private lateinit var context: Context
/** /**
* Init this object * Init this object