Skip to content

Commit

Permalink
Merge branch 'release/2.13.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
yostyle committed Nov 16, 2024
2 parents d317599 + 32a437c commit e4d5055
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 28 deletions.
10 changes: 4 additions & 6 deletions TCHAP_CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
Changes in Tchap 2.13.11 (2024-11-15)
Changes in Tchap 2.13.11 (2024-11-16)
=====================================

No significant changes.
Bugfixes 🐛
----------
- Correction du crash quand on reçoit ou émet un appel sur Tchap. ([#1126](https://github.com/tchapgouv/tchap-android/issues/1126))

Changes in Tchap 2.13.10 (2024-11-15)
=====================================
Expand All @@ -10,10 +12,6 @@ Improvements 🙌
--------------
- Modification du commentaire lorsqu'on active l'accès à un salon par lien. ([#1112](https://github.com/tchapgouv/tchap-android/issues/1112))

Bugfixes 🐛
----------
- Correction du crash quand on reçoit ou émet un appel sur Tchap. ([#1126](https://github.com/tchapgouv/tchap-android/issues/1126))

Changes in Tchap 2.13.9 (2024-11-12)
====================================

Expand Down
2 changes: 1 addition & 1 deletion vector-config/src/tchap/res/values/config-features.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<bool name="tchap_is_cross_signing_enabled">true</bool>
<bool name="tchap_is_key_backup_enabled">true</bool>
<bool name="tchap_is_thread_enabled">false</bool>
<bool name="tchap_is_secure_backup_required">true</bool>
<bool name="tchap_is_secure_backup_required">false</bool>

<string-array name="tchap_is_visio_supported_homeservers" translatable="false">
<item>agent.dinum.tchap.gouv.fr</item>
Expand Down
4 changes: 3 additions & 1 deletion vector/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@

<!-- For CallAndroidService -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />

<!-- For VectorSyncAndroidService -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
Expand All @@ -58,6 +57,9 @@
<!-- Jitsi SDK is now API23+ -->
<uses-sdk tools:overrideLibrary="com.swmansion.gesturehandler,org.jitsi.meet.sdk,com.oney.WebRTCModule,com.learnium.RNDeviceInfo,com.reactnativecommunity.asyncstorage,com.ocetnik.timer,com.calendarevents,com.reactnativecommunity.netinfo,com.kevinresol.react_native_default_preference,com.rnimmersive,com.corbt.keepawake,com.BV.LinearGradient,com.horcrux.svg,com.oblador.performance,com.reactnativecommunity.slider,com.brentvatne.react,com.reactnativecommunity.clipboard,com.swmansion.gesturehandler.react,org.linusu,org.reactnative.maskedview,com.reactnativepagerview,com.swmansion.reanimated,com.th3rdwave.safeareacontext,com.swmansion.rnscreens,org.devio.rn.splashscreen,com.reactnativecommunity.webview,org.wonday.orientation" />

<!-- For MicrophoneAccessService -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />

<!-- Tchap: Jitsi libs adds CALENDAR permissions, but we can remove them safely
according to https://github.com/jitsi/jitsi-meet/issues/4068#issuecomment-480482481 -->
<uses-permission android:name="android.permission.READ_CALENDAR" tools:node="remove" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,11 @@ class CallAndroidService : VectorAndroidService() {
title = callInformation.opponentMatrixItem?.getBestName() ?: callInformation.opponentUserId,
fromBg = fromBg
)
// TCHAP fix crash when a call incoming on Androd 14 and higher
notificationManager.notify(callId.hashCode(), notification)
if (knownCalls.isEmpty()) {
startForegroundCompat(callId.hashCode(), notification)
} else {
notificationManager.notify(callId.hashCode(), notification)
}
knownCalls[callId] = callInformation
}

Expand All @@ -200,8 +203,7 @@ class CallAndroidService : VectorAndroidService() {
}
val notification = notificationUtils.buildCallEndedNotification(false)
val notificationId = callId.hashCode()
// TCHAP fix crash when a call incoming on Androd 14 and higher
notificationManager.notify(notificationId, notification)
startForegroundCompat(notificationId, notification)
if (knownCalls.isEmpty()) {
Timber.tag(loggerTag.value).v("No more call, stop the service")
stopForegroundCompat()
Expand Down Expand Up @@ -262,8 +264,11 @@ class CallAndroidService : VectorAndroidService() {
call = call,
title = callInformation.opponentMatrixItem?.getBestName() ?: callInformation.opponentUserId
)
// TCHAP fix crash when a call incoming on Androd 14 and higher
startForegroundCompat(callId.hashCode(), notification)
if (knownCalls.isEmpty()) {
startForegroundCompat(callId.hashCode(), notification)
} else {
notificationManager.notify(callId.hashCode(), notification)
}
knownCalls[callId] = callInformation
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.core.extensions.startForegroundCompat
import im.vector.app.core.services.VectorAndroidService
import im.vector.app.features.notifications.NotificationUtils
import im.vector.lib.core.utils.timer.Clock
import javax.inject.Inject

@AndroidEntryPoint
class MicrophoneAccessService : VectorAndroidService() {

@Inject lateinit var notificationUtils: NotificationUtils
@Inject lateinit var clock: Clock
private val binder = LocalBinder()

override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
Expand All @@ -38,7 +40,7 @@ class MicrophoneAccessService : VectorAndroidService() {
}

private fun showMicrophoneAccessNotification() {
val notificationId = System.currentTimeMillis().toInt()
val notificationId = clock.epochMillis().toInt()
val notification = notificationUtils.buildMicrophoneAccessNotification()
startForegroundCompat(notificationId, notification)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,26 +251,24 @@ class VectorCallActivity :
}

private fun startMicrophoneService() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO)
== PackageManager.PERMISSION_GRANTED) {

// Only start the service if the app is in the foreground
if (isAppInForeground()) {
Timber.tag(loggerTag.value).v("Starting microphone foreground service")
val intent = Intent(this, MicrophoneAccessService::class.java)
ContextCompat.startForegroundService(this, intent)
} else {
Timber.tag(loggerTag.value).v("App is not in foreground; cannot start microphone service")
}
} else {
Timber.tag(loggerTag.value).v("Microphone permission not granted; cannot start service")
val isConnected = withState(callViewModel) {
val callState = it.callState.invoke()
callState is CallState.Connected
}
if (!isAppInForeground()) return
if (!isConnected) return
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_DENIED) return

Timber.tag(loggerTag.value).d("Starting microphone foreground service")
val intent = Intent(this, MicrophoneAccessService::class.java)
ContextCompat.startForegroundService(this, intent)
}

private fun isAppInForeground(): Boolean {
val appProcess = ProcessLifecycleOwner.get().lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)
return appProcess
}

private fun stopMicrophoneService() {
Timber.tag(loggerTag.value).d("Stopping MicrophoneAccessService (if needed).")
val intent = Intent(this, MicrophoneAccessService::class.java)
Expand All @@ -292,6 +290,7 @@ class VectorCallActivity :
turnScreenOffAndKeyguardOn()
removeOnPictureInPictureModeChangedListener(pictureInPictureModeChangedInfoConsumer)
screenCaptureServiceConnection.unbind()
stopMicrophoneService()
super.onDestroy()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@

package im.vector.app.features.call

import android.Manifest
import android.app.Activity
import android.app.KeyguardManager
import android.app.PictureInPictureParams
import android.content.Context
import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP
import android.content.pm.PackageManager
import android.graphics.Color
import android.media.projection.MediaProjection
import android.media.projection.MediaProjectionManager
Expand All @@ -40,6 +42,8 @@ import androidx.core.content.getSystemService
import androidx.core.util.Consumer
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.ProcessLifecycleOwner
import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.Mavericks
import com.airbnb.mvrx.viewModel
Expand All @@ -57,6 +61,7 @@ import im.vector.app.core.utils.PERMISSIONS_FOR_VIDEO_IP_CALL
import im.vector.app.core.utils.checkPermissions
import im.vector.app.core.utils.registerForPermissionsResult
import im.vector.app.databinding.ActivityCallBinding
import im.vector.app.features.call.audio.MicrophoneAccessService
import im.vector.app.features.call.dialpad.CallDialPadBottomSheet
import im.vector.app.features.call.dialpad.DialPadFragment
import im.vector.app.features.call.transfer.CallTransferActivity
Expand Down Expand Up @@ -245,11 +250,47 @@ class VectorCallActivity :
}
}

private fun startMicrophoneService() {
val isConnected = withState(callViewModel) {
val callState = it.callState.invoke()
callState is CallState.Connected
}
if (!isAppInForeground()) return
if (!isConnected) return
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_DENIED) return

Timber.tag(loggerTag.value).d("Starting microphone foreground service")
val intent = Intent(this, MicrophoneAccessService::class.java)
ContextCompat.startForegroundService(this, intent)
}

private fun isAppInForeground(): Boolean {
val appProcess = ProcessLifecycleOwner.get().lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)
return appProcess
}

private fun stopMicrophoneService() {
Timber.tag(loggerTag.value).d("Stopping MicrophoneAccessService (if needed).")
val intent = Intent(this, MicrophoneAccessService::class.java)
stopService(intent)
}

override fun onPause() {
super.onPause()
startMicrophoneService()
}

override fun onResume() {
super.onResume()
stopMicrophoneService()
}

override fun onDestroy() {
detachRenderersIfNeeded()
turnScreenOffAndKeyguardOn()
removeOnPictureInPictureModeChangedListener(pictureInPictureModeChangedInfoConsumer)
screenCaptureServiceConnection.unbind()
stopMicrophoneService()
super.onDestroy()
}

Expand Down

0 comments on commit e4d5055

Please sign in to comment.