-
Notifications
You must be signed in to change notification settings - Fork 46
Fix Switch browser back stack error #2750
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
|
❌ Work item link check failed. Description does not contain AB#{ID}. Click here to Learn more. |
…ine intent handling and improve code clarity
…uce SwitchBrowserActivity for improved browser switching flow
…mproved logging and clarity; streamline intent creation in SwitchBrowserProtocolCoordinator
… remove unused parameters for improved clarity and simplicity
…dle user cancellations and improve activity lifecycle management
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a redesigned switch browser flow to fix back stack management issues. The changes replace direct browser launching from the challenge handler with a dedicated SwitchBrowserActivity that manages the browser lifecycle more cleanly.
Key Changes:
- Introduced
SwitchBrowserActivityto handle browser launch and redirect management - Updated
SwitchBrowserRequestHandlerto delegate to the new activity instead of launching browsers directly - Modified protocol coordinator to support the new activity-based flow
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| SwitchBrowserActivity.kt | New activity that manages browser launch and authentication redirects |
| SwitchBrowserRequestHandler.kt | Simplified to launch SwitchBrowserActivity instead of managing browsers directly |
| SwitchBrowserProtocolCoordinator.kt | Updated to work with new activity and renamed property |
| WebViewAuthorizationFragment.java | Added static bundle management for switch browser resume data |
| BrokerAuthorizationActivity.java | Removed switch browser specific onNewIntent handling |
| AuthorizationActivityFactory.kt | Removed switch browser specific intent flags |
| Test files | Updated to reflect API changes and removed unused dependencies |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...va/com/microsoft/identity/common/internal/providers/oauth2/WebViewAuthorizationFragment.java
Show resolved
Hide resolved
...va/com/microsoft/identity/common/internal/providers/oauth2/WebViewAuthorizationFragment.java
Outdated
Show resolved
Hide resolved
...c/main/java/com/microsoft/identity/common/internal/providers/oauth2/SwitchBrowserActivity.kt
Outdated
Show resolved
Hide resolved
…oviders/oauth2/SwitchBrowserActivity.kt Co-authored-by: Copilot <[email protected]>
…oviders/oauth2/WebViewAuthorizationFragment.java Co-authored-by: Copilot <[email protected]>
...c/main/java/com/microsoft/identity/common/internal/providers/oauth2/SwitchBrowserActivity.kt
Outdated
Show resolved
Hide resolved
...c/main/java/com/microsoft/identity/common/internal/providers/oauth2/SwitchBrowserActivity.kt
Show resolved
Hide resolved
…rove browser launch logic
Problem
The current DUNA implementation launches
BrokerAuthorizationActivitywithFLAG_ACTIVITY_NEW_TASKandFLAG_ACTIVITY_CLEAR_TASK.This causes:
The issue arises because the activity stack is cleared, preventing proper continuation of dependent flows.
Solution
Introduce
SwitchBrowserActivityto handle the browser switch during the DUNA authentication flow.This approach:
Activity Stack Behavior
BrokerAuthorizationActivitylaunchesSwitchBrowserActivityin Task 2BrokerAuthorizationActivity| Task 2:SwitchBrowserActivity→ Chrome Custom TabsBrokerAuthorizationActivity| Task 2:SwitchBrowserActivity→ Chrome Custom Tabs | Task 3:BrokerBrowserRedirectActivityBrokerAuthorizationActivity| Task 2:SwitchBrowserActivity→ Chrome Custom Tabs | Task 3:BrokerBrowserRedirectActivity(finishes)Flow Overview of
SwitchBrowserActivityWebViewAuthorizationFragmentreceives a SwitchBrowser challengeSwitchBrowserActivityis launched with browser configuration parametersBrokerBrowserRedirectActivityin a new taskBrokerBrowserRedirectActivityforwards redirect result back toSwitchBrowserActivityviaonNewIntent()SwitchBrowserActivitypasses the result toWebViewAuthorizationFragmentSwitchBrowserActivityfinishes and removes itself from the task stackSecurity Note
SwitchBrowserActivityis not exported