fix(network_info_plus): Get SSID on Android 12 and newer #1231
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
As it turned out in Android 12 and newer
SSID
andBSSID
are considered a location sensitive info, thus the new API to get WifiInfo viagetNetworkCapabilities()
returned all info except these 2 values. And it doesn't matter that app has required permissions. Explanation is provided in the official docs:https://developer.android.com/reference/android/net/ConnectivityManager#getNetworkCapabilities(android.net.Network)
The suggested way to register a callback with required flag seems not the best option for the
network_info_plus
as we want to get info on demand, not wait till something changes in network configuration.It seems we are not the only ones, who issue this problem: https://stackoverflow.com/questions/71281724/getting-wifi-ssid-from-connectivitymanager-networkcapabilities-synchronously
Based on the info above I decided to revert one of changes I made in #1151 and rely on deprecated function to get needed required info. I think we are safe to live till time comes to kill this deprecated API in next Android releases. However, hope that Google introduces some better API to not have only callbacks way.
Related Issues
Closes #1181
Checklist
CHANGELOG.md
nor thepubspec.yaml
files.flutter analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?
!
in the title as explained in Conventional Commits).