feat: add network preference settings to shortcuts#559
Open
cheriu wants to merge 5 commits into
Open
Conversation
- Added a new enum class `NetworkPreference` to define network usage options (e.g., prefer cellular, only Wi-Fi). - Updated the `AdvancedSettingsContent`, `AdvancedSettingsScreen`, and `AdvancedSettingsViewModel` to include network preference selection. - Modified the `Shortcut` model to store the selected network preference. - Enhanced the `HttpRequester` to utilize the specified network preference when making requests. - Updated the database schema to include a new column for network preference and incremented the version. - Added necessary imports and updated the import/export functionality to handle network preference. - Added new strings for network preference options in `strings.xml`.
PREFER_* timeouts let the call return null after 5s so execution falls back to the default route; ONLY_* waits 15s before throwing.
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.
Summary
Adds per-shortcut network interface binding, allowing shortcuts to force HTTP traffic through a specific network (cellular or Wi-Fi) while keeping both TCP and DNS on the same interface.
Motivation
On devices with both Wi-Fi and cellular connections active, the system always routes traffic through Wi-Fi (lower metric). Some use cases require shortcuts to use mobile data instead — for example, if Wi-Fi has no IPv6 but the cellular network does, connecting to IPv6-only domains will fail.
Feature
A new Network Preference dropdown in Advanced Shortcut Settings with 5 options:
The network is requested via
ConnectivityManager.requestNetwork(), which requires the CHANGE_NETWORK_STATE permission. This will wake the cellular modem and may increase battery consumption.