android
android copied to clipboard
Samsung - alarm_stream notifications still silent
Home Assistant Android version: beta-637-94e1f15
Android version: 11
Phone model: SM-G991U
Home Assistant version: 2021.3.4
Last working Home Assistant release (if known):
Description of problem: alarm_stream notifications still silent installing latest beta and fresh start. Configuration below:
type: button
tap_action:
confirmation:
text: Find Phone?
action: call-service
service: notify.mobile_app_s21r8
service_data:
title: Finding Phone
message: Ringing phone
data:
ttl: 0
importance: high
priority: high
tag: Find
channel: alarm_stream
name: Find S21
icon: 'mdi:cellphone-wireless'
Traceback (if applicable, to get the logs you may refer to: https://companion.home-assistant.io/docs/troubleshooting/faqs/#android-crash-logs):
[03-29 15:55:48.322 21235:31640 D/MessagingService]
From: 331041709873
[03-29 15:55:48.323 21235:31640 D/MessagingService]
Message data payload: {tag=Find, title=Finding Phone, channel=alarm_stream, message=Ringing phone, importance=high}
[03-29 15:55:48.325 1740:4671 D/SamsungAlarmManager]
Cancel Alarm calling from uid:10245 pid :3068 / OP:PendingIntent{d45bbac: PendingIntentRecord{12521f2 com.google.android.gms/com.google.android.gms.gcm broadcastIntent}}
[03-29 15:55:48.325 1740:4671 I/SamsungAlarmManager]
setLocked to kernel - T:2 / 20210329T155852, set=30546841, now=30362501
[03-29 15:55:48.326 1740:4671 I/SamsungAlarmManager]
setLocked to kernel - T:3 / 20210329T155559, set=30373189, now=30362501
[03-29 15:55:48.329 21235:21235 D/MessagingService]
Creating notification with following data: {tag=Find, title=Finding Phone, channel=alarm_stream, message=Ringing phone, importance=high}
[03-29 15:55:48.334 21235:21235 D/RingtoneManager]
getActualDefaultRingtoneUri type :4
[03-29 15:55:48.335 21235:21235 I/RingtoneManager]
Ringtone value : content://media/internal/audio/media/110?title=Homecoming&canonical=1
[03-29 15:55:48.336 21235:21235 D/RingtoneManager]
getActualDefaultRingtoneUri type :4
[03-29 15:55:48.336 21235:21235 I/RingtoneManager]
Ringtone value : content://media/internal/audio/media/110?title=Homecoming&canonical=1
[03-29 15:55:48.342 4325:4325 D/BoundBrokerSvc]
onBind: Intent { act=com.google.android.gms.measurement.START pkg=com.google.android.gms }
[03-29 15:55:48.342 4325:4325 D/BoundBrokerSvc]
Loading bound service for intent: Intent { act=com.google.android.gms.measurement.START pkg=com.google.android.gms }
[03-29 15:55:48.342 21235:21235 D/MessagingService]
Show notification with tag "Find" and id "2189785"
[03-29 15:55:48.345 1740:2484 D/ApplicationPolicy]
isStatusBarNotificationAllowedAsUser: packageName = io.homeassistant.companion.android,userId = 0
[03-29 15:55:48.345 1740:2484 D/PersonaManagerAdapter]
ContainerOnlyMode - EOS
[03-29 15:55:48.345 1740:1794 D/SettingsProvider]
isChangeAllowed() : name = enabled_notification_listeners
[03-29 15:55:48.345 1740:1794 D/SettingsProvider]
isChangeAllowed() : name = enabled_notification_assistant
[03-29 15:55:48.345 1740:1794 D/SettingsProvider]
isChangeAllowed() : name = enabled_notification_policy_access_packages
[03-29 15:55:48.346 1740:2484 D/ApplicationPolicy]
isStatusBarNotificationAllowedAsUser: packageName = io.homeassistant.companion.android,userId = 0
[03-29 15:55:48.346 1740:2484 D/PersonaManagerAdapter]
ContainerOnlyMode - EOS
[03-29 15:55:48.383 1740:4671 D/SamsungAlarmManager]
Cancel Alarm calling from uid:10245 pid :4325 / OP:PendingIntent{71a70e5: PendingIntentRecord{b070f9c com.google.android.gms/com.google.android.gms.measurement broadcastIntent}}
[03-29 15:55:48.457 2394:2511 D/NetworkController.SecMobileSignalController(0/1)]
onDataActivity: direction=3
[03-29 15:55:48.459 2394:2511 D/MobileSignalIconsSelector]
getDataIconGroup(): connected=true,enabled=true,level=5,inetCondition=1,dataIconGroup=DataIconGroup(5G_TMO),activityIn=true,activityOut=true,lastModified=03-29 15:55:48.458,dataSim=true,networkName=T-Mobile,networkNameData=T-Mobile,dataConnected=true,roaming=false,isDefault=true,isEmergency=false,airplaneMode=false,carrierNetworkChangeMode=false,userSetup=true,defaultDataOff=false,cdmaEriIconIndex=-1,cdmaEriIconMode=-1,callState=0,voWifiConnected=false,shouldShowDisabledDataIcon=false,bluetoothTethered=false,isLTEFemtoCell=false,cardOperator=OTHERS,optionalRadioTech=0,isCAIndicator=false,isLimitedStateForCTCSlaveVoLTE=false,isSWRoaming=false,isMobileDataSettingEnabled=false,nwBoosterRilEnabled=false,nwBoosterSettingEnabled=false,emergencyModeActivated=false,ismmW5G=false, iconSet = null
[03-29 15:55:48.459 2394:2394 D/StatusbarSignalPolicy]
setMobileDataIndicators state = MobileIconState(subId=1, strengthId=2131233570, roaming=false, typeId=2131233374, visible=true, activityId=0, roamingId=0, slotId=0)
[03-29 15:55:48.490 1012:27998 I/sensors-hal]
handle_sns_client_event:182, auto_rotation_event: mode:255, type:1:0/0.010,0.065,9.882
[03-29 15:55:48.517 1028:1120 I/[email protected]]
drmIOCTLLib connectorId: 55
[03-29 15:55:48.518 1028:1120 I/[email protected]]
drmIOCTLLib ret: 0
[03-29 15:55:48.518 886:886 E/audit]
type=1400 audit(1617051348.513:28926): avc: denied { sys_admin } for pid=1028 comm="[email protected]" capability=21 scontext=u:r:vendor_hal_perf_default:s0 tcontext=u:r:vendor_hal_perf_default:s0 tclass=capability permissive=0 SEPF_SM-G991U_11_0007 audit_filtered
[03-29 15:55:48.518 1028:1120 I/[email protected]]
drmIOCTLLib close return 0
[03-29 15:55:48.548 1740:1740 I/NotificationService]
RuneStone mIsRuneStoneSupported = true, mIsRuneStoneEnabled = false
[03-29 15:55:48.552 1740:1740 I/AccessibilityManager]
semStartFlashNotification notitype = alarm
[03-29 15:55:48.552 1740:1740 D/AccessibilityManagerService]
semStartFlashNotification
[03-29 15:55:48.552 1740:1740 I/AccessibilityManagerService]
semStartFlashNotificationInner() type=Default, pkgName=android, token=android.os.Binder@226e1c6
[03-29 15:55:48.552 1740:1740 D/AccessibilityManagerService]
Can not use light notification
[03-29 15:55:48.555 1740:1740 D/EdgeLightingManager]
isCallingUserSupported : callingUserId=0, mUserId=0, isDualAppId=false, isKnoxId=false
[03-29 15:55:48.555 1740:1740 D/EdgeLightingManager]
showForNotification : isInteractive=true, isHeadUp=true, color=0, canBypassDnd=false, sbn = StatusBarNotification(pkg=io.homeassistant.companion.android user=UserHandle{0} id=2189785 tag=Find key=0|io.homeassistant.companion.android|2189785|Find|10291: Notification(channel=alarm_stream shortcut=null contentView=null vibrate=null sound=null defaults=0x0 flags=0x10 color=0xff03a9f4 category=alarm vis=PRIVATE semFlags=0x0 semPriority=0 semMissedCount=0))
[03-29 15:55:48.555 1740:1740 D/EdgeLightingClientManager]
isAvailableEdgeLighting: condition=1 mCondition=3 mIsConnected=false0
[03-29 15:55:48.555 1740:1740 D/EdgeLightingManager]
showForNotificationScreenOn : return false by isAvailableEdgeLighting.
[03-29 15:55:48.567 2736:2736 I/Launcher.NotificationListener]
onNotificationPosted : io.homeassistant.companion.android number : 0
[03-29 15:55:48.567 2736:2852 I/Launcher.NotificationListener]
notificationIsValidForUI : io.homeassistant.companion.android missingTitleAndText : false isGroupHeader : false
[03-29 15:55:48.576 2394:2394 D/InterruptionStateProvider]
No bubble up: not allowed to bubble: 0|io.homeassistant.companion.android|2189785|Find|10291
[03-29 15:55:48.577 2394:2394 W/NotifBindPipeline]
Row is not set so pipeline will not run. notif = 0|io.homeassistant.companion.android|2189785|Find|10291
Screenshot of problem:
Additional information:
Were going to need help from a developer who has a samsung device and is familiar with the API changes they have done. I can see the proper ringtone being grabbed but still unused. I cannot reproduce on my pixel and I know other manufacturers do not have issues.
@dshokouhi I have a samsung tablet. Can i help you with debugging?
@dshokouhi I have a samsung tablet. Can i help you with debugging?
I suppose we could add some more debug logs but based on what I see in the logs above the ringtone URI is successfully retrieved but the notification call strips it out for some reason. I dont know if its something samsung has done to the actual notification API or not but I know resorting to media player/ringtone player is not desireable as the audio wont stop naturally like it does on my pixel. Honestly not really sure where to start with it, everything about hte code suggests it should work. Based on the logs above I know my assumption was correct in that the default alarm ringtone was null but not sure why the ringtone itself wont work when its not null.
https://github.com/home-assistant/android/blob/master/app/src/full/java/io/homeassistant/companion/android/notifications/MessagingService.kt#L1032
Can you reproduce it on the tablet?
Just did a quick test with my samsung tablet and send the same alarm notification as jojeda654. No problems here.
So I am not sure if this is the actual issue however I noticed the following sentry error for a couple samsung devices that suspiciously call out the updated code
java.lang.SecurityException: io.homeassistant.companion.android was not granted this permission: android.permission.WRITE_SETTINGS.
at android.os.Parcel.createExceptionOrNull(Parcel.java:2385)
at android.os.Parcel.createException(Parcel.java:2369)
at android.os.Parcel.readException(Parcel.java:2352)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
at android.content.ContentProviderProxy.call(ContentProviderNative.java:732)
at android.provider.Settings$NameValueCache.putStringForUser(Settings.java:2794)
at android.provider.Settings$System.putStringForUser(Settings.java:3422)
at android.provider.Settings$System.putStringForUser(Settings.java:3406)
at android.media.RingtoneManager.setActualDefaultRingtoneUri(RingtoneManager.java:910)
at android.media.RingtoneManager.setRingtonesAsInitValue(RingtoneManager.java:1439)
at android.media.RingtoneManager.getActualDefaultRingtoneUri(RingtoneManager.java:860)
at io.homeassistant.companion.android.notifications.MessagingService.handleChannelSound(MessagingService.kt:1047)
at io.homeassistant.companion.android.notifications.MessagingService.handleChannel(MessagingService.kt:1002)
at io.homeassistant.companion.android.notifications.MessagingService.sendNotification(MessagingService.kt:547)
at io.homeassistant.companion.android.notifications.MessagingService$onMessageReceived$$inlined$let$lambda$9.invokeSuspend(MessagingService.kt:282)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8443)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:596)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Now heres the tricky part, we don't normally do a permission request for a normal notification being received. I also only see Samsung devices with this issue. So while we can add the permission to our manifest users still need to grant the permission on an additional screen that is not the same as a normal permission. WRITE_SETTINGS requires the user to grant it for the app on a separate activity.
As this is only a samsung issue I am hesitant to add a check like we normally do because we don't want to prevent an already working notification on other devices. I think we may just opt to add it to the app manifest and keep it as a troubleshooting step for users to enable if they experience issues. I am also not even sure if this permission will work. We may indeed get a separate error on these devices after we pass this step. Also why do we need a WRITE permission if we are just reading the URI? Setting a notification channel sound doesnt require special permissions. This is just odd :)
I have the same issue on 2 devices: Samsung Galaxy A40 and Samsung Galaxy S8. I would like to test this fix. But when I install the APK of the pull request, a popup tells me that I won't be able to receive any notification
But when I install the APK of the pull request, a popup tells me that I won't be able to receive any notification
notifications do not work in debug builds unfortunately....are you able to see the error I just posted above in your logs? it would be helpful to know if you do :)
I have no error in logs. I have almost the same log as jojeda654
@RudyWI can you check if you have a default alarm ringtone set? Have you set an alarm on the device before?
Also why do we need a WRITE permission if we are just reading the URI? Setting a notification channel sound doesnt require special permissions. This is just odd :)
And why does this work without this permission on my samsung tablet? Also this permission should be used on all devices. Thats really weird.
Yea the error above suggests all users should be hitting it but its the first time I have seen it so it tells me the initial hunch that the alarm ringtone was null
was correct. Since it works on your tablet it also tells me that not all samsung users experience this issue. Even when I look at API docs for android for getActualDefaultRingtoneUri
it does not mention this permission. It seems to be specific to the device implementation of the API. Thats why in the PR I opted not to force users to accept the setting since it seems to be more of a "if you need it" type of thing. But that assumes that these users are hitting the same issue up above. It could be 2 separate ones.
My log:
04-17 09:43:05.886 19020 4179 D MessagingService: From: 331041709873
04-17 09:43:05.886 19020 4179 D MessagingService: Message data payload: {tag=Find, title=Finding Phone, channel=alarm_stream, message=Ringing phone, importance=high}
04-17 09:43:05.894 19020 19020 D MessagingService: Creating notification with following data: {tag=Find, title=Finding Phone, channel=alarm_stream, message=Ringing phone, importance=high}
04-17 09:43:05.903 19020 19020 D RingtoneManager: getActualDefaultRingtoneUri type :4
04-17 09:43:05.905 19020 19020 I RingtoneManager: Ringtone value : content://media/internal/audio/media/201
04-17 09:43:05.913 19020 19020 D RingtoneManager: getActualDefaultRingtoneUri type :4
04-17 09:43:05.913 19020 19020 I RingtoneManager: Ringtone value : content://media/internal/audio/media/201
04-17 09:43:05.924 19020 19020 D MessagingService: Show notification with tag "Find" and id "2189785"
There is no "alarm ringstone" parameter in my phone. But I have set alarm in the default "clock" app and in another "alarm" app.
When I set volume up manually and then send the alarm notification from HA, the phone is ringing.
I have discovered in my phone that there is no "alarm volume" that appears when I press volume up or down buttons. There is only ringstone, media, notification or system.
When an alarm is ringing, the phone seems to use "ringstone" volume level
There is no "alarm ringstone" parameter in my phone. But I have set alarm in the default "clock" app and in another "alarm" app.
so the app will default to the devices ringtone if you dont have an alarm one set, we can see that in the logs above
When I set volume up manually and then send the alarm notification from HA, the phone is ringing.
What do you mean by this? Do you mean to say the volume was at 0 and then it started to make a sound when you sent the notification?
I have discovered in my phone that there is no "alarm volume" that appears when I press volume up or down buttons.
Can you enable the alarm volume sensor and see what value you get for the state?
When an alarm is ringing, the phone seems to use "ringstone" volume level
Compare the 2 volume sensor for ringer and audio and see if they are always the same or not.
It looks like the fix I submitted will not be accepted. If someone can please setup the project according to the full readme instructions including the firebase stuff for notifications and then try the linked PR locally to see if it will work or not. We will probably need to hold off on future fixes until someone can reproduce this who is a developer to help out.
What do you mean by this? Do you mean to say the volume was at 0 and then it started to make a sound when you sent the notification?
I set ringtstone volume to max using "volume up" button on my phone. And then it started to make a sound when I sent the notification on "alarm_stream" channel.
Compare the 2 volume sensor for ringer and audio and see if they are always the same or not.
When "alarm" sensor is at 15 and ringstone sensor is at 0, my phone is not making sound when I sent the notification.
It looks like the fix I submitted will not be accepted. If someone can please setup the project according to the full readme instructions including the firebase stuff for notifications and then try the linked PR locally to see if it will work or not. We will probably need to hold off on future fixes until someone can reproduce this who is a developer to help out.
I'm a java and web developer, not android. I'll try to setup the project. Deploy server side on firebase is not free. Can I deploy it locally to test notifications ?
I have setup project localy and applied your PR, but it does not solved the problem (alarm is still silent) :-(
I have setup project localy and applied your PR, but it does not solved the problem (alarm is still silent) :-(
So I think you may be on to something about the device not having an alarm stream. I would think looking into how your actual alarm sounds off on the device may be helpful. Logcat could potentially provide some clues as to how it works. Tasker might be a good place to check as well. There will need to be research done to find a good path forward. Its very strange that an alarm stream is missing if that is the case.
Can you try a TTS alarm stream notification?
https://companion.home-assistant.io/docs/notifications/critical-notifications
Try the last 2 examples, this uses a completely separate API from notifications as its TTS to access the alarm stream
I tried the last 2 examples: TTS over "alarm_stream" and "alarm_stream_max" channels. Both works very well: even if my phone is in silent mode, the sound of the TTS is loud
I have a Samsung S21 and can confirm when my phone is on silent/volume 0 TTS works but nothing else does. Is this as expected? I guess I can have TTS saying "weeeeewoooooo alert alert" ;)
I have a Samsung S21 and can confirm when my phone is on silent/volume 0 TTS works but nothing else does. Is this as expected?
Per the description of this bug, yes Samsung devices do not work with this API call which is documented in Android dev docs. TTS uses a completely different API and luckily Samsung did not modify that. Alternatively you can use notification commands to change device ringer mode, DND and volume level so you can definitely get around this today.
https://companion.home-assistant.io/docs/notifications/notification-commands
Maybe we should write this into the app documentation? I spent a lot of time trying to figure out why it didn't work. Another workaround is to use Tasker, then you can catch when Home assistant sends a notification with a certain text, I write "Important" in the beginning of the title for example, and make it sound louder and circumvent dnd.
Hey everyone so a few weeks ago I reached out to Samsung as they had reached out with bug reports so I thought about asking them about this issue. Here is the response from their dev team.
In some 3rd apps, despite being in vibration mode, there was a problem of arbitrarily increasing notification volume and playing
As a result, we have received many market VOCs that notifications will occur in places where it is needed to be quiet.
Therefore, Samsung devices does not generate notification sound in vibration mode
We will check it if you can play the sound for the API you are using.
It seems that you need to play the sound directly using mediaplayer temporarily.
So they did provide a workaround which will be a lot of work as it will involve the app using a media player in the background which will also require us to use a pre-defined notification sound. More than likely we would need to stick to whatever the default alarm or ringtone is without much option to change. This also means that it will not work as a normal notification, there will be no notification channel to allow for DND overrides. I am not sure this will be sufficient for our actual use case here especially if its only going to be a workaround.
For now I think its best that if you hit this issue you continue to use app provided features to workaround this in an automation. There are sensors to check the DND/ringer mode state and also notification commands to take them in and out of the state. I understand that its still not 100% the same but until they can fix this on their end there is not much the app can do. The good news is that they are aware and the change made seems to be deliberate so hopefully they can open it up for the alarm stream. If I hear anything else I'll make sure to update this thread.
Thanks for the update. Disabling DND before sending TTS is an alternative that never failed in my case. Posting the actions for anyone interested.
action:
- service: notify.mobile_app_telephone_julien
data:
message: command_dnd
title: 'off'
- service: notify.mobile_app_telephone_julien
data:
title: 🔔 Alarme déclenchée ! 🔔
message: Alarme déclenchée
data:
channel: Déclenchement Alarme
importance: high
vibrationPattern: >-
0, 3000, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100, 100, 3000, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100
ledColor: red
ttl: 0
priority: high
- service: notify.mobile_app_telephone_julien
data:
message: TTS
data:
ttl: 0
priority: high
channel: alarm_stream_max
title: Alarme déclenchée !
I have Samsung S21 FE, even with do not disturb off I cannot get any ringtone to play, even tried increasing the volume using command_volume_level but it doesn't increase the volume
I have Samsung S21 FE, even with do not disturb off I cannot get any ringtone to play,
check your notification channel settings
even tried increasing the volume using command_volume_level but it doesn't increase the volume
lets not combine multiple issues into one. please create a new issue providing the logs and YAML used so we can troubleshoot. Also make sure the proper permission is granted for this command.
pro tip: try assigning a new notification channel whenever you change some parameter, as Android seems to cache them when a notification channel is first created (at least this is my experience). I always name my notification channels like Very important stuff #4
and always increment the number, as I experiment with parameters.
as Android seems to cache them when a notification channel is first created (at least this is my experience)
yes that is correct certain parameters can ONLY be set the first time you create a channel. Vibration and LED color are some of them. We detail this in the docs here:
https://companion.home-assistant.io/docs/notifications/notifications-basic/#notification-channels
Deleting a channel also only removes the channel from the list, the settings are still restored when its recreated. The only way to truly clear those one time settings is to clear data in the app.
@dshokouhi until I put the ringer volume on, nothing works, can you please look at the attached and let me know if you find anything I'm doing wrong, thanks!
Button YAML:
show_name: true
show_icon: true
type: button
tap_action:
confirmation:
text: Find Phone?
action: call-service
service: script.find_phone
target: {}
name: Find Phone
icon: mdi:cellphone-sound
show_name: true
show_icon: true
type: button
tap_action:
confirmation:
text: Find Phone?
action: call-service
service: script.find_phone
target: {}
name: Find Phone
icon: mdi:cellphone-sound
Find phone script(calls 2 other scripts to volume up and ring phone):
alias: Find Phone
sequence:
- service: script.volume
data: {}
- service: script.ring_phone
data: {}
mode: single
icon: mdi:cellphone-marker
Volume Up:
alias: Ring Volume Up
sequence:
- service: notify.mobile_app_ali_s_phone
data:
message: command_volume_level
title: 20
data:
channel: alarm_stream
mode: single
Ring phone:
alias: Ring Phone
sequence:
- service: notify.mobile_app_ali_s_phone
data:
message: You found me!
data:
ttl: 0
priority: high
channel: alarm_stream
mode: single
alarm_stream notification settings:
@Ali229 use a different channel other than alarm_stream
. It will not work for you. Just change channel: alarm_stream
to anything else.
Didn't change anything same problem only works when ringer volume is up channel: find_phone
, otherwise just vibrates
are you sure you are changing the ringer mode to normal
and you are adjusting the correct volume stream?
Lets please stop conflating this issue with something unrelated. If you are unable to figure it out please create a new issue with all the YAML you used along with device logs.