[client] Android profile switch
Describe your changes
Expose the profile-manager service for Android. Logout was not part of the manager service implementation. In the future, I recommend moving this logic there.
Issue ticket number and link
Stack
Checklist
- [ ] Is it a bug fix
- [ ] Is a typo/documentation fix
- [x] 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
- [x] Documentation is not needed for this change (explain why)
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
https://github.com/netbirdio/docs/pull/__
Summary by CodeRabbit
-
New Features
- Added Android profile management: list, switch, create, remove, logout profiles, and view active profile; exposes config/state path utilities for mobile.
-
Refactor
- Android client startup now uses platform-aware config/state handling and logs the active config and state files.
- Service manager can use an alternate profiles directory to support mobile/embedded paths.
✏️ Tip: You can customize this high-level summary in your review settings.
Walkthrough
Platform-specific config/state file handling moved out of the Android Client struct into method parameters; an Android ProfileManager wrapper was added; ServiceManager gained an optional profiles directory override; the engine now uses mobile-provided state paths on iOS/Android while preserving desktop behavior.
Changes
| Cohort / File(s) | Summary |
|---|---|
Client parameter refactor client/android/client.go |
Removed Client.cfgFile and Client.stateFile fields. NewClient signature changed to remove platformFiles. Run and RunWithoutLogin now accept platformFiles, derive local cfgFile/stateFile, log active config/state, and pass stateFile to downstream functions; all references to former struct fields removed. |
Android profile manager (new) client/android/profile_manager.go |
Added Android-focused ProfileManager wrapper types (Profile, ProfileArray, ProfileManager) and public methods: ListProfiles, GetActiveProfile, SwitchProfile, AddProfile, LogoutProfile, RemoveProfile, plus config/state path getters and Android-specific pathing/sanitization. |
Mobile state path change client/internal/engine.go |
On mobile (iOS/Android) use mobileDep.StateFilePath (creating the file if missing) for state path; non-mobile platforms continue using ServiceManager-derived state path. |
ServiceManager override capability client/internal/profilemanager/service.go |
Added profilesDir field and NewServiceManagerWithProfilesDir constructor. Introduced getConfigDir helper and updated Add/Remove/List/GetStatePath to honor an optional profiles directory override. |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
- Check all call sites for updated
NewClient,Run, andRunWithoutLoginsignatures. - Verify ProfileManager methods correctly map to internal profilemanager behavior and path conventions (especially active_profile handling and logout clearing of keys).
- Confirm ServiceManager
profilesDiroverride doesn't regress non-mobile path resolution. - Validate engine mobile path creation error handling and that it preserves previous desktop behavior.
Poem
🐰 I hopped through code with whiskers bright,
Moved configs from burrows into daylight,
A ProfileManager nested snug and small,
Paths now tidy under Android's hall,
I nibble bugs and bounce — rejoice, one and all!
Pre-merge checks and finishing touches
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title '[client] Android profile switch' clearly and concisely describes the main change: exposing profile-manager functionality for Android. It is specific, directly related to the changeset, and avoids vague terms. |
| Description check | ✅ Passed | The description covers the main change (exposing profile-manager for Android) and checklist items. However, it lacks an issue ticket reference and leaves the Docs PR URL field partially unfilled despite checking documentation-related items. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
- [ ] Commit unit tests in branch
android-profile-switch
📜 Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 4cee5bebf1b022c3ceff4d33ee06a71a57155019 and 5b69abb3024c7d9906f6f534a562d77bd51130de.
📒 Files selected for processing (1)
client/android/profile_manager.go(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- client/android/profile_manager.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
- GitHub Check: Management / Unit (amd64, postgres)
- GitHub Check: Client / Unit (amd64)
- GitHub Check: Relay / Unit (amd64, -race)
- GitHub Check: Management / Unit (amd64, sqlite)
- GitHub Check: Management / Unit (amd64, mysql)
- GitHub Check: Client (Docker) / Unit
- GitHub Check: Client / Unit (386)
- GitHub Check: Relay / Unit (386)
- GitHub Check: Darwin
- GitHub Check: Linux
- GitHub Check: Windows
- GitHub Check: Client / Unit
- GitHub Check: Client / Unit
- GitHub Check: release_ui_darwin
- GitHub Check: release
- GitHub Check: Client / Unit
- GitHub Check: release_ui
- GitHub Check: JS / Lint
- GitHub Check: Android / Build
- GitHub Check: iOS / Build
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 @coderabbitai help to get the list of available commands and usage tips.
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code