Make the Android Video SDK compatible with Android 17. - #1752
Make the Android Video SDK compatible with Android 17.#1752rahul-lohra wants to merge 9 commits into
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
WalkthroughIncoming-call foreground service selection now uses a dedicated SDK-aware path. Android 17+ uses the phone-call service type when supported, while earlier versions retain the existing fallback. Tests cover both runtime SDK branches. ChangesIncoming call foreground service type
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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
`@stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/permissions/ForegroundServicePermissionManager.kt`:
- Around line 103-106: Replace the hardcoded 37 in the API-level check within
ForegroundServicePermissionManager with a named ANDROID_17_API_LEVEL constant,
and remove the TODO comment. Use the constant in the Build.VERSION.SDK_INT
comparison while preserving the existing foreground service type condition;
track the future compileSdk upgrade separately.
🪄 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 Plus
Run ID: 74a1c0bf-57c9-4fc2-b260-e8e63754ed25
📒 Files selected for processing (2)
stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/permissions/ForegroundServicePermissionManager.ktstream-video-android-core/src/test/kotlin/io/getstream/video/android/core/notifications/internal/service/permissions/ForegroundServicePermissionManagerTest.kt
|
|
||
| @Test | ||
| @Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE]) | ||
| fun `incoming call keeps short service below android 17`() { |
There was a problem hiding this comment.
Coverage suggestion: this only exercises API 34, but Android 16 (API 36 / BAKLAVA) is the current stable release and the most likely spot for an accidental regression. Could we add a case at 36 (and ideally 35) so "SHORT_SERVICE is preserved on Android 15/16" is locked by a test rather than inferred from the shared branch? A parameterized @Config(sdk = [...]) would cover all three cheaply.
There was a problem hiding this comment.
Nice suggestion.
Our current Robolectric version (4.11.1) only supports @config up to API 34, so we can’t include API 35/36 in the parameterized test.
I’ll add a separate test to explicitly verify the behavior on newer Android versions and prevent regressions.
There was a problem hiding this comment.
Added 2 new tests
| * so phoneCall-capable VoIP services use phoneCall instead. Other services keep [noPermissionServiceType]. | ||
| */ | ||
| @SuppressLint("InlinedApi") | ||
| internal open fun incomingRingingServiceType(): Int = |
There was a problem hiding this comment.
requiredForegroundTypes is open, so a subclass could override it without PHONE_CALL. On 37+ that should fall through to noPermissionServiceType(), but there's no test for that path. Narrow case, low priority — just flagging since the extension point is exposed to subclasses.
There was a problem hiding this comment.
Added a new test-case
| // TODO: replace the hardcoded 37 with Build.VERSION_CODES.<ANDROID_17> once compileSdk / | ||
| // targetSdk are raised to 37; the constant does not exist at the current compileSdk. | ||
| if (requiredForegroundTypes.contains(ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL) && | ||
| Build.VERSION.SDK_INT >= 37 |
There was a problem hiding this comment.
The hardcoded 37 appears here and in the test. The TODO already explains why the constant isn't available yet — could we extract a single private const val ANDROID_17_SDK = 37 and reference it from both? One place to update when Build.VERSION_CODES catches up.
| // Android 17 background-audio hardening mutes the ringtone under SHORT_SERVICE; use the | ||
| // while-in-use phoneCall type instead. Robolectric 4.11.1 caps @Config at API 34, so the | ||
| // >= 37 branch is exercised by forcing SDK_INT. | ||
| ReflectionHelpers.setStaticField(Build.VERSION::class.java, "SDK_INT", 37) |
There was a problem hiding this comment.
Nit: SDK_INT isn't restored after this. Robolectric's per-method sandbox means it won't leak today, so this is fine — just noting a @Config-based approach or a try/finally reset would be more robust if that isolation ever changes.
Move VERSION_CODES polyfills to shared AndroidVersionCodes.kt (fix BALAKLAVA typo). Force SDK_INT for API 35/36/37 tests and restore it via @after teardown.
|



Goal
Closes AND-1324
Make the Android Video SDK compatible with Android 17.
Android 17 introduces new restrictions on background media playback Link . Previously, the SDK relied on the
SHORT_SERVICEforeground service type to play the incoming call ringtone while the app was in the background. This approach is no longer suitable on Android 17.Solution:
For incoming calls on Android 17, replace
SHORT_SERVICEwithServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL.Additional changes added to compile with compile SDK 37
Implementation
Replace
SHORT_SERVICEwithServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALLfor the incoming call foreground service on Android 17.🎨 UI Changes
None
Testing
Summary by CodeRabbit
Bug Fixes
Tests