Add Lazy connection toggle to Advanced settings#171
Add Lazy connection toggle to Advanced settings#171MichaelUray wants to merge 1 commit intonetbirdio:mainfrom
Conversation
Adds a switch in the Advanced fragment that controls the LazyConnectionEnabled engine setting. Default is OFF so existing behavior is preserved; users opt in to per-peer connection on first traffic for reduced background load. The toggle wires through the new GetLazyConnectionEnabled / SetLazyConnectionEnabled methods on the gomobile Preferences bridge. Tested on a Galaxy S21 (Android 15): toggling the switch persists LazyConnectionEnabled in the config; on reconnect 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) and peers are wired up on demand instead of eagerly.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughA new "Lazy Connection" configuration switch is added to the advanced settings UI. The implementation includes Java logic to load and persist the setting, layout XML defining the switch component, and localized string resources for the label and description. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Describe your changes
Adds a "Lazy connection" switch to the Advanced settings fragment (sits between Block inbound connections and Disable client routes). The toggle controls the engine's
LazyConnectionEnabledsetting via the gomobilePreferencesbridge.layout_lazy_connectionblock infragment_advanced.xml; the constraint chain is updated solayout_disable_client_routesis anchored below the new block.advanced_lazy_connection/advanced_lazy_connection_desc.AdvancedFragment.initializeEngineConfigSwitches()reads the current value viagoPreferences.getLazyConnectionEnabled()and writes back viasetLazyConnectionEnabled()+commit()on toggle, with a TV-remote layout click handler wired throughlayout_lazy_connection.toggle().Default is off, so behavior on existing installs does not change until a user enables it explicitly.
Issue ticket number and link
N/A.
Checklist
Dependency
This PR consumes two new bridge methods on the gomobile
Preferencestype:GetLazyConnectionEnabled() (bool, error)SetLazyConnectionEnabled(enabled bool)Those are added in netbirdio/netbird#5994. This PR's submodule pointer is intentionally not bumped — it should land after #5994 merges, at which point a routine submodule update will pick up the new bridge symbols and this PR will compile.
Testing
Verified end-to-end on a Galaxy S21 (SM-G991B, Android 15) with a local build that includes the bridge change:
aapt2 dump resourcesconfirmsid/layout_lazy_connection,id/switch_lazy_connection,string/advanced_lazy_connectionare baked into the APK.dexdumpconfirmsAdvancedFragmentcallsPreferences.{get,set}LazyConnectionEnabled.client/internal/lazyconn/manager/manager.go: setup lazy connection serviceclient/internal/lazyconn/inactivity/manager.go: inactivity threshold configured: 15m0sclient/internal/conn_mgr.go: peer added to lazy conn manager(per peer)client/internal/lazyconn/activity/listener_udp.go: created activity listener: 127.0.0.1:NNNNNremoving activity listener→adding peer to inactivity managerclient/internal/conn_mgr.go: lazy connection manager is disabled.Summary by CodeRabbit