-
Notifications
You must be signed in to change notification settings - Fork 159
EMT-2135 Replace SESSION_STATE with StateFlow #1280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Replaced the legacy SESSION_STATE enum with a new StateFlow-based system for improved session state management. - Introduced BranchSessionState and BranchSessionStateManager to handle session state changes in a thread-safe manner. - Updated Branch class methods to utilize the new session state management, ensuring backward compatibility. - Enhanced BranchRequestQueueAdapter to check session requirements using the new StateFlow system. - Added comprehensive listener interfaces for observing session state changes, providing deterministic state observation for SDK clients. - Ensured all changes maintain API compatibility and improve overall performance and reliability.
- Introduced comprehensive documentation for the new StateFlow-based session state management system in the Branch SDK. - Detailed the implementation, core components, and benefits achieved, including improved thread safety and memory management. - Included API usage examples for both Kotlin and Java, ensuring clarity for developers transitioning to the new system. - Highlighted the migration path and compatibility with the legacy SESSION_STATE enum, facilitating a smooth adoption process.
- Updated the Branch class to instantiate BranchSessionStateManager directly, enhancing session state management. - Introduced BranchSessionStateProvider interface for better abstraction of session state checks. - Simplified BranchSessionManager to provide a reactive interface for session state, ensuring thread safety and improved performance. - Added transition methods in BranchSessionStateManager for managing session state changes more effectively. - Ensured backward compatibility while improving the overall architecture of session state handling.
- Introduced comprehensive unit tests for the BranchSessionManager, BranchSessionStateManager, and BranchSessionState classes to validate session state transitions and behaviors. - Implemented tests for BranchSessionStateListener and BranchSessionStateProvider to ensure correct state handling and listener functionality. - Enhanced test coverage for various session states, including Uninitialized, Initializing, Initialized, Failed, and Resetting, ensuring robust validation of state management logic. - Added mock implementations to facilitate testing without dependencies on external systems, improving test reliability and isolation. - Ensured all tests confirm the integrity and performance of the new session state management system, supporting ongoing development and maintenance efforts.
ReferenceEMT-2135 -- Replace SESSION_STATE with StateFlow. Description🔄 What ChangedThis pull request introduces a significant refactoring of the Branch SDK's session state management. The previous enum-based Key changes include:
🔍 Impact of the ChangeThis change significantly improves the SDK's state management by:
📁 Total Files Changed7 files changed. 🧪 Test AddedYes, comprehensive unit tests have been added for the new state management system:
🔒Security VulnerabilitiesNo new security vulnerabilities were detected in this pull request. The changes improve the robustness of the SDK's internal state management, which can indirectly contribute to overall stability and reliability. Testing Instructions
Risk Assessment [
|
|
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
Reference
SDK-EMT-2135 -- Implement StateFlow-based session state management in Branch SDK.
Description
This PR introduces a comprehensive refactoring of the Branch SDK's session state management system, replacing the legacy
SESSION_STATEenum with a modern StateFlow-based architecture. The changes improve thread safety, performance, and provide better state observation capabilities while maintaining full backward compatibility.Key Changes:
SESSION_STATEenum withBranchSessionStateandBranchSessionStateManagerfor thread-safe state managementBranchSessionStateProviderinterface for better abstraction andBranchSessionStateListenerfor deterministic state observationBranchSessionManagerto provide reactive interfaces, reducing memory overhead and improving responsivenessBenefits:
Testing Instructions
./gradlew testBranchSessionStateListenercorrectly receives state change notificationsRisk Assessment
MEDIUMThis refactoring involves core session state management changes that affect the SDK's fundamental behavior. While backward compatibility is maintained, the changes are significant enough to warrant thorough testing across different Android versions and device configurations.
Additional Notes:
All existing API contracts remain unchanged to ensure seamless integration
Comprehensive unit tests provide confidence in the new implementation
Documentation includes migration guides for developers transitioning to the new system
Performance improvements should be validated across various device specifications
I, the PR creator, have tested — integration, unit, or otherwise — this code.
Reviewer Checklist (To be checked off by the reviewer only)
cc @BranchMetrics/saas-sdk-devs for visibility.