flutter-webrtc / callkeep

iOS CallKit and Android ConnectionService for Flutter
MIT License
130 stars 139 forks source link

Android - No microphone audio when app is terminated #144

Closed cmendes0101 closed 2 years ago

cmendes0101 commented 2 years ago

Pixel 4 with Android 12 Pixel 5 with Android 13

Everything is working as expected in my setup except for the scenario when the device is locked, the app is terminated and a push notification is received. I can answer the call and hear the calling party along with toggling controls with the Phone app display but there is no microphone audio going out. The permissions show the native phone app is accessing the microphone but not my app. callKeep.backToForeground() does not seem to work.

If the app is foreground or in the background and a call is received it works the same way and displays with controls working and the audio microphone is working. The permissions show Phone app and my app are accessing the microphone at the same time. callKeep.backToForeground() works correctly.

Is this due to the restrictions in Android 12+ where a foreground service cannot start the microphone?

cmendes0101 commented 2 years ago

As a workaround, I added turnScreenOn and showWhenLocked to the AndroidManifest.xml. This allowed the app to open to allow microphone permission. Downside is instead of the full-screen incoming call it has the call as a heads-up notification.

android:showWhenLocked="true" android:turnScreenOn="true"