Skip to content

fix: don't pin OEM resolver packages as the default browser - #1353

Open
6east-666 wants to merge 1 commit into
ReadYouApp:mainfrom
6east-666:fix/oem-resolver-default-browser
Open

6east-666 wants to merge 1 commit into
ReadYouApp:mainfrom
6east-666:fix/oem-resolver-default-browser

Conversation

@6east-666

Copy link
Copy Markdown

Problem

On some OEM ROMs, PackageManager.resolveActivity(ACTION_VIEW, MATCH_DEFAULT_ONLY) returns the platform's own resolver activity instead of a real browser. On Lenovo this is com.zui.resolver; on other devices it can be android, com.hihonor.android.internal.app, com.transsion.resolver, etc. These packages resolve for implicit VIEW intents but are not exported browser activities that can be started by another app.

The Force default browser mode pins the resolved package with setPackage(). That makes the first startActivity() throw ActivityNotFoundException; the existing catch then retries with the same mutated intent and crashes (see #849). Even once the retry is fixed by #1320, this path still fails once per link and shows a "setting ignored" toast before falling back to a chooser.

A real-world trace from Read You 0.16.2 (Lenovo TB373FU, Android 16) shows exactly this:

ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=https://www.bbc.co.uk/... pkg=com.zui.resolver }
    at ...AppUriHandler.openUri(UriHandler.kt:397)

Fix

Only pin the default-browser package when an explicit intent for that package actually resolves. If it does not, leave the intent implicit so the system dispatches to the actual default browser or shows its normal chooser.

Both call sites are updated: AppUriHandler.openUri() and the deprecated Context.openURL().

Related

Testing

No Lenovo device available here; this is a small platform-behavior change verified by CI. The resolver-package behavior is the same one worked around by other Android apps (e.g. Mihon's invalidDefaultBrowsers list).

@ibrahim-iqbal ibrahim-iqbal left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Makes sense to fall back to the plain intent when the pinned one doesn't resolve, and it also removes the !! crash when there's no default browser at all. Same change in both places, good.

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.

2 participants