-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Fix android#1982: Improved ConnectivityManagerNetworkMonitor #2036
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
base: main
Are you sure you want to change the base?
Fix android#1982: Improved ConnectivityManagerNetworkMonitor #2036
Conversation
…dated internet, transport checks, and distinctUntilChanged()
Summary of ChangesHello @Syedovaiss, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the reliability and accuracy of network connectivity monitoring within the application. By integrating NET_CAPABILITY_VALIDATED and restricting checks to specific, validated transport types, it ensures that the reported network status truly reflects usable internet access. These changes also improve code consistency and optimize flow emissions, leading to a more robust and efficient network monitoring solution. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request significantly improves the ConnectivityManagerNetworkMonitor by incorporating NET_CAPABILITY_VALIDATED and filtering for specific transport types (Wi-Fi, Cellular, Ethernet). This ensures that the reported network connectivity is truly usable for internet access, addressing previous inconsistencies. The refactoring of isCurrentlyConnected() into smaller, focused helper functions enhances readability and maintainability. Additionally, the introduction of distinctUntilChanged() optimizes the flow by preventing redundant emissions. Overall, these changes make the network monitoring more robust and accurate.
|
@dturner would appreciate your review when available. Key intent here was to ensure:
Open to any feedback or alternative approaches. |
|
If we only need to validate for Internet connection, hasSupportedTransport() check seems to be redundant. |
Thanks for the feedback — good point. NET_CAPABILITY_VALIDATED does ensure that the network has verified internet access, but the additional hasSupportedTransport() check was added intentionally to align with the scope of connectivity this app considers “online.” In practice, a network can be validated but still be backed by transports such as VPN or other specialized links. While these may technically provide internet access, they can produce connectivity signals that differ from what the app expects for general online behavior. The transport filter ensures: That said, I’m happy to simplify this if the project prefers to rely solely on NET_CAPABILITY_VALIDATED and treat all validated transports as acceptable. Please let me know which direction you’d prefer, and I can update the implementation accordingly. |
What I have done and why
Fix #1982: Align NetworkRequest and improve transport check readability
Changes
Added NET_CAPABILITY_VALIDATED and transport type checks to
ConnectivityManagerNetworkMonitor:Updated NetworkRequest in registerNetworkCallback:
isCurrentlyConnected()for consistency.Refactored transport check logic:
hasSupportedTransport()helper.any()for cleaner, more maintainable code.Added
distinctUntilChanged()to the flow:Motivation
isCurrentlyConnected()andNetworkRequestused in the callback could disagree on connectivity state.truefor networks that are not actually usable for internet access.Additional Context