[Android] Speaker can't be selected while a call is registered with Telecom (no way to request a Telecom call endpoint)

オープン
#1,621 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
android, dart

調査の方向性

Start by tracing Call.setAudioOutputDevice through RtcManager.setAudioOutputDevice, then inspect the Telecom integration’s TelecomCallAction.kt, TelecomCallRepository.processCallActions, and StreamTelecomManager method-channel events. Compare endpoint switching with the Android and React Native SDKs cited in the issue. Done means selecting speaker during a Telecom-managed call requests the matching Telecom endpoint and routes audio through the speaker.

索引モデルが issue の本文から書いたものです。

説明

[Android] Speaker can't be selected while a call is registered with Telecom (no way to request a Telecom call endpoint)

Summary

With the Android Telecom integration of stream_video_push_notification enabled, switching the call audio to the loudspeaker with call.setAudioOutputDevice(speaker) has no effect on Android 17: the audio keeps playing through the earpiece.

Once a call is registered with Telecom through Jetpack Telecom (CallsManager.addCall), Telecom owns the call's audio route (its call endpoint). The plugin observes the endpoint (currentCallEndpoint / availableEndpoints, forwarded as the telecomAudioEndpointsChanged custom event), but there is no way to change it: TelecomCallAction only has Answer, Disconnect, Hold and Activate, and CallControlScope.requestEndpointChange is never called. Meanwhile the SDK's own output API goes around Telecom (setAudioOutputDevice → rtc.Helper.selectAudioOutput → AudioSwitch → AudioManager.setSpeakerphoneOn), so on Android 17 Telecom keeps its own route.

The integration is on by default on Android 17, and an accepted ringing call stays registered with Telecom (dismissRingingCall), so this probably affects any app that offers a speaker toggle on Android 17, not only apps that opt in below 17. We have only reproduced it with an outgoing call registered through startOutgoingCall; the ringing path is an inference from the code.

Stream's native Android SDK and React Native SDK already solve this by routing output selection through requestEndpointChange while the call is Telecom-managed (details below). The Flutter plugin is missing that part of the integration.

Environment

stream_video / stream_video_flutter / stream_video_push_notification 1.7.2, git ref 2ec78303dbc6fe8043e104b4cd378d56b2159a4e. The same code is still on main as of a1f1862b.
stream_webrtc_flutter 4.0.1
androidx.core:core-telecom 1.0.1 (via the plugin)
Device Google Pixel 6a, Android 17
Not reproducible on Android 15, same build (Telecom integration also active there)
App targetSdk 36

Steps to reproduce

  1. Enable the Telecom integration:

    StreamVideoPushNotificationManager.create(
      // providers ...
      pushConfiguration: const StreamVideoPushConfiguration(
        android: AndroidPushConfiguration(
          telecom: TelecomPushConfiguration(enabled: true), // default on Android 17
        ),
      ),
    );
    
  2. Join an audio call on the earpiece, then register it with Telecom:

    await call.join(connectOptions: CallConnectOptions(
      audioOutputDevice: earpiece, // RtcMediaDevice with id 'earpiece'
    ));
    await pushManager.startOutgoingCall(uuid: uuid, callCid: call.callCid.value, ...);
    await pushManager.setCallConnected(uuid);
    
  3. During the call, switch to the loudspeaker:

    await call.setAudioOutputDevice(speaker); // RtcMediaDevice with id 'speaker'
    

Expected: audio plays through the loudspeaker.

Actual: audio keeps playing through the earpiece. setAudioOutputDevice returns success.

The same steps worked before we enabled the Telecom integration, and still work on Android 15 with it enabled.

Evidence

  • In our logs, the ActionCallCustom events (telecomAudioEndpointsChanged) arrive once or twice right after the call connects and never again after the user selects the speaker. If Telecom's route had changed, currentCallEndpoint would have emitted and a new event would have arrived. So Telecom never moved off the earpiece.
  • TelecomCallAction.kt has only Answer, Disconnect(cause), Hold and Activate. Nothing in TelecomCallRepository.processCallActions calls requestEndpointChange.
  • StreamTelecomManager forwards endpoint changes to Dart (onCallAudioEndpointsChanged → ACTION_CALL_CUSTOM with type: telecomAudioEndpointsChanged), but there is no method-channel call or Dart API to request one.
  • RtcManager.setAudioOutputDevice on mobile calls rtc.Helper.selectAudioOutput(device.id). On Android that goes to AudioSwitch, which switches to the speaker with AudioManager.setSpeakerphoneOn(true) (deprecated since API 31) and doesn't involve Telecom.
  • For calls added through CallsManager, the documented way to change the route is CallControlScope.requestEndpointChange(CallEndpointCompat). Android 15 apparently still respects an app's own setSpeakerphoneOn for such calls. Android 17 does not.

We haven't pinned down which platform change in Android 17 causes Telecom to keep its route, and can capture adb logcat -s Telecom AudioService / dumpsys telecom if that helps. Going by the comment in your Android SDK (below), it isn't specific to Android 17: it was already seen on a Samsung S21 Ultra running Android 14.

How the other Stream SDKs handle it

Android SDK (GetStream/stream-video-android, checked at e344e8c)

  • MediaManager.kt, select(device): after selecting the device through the audio handler, it mirrors the selection to Telecom whenever the call is Telecom-managed (requestTelecomEndpointSwitch). The code comment explains why: for Telecom-managed calls, Telecom's routing takes priority over AudioManager.setCommunicationDevice(), and it cites a Samsung S21 Ultra on Android 14.
  • It maps Speakerphone / Earpiece / BluetoothHeadset / WiredHeadset to the matching CallEndpointCompat.TYPE_*. If that endpoint isn't available yet, it waits up to 2 seconds for it. It skips the request when the endpoint is already current, and lets a newer selection supersede an older one (TelecomEndpointSwitchCoordinator).
  • JetpackTelecomRepository.kt handles TelecomCallAction.SwitchAudioEndpoint with requestEndpointChange and logs the result.

React Native SDK (GetStream/stream-video-js, checked at c6df247)

  • react-native-callingx (Android) exposes requestAudioEndpointChange(callId, endpointId) and getAvailableAudioEndpoints(callId). On the Kotlin side these become CallAction.SwitchAudioEndpoint → requestEndpointChange in TelecomCallRepository.kt.
  • react-native-sdk, CallManager.ts: when the call is Telecom-managed ("Android Telecom owns routing"), select(deviceId) and setForceSpeakerphoneOn(force) go through callingx, and the device list and selected device are read from the Telecom endpoint snapshot.
  • callingx also passes a preferred starting endpoint when adding the call, based on CallsManager.getAvailableStartingCallEndpoints and a sticky default preference. That way a call that should start on the speaker does so under Telecom too.

Suggested fix

Essentially, port what the Android SDK and React Native SDK already do:

  1. Add an endpoint request to the Telecom integration, for example:
    • TelecomCallAction.RequestEndpoint(type) handled in processCallActions with requestEndpointChange(...). Look the endpoint up in the repository's tracked availableCallEndpoints, not by collecting availableEndpoints a second time: those flows are channel-backed, so a second collector steals values from the first.
    • a method-channel call and Dart API, e.g. StreamVideoPushNotificationManager.setTelecomAudioEndpoint(uuid, type), returning whether Telecom accepted it.
  2. While a call is registered with Telecom, have Call.setAudioOutputDevice on Android also request the matching Telecom endpoint. The ids map one to one: speaker → TYPE_SPEAKER, earpiece → TYPE_EARPIECE, wired-headset → TYPE_WIRED_HEADSET, bluetooth → TYPE_BLUETOOTH.
  3. Optionally, follow Telecom when it changes the route itself (system output switcher, a headset connecting), so CallState.audioOutputDevice stays accurate.
  4. Optionally, pass a preferred starting endpoint when registering the call, as callingx does, so a call joined with speakerDefaultOn / a speaker audioOutputDevice starts on the speaker under Telecom too.
  5. Until then, the README section "Android Telecom integration" could mention that output switching isn't supported while a call is registered with Telecom.
主要言語
Dart
スター
79
フォーク
55
平均マージ
2日 12時間
マージ済み PR(30日)
142

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

GetStream/stream-video-flutter のほかの issue

GetStream/stream-video-flutter の issue をすべて見る

似ている issue

Dart の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。