Fix IAM display rendering issues on foldable Android devices (Samsung Galaxy Fold/Flip)
Description
One Line Summary
Fix In-App Message (IAM) display rendering issues on foldable Android devices, gated behind a remote feature flag.
Details
Motivation
Foldable Android devices like Samsung Galaxy Fold and Flip experience IAM rendering issues when users fold/unfold their devices. The IAM content may appear cut-off, mispositioned, or incorrectly sized because:
-
Screen size changes without orientation change: When a foldable device transitions between its cover screen and main screen (or vice versa), the screen dimensions change dramatically without triggering an orientation change event.
-
Deprecated APIs: The SDK was using deprecated
defaultDisplay.getSize()APIs that don't properly handle multi-window and foldable device scenarios on Android 11+. -
Missing configuration detection: The SDK only listened for
CONFIG_ORIENTATIONchanges, missing theCONFIG_SCREEN_SIZEchanges that foldable devices trigger.
Feature Flag Implementation
All changes are gated behind a remote feature flag: SDK_050800_FOLDABLE_IAM_FIX
- When OFF (default): Legacy behavior is used - no changes to existing functionality
- When ON: New foldable-aware behavior is activated:
- Uses WindowMetrics API for accurate window dimensions on API 30+
- Detects screen size changes from fold/unfold events
- Recalculates IAM dimensions when screen size changes
This allows for safe rollout and easy rollback if issues are discovered.
Scope
What is affected:
- In-App Message display on foldable devices (Samsung Galaxy Fold, Flip, and similar devices)
- Window dimension calculations on Android 11+ (API 30+)
What is NOT affected:
- IAM behavior when feature flag is disabled (default)
- IAM behavior on non-foldable devices when flag is enabled (no functional change expected)
- Other SDK features (notifications, outcomes, sessions, etc.)
Technical Changes
-
FoldableIAMFeature.kt (NEW):
- Global feature switch object similar to
ThreadingMode isEnabledproperty controlled byFeatureManager- Provides centralized access to feature state from static utilities
- Global feature switch object similar to
-
FeatureFlag.kt:
- Added
SDK_050800_FOLDABLE_IAM_FIXfeature flag - Uses
IMMEDIATEactivation mode for instant toggling
- Added
-
FeatureManager.kt:
- Added side effect handler for the new feature flag
- Updates
FoldableIAMFeature.isEnabledwhen flag changes
-
ViewUtils.kt:
getWindowHeight(): Uses WindowMetrics API (API 30+) when FF enabledgetWindowWidth(): Uses WindowMetrics API (API 30+) when FF enabledgetFullbleedWindowWidth(): Uses WindowMetrics API (API 30+) when FF enabled- Falls back to legacy behavior when FF disabled
-
ApplicationService.kt:
- Screen size change detection only runs when FF enabled
- Detects fold/unfold via
screenWidthDp/screenHeightDpchanges - Triggers IAM view recreation on screen size change
-
WebViewManager.kt:
- Updated comment to clarify fold/unfold handling alongside rotation
Testing
Unit testing
- Existing
ApplicationServiceTestspass - Existing
FeatureManagerTestspass - The feature flag integration follows the same pattern as
SDK_050800_BACKGROUND_THREADING
Manual testing
Recommended testing scenarios:
- With flag OFF: Verify no change in behavior on any device
- With flag ON on foldable device: Display an IAM, then fold/unfold - IAM should resize correctly
- With flag ON on non-foldable device: Verify no regression
- Test all IAM positions (TOP_BANNER, BOTTOM_BANNER, CENTER_MODAL, FULL_SCREEN) during fold/unfold
Affected code checklist
- [ ] Notifications
- [ ] Display
- [ ] Open
- [ ] Push Processing
- [ ] Confirm Deliveries
- [ ] Outcomes
- [ ] Sessions
- [x] In-App Messaging
- [ ] REST API requests
- [ ] Public API changes
Checklist
Overview
- [x] I have filled out all REQUIRED sections above
- [x] PR does one thing
- [x] Any Public API changes are explained in the PR details and conform to existing APIs
Testing
- [x] I have included test coverage for these changes, or explained why they are not needed
- [x] All automated tests pass, or I explained why that is not possible
- [ ] I have personally tested this on my device, or explained why that is not possible
Final pass
- [x] Code is as readable as possible.
- [x] I have reviewed this PR myself, ensuring it meets each checklist item

