Skip to content

Remove unused code from Call Class - #1762

Merged
PratimMallick merged 1 commit into
refactor/call-class-decompositionfrom
refactor/call-class-decomposition-remove-unused-code
Aug 5, 2026
Merged

Remove unused code from Call Class#1762
PratimMallick merged 1 commit into
refactor/call-class-decompositionfrom
refactor/call-class-decomposition-remove-unused-code

Conversation

@rahul-lohra

@rahul-lohra rahul-lohra commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Goal

Remove unused internal code

Implementation

Remove unused internal code

🎨 UI Changes

None

Testing

None

Summary by CodeRabbit

  • Documentation

    • Added clarifying documentation for media manager initialization and application of server-provided call settings.
  • Refactor

    • Removed obsolete internal code and unused references.
    • No changes to public APIs or user-visible behavior.

@rahul-lohra rahul-lohra self-assigned this Aug 5, 2026
@rahul-lohra rahul-lohra added the pr:internal Internal or infra-only changes label Aug 5, 2026
@rahul-lohra rahul-lohra changed the title Remove unused code Remove unused code from Call Class Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

PR checklist ❌

The following issues were detected:

  • Linked issue missing. Add a Linear ticket reference (e.g. AND-123, Closes AND-123, or a https://linear.app/... link) or a GitHub issue (Closes #123) to the PR description.

What we check

  1. Title is concise (5–18 words) unless labeled pr:ignore-for-release.
  2. At least one pr: label exists (e.g., pr:bug, pr:new-feature).
  3. Sections ### Goal, ### Implementation, and ### Testing contain content. Bot-authored PRs are exempt.
  4. PR description references an issue (Linear ticket like AND-123, a Linear URL, or a GitHub Closes #N). Bot-authored PRs are exempt.

@rahul-lohra
rahul-lohra marked this pull request as ready for review August 5, 2026 06:48
@rahul-lohra
rahul-lohra requested a review from a team as a code owner August 5, 2026 06:48
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0a95c035-794c-46c9-9604-7f3c454648ef

📥 Commits

Reviewing files that changed from the base of the PR and between 60c1286 and 6cdc4d4.

📒 Files selected for processing (2)
  • stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/Call.kt
  • stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/components/CallMediaManager.kt
💤 Files with no reviewable changes (1)
  • stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/Call.kt

Walkthrough

The change removes obsolete internal members and helpers from Call.kt. It also documents lazy peer connection factory creation and server-provided settings updates in CallMediaManager.kt. No exported or public entity declarations change.

Changes

Call internals cleanup

Layer / File(s) Summary
Remove obsolete Call internals
stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/Call.kt
Removes an unused import, obsolete comment, internal lifecycle accessor, client capability storage, audio-profile helper, and internal join and media-setting helpers.
Document media manager behavior
stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/components/CallMediaManager.kt
Documents lazy factory creation with the current audio bitrate profile and application of server-provided call settings.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: pr:improvement

Suggested reviewers: pratimmallick

Poem

A rabbit trims the Call with care,
Removes old helpers hiding there.
The media notes now clearly say
How factories form and settings stay.
Hop, hop—clean code leads the way!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the removal of unused code from the Call class.
Description check ✅ Passed The description covers the main template sections and matches the objective, with no UI changes and no testing required.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/call-class-decomposition-remove-unused-code

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.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-video-android-core 12.27 MB 12.29 MB 0.02 MB 🟢
stream-video-android-ui-xml 5.68 MB 5.70 MB 0.02 MB 🟢
stream-video-android-ui-compose 6.20 MB 6.19 MB -0.02 MB 🚀

@sonarqubecloud

sonarqubecloud Bot commented Aug 5, 2026

Copy link
Copy Markdown

@PratimMallick
PratimMallick merged commit 9c374ea into refactor/call-class-decomposition Aug 5, 2026
12 of 16 checks passed
@PratimMallick
PratimMallick deleted the refactor/call-class-decomposition-remove-unused-code branch August 5, 2026 07:05
PratimMallick added a commit that referenced this pull request Aug 5, 2026
* refactor(core): decompose Call into focused internal components

Break the ~2,260-line Call class into 11 internal collaborators under
call/components (CallApiClient, CallStatsReporter, CallRenderer,
CallEventManager, CallMediaManager, CallSessionManager,
CallIceConnectionMonitor, CallConnectivityMonitor, CallJoinCoordinator,
CallReconnector, CallLifecycleManager). Call remains a thin, binary-compatible
public facade that delegates to them; public API is unchanged (apiCheck passes).

Update white-box reflection tests to target the new component owners after
internals moved out of Call.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(core): remove duplicated join preflight from Call facade

Call.join() ran join analytics, permission checks, and the guest-token
wait before delegating to CallJoinCoordinator.join(), which performed the
exact same preflight — so every join() executed it twice. Make the facade
a pure delegation so the preflight runs only once in the coordinator.

Co-authored-by: Cursor <cursoragent@cursor.com>

* test(core): add unit tests for Call decomposition components

Add JVM unit tests for the extracted Call collaborators (CallApiClient,
CallEventManager, CallSessionManager, CallRenderer, CallMediaManager) to
raise coverage on the refactor's new code toward the SonarCloud gate.

Co-authored-by: Cursor <cursoragent@cursor.com>

* test(core): add unit tests for join/reconnect/connectivity/ice components

Broaden new-code coverage for the extracted Call components: exercise the
CallJoinCoordinator retry loop and join-and-ring flow (via the RtcSession test
factory), the CallConnectivityMonitor reconnect/leave listener, the reachable
CallReconnector state-machine branches, the CallIceConnectionMonitor restart
paths, plus additional CallMediaManager (monitorHeadset, not-selected devices)
and CallApiClient (ring request, ringing create) cases.

Co-authored-by: Cursor <cursoragent@cursor.com>

* test(core): cover reconnector rejoin/migrate and renderer audio paths

Add a unitTestRtcSessionFactory seam to CallReconnector's rejoin/migrate so the
session-swap, monitor and finalize paths are unit-testable, and add tests for
them (success + retry-until-exhausted). Also cover CallRenderer's incoming-audio
track walking for all/selected participants.

Co-authored-by: Cursor <cursoragent@cursor.com>

* refactor(core): decouple Call collaborators from the Call facade

Give the Call decomposition components explicit dependencies so they no longer
reach into the Call facade:

- CallApiClient, CallConnectivityMonitor, CallEventManager,
  CallIceConnectionMonitor, CallRenderer, CallStatsReporter, CallSessionManager
  and CallMediaManager now take the granular collaborators they need
  (type/id/scope/state/session/clientImpl/eglBase) instead of a Call.
- Isolate the unavoidable identity hand-offs behind small seams/providers:
  RingingCallRegistrar for CallApiClient's ring/accept client-state writes, and
  a lazy () -> Call provider for CallMediaManager's MediaManagerImpl (a public
  type that requires a Call).
- Behaviour is unchanged; component unit tests now construct each collaborator
  directly without a Call mock.

The three orchestrators (CallReconnector, CallJoinCoordinator,
CallLifecycleManager) still hold Call and are left for a follow-up.

Co-authored-by: Cursor <cursoragent@cursor.com>

* refactor(core): finish decoupling Call collaborators and repair the suite

Removes the last Call references from the extracted components so no class
under call/components holds the facade any more.

CallLifecycleManager now takes its collaborators directly (lazy providers,
since it is constructed before CallState and the monitors exist), which made
Call.stopConnectionMonitors/stopStatsReporting/cancelSfuObservers/
shutDownJobsGracefully dead; they are removed. CallMediaManager gains
disableLocalCapture() so the lifecycle no longer reaches through to the
device handles.

The three callback interfaces into Call (CallHost, CallTeardownHost,
RingingCallRegistrar) were named after who implements them rather than what
they do, and six of their eight methods did the same thing: register or
deregister this call in the client's ringing/active registries. Two were
byte-identical. They collapse into one ClientCallRegistry; the genuine
outliers (hasRequiredPermissions, shutDownJobs) become plain lambdas.

Two production fixes surfaced while repairing the tests:

- CallMediaManager evaluated eglBase().eglBaseContext to build an argument
  for MediaManagerFactory.create, forcing a real EGL context before the
  factory ran. Call owns both the context and the factory, so the parameter
  is dropped and the factory resolves it itself.

- The reconnect loop reads connectivity straight off the connection module
  (it must not go through CallConnectivityMonitor, which would close a
  dependency cycle), but injectMockNetwork was repointed at the monitor. The
  loop therefore polled the real provider and stalled without consuming an
  attempt. Injecting at the module fixes three reconnect tests that had been
  failing since the decomposition commit.

JoinRecoverableFailureTest is rebuilt on the coordinator harness: it relied
on spying Call and reflectively repointing CallJoinCoordinator.call, a field
that no longer exists.

Core suite: 978 tests, 0 failures.

Co-authored-by: Cursor <cursoragent@cursor.com>

* refactor(core): read session state from its owner instead of the Call facade

CallSessionManager owns the session identity and reconnect bookkeeping, but
Call still re-exposed it through internal accessors that mostly existed for a
single caller. Remove them: location and nonFastReconnectAttempts were only
reachable from tests, connectStartTime/reconnectStartTime had dead setters, and
unifiedSessionId was read by RtcSession alone.

RtcSession now takes CallSessionManager directly and reads session identity and
reconnect timings from it. The elapsed-time arithmetic moves onto the manager as
connectionTimeSeconds()/reconnectionTimeSeconds(), next to the timestamps it
derives from. The two test-only reads move into CallTestSeams.kt so they stay
out of the production API.

Co-authored-by: Cursor <cursoragent@cursor.com>

* refactor(core): break the reconnector/join-coordinator dependency cycle

CallReconnector and CallJoinCoordinator each depended on the other, so one
had to be injected as a lazy provider. Move the shared joinRequest into
CallApiClient, which already owns the coordinator REST calls, and relocate
the failed-SFU set to CallSessionManager so the request no longer has to ask
the reconnector for it. Both orchestrators now depend on the api client and
neither depends on the other.

Also drops the provider lambdas around state, analytics, stats and media by
declaring those components before their consumers.

FailedSfuIdsTest no longer needs reflection into private reconnector members;
the behaviour is covered directly in CallSessionManagerTest.

Co-authored-by: Cursor <cursoragent@cursor.com>

* chore: remove unused code (#1762)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Rahul Kumar Lohra <tgunix@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:internal Internal or infra-only changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants