TECH7Fox / sip-hass-card

A SIP client inside home assistant!
MIT License
179 stars 38 forks source link

Home Assistant companion app crashes when CALL is pressed #96

Closed Suxsem closed 1 year ago

Suxsem commented 1 year ago

Hello, I have configured an asterisk server on my network with websocket support and installed the sip-hass-card in my home assistant dashboard.

I have 3 extensions like so:

extensions:
  - person: person.casa
    name: Tablet
    extension: '8002'
    secret: ***
    icon: mdi:tablet
  - person: person.stefano
    name: Stefano
    extension: '8003'
    secret: ***
    icon: mdi:alpha-s-box-outline
  - person: person.roberta
    name: Roberta
    extension: '8004'
    secret: ***
    icon: mdi:alpha-r-box-outline

In web browser, I can successfully make calls between devices.

The problem is related to the Android companion app. If I try to make a call from it, the first time I get the microphone permission screen, I then press ALLOW but then the app crashes. If I try to do it again, the app crashes.

I checked my phone logcat and this is the relevant part:

03-08 16:50:12.261  9201  9201 W System.err: java.lang.IllegalStateException: Either grant() or deny() has been already called.
03-08 16:50:12.262  9201  9201 W System.err:    at org.chromium.android_webview.permission.AwPermissionRequest.a(chromium-TrichromeWebViewGoogle.aab-stable-548115333:34)
03-08 16:50:12.262  9201  9201 W System.err:    at Wz0.grant(chromium-TrichromeWebViewGoogle.aab-stable-548115333:109)
03-08 16:50:12.262  9201  9201 W System.err:    at io.homeassistant.companion.android.webview.WebViewActivity$onCreate$2$4.onPermissionRequest(WebViewActivity.kt:491)
03-08 16:50:12.262  9201  9201 W System.err:    at org.chromium.android_webview.AwContents.onPermissionRequest(chromium-TrichromeWebViewGoogle.aab-stable-548115333:46)
03-08 16:50:12.262  9201  9201 W System.err:    at android.os.MessageQueue.nativePollOnce(Native Method)
03-08 16:50:12.262  9201  9201 W System.err:    at android.os.MessageQueue.next(MessageQueue.java:363)
03-08 16:50:12.262  9201  9201 W System.err:    at android.os.Looper.loop(Looper.java:176)
03-08 16:50:12.262  9201  9201 W System.err:    at android.app.ActivityThread.main(ActivityThread.java:8668)
03-08 16:50:12.262  9201  9201 W System.err:    at java.lang.reflect.Method.invoke(Native Method)
03-08 16:50:12.262  9201  9201 W System.err:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
03-08 16:50:12.262  9201  9201 W System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)

So it seems that the app is trying to ask for permissions multiple times. Anyone have this issue?

I tested on two different Android devices. Thank you

Suxsem commented 1 year ago

I found the issue, is a bug of Home Assistant companion app. This prevents audio&video calls to be made. I will fix the issue and open a PR in the Home Assistant companion app repository. Please keep this issue open, I will update it once the PR is made

Suxsem commented 1 year ago

Fixed! Will be available in the next android home assistant release

https://github.com/home-assistant/android/pull/3411/commits/8c9da624b6a8779e5185280523ffd341cda91420

TECH7Fox commented 1 year ago

@Suxsem that's great news! Thank you for finding and fixing the problem. 👍

Suxsem commented 1 year ago

@TECH7Fox you're welcome! I'm starting using this card very often in my projects, expect some PRs soon from me in order to add some minor missing feature :) thank you for your work!