Fixed call duration timer when leaving & resuming active call fragment

This commit is contained in:
Sylvain Berfini 2023-09-22 17:33:27 +02:00
parent 46e06f2c9d
commit 913e7cdb02
4 changed files with 14 additions and 4 deletions

View file

@ -325,7 +325,7 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
@WorkerThread
fun terminateCall(call: Call) {
Log.i("$TAG Terminating call $call")
Log.i("$TAG Terminating call [${call.remoteAddress.asStringUriOnly()}]")
call.terminate()
}

View file

@ -218,7 +218,7 @@ class TelecomCallControlCallback constructor(
override suspend fun onDisconnect(disconnectCause: DisconnectCause): Boolean {
Log.i("$TAG We're asked to terminate the call with reason [$disconnectCause]")
coreContext.postOnCoreThread {
Log.i("$TAG Terminating call")
Log.i("$TAG Terminating call [${call.remoteAddress.asStringUriOnly()}]")
call.terminate() // TODO: use cause
}
return true

View file

@ -219,6 +219,9 @@ class ActiveCallFragment : GenericCallFragment() {
core.nativeVideoWindowId = binding.remoteVideoSurface
coreContext.core.nativePreviewWindowId = binding.localPreviewVideoSurface
binding.localPreviewVideoSurface.setOnTouchListener(previewTouchListener)
// Need to be done manually
callViewModel.updateCallDuration()
}
}

View file

@ -150,7 +150,7 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
if (currentCall != null) {
call = currentCall
Log.i("$TAG Found call [$call]")
Log.i("$TAG Found call [${call.remoteAddress.asStringUriOnly()}]")
configureCall(call)
} else {
Log.e("$TAG Failed to find call!")
@ -185,7 +185,7 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
fun hangUp() {
coreContext.postOnCoreThread {
if (::call.isInitialized) {
Log.i("$TAG Terminating call [$call]")
Log.i("$TAG Terminating call [${call.remoteAddress.asStringUriOnly()}]")
call.terminate()
}
}
@ -421,6 +421,13 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
callDuration.postValue(call.duration)
}
@WorkerThread
fun updateCallDuration() {
if (::call.isInitialized) {
callDuration.postValue(call.duration)
}
}
private fun updateOutputAudioDevice(audioDevice: AudioDevice?) {
isSpeakerEnabled.postValue(audioDevice?.type == AudioDevice.Type.Speaker)
isHeadsetEnabled.postValue(