Skip to content

feat: SDK-4210: Standardize BACKGROUND_THREADING feature flag key naming#2598

Merged
abdulraqeeb33 merged 1 commit intomainfrom
ar/sdk-4210-standardize-background-threading-ff-key-naming
Mar 26, 2026
Merged

feat: SDK-4210: Standardize BACKGROUND_THREADING feature flag key naming#2598
abdulraqeeb33 merged 1 commit intomainfrom
ar/sdk-4210-standardize-background-threading-ff-key-naming

Conversation

@abdulraqeeb33
Copy link
Copy Markdown
Contributor

Summary

  • rename the canonical BACKGROUND_THREADING feature flag key to SDK_050800_BACKGROUND_THREADING using the SDK-prefixed naming convention
  • remove pre-release legacy key aliases and evaluate the flag using canonical key matching only
  • update feature consumers/tests and add FeatureFlagTests to guard naming pattern + expected canonical key

Test 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

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
Copilot AI review requested due to automatic review settings March 26, 2026 21:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 FeatureFlag enum entry and updates all feature consumers to use SDK_050800_BACKGROUND_THREADING.
  • Switches FeatureManager evaluation to use FeatureFlag.isEnabledIn(...) (canonical-key matching).
  • Adds FeatureFlagTests to 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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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.kt line 24: the Logging.warn message still says BACKGROUND_THREADING in StartupService
  • OneSignalImp.kt line 185: the Logging.warn message still says BACKGROUND_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:

  1. At app startup, StartupService.scheduleStart() calls featureManager.isEnabled(FeatureFlag.SDK_050800_BACKGROUND_THREADING).
  2. Suppose IFeatureManager is not yet registered and getService() throws — the catch block fires.
  3. Logcat receives: OneSignal: Failed to resolve BACKGROUND_THREADING in StartupService.
  4. A developer greps logcat for SDK_050800_BACKGROUND_THREADING to 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.

@abdulraqeeb33 abdulraqeeb33 changed the title SDK-4210: Standardize BACKGROUND_THREADING feature flag key naming feat: SDK-4210: Standardize BACKGROUND_THREADING feature flag key naming Mar 26, 2026
@abdulraqeeb33 abdulraqeeb33 merged commit 1bc6dc4 into main Mar 26, 2026
14 of 16 checks passed
@abdulraqeeb33 abdulraqeeb33 deleted the ar/sdk-4210-standardize-background-threading-ff-key-naming branch March 26, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants