Skip to content

Fix runCallServiceInForeground handling for incoming PN and non-ringing call flows#1729

Merged
aleksandar-apostolov merged 10 commits into
developfrom
bugfix/rahullohra/background-call-disabled-regression
Jun 23, 2026
Merged

Fix runCallServiceInForeground handling for incoming PN and non-ringing call flows#1729
aleksandar-apostolov merged 10 commits into
developfrom
bugfix/rahullohra/background-call-disabled-regression

Conversation

@rahul-lohra

@rahul-lohra rahul-lohra commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Goal

Close #AND-1250

  • Fix a regression introduced during support for configurations where runCallServiceInForeground = false.
  • Ensure runCallServiceInForeground is respected when:
    1. Handling incoming calls from the Push Notification flow.
    2. Joining non-ringing calls.

Demo-app

  • Add a Call Settings screen that allows toggling call configuration options on a per-call-type basis.

Implementation

Just add a boolean check of runCallServiceInForeground on critical code-flows

🎨 UI Changes

Image Description
image Call Settings Menu from main screen
image Call Settings Screen

None

Testing

Smoke test 1-1 calls, normal calls

Summary by CodeRabbit

Release Notes

  • New Features
    • Added a call settings interface to configure service behavior options
    • Made foreground service execution configurable per call type
    • Improved notification styling for incoming and outgoing calls

@rahul-lohra rahul-lohra self-assigned this Jun 19, 2026
@rahul-lohra rahul-lohra added the pr:bug Fixes a bug label Jun 19, 2026
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

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, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

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

@rahul-lohra rahul-lohra changed the title [WIP] Fix regression when foreground call service is disabled Fix regression when foreground call service is disabled Jun 22, 2026
@rahul-lohra rahul-lohra changed the title Fix regression when foreground call service is disabled Fix runCallServiceInForeground handling for incoming PN and non-ringing call flows Jun 22, 2026
@rahul-lohra rahul-lohra changed the title Fix runCallServiceInForeground handling for incoming PN and non-ringing call flows [And-1250] Fix runCallServiceInForeground handling for incoming PN and non-ringing call flows Jun 22, 2026
@rahul-lohra rahul-lohra marked this pull request as ready for review June 22, 2026 08:03
@rahul-lohra rahul-lohra requested a review from a team as a code owner June 22, 2026 08:03
@rahul-lohra rahul-lohra changed the title [And-1250] Fix runCallServiceInForeground handling for incoming PN and non-ringing call flows Fix runCallServiceInForeground handling for incoming PN and non-ringing call flows Jun 22, 2026
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds per-call-type foreground service config gating to ClientState.setActiveCall and StreamDefaultNotificationHandler.onRingingCall, extracts CallStyle construction into a new StyleProvider class, exposes CallServiceConfigRegistry from StreamVideoInitHelper, and adds a Compose debug UI (CallSettingsScreen) accessible from the join screen header menu.

Changes

Core SDK: Foreground Service Gating and Notification Style Refactoring

Layer / File(s) Summary
StyleProvider extraction and notification handler style delegation
stream-video-android-core/.../notifications/style/StyleProvider.kt, stream-video-android-core/.../notifications/handlers/StreamDefaultNotificationHandler.kt
Adds StyleProvider with getOutgoingCallStyle and getIncomingCallStyle methods. StreamDefaultNotificationHandler replaces inlined CallStyle/Person/IconCompat construction with styleProvider delegation for both outgoing hang-up and incoming accept/reject notifications.
Foreground service config gating in ClientState and onRingingCall
stream-video-android-core/.../core/CallState.kt, stream-video-android-core/.../core/ClientState.kt, stream-video-android-core/.../notifications/handlers/StreamDefaultNotificationHandler.kt
Changes updateRingingState from private to internal. Refactors setActiveCall to fetch callServiceConfig once and gate foreground service scheduling on runCallServiceInForeground across incoming, outgoing, and idle branches. Gates serviceLauncher.showIncomingCall in onRingingCall behind the same config flag.

Demo App: CallServiceConfig Debug Settings UI

Layer / File(s) Summary
StreamVideoInitHelper registry exposure
demo-app/.../util/StreamVideoInitHelper.kt
Adds a callServiceConfigRegistry public property with private set and assigns the constructed registry to it during SDK initialization.
CallSettingsUi screen implementation
demo-app/.../ui/CallSettingsUi.kt
Adds CallTypeConfigItem, AudioUsageOption data models and static option lists. Implements stateful CallSettingsScreen reading/writing the live registry, stateless CallSettingsContent with a LazyColumn of CallTypeConfigCard, reusable ToggleRow and AudioUsageSelector components, and two Compose previews.
CallJoinScreen integration and string resource
demo-app/.../ui/join/CallJoinScreen.kt, demo-app/src/main/res/values/strings.xml
Adds renderCallSettingsUi state, extends CallJoinHeader with an onCallSettingsClink callback, inserts a "Call Settings" popup menu entry in non-production builds, conditionally overlays CallSettingsScreen, and adds the call_settings string resource.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • aleksandar-apostolov

Poem

🐰 Hop hop, the settings are neat,
Per-call configs now skip the beat,
StyleProvider builds the style right,
Foreground service? Only when right!
A debug screen from the join menu appears —
The rabbit tidies configs with cheers! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.74% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: handling runCallServiceInForeground for incoming PN and non-ringing call flows, which aligns with the core regression being addressed.
Description check ✅ Passed The description covers Goal, Implementation, UI Changes with screenshots, and Testing sections. However, the Contributor Checklist and most verification items are incomplete with unchecked boxes, and changelog/documentation updates are not explicitly mentioned.
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/rahullohra/background-call-disabled-regression

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@demo-app/src/main/kotlin/io/getstream/video/android/ui/CallSettingsUi.kt`:
- Around line 94-107: The registry snapshot is being captured once with remember
on line 94, which prevents the UI from updating when the SDK initializes or the
registry is replaced. Remove the remember wrapper around
StreamVideoInitHelper.callServiceConfigRegistry so it reads the current registry
value on each recomposition. Additionally, restructure the items state
initialization so it recomputes whenever the live registry reference changes,
ensuring that when editableCallTypes.map runs, it always pulls fresh data from
the current registry instead of a stale captured snapshot.

In
`@demo-app/src/main/kotlin/io/getstream/video/android/ui/join/CallJoinScreen.kt`:
- Around line 342-354: The Spacer component following the StreamButton is using
width(5.dp) which creates horizontal spacing, but since this Spacer is placed
inside a vertical Column layout, the gap will not be visible between stacked
elements. Replace the width-based Spacer with a height-based Spacer to create
proper vertical spacing between the StreamButton and subsequent elements in the
Column. Change the Spacer modifier from width(5.dp) to height(5.dp) to ensure
the spacing is applied correctly in the vertical layout.

In
`@demo-app/src/main/kotlin/io/getstream/video/android/util/StreamVideoInitHelper.kt`:
- Around line 133-141: The callServiceConfigRegistry property (defined around
line 133) only gets assigned on successful initialization (line 402) but is
never cleared when teardown occurs or initialization fails. This causes the
debug UI to expose a stale registry instance from a previous client. Add a null
assignment to callServiceConfigRegistry in the teardown/cleanup path and
wherever initialization fails to ensure the property only reflects the current
active client's registry state and doesn't expose outdated configuration.

In
`@stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/style/StyleProvider.kt`:
- Around line 35-43: The icon selection logic in the setIcon block only sets the
single-user icon when remoteParticipantCount equals 0, but fails to handle the
case when remoteParticipantCount equals 1, which represents a valid one-to-one
active call scenario. Modify the conditional check to include both cases by
changing the condition from checking if remoteParticipantCount == 0 to checking
if remoteParticipantCount is less than or equal to 1, so that the
stream_video_ic_user icon is properly set for both single-user and one-to-one
call scenarios.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8f719784-4253-4dbf-a9e5-03de24db00d3

📥 Commits

Reviewing files that changed from the base of the PR and between 0a52f05 and 33702ab.

📒 Files selected for processing (8)
  • demo-app/src/main/kotlin/io/getstream/video/android/ui/CallSettingsUi.kt
  • demo-app/src/main/kotlin/io/getstream/video/android/ui/join/CallJoinScreen.kt
  • demo-app/src/main/kotlin/io/getstream/video/android/util/StreamVideoInitHelper.kt
  • demo-app/src/main/res/values/strings.xml
  • stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/CallState.kt
  • stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/ClientState.kt
  • stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/handlers/StreamDefaultNotificationHandler.kt
  • stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/style/StyleProvider.kt

@aleksandar-apostolov aleksandar-apostolov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@aleksandar-apostolov aleksandar-apostolov merged commit d0e1456 into develop Jun 23, 2026
16 of 17 checks passed
@aleksandar-apostolov aleksandar-apostolov deleted the bugfix/rahullohra/background-call-disabled-regression branch June 23, 2026 08:12
@stream-public-bot stream-public-bot added the released Included in a release label Jun 23, 2026
@stream-public-bot

Copy link
Copy Markdown
Collaborator

🚀 Available in v1.28.0

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

Labels

pr:bug Fixes a bug released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants