Skip to content

Comments

Leave an active call when Telecom puts it to inactive or hold#1622

Open
rahul-lohra wants to merge 1 commit intodevelopfrom
bugfix/rahullohra/telecom-call-shift-focus
Open

Leave an active call when Telecom puts it to inactive or hold#1622
rahul-lohra wants to merge 1 commit intodevelopfrom
bugfix/rahullohra/telecom-call-shift-focus

Conversation

@rahul-lohra
Copy link
Contributor

@rahul-lohra rahul-lohra commented Feb 20, 2026

Goal

Ensure active call is correctly left when Android Telecom transitions the SDK state to HOLD , preventing inconsistent call and UI states.

Implementation

We observe Android Telecom state changes via JetpackTelecomRepository.currentCall and react when the registered Telecom call is placed on hold.

When isOnHold becomes true, we reconcile the SDK call state with Telecom by taking explicit action based on the current RingingState:
• Active → Leave the call
• Other states → No action

 [RingingState.Incoming] and [RingingState.Outgoing] are intentionally not observed.
 In Android Telecom, hold states are only applicable once a call is active (answered).

The observer job is cancelled and restarted to avoid multiple collectors and ensure only one active Telecom state observer at a time.

🎨 UI Changes

None

Before After
img img

Add relevant videos

Testing

  1. Make audio/video call to other person
  2. Test the call-on hold for RingingState.Active
  3. To introduce call-on hold scenario, just make a whats app call to that user

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced telecom call handling to automatically respond to on-hold scenarios by rejecting or leaving the call as appropriate based on the current call state.

@rahul-lohra rahul-lohra self-assigned this Feb 20, 2026
@rahul-lohra rahul-lohra requested a review from a team as a code owner February 20, 2026 13:59
@rahul-lohra rahul-lohra added the pr:bug Fixes a bug label Feb 20, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2026

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled.

🎉 Great job! This PR is ready for review.

@coderabbitai
Copy link

coderabbitai bot commented Feb 20, 2026

Walkthrough

The change adds telecom hold state observation to CallState by introducing a custom setter for jetpackTelecomRepository that automatically observes hold conditions and rejects or leaves calls when held, depending on ringing state.

Changes

Cohort / File(s) Summary
Telecom Hold Observation
stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/CallState.kt
Added imports for TelecomCall and Dispatchers. Introduced telecomHoldObserverJob to manage observer lifecycle. Extended jetpackTelecomRepository setter to trigger observeTelecomHold(). Added private function to observe telecom call hold state and handle rejection or exit logic. Note: The observeTelecomHold() function implementation appears twice (duplicate).

Sequence Diagram

sequenceDiagram
    participant Caller as Caller
    participant CS as CallState
    participant JTR as JetpackTelecomRepository
    participant TC as TelecomCall
    participant Coroutine as Coroutine (Default)

    Caller->>CS: Set jetpackTelecomRepository
    activate CS
    CS->>CS: Custom setter invoked
    CS->>CS: Call observeTelecomHold(repo)
    activate CS
    CS->>Coroutine: Launch coroutine
    deactivate CS
    activate Coroutine
    Coroutine->>JTR: Observe currentCall flow
    activate JTR
    JTR->>TC: Emit TelecomCall state
    deactivate JTR
    activate TC
    TC-->>Coroutine: Is on-hold?
    deactivate TC
    alt On-hold detected
        Coroutine->>CS: Check ringing state
        alt Is ringing
            Coroutine->>CS: Reject call
        else Not ringing
            Coroutine->>CS: Leave call
        end
    end
    deactivate Coroutine
    deactivate CS
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A hop and a bound through telecom's hold,
When calls are held, our story unfolds,
Reject or depart with logic so true,
But watch for that duplicate—there's quite a clue! 🎪

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description covers the goal and implementation, but is missing several required sections and checklist items. Add missing sections: Testing details beyond steps (how to verify the fix works), ☑️Contributor Checklist (CLA signature, assignee, branch target, issue link), Changelog entry, and the 🎉 GIF section. Provide actual before/after media or remove placeholder images.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title directly reflects the main objective of the PR: observing Telecom hold state and leaving/rejecting calls when Telecom transitions them to hold or inactive state, which is exactly what the implementation does.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/rahullohra/telecom-call-shift-focus

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/CallState.kt`:
- Around line 728-732: The setter for jetpackTelecomRepository only starts
observation when a non-null value is assigned but never cancels
telecomHoldObserverJob when the repository is cleared, causing a coroutine leak;
update the setter for jetpackTelecomRepository so that when value is null it
cancels and nulls telecomHoldObserverJob (and any related observers) and when
non-null calls observeTelecomHold(value), ensuring observeTelecomHold and the
telecomHoldObserverJob lifecycle are symmetrical and safe to call multiple
times.
- Around line 1764-1789: The telecom hold handler is firing for every
re-emission of the same Registered call because repo.currentCall is collected
directly; change the collector to only react to changes in the isOnHold flag
(rising edge) by applying a distinctUntilChanged on the isOnHold value before
handling. Specifically, update the logic around telecomHoldObserverJob that
collects repo.currentCall/TelecomCall.Registered so it maps to the isOnHold
state (or filters Registered then maps) and uses distinctUntilChanged() to only
enter the block when isOnHold transitions true, then perform the existing
ringingState checks and call.reject/call.leave; keep references to
TelecomCall.Registered, ringingState, call.reject, and call.leave when locating
the code to modify.

@rahul-lohra rahul-lohra changed the title Improve update call state handling when Telecom transitions call to inactive or hold [wip]Improve update call state handling when Telecom transitions call to inactive or hold Feb 20, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2026

SDK Size Comparison 📏

SDK Before After Difference Status
stream-video-android-core 12.00 MB 12.00 MB 0.00 MB 🟢
stream-video-android-ui-xml 5.68 MB 5.68 MB 0.00 MB 🟢
stream-video-android-ui-compose 6.28 MB 6.28 MB 0.00 MB 🟢

@rahul-lohra rahul-lohra force-pushed the bugfix/rahullohra/telecom-call-shift-focus branch from 3284e0b to 3dbce6e Compare February 20, 2026 14:16
@rahul-lohra rahul-lohra changed the title [wip]Improve update call state handling when Telecom transitions call to inactive or hold Leave an active call when Telecom puts it to inactive or hold Feb 20, 2026
@rahul-lohra rahul-lohra added pr:improvement Enhances an existing feature or code and removed pr:bug Fixes a bug labels Feb 20, 2026
@rahul-lohra rahul-lohra force-pushed the bugfix/rahullohra/telecom-call-shift-focus branch from 3dbce6e to 2d0b36e Compare February 20, 2026 14:20
@rahul-lohra rahul-lohra changed the title Leave an active call when Telecom puts it to inactive or hold [AND-1077] Leave an active call when Telecom puts it to inactive or hold Feb 20, 2026
@rahul-lohra rahul-lohra changed the title [AND-1077] Leave an active call when Telecom puts it to inactive or hold Leave an active call when Telecom puts it to inactive or hold Feb 20, 2026
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:improvement Enhances an existing feature or code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant