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

Prevent crash when removing default channel #1405

Merged
merged 1 commit into from Mar 8, 2021

Conversation

dshokouhi
Copy link
Member

Summary

Fixes the following sentry error that I was able to reproduce:

java.lang.IllegalArgumentException: Cannot delete default channel
    at android.os.Parcel.createExceptionOrNull(Parcel.java:2377)
    at android.os.Parcel.createException(Parcel.java:2357)
    at android.os.Parcel.readException(Parcel.java:2340)
    at android.os.Parcel.readException(Parcel.java:2282)
    at android.app.INotificationManager$Stub$Proxy.deleteNotificationChannel(INotificationManager.java:4004)
    at android.app.NotificationManager.deleteNotificationChannel(NotificationManager.java:906)
    at androidx.core.app.NotificationManagerCompat.deleteNotificationChannel(NotificationManagerCompat.java:341)
    at io.homeassistant.companion.android.notifications.MessagingService.removeNotificationChannel(MessagingService.kt:305)
    at io.homeassistant.companion.android.notifications.MessagingService.onMessageReceived(MessagingService.kt:170)
    at com.google.firebase.messaging.FirebaseMessagingService.dispatchMessage(com.google.firebase:firebase-messaging@@20.3.0:74)
    at com.google.firebase.messaging.FirebaseMessagingService.passMessageIntentToSdk(com.google.firebase:firebase-messaging@@20.3.0:44)
    at com.google.firebase.messaging.FirebaseMessagingService.handleMessageIntent(com.google.firebase:firebase-messaging@@20.3.0:27)
    at com.google.firebase.messaging.FirebaseMessagingService.handleIntent(com.google.firebase:firebase-messaging@@20.3.0:17)
    at com.google.firebase.messaging.EnhancedIntentService.lambda$processIntent$0$EnhancedIntentService(com.google.firebase:firebase-messaging@@20.3.0:43)
    at com.google.firebase.messaging.EnhancedIntentService$$Lambda$0.run
    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(com.google.android.gms:play-services-basement@@17.5.0:6)
    at java.lang.Thread.run(Thread.java:923)

Basically added a conditional check: https://android.googlesource.com/platform/frameworks/base.git/+/master/services/core/java/com/android/server/notification/NotificationManagerService.java#3412

Not sure if we should print a logger for this, it seemed best to just skip the error unless we decide to notify the user.

For the record our default channel seems to be miscellaneous

Also fixes an incorrect variable in debug logs

Screenshots

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

@JBassett JBassett merged commit 6109ce4 into home-assistant:master Mar 8, 2021
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