[PR #5644] [MERGED] [client] Refactor Android PeerInfo to use proper ConnStatus enum type #28263

Closed
opened 2026-08-05 08:06:03 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/5644
Author: @iakshayubale
Created: 3/20/2026
Status: Merged
Merged: 3/30/2026
Merged by: @pappz

Base: mainHead: client/android-connstatus-enum


📝 Commits (2)

  • b187efe Simplify Android ConnStatus API with integer constants
  • 425aa40 test: add All group to setupTestAccount fixture

📊 Changes

3 files changed (+17 additions, -2 deletions)

View changed files

📝 client/android/client.go (+1 -1)
📝 client/android/peer_notifier.go (+10 -1)
📝 management/server/types/account_test.go (+6 -0)

📄 Description

Describe your changes

Simplifies Android PeerInfo ConnStatus API by replacing dual-field complexity with gomobile-friendly integer constants.

Before:

  • ConnStatus field was a string placeholder requiring conversion
  • Todo comment indicating need to migrate to enum type

After (Current Implementation):

  • Single ConnStatus int field replacing string
  • Exported three gomobile-friendly constants:
    • ConnStatusIdle = int(peer.StatusIdle)
    • ConnStatusConnecting = int(peer.StatusConnecting)
    • ConnStatusConnected = int(peer.StatusConnected)
  • Direct enum-to-int conversion in PeersList()
  • Integer constants map directly to peer.ConnStatus enum values

Key Point:
Since the Android repo pins an explicit version of this codebase, we control both sides of the change and can update them together without maintaining backward compatibility constraints.

Benefits:

  • Simpler API surface with single ConnStatus int field
  • Better gomobile compatibility for Java/Kotlin integration
  • Type-safe integer constants across language boundaries
  • Eliminates abstraction layers and helper methods
  • Resolves TODO comment requesting enum migration
  • Android side implements Status.fromInt() matching exported constants

Resolves TODO comment in client/android/peer_notifier.go

Stack

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)

Documentation

  • Documentation is not needed for this change (Internal refactoring with simplified single-field approach. PeerInfo struct documentation covers the int field.)

Docs PR URL

N/A

Summary by CodeRabbit

  • Refactors
    • Simplified ConnStatus field in PeerInfo from string to int for improved type safety
    • Exported gomobile-friendly integer constants mapping peer connection states
    • Removed dual-field complexity in favor of single int field with mapped constants
    • Updated PeersList() to directly convert peer.ConnStatus enum to int
    • Added test verification for constant mappings and type consistency
    • No public API signatures removed; implementation is cleaner and more maintainable

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/5644 **Author:** [@iakshayubale](https://github.com/iakshayubale) **Created:** 3/20/2026 **Status:** ✅ Merged **Merged:** 3/30/2026 **Merged by:** [@pappz](https://github.com/pappz) **Base:** `main` ← **Head:** `client/android-connstatus-enum` --- ### 📝 Commits (2) - [`b187efe`](https://github.com/netbirdio/netbird/commit/b187efe91df93e7cd19ec391db17cce854a40bd8) Simplify Android ConnStatus API with integer constants - [`425aa40`](https://github.com/netbirdio/netbird/commit/425aa407b906bdea1371a8645a6aa382e4f69c44) test: add All group to setupTestAccount fixture ### 📊 Changes **3 files changed** (+17 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `client/android/client.go` (+1 -1) 📝 `client/android/peer_notifier.go` (+10 -1) 📝 `management/server/types/account_test.go` (+6 -0) </details> ### 📄 Description ## Describe your changes Simplifies Android `PeerInfo` ConnStatus API by replacing dual-field complexity with gomobile-friendly integer constants. **Before:** - `ConnStatus` field was a string placeholder requiring conversion - Todo comment indicating need to migrate to enum type **After (Current Implementation):** - Single `ConnStatus` int field replacing string - Exported three gomobile-friendly constants: - `ConnStatusIdle` = int(peer.StatusIdle) - `ConnStatusConnecting` = int(peer.StatusConnecting) - `ConnStatusConnected` = int(peer.StatusConnected) - Direct enum-to-int conversion in `PeersList()` - Integer constants map directly to peer.ConnStatus enum values **Key Point:** Since the Android repo pins an explicit version of this codebase, we control both sides of the change and can update them together without maintaining backward compatibility constraints. **Benefits:** - ✅ Simpler API surface with single ConnStatus int field - ✅ Better gomobile compatibility for Java/Kotlin integration - ✅ Type-safe integer constants across language boundaries - ✅ Eliminates abstraction layers and helper methods - ✅ Resolves TODO comment requesting enum migration - ✅ Android side implements Status.fromInt() matching exported constants ## Issue ticket number and link Resolves TODO comment in [client/android/peer_notifier.go](https://github.com/netbirdio/netbird/blob/main/client/android/peer_notifier.go) ## Stack ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [x] It is a refactor - [ ] Created tests that fail without the change (if possible) ## Documentation - [x] Documentation is **not needed** for this change (Internal refactoring with simplified single-field approach. PeerInfo struct documentation covers the int field.) ### Docs PR URL N/A <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactors** * Simplified ConnStatus field in PeerInfo from string to int for improved type safety * Exported gomobile-friendly integer constants mapping peer connection states * Removed dual-field complexity in favor of single int field with mapped constants * Updated PeersList() to directly convert peer.ConnStatus enum to int * Added test verification for constant mappings and type consistency * No public API signatures removed; implementation is cleaner and more maintainable <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 08:06:03 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#28263