Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow TTS notifications to use the alarm stream #1037

Merged
merged 2 commits into from Oct 13, 2020

Conversation

dshokouhi
Copy link
Member

Was doing some more testing around TTS notifications. Came to find out that by default they use the MUSIC_STREAM which means that they will ignore the devices ringer mode but not the volume level. By using the ALARM_STREAM we use a separate volume level so it can bypass if media volume is off.

Example:

message: TTS
title: I am speaking
data:
  channel: alarm_stream

channel: alarm_stream is only used to override the default stream.

@dshokouhi
Copy link
Member Author

Added a fix for the following sentry error that was crashing:

java.lang.NullPointerException: Can't toast on a thread that has not called Looper.prepare()
    at com.android.internal.util.Preconditions.checkNotNull(Preconditions.java:157)
    at android.widget.Toast.getLooper(Toast.java:179)
    at android.widget.Toast.<init>(Toast.java:164)
    at android.widget.Toast.makeText(Toast.java:492)
    at android.widget.Toast.makeText(Toast.java:480)
    at io.homeassistant.companion.android.notifications.MessagingService$speakNotification$1.onInit(MessagingService.kt:205)
    at android.speech.tts.TextToSpeech.dispatchOnInit(TextToSpeech.java:863)
    at android.speech.tts.TextToSpeech.initTts(TextToSpeech.java:841)
    at android.speech.tts.TextToSpeech.<init>(TextToSpeech.java:772)
    at android.speech.tts.TextToSpeech.<init>(TextToSpeech.java:751)
    at android.speech.tts.TextToSpeech.<init>(TextToSpeech.java:735)
    at io.homeassistant.companion.android.notifications.MessagingService.speakNotification(MessagingService.kt:183)
    at io.homeassistant.companion.android.notifications.MessagingService.onMessageReceived(MessagingService.kt:119)
    at com.google.firebase.messaging.FirebaseMessagingService.zzc(com.google.firebase:firebase-messaging@@20.1.5:80)
    at com.google.firebase.messaging.zzh.run(com.google.firebase:firebase-messaging@@20.1.5:2)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at com.google.android.gms.common.util.concurrent.zza.run
    at java.lang.Thread.run(Thread.java:923)

@JBassett JBassett merged commit 6972f82 into home-assistant:master Oct 13, 2020
@dshokouhi dshokouhi deleted the tts_alarm_stream branch March 24, 2021 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants