Skip to content

[client] expose LazyConnectionEnabled in Android Preferences bridge - #5994

Open
MichaelUray wants to merge 2 commits into
netbirdio:mainfrom
MichaelUray:feat/android-lazy-connection-toggle-upstream
Open

[client] expose LazyConnectionEnabled in Android Preferences bridge#5994
MichaelUray wants to merge 2 commits into
netbirdio:mainfrom
MichaelUray:feat/android-lazy-connection-toggle-upstream

Conversation

@MichaelUray

@MichaelUray MichaelUray commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Describe your changes

Adds two methods to the Android Preferences bridge so the Android UI can read and write the existing LazyConnectionEnabled engine setting:

  • GetLazyConnectionEnabled() (bool, error)
  • SetLazyConnectionEnabled(enabled bool)

The implementation mirrors the adjacent BlockInbound bridge: it returns the in-memory configInput value first if set, otherwise falls back to reading the persisted config; the setter buffers the value in configInput and waits for Commit().

Issue ticket number and link

N/A — bridge addition only, no behavior change in the engine.

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

This is an internal Go-mobile bridge addition with no user-facing surface in this repo. The LazyConnectionEnabled setting itself is already honored by the engine and presumably already documented at the engine level. The Android UI that consumes these methods is filed at netbirdio/android-client#171; if user docs are needed for the toggle, they belong with that UI change.

Docs PR URL (required if "docs added" is checked)

N/A.

Notes

  • The LazyConnectionEnabled field already exists in client/internal/profilemanager/config.go and is honored by the engine; this change only exposes it through the gomobile bridge.
  • Companion UI work that consumes these methods is filed at Add Lazy connection toggle to Advanced settings android-client#171.
  • Verified locally with go build ./client/android/... and go test ./client/android/... (existing tests pass; no new test added because the new methods are pure passthroughs to the well-tested configInput / ReadConfig / UpdateOrCreateConfig code paths). Tested end-to-end on a Galaxy S21 (Android 15) — toggle in the Android UI persists LazyConnectionEnabled to the config file and the engine activates the lazy-connection manager (setup lazy connection service, per-peer activity listeners on 127.0.0.1:N, 15-minute inactivity threshold) as expected.

Documentation

  • Documentation is not needed

These changes are internal lifecycle / behavioural improvements; no user-visible API or CLI flag added that warrants new public docs. Existing flags/Settings already documented at netbirdio/docs cover the surface area.

Summary by CodeRabbit

  • New Features
    • Added lazy-connection preference setting for Android devices, enabling users to configure this option through the app's preferences interface.

Review Change Stack

Mirrors the existing BlockInbound bridge: the new GetLazyConnectionEnabled /
SetLazyConnectionEnabled methods read/write the field via the same
configInput-buffer-then-Commit pattern, so the Android UI can manage the
LazyConnectionEnabled setting that the engine already understands.
@coderabbitai

coderabbitai Bot commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: efa39531-b2e8-404e-a9a7-01404af3a138

📥 Commits

Reviewing files that changed from the base of the PR and between c17355d and 5ddcb32.

📒 Files selected for processing (1)
  • client/android/preferences.go

📝 Walkthrough

Walkthrough

Two new accessor methods are added to the Android Preferences struct for managing a "lazy-connection" setting. The getter retrieves the cached value or loads from config, while the setter updates the in-memory field pending the existing commit operation.

Changes

Lazy Connection Preference Accessors

Layer / File(s) Summary
Get/Set lazy-connection accessors
client/android/preferences.go
Added GetLazyConnectionEnabled() and SetLazyConnectionEnabled() methods following the existing pattern: getter returns cached pointer or reads via profilemanager.ReadConfig, setter updates configInput.LazyConnectionEnabled in memory.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • pappz

Poem

I hop through code with ears held high, 🐇
A flag for lazy links beneath the sky,
Get and set with tidy, gentle care,
Memory holds the change until commit’s there,
Happy hops for prefs made fair.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: exposing LazyConnectionEnabled in the Android Preferences bridge.
Description check ✅ Passed The description is comprehensive, follows the template structure, and addresses all key sections including changes, documentation rationale, testing, and related work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@MichaelUray

Copy link
Copy Markdown
Contributor Author

The companion UI change consuming these bridge methods is filed at netbirdio/android-client#171.

Pull current upstream/main into this PR branch. SHAs of
pre-existing commits on the branch are preserved so inline
review anchors stay valid. PR diff against upstream is recomputed
automatically by GitHub.

# Conflicts:
#	client/android/preferences.go
@sonarqubecloud

Copy link
Copy Markdown

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