-
-
Notifications
You must be signed in to change notification settings - Fork 974
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
fix(connectivity_plus): Ensure Connectivity on Android is correctly reported when lost #2836
Conversation
Reading a bit more the Android documentation, I need to do some changes, as this is not fully correct still. edit: done. |
It is something I shared in this PR adding 100 ms delay: #2673 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that there is a distinct
now, but I don't like that none
in the middle due to onLost
sending none
status, because it is wrong for scenarios like you described in your vpn + wifi case.
I will also do some testing of these changes later
In the PR that I already mentioned above there is a screen recording that disconnecting mobile works fine and updates status properly. It was on a real device. And same happened on emulator. |
Understandable, I think a middle ground solution would be do the delayed call to obtain the connectivity status in I'd also increase the delay time. I did see problems in my Android phone (Pixel 5) when switching off mobile network. WiFi works well, but with mobile networks the stream did emit a |
I have updated the implementation, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some testing for various cases on my Pixel 7 and everything works as it should.
I think we would still see some devices with customised ROMs to have a similar issue, but hope that increased delay would help.
2 important commits: v6.0.2: fluttercommunity/plus_plugins#2763 v6.0.3: fluttercommunity/plus_plugins#2836
2 important commits: v6.0.2: fluttercommunity/plus_plugins#2763 v6.0.3: fluttercommunity/plus_plugins#2836
2 important commits: v6.0.2: fluttercommunity/plus_plugins#2763 v6.0.3: fluttercommunity/plus_plugins#2836
2 important commits: v6.0.2: fluttercommunity/plus_plugins#2763 v6.0.3: fluttercommunity/plus_plugins#2836
Description
onConnectivityChange
were not correct.onConnectivityChange
was still reporting connectivitymobile
.onLost
callback: Increased the delay to 500 milliseconds to avoid race conditions.onLost
.distinct
to the stream, because the callback was being called a lot of times after a change. I don't think users will miss that ;)What a plugin consumer will see:
[wifi]
is emitted.[mobile]
is emitted. (Note: Users may still see a[none]
event if the phone fails to connect to mobile while switching)[wifi]
is emitted.[none]
is emitted.With a VPN + wifi:
[wifi, vpn]
[wifi]
BTW, from the Android documentation:
Which is why users were still seeing mobile connectivity even if it was disconnected.
The 100 ms delay we had in place was not enough to ensure that wasn't an issue.
This is why it is increased to 500 ms and used only in
onLost
since it is the only place where it is strictly necessary.Related Issues
Checklist
CHANGELOG.md
nor the plugin version inpubspec.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).