Internal custom URL no longer requires network - #1301
Open
dchp wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Context
When Custom URL logging is enabled, outgoing HTTP requests are scheduled via WorkManager. For public URLs, the job is constrained to an internet-capable network (Wi‑Fi or mobile data, optionally Wi‑Fi only).
This works for remote servers, but blocks jobs when the destination is reachable locally without internet access - for example a server on the LAN, localhost, or over USB tethering/RNDIS.
Problem
Users logging to localhost or utilizing USB RNDIS Reverse Tethering encounter an issue where the Android system correctly identifies that the device has no active internet (Wi-Fi/Cellular), which consequently prevents the log transmission job from running. However, in these scenarios, traditional internet connectivity is not required, as the traffic is routed locally or over a physical USB connection.
Solution
I have introduced an InternalAddresses utility class that detects local/private IP addresses without requiring DNS lookups or adding external dependencies.
If the destination URL is determined to be an internal address, the network constraints for the WorkManager job are relaxed, allowing the task to run regardless of the active network status.
Detected Ranges:
Intentionally not treated as internal:
Technical Details
If a destination is defined as a private IP but is unreachable (e.g., the USB cable is disconnected), the attempt will naturally fail at the socket level. This is preferred behavior, as it allows the WorkManager to trigger the job and utilize its built-in retry mechanism once connectivity is restored, rather than blocking the task from ever initiating.