Improve browser selection in WebAuthenticationProvider#347
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR improves browser selection in WebAuthenticationProvider by adding validation to ensure selected packages are actual browsers capable of opening URLs. The change addresses an issue where non-browser apps that support Custom Tabs connections could be incorrectly selected, causing launch failures.
Key changes:
- Added a new
isBrowserPackagefunction to validate that a package can handle VIEW intents with BROWSABLE category - Updated browser selection logic to validate both preferred and available Custom Tabs providers before returning them
- Enhanced test coverage with a new test case for Custom Tabs providers that aren't browsers
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| WebAuthenticationProvider.kt | Implemented browser validation logic and refactored browser selection to check packages before returning them |
| DefaultWebAuthenticationProviderTest.kt | Added test for non-browser Custom Tabs providers and updated helper method to support this scenario |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This PR adds validation for the packages selected as browsers.
I encountered an issue on a device with Google Chrome disabled and another browser set as the default. Also, that device has an application installed that appears when querying for
ACTION_CUSTOM_TABS_CONNECTIONbut is not a browser. This app is listed first and is returned as a valid browser, but it cannot be used to open a URL.To address this, each package is checked for validity as a browser using the
isBrowserPackagefunction.