Skip to content

Early promote to FG service for active calls#1628

Merged
aleksandar-apostolov merged 1 commit intodevelopfrom
bugfix/rahullohra/early-promote-ongoing-call-fgs
Mar 10, 2026
Merged

Early promote to FG service for active calls#1628
aleksandar-apostolov merged 1 commit intodevelopfrom
bugfix/rahullohra/early-promote-ongoing-call-fgs

Conversation

@rahul-lohra
Copy link
Contributor

@rahul-lohra rahul-lohra commented Mar 9, 2026

Goal

Resolve ForegroundServiceDidNotStartInTimeException for ongoing calls

Implementation

Early promote to FG service for active calls

🎨 UI Changes

None

Testing

Simple call

Summary by CodeRabbit

  • Bug Fixes
    • Improved call notification reliability by ensuring foreground service properly initiates whenever a notification is available, regardless of current call status. This resolves inconsistent notification delivery during calls.

@rahul-lohra rahul-lohra self-assigned this Mar 9, 2026
@rahul-lohra rahul-lohra requested a review from a team as a code owner March 9, 2026 13:16
@rahul-lohra rahul-lohra added the pr:improvement Enhances an existing feature or code label Mar 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 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.

@rahul-lohra rahul-lohra changed the title Early promote to FG service for active calls [AND-1109] Early promote to FG service for active calls Mar 9, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

Walkthrough

The CallService notification logic was simplified by removing a conditional check that previously gated foreground service startup based on active call state. The service now unconditionally attempts to start foreground notifications when a setup notification is available, eliminating the prior state-dependent branching logic.

Changes

Cohort / File(s) Summary
Service Notification Simplification
stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt
Removed conditional logic that checked for active calls before starting foreground notifications. Service now directly starts foreground using setup notification when available, regardless of active call state. Associated logging and hasActiveCall control flow eliminated.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A simpler path the service now takes,
No branching doubts, no state it forsakes—
Notifications flow with clarity bright,
Foreground starts swift, without the fight!
~CodeRabbit's nibbling refactor delight

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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 ❓ Inconclusive The description covers Goal and Implementation sections with reasonable detail, but lacks several required sections like Testing explanation, UI Changes details, and Contributor Checklist items. Expand Testing section with specific test cases and steps; complete the Contributor Checklist to verify all requirements are met.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: early promotion to foreground service for active calls to resolve timing exceptions.

✏️ 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/early-promote-ongoing-call-fgs

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.

🧹 Nitpick comments (1)
stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt (1)

653-666: Function name no longer reflects its behavior.

The function promoteToFgServiceIfNoActiveCall now unconditionally promotes to foreground (when notification is available), but the name still implies it only does so when there's no active call. This could mislead future maintainers.

Consider renaming to better reflect the new behavior, e.g., promoteToFgServiceEarly or ensureForegroundStarted.

Suggested rename
-    private fun promoteToFgServiceIfNoActiveCall(
+    private fun promoteToFgServiceEarly(
         videoClient: StreamVideoClient,
         notificationId: Int,
         trigger: String,
     ) {
         videoClient.getSettingUpCallNotification()?.let { notification ->
             startForegroundWithServiceType(
                 notificationId,
                 notification,
                 trigger,
                 permissionManager.getServiceType(baseContext, trigger),
             )
         }
     }

Also update the call site at line 219:

promoteToFgServiceEarly(params.streamVideo, notificationId, params.trigger)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt`
around lines 653 - 666, Rename the misleading function
promoteToFgServiceIfNoActiveCall to a name that reflects unconditional promotion
(for example promoteToFgServiceEarly or ensureForegroundStarted) and update its
single call site where it's invoked as
promoteToFgServiceEarly(params.streamVideo, notificationId, params.trigger);
ensure the implementation (which uses
videoClient.getSettingUpCallNotification(), startForegroundWithServiceType(...),
permissionManager.getServiceType(baseContext, trigger)) remains unchanged but
the new name is used consistently across the file and any references are
updated.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt`:
- Around line 653-666: Rename the misleading function
promoteToFgServiceIfNoActiveCall to a name that reflects unconditional promotion
(for example promoteToFgServiceEarly or ensureForegroundStarted) and update its
single call site where it's invoked as
promoteToFgServiceEarly(params.streamVideo, notificationId, params.trigger);
ensure the implementation (which uses
videoClient.getSettingUpCallNotification(), startForegroundWithServiceType(...),
permissionManager.getServiceType(baseContext, trigger)) remains unchanged but
the new name is used consistently across the file and any references are
updated.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 075e38c5-9f85-48ec-81a0-96e306153aec

📥 Commits

Reviewing files that changed from the base of the PR and between 94feaea and afd52ba.

📒 Files selected for processing (1)
  • stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 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.27 MB 6.27 MB 0.00 MB 🟢

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 9, 2026

@aleksandar-apostolov aleksandar-apostolov merged commit f5d0c77 into develop Mar 10, 2026
14 of 15 checks passed
@aleksandar-apostolov aleksandar-apostolov deleted the bugfix/rahullohra/early-promote-ongoing-call-fgs branch March 10, 2026 09:12
@rahul-lohra rahul-lohra changed the title [AND-1109] Early promote to FG service for active calls Early promote to FG service for active calls Mar 10, 2026
@stream-public-bot
Copy link
Collaborator

🚀 Available in v1.20.1

@stream-public-bot stream-public-bot added the released Included in a release label Mar 10, 2026
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 released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants