feat: SDK-4210: Standardize BACKGROUND_THREADING feature flag key naming#2598
Conversation
Use SDK_050800 naming for the background threading feature flag, remove legacy key aliases pre-release, and update feature consumers/tests to assert canonical key usage. Made-with: Cursor
There was a problem hiding this comment.
Pull request overview
Standardizes the BACKGROUND_THREADING remote feature flag to use an SDK-version-prefixed canonical key (SDK_050800_BACKGROUND_THREADING) and updates the SDK’s feature evaluation and related tests to match.
Changes:
- Renames the
FeatureFlagenum entry and updates all feature consumers to useSDK_050800_BACKGROUND_THREADING. - Switches
FeatureManagerevaluation to useFeatureFlag.isEnabledIn(...)(canonical-key matching). - Adds
FeatureFlagTeststo enforce the key naming pattern and the expected canonical key.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| OneSignalSDK/onesignal/core/src/test/java/com/onesignal/debug/internal/crash/OneSignalCrashUploaderWrapperTest.kt | Updates mocking to use the new canonical feature flag entry. |
| OneSignalSDK/onesignal/core/src/test/java/com/onesignal/core/internal/startup/StartupServiceTests.kt | Updates feature flag usage in startup-related tests. |
| OneSignalSDK/onesignal/core/src/test/java/com/onesignal/core/internal/features/FeatureManagerTests.kt | Updates feature-key assertions to the new canonical key. |
| OneSignalSDK/onesignal/core/src/test/java/com/onesignal/core/internal/features/FeatureFlagTests.kt | Adds tests enforcing feature flag key naming pattern and canonical BACKGROUND_THREADING key. |
| OneSignalSDK/onesignal/core/src/main/java/com/onesignal/internal/OneSignalImp.kt | Uses the canonical feature flag entry when selecting runtime threading behavior. |
| OneSignalSDK/onesignal/core/src/main/java/com/onesignal/debug/internal/crash/OneSignalCrashUploaderWrapper.kt | Gates crash uploader threading behavior on the canonical flag entry. |
| OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/startup/StartupService.kt | Uses the canonical feature flag entry during startup threading mode selection. |
| OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/features/FeatureManager.kt | Evaluates desired state via FeatureFlag.isEnabledIn(...) and updates side effects to the new enum entry. |
| OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/features/FeatureFlag.kt | Renames the flag to SDK_050800_BACKGROUND_THREADING, documents naming convention, and adds isEnabledIn. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| featureManager.isEnabled(FeatureFlag.BACKGROUND_THREADING) | ||
| featureManager.isEnabled(FeatureFlag.SDK_050800_BACKGROUND_THREADING) | ||
| } catch (t: Throwable) { | ||
| Logging.warn("OneSignal: Failed to resolve BACKGROUND_THREADING in StartupService. Falling back to legacy thread.", t) |
There was a problem hiding this comment.
🟡 Two catch-block warning messages still reference the old BACKGROUND_THREADING key name after the PR renamed the canonical key to SDK_050800_BACKGROUND_THREADING. A developer searching logcat for SDK_050800_BACKGROUND_THREADING when diagnosing startup threading failures would silently miss these warnings in StartupService.kt:24 and OneSignalImp.kt:185. Update both strings to match the new canonical key.
Extended reasoning...
This PR correctly renamed every FeatureFlag.BACKGROUND_THREADING enum reference to FeatureFlag.SDK_050800_BACKGROUND_THREADING, but the adjacent human-readable strings inside catch blocks were not updated to match.
Affected locations:
StartupService.ktline 24: theLogging.warnmessage still saysBACKGROUND_THREADING in StartupServiceOneSignalImp.ktline 185: theLogging.warnmessage still saysBACKGROUND_THREADING feature
How the inconsistency manifests:
Both sites follow the same pattern: a try block calls featureManager.isEnabled(FeatureFlag.SDK_050800_BACKGROUND_THREADING) (correctly updated) and a catch (t: Throwable) block logs a warning (not updated). When an exception occurs during flag resolution, the logged message says BACKGROUND_THREADING while every other trace in the system says SDK_050800_BACKGROUND_THREADING.
Concrete step-by-step proof:
- At app startup,
StartupService.scheduleStart()callsfeatureManager.isEnabled(FeatureFlag.SDK_050800_BACKGROUND_THREADING). - Suppose
IFeatureManageris not yet registered andgetService()throws — the catch block fires. - Logcat receives:
OneSignal: Failed to resolve BACKGROUND_THREADING in StartupService. - A developer greps logcat for
SDK_050800_BACKGROUND_THREADINGto trace what happened — this warning is absent from results, misleading them into thinking the flag was never consulted.
Why existing code does not prevent it:
Log message strings are plain string literals with no compile-time binding to the enum key. Renaming the enum entry produces no build error or warning for stale adjacent strings.
Impact:
No functional impact — the fallback value false is still returned correctly. The impact is purely on debuggability: stale log strings can mislead engineers triaging threading startup failures.
Fix:
Update both log strings to reference the new canonical key name SDK_050800_BACKGROUND_THREADING.
Summary
BACKGROUND_THREADINGfeature flag key toSDK_050800_BACKGROUND_THREADINGusing the SDK-prefixed naming conventionFeatureFlagTeststo guard naming pattern + expected canonical keyTest plan
./gradlew --console=plain --no-daemon :onesignal:core:testDebugUnitTest --tests \"com.onesignal.core.internal.features.FeatureFlagTests\" --tests \"com.onesignal.core.internal.features.FeatureManagerTests\"Made with Cursor