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

Check for permissions and notify if they are missing when command_bluetooth is used #2205

Merged
merged 1 commit into from
Jan 27, 2022

Conversation

dshokouhi
Copy link
Member

Summary

Fixes the below sentry error by checking for permissions and if the user has not granted them we notify the user and explain how to grant them. As this command needs a different permission not linked to a particular activity and the commands are sent in the background we take the user to app details and have them grant the permission. String was also updated to reflect this. Only impacts users on Android 12 who attempt to use command_bluetooth without proper permissions, usualy a user will have already granted this permission assuming they had the sensor enabled.

java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for AttributionSource { uid = 10309, packageName = io.homeassistant.companion.android, attributionTag = null, token = android.os.BinderProxy@ba98dfd, next = null }: enable
    at android.os.Parcel.createExceptionOrNull(Parcel.java:2437)
    at android.os.Parcel.createException(Parcel.java:2421)
    at android.os.Parcel.readException(Parcel.java:2404)
    at android.os.Parcel.readException(Parcel.java:2346)
    at android.bluetooth.IBluetoothManager$Stub$Proxy.enable(IBluetoothManager.java:987)
    at android.bluetooth.BluetoothAdapter.enable(BluetoothAdapter.java:2200)
    at io.homeassistant.companion.android.notifications.MessagingManager.handleDeviceCommands(MessagingManager.kt:550)
    at io.homeassistant.companion.android.notifications.MessagingManager.handleMessage(MessagingManager.kt:277)
    at io.homeassistant.companion.android.notifications.FirebaseCloudMessagingService.onMessageReceived(FirebaseCloudMessagingService.kt:38)
    at com.google.firebase.messaging.FirebaseMessagingService.dispatchMessage(com.google.firebase:firebase-messaging@@23.0.0:12)
    at com.google.firebase.messaging.FirebaseMessagingService.passMessageIntentToSdk(com.google.firebase:firebase-messaging@@23.0.0:8)
    at com.google.firebase.messaging.FirebaseMessagingService.handleMessageIntent(com.google.firebase:firebase-messaging@@23.0.0:3)
    at com.google.firebase.messaging.FirebaseMessagingService.handleIntent(com.google.firebase:firebase-messaging@@23.0.0:3)
    at com.google.firebase.messaging.EnhancedIntentService.lambda$processIntent$0$com-google-firebase-messaging-EnhancedIntentService(com.google.firebase:firebase-messaging@@23.0.0:1)
    at com.google.firebase.messaging.EnhancedIntentService$$ExternalSyntheticLambda1.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@@18.0.0:2)
    at java.lang.Thread.run(Thread.java:920)

Screenshots

Link to pull request in Documentation repository

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

Any other notes

@JBassett JBassett merged commit 7d6c629 into home-assistant:master Jan 27, 2022
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.

3 participants