Skip to content

feat: implement Android connectivity detection#14

Open
gabref wants to merge 5 commits into
silvermine:masterfrom
gabref:gabref/android-connectivity-status
Open

feat: implement Android connectivity detection#14
gabref wants to merge 5 commits into
silvermine:masterfrom
gabref:gabref/android-connectivity-status

Conversation

@gabref
Copy link
Copy Markdown

@gabref gabref commented Jun 5, 2026

Closes #10.

Adds Android support for connection_status() using Tauri's mobile plugin bridge and Android's ConnectivityManager / NetworkCapabilities APIs.

Changes

  • Added Android plugin scaffold under android/src/main/.
  • Added Kotlin bridge invoked from Rust through src/mobile.rs.
  • Maps Android connectivity state into the existing ConnectionStatus fields:
    • connected: active network with NET_CAPABILITY_INTERNET and NET_CAPABILITY_VALIDATED
    • metered: absence of NET_CAPABILITY_NOT_METERED, with NET_CAPABILITY_TEMPORARILY_NOT_METERED treated as unmetered while present
    • constrained: Data Saver / RESTRICT_BACKGROUND_STATUS_ENABLED
    • connectionType: Wi-Fi, Ethernet, Cellular, or Unknown
  • Added android.permission.ACCESS_NETWORK_STATE to the Android manifest.
  • Kept desktop backends in src/platform.rs and added a separate mobile bridge path for Android and future mobile platforms.
  • Added Android unit tests for the mapping logic.
  • Added manual Android testing documentation, including Data Saver adb commands and tested scenarios.

Testing

Automated:

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • npm test
  • npm run eslint
  • npm run type-check
  • npm run markdownlint
  • COMMITLINT_FROM=HEAD~1 COMMITLINT_TO=HEAD npm run commitlint
  • Android unit tests: :tauri-plugin-connectivity:testDebugUnitTest

Manual Android testing with the example app:

  • Wi-Fi connected
  • Cellular connected
  • Airplane mode / disconnected
  • Data Saver constrained state
  • Metered Wi-Fi through hotspot

Android debug build was also verified with:

npm run tauri android build -- --debug --ignore-version-mismatches

gabu added 5 commits June 2, 2026 11:13
Linux needs a passive backend that works with NetworkManager when available.

Smaller systems without NetworkManager should still get a predictable answer.

Use cached NetworkManager properties for connectivity, metering, and transport.

Fall back to the kernel route table and sysfs instead of active probes.
Update the Linux support matrix and API docs to describe how the backend maps
NetworkManager connectivity, portal state, metering, transport, and constrained
fallback behavior.
Manual Linux testing is easier when the example app emits plugin debug logs.

Install a debug-friendly tracing subscriber in the example app.

Refresh its lockfile for logging and the Linux backend dependency graph.
Document tested Linux scenarios, expected responses, and setup commands.

Note that ModemManager cellular and roaming scenarios remain untested.
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.

Implement Android support for connectivity detection

1 participant