Skip to content

feat: implement AVS quick network switch recovery [WPB-22679]#4533

Merged
saleniuk merged 4 commits intodevelopfrom
feat/network-switch-quick-call-recovery
Jan 21, 2026
Merged

feat: implement AVS quick network switch recovery [WPB-22679]#4533
saleniuk merged 4 commits intodevelopfrom
feat/network-switch-quick-call-recovery

Conversation

@saleniuk
Copy link
Copy Markdown
Contributor

@saleniuk saleniuk commented Jan 16, 2026

https://wearezeta.atlassian.net/browse/WPB-22679


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Issues

When device is switching networks, call freezes for even 15-20 seconds as it needs to timeout current connection in order for AVS to try to reconnect.

Solutions

Changed kalium version to use the one that contains changes required for the AVS quick network switching and updated TestNetworkStateObserver to adjust to these changes.

Dependencies (Optional)

Needs releases with:

Testing

How to Test

Start/join a call, switch network between wifi and cellular.

Attachments (Optional)

Before After
switch-network-before.mp4
switch-network-after.mp4

PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

@MohamadJaara
Copy link
Copy Markdown
Member

@claude review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 20, 2026

Pull Request Review - feat: implement AVS quick network switch recovery WPB-22679

Overview

This PR implements AVS quick network recovery by updating the Kalium dependency and adjusting the TestNetworkStateObserver to support the new observeCurrentNetwork() method required by the updated NetworkStateObserver interface.

Code Quality: ✅ Good

Strengths:

  • Clean, minimal changes that directly address the requirement
  • Proper default values for backward compatibility
  • Consistent naming conventions and code style
  • Good use of nullable types for CurrentNetwork

Minor Issues:

  1. Missing Import ⚠️

    • Location: app/src/androidTest/kotlin/com/wire/android/TestNetworkStateObserver.kt:24
    • Issue: The code adds StateFlow as a return type but only imports MutableStateFlow
    • Fix: Add import for StateFlow:
    import kotlinx.coroutines.flow.StateFlow
    • Impact: This will likely cause a compilation error
  2. Potential Name Shadowing ⚠️

    • Location: Lines 27 & 28
    • Issue: The constructor parameter currentNetwork shadows the private property currentNetwork
    currentNetwork: CurrentNetwork? = CurrentNetwork("0", CurrentNetwork.Type.UNKNOWN, true)
    ) : NetworkStateObserver {
        private val currentNetwork = MutableStateFlow(currentNetwork)  // shadows parameter
    • Fix: Rename the property to avoid confusion:
    private val _currentNetwork = MutableStateFlow(currentNetwork)
    override fun observeCurrentNetwork(): StateFlow<CurrentNetwork?> = _currentNetwork
    • Impact: Low - works but reduces code clarity
  3. Default Network ID Ambiguity 💭

    • Location: Line 26
    • Issue: Default CurrentNetwork("0", CurrentNetwork.Type.UNKNOWN, true) uses a hardcoded ID
    • Question: Is "0" a meaningful default for tests, or should this be null or a more descriptive value?
    • Impact: Low - works for tests but worth confirming the intent

Potential Bugs: ⚠️ One Critical Issue

CRITICAL:

  • Missing StateFlow import will cause compilation failure
  • This must be fixed before merging

Performance Considerations: ✅ Good

  • No performance concerns
  • Proper use of StateFlow for observable state
  • Minimal overhead from additional state tracking

Security Concerns: ✅ None

  • No security issues identified
  • Test-only code with no production impact

Test Coverage: ⚠️ Needs Attention

Concerns:

  1. New Method Not Used in Tests

    • The new updateCurrentNetwork() method has no test coverage
    • Consider adding tests that exercise network switching scenarios
  2. Default Value Testing

    • No tests verify that the default CurrentNetwork value is appropriate
    • Should verify behavior when currentNetwork is null vs non-null
  3. Integration Testing

    • While manual testing is described (switching between WiFi and cellular during calls), automated tests would be valuable
    • Consider adding instrumentation tests that verify the NetworkStateObserver properly propagates network changes

Recommendations:

  • Add test cases that call updateCurrentNetwork() and verify the flow emits correctly
  • Verify that existing tests still pass with the interface changes
  • Consider adding regression tests for the network switching scenario

Dependencies: ✅ Good

  • Kalium submodule update appears intentional and properly tracked
  • Dependency on kalium#3814 is clearly documented
  • Consider verifying that the kalium PR is merged and released before merging this

Action Items

Must Fix Before Merge:

  1. Add missing import kotlinx.coroutines.flow.StateFlow

Should Consider:

  1. Rename private property to avoid shadowing (e.g., _currentNetwork)
  2. Add test coverage for updateCurrentNetwork() method
  3. Verify kalium dependency PR is merged
  4. Consider adding instrumentation tests for network switching

Nice to Have:

  1. Document the default CurrentNetwork value choice
  2. Add KDoc comments explaining when tests should use non-null vs null CurrentNetwork

Summary

The PR is well-focused and addresses the quick network recovery issue effectively. However, there's a critical compilation error due to the missing StateFlow import that must be fixed. The code quality is otherwise good, but would benefit from additional test coverage for the new functionality.

Recommendation: Request changes to fix the missing import, then approve after verification.


Review completed by Claude Code

@sonarqubecloud
Copy link
Copy Markdown

@saleniuk saleniuk added this pull request to the merge queue Jan 21, 2026
Merged via the queue into develop with commit 7691759 Jan 21, 2026
17 of 18 checks passed
@saleniuk saleniuk deleted the feat/network-switch-quick-call-recovery branch January 21, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants