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

Always request Bluetooth permission for Improv if 1/2 is granted #4952

Merged

Conversation

jpelgrom
Copy link
Member

@jpelgrom jpelgrom commented Jan 4, 2025

Summary

Fixes #4936. The issue is caused by the following combination:

  1. from the Nearby devices permission group a Bluetooth permission is granted, so the system settings show the permission as on, but not all permissions are granted
  2. the in-app permission prompt was shown at least twice so it is not shown again

It results in the user thinking everything is good, while the app doesn't continue and doesn't request additional permissions -> confusion why nothing is discovered.

This PR tries to fix it by checking when 1) not all permissions are granted and 2) the prompt was shown at least twice, if we need just one Bluetooth permission, and if so always requesting that permission. Because Improv needs two Bluetooth permissions that means something from the Nearby devices group was granted so when requesting it Android automatically grants it without asking the user.

For testing this you probably want to use some adb commands:

  • adb shell dumpsys package io.homeassistant.companion.android.debug | grep permission to verify what exactly is granted
  • adb shell pm revoke io.homeassistant.companion.android.debug android.permission.BLUETOOTH_CONNECT to revoke one but not the other Bluetooth permission (or the grant equivalent)
    adb output with Improv related permissions highlighted

Screenshots

n/a

Link to pull request in Documentation repository

n/a

Any other notes

@jpelgrom
Copy link
Member Author

jpelgrom commented Jan 4, 2025

FYI some additional details:

packageManager.getPlatformPermissionsForGroup(
    android.Manifest.permission_group.NEARBY_DEVICES,
    mainExecutor
)

returns the following list: android.permission.BLUETOOTH_ADVERTISE, android.permission.BLUETOOTH_CONNECT, android.permission.BLUETOOTH_SCAN, android.permission.UWB_RANGING, android.permission.NEARBY_WIFI_DEVICES.

The app does not use UWB_RANGING or NEARBY_WIFI_DEVICES anywhere. Improv requires BLUETOOTH_SCAN and BLUETOOTH_CONNECT. The 3 Bluetooth permissions are used by some parts of the app in varying combinations, but BLUETOOTH_ADVERTISE is only used here in a combination with BLUETOOTH_CONNECT so the proposed check is fine (no way to only have BLUETOOTH_ADVERTISE).

@dshokouhi dshokouhi merged commit bd61abc into home-assistant:master Jan 4, 2025
4 checks passed
@jpelgrom jpelgrom deleted the improv-permission-ask-if-group branch January 4, 2025 21:25
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.

Voice PE / Improv Wi-Fi device Not Discovered
2 participants