系统管理的连接 - 拨打出站电话而不将其视为 SIM 电话

发布于 2025-01-17 20:17:33 字数 2024 浏览 2 评论 0原文

我正在努力实现 voip 应用程序的呼叫功能,并努力使用系统管理的连接服务进行出站呼叫 **

我正在努力解决的部分如下:

    val extras = Bundle()
    extras.putString(EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle.id) // I assume I need this, otherwise how will it know which connection service to invoke?
    telecomManager.placeCall(Uri.parse("tel:+4412345"), extras)

我希望发生的是默认情况dialer 被调用,然后因为我告诉它我自己的电话帐户句柄,它会通过以下方式回调到我自己的连接服务实现: onCreateOutgoingConnection 然后我可以自己设置 voip 呼叫并维护连接状态。

然而,实际发生的情况是,默认拨号器被调用,然后它只是尝试像正常的 sim 呼叫一样拨打它(所以我无法通过 webrtc 自己代理连接)

我的电话帐户设置如下:

    val extras = Bundle()
    val builder = PhoneAccount.builder(phoneAccountHandle, label)
    builder.setCapabilities(PhoneAccount.CAPABILITY_CONNECTION_MANAGER) // because I want to manage my own call connections but use default UI
    builder.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER) // because I want to make calls
    // builder.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED) // commented out because otherwise I have to be self managed for inbound
    builder.setExtras(extras)
    val phoneAccount = builder.build()

    telecomManager.registerPhoneAccount(phoneAccount)

对于它的价值,我已经弄清楚了事情的入站方面,并且工作得很好(我收到一条 firebase 消息,我告诉电信有一个入站呼叫,然后它回拨到onCreateIncomingConnection,然后它调用通话 UI 中的默认设置,然后我继续完成双方之间的 webrtc 连接)

我对 Android 开发相当陌生,所以我希望我错过了一些“明显”的事情,而不是我试图做的不可能的事情。有人可以给我任何帮助吗?

注意:我知道 https://developer.android 上的文档。 com/guide/topics/connectivity/telecom/selfManaged 但这是用于自我管理的连接,(另外,我最初在尝试自我管理的解决方案时遵循了这一点,但后来放弃了(见下文)。在我的案例一真的不想显示我自己的 UI(因为这会破坏与入站调用的对称性 - 然后我很难尝试与其他 UI 正确互操作))


** 我选择系统管理而不是自我管理的原因是我必须很好地处理其他 sim 调用,并且我在尝试处理我的应用程序调用跟随正在进行的 sim 调用的情况时感到非常痛苦(似乎我对自己的连接所做的任何事情都没有导致任何更改其他连接(例如保持通话)所以我最终同时接到两个电话)。

更新:如果我添加正确的额外内容会有帮助!它应该是可打包的,并提供phoneAccountHandle ...设法走得更远,如果我得到这个工作,可能会回答我自己的问题...

I'm working on implementing the calling functionality for a voip app and struggling with making an outbound call with a system managed connection service **

The part I'm struggling with is as follows:

    val extras = Bundle()
    extras.putString(EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle.id) // I assume I need this, otherwise how will it know which connection service to invoke?
    telecomManager.placeCall(Uri.parse("tel:+4412345"), extras)

what I'd like to happen is that the default dialler is invoked and then because I told it my own phone account handle it will then callback to my own implementation of connection service via: onCreateOutgoingConnection where I can then rig up the voip call and maintain the connection state myself.

What actually happens however is that the default dialler is invoked and then it just attempts to ring it as it would with a normal sim call (so I can't broker the connection myself via webrtc)

My setup for the phone account is as follows:

    val extras = Bundle()
    val builder = PhoneAccount.builder(phoneAccountHandle, label)
    builder.setCapabilities(PhoneAccount.CAPABILITY_CONNECTION_MANAGER) // because I want to manage my own call connections but use default UI
    builder.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER) // because I want to make calls
    // builder.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED) // commented out because otherwise I have to be self managed for inbound
    builder.setExtras(extras)
    val phoneAccount = builder.build()

    telecomManager.registerPhoneAccount(phoneAccount)

For what it's worth I've figured out the inbound side of things and that's working pretty well (I receive a firebase message, I tell telecom there is an inbound call, it then calls back to onCreateIncomingConnection, it then invokes the default in call UI, and I then crack on with completing the webrtc connection between both parties)

I'm fairly new to android development so I'm hoping that I've missed something "obvious" as opposed to what I'm attempting being impossible. Can anyone give me any help on this?

Note: I'm aware of the documentation at https://developer.android.com/guide/topics/connectivity/telecom/selfManaged but that is for a self managed connection, (also, I did initially follow this when attempting a self-managed solution but then gave up (see below). In my case I don't really want to show my own UI (because that would break symmetry with the inbound calls - and then I have the pain of trying to interoperate with other UIs correctly))


** The reason I've chosen system managed over self managed is that I have to play nicely with other sim calls and I had a world of pain trying to handle the case that my app call follows an ongoing sim call (seemed that nothing I did to my own connection did anything to cause a change in the other connection (like hold the call) so I wound up with two calls going on at the same time).

Update: helps if I add the right kind of extra! it should be parcelable and provide the phoneAccountHandle ... managed to get a bit further and may answer my own question if I get this working ...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

去了角落 2025-01-24 20:17:33

我在这里的错误(在原始帖子中剩下的帖子)是,在拨打电话时,我应该将实际的电话帐户句柄作为包裹额外的额外添加,而不是将电话帐户句柄ID添加为字符串。现在,这提出了默认的UI,呼叫我的连接服务,然后什么也不做(这很好,因为我还没有操纵WebRTC)

My mistake here (left in original post for posterity) is that instead of adding the phone account handle id as a string extra when placing the call, I should have supplied the actual phone account handle as a parcelable extra. This now brings up the default UI, calls out to my connection service and then does nothing (which is fine because I haven't rigged up the webrtc yet)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文