Skip to content

feat: add network preference settings to shortcuts#559

Open
cheriu wants to merge 5 commits into
Waboodoo:developfrom
cheriu:pr/prefer-network
Open

feat: add network preference settings to shortcuts#559
cheriu wants to merge 5 commits into
Waboodoo:developfrom
cheriu:pr/prefer-network

Conversation

@cheriu
Copy link
Copy Markdown

@cheriu cheriu commented May 26, 2026

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:

Option Behavior
System default No binding — routes through default interface
Prefer mobile data Binds to cellular if available (timeout 5s), falls back to default
Mobile data only Strictly cellular (timeout 15s); fails if unavailable
Prefer Wi-Fi Binds to Wi-Fi if available (timeout 5s), falls back to default
Wi-Fi only Strictly Wi-Fi (timeout 15s); fails if unavailable

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.

cheriu added 5 commits May 26, 2026 14:53
- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant