Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,12 @@ class BrowserTabFragment :
Intent(Intent.ACTION_VIEW).apply {
data = Uri.parse(url)
}
startActivity(intent)

if (requireActivity().packageManager.resolveActivity(intent, 0) != null) {
startActivity(intent)
} else {
showToast(R.string.unableToOpenLink)
}
}

private fun launchPopupMenu(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class SpecialUrlDetectorImpl(
): UrlType {
val uriString = uri.toString()

logcat(tag = "RadoiuC") { "Uri: $uri scheme: ${uri.scheme}" }
return when (val scheme = uri.scheme) {
TEL_SCHEME -> buildTelephone(uriString)
TELPROMPT_SCHEME -> buildTelephonePrompt(uriString)
Expand Down Expand Up @@ -91,7 +92,9 @@ class SpecialUrlDetectorImpl(
}
// if there's no redirects (initiatingUrl = null) then it's user initiated
val userInitiated = initiatingUrl == null
checkForIntent(scheme, uriString, intentFlags, userInitiated)
checkForIntent(scheme, uriString, intentFlags, userInitiated).also {
logcat(tag = "RadoiuC") { "Check for intent result: $it" }
}
}
}
}
Expand Down Expand Up @@ -206,7 +209,7 @@ class SpecialUrlDetectorImpl(
return try {
val intent = Intent.parseUri(uriString, intentFlags)
// only proceed if something can handle it
if (userInitiated && (intent == null || packageManager.resolveActivity(intent, 0) == null) &&
if (userInitiated && invalidIntentWithNoPackage(intent) &&
androidBrowserConfigFeature.validateIntentResolution().isEnabled()
) {
return UrlType.Unknown(uriString)
Expand Down Expand Up @@ -234,6 +237,9 @@ class SpecialUrlDetectorImpl(
return UrlType.SearchQuery(uriString)
}

private fun invalidIntentWithNoPackage(intent: Intent?) = intent == null ||
(packageManager.resolveActivity(intent, 0) == null && intent.`package` == null)

private fun buildFallbackIntent(fallbackUrl: String?): Intent? {
if (determineType(fallbackUrl) is UrlType.NonHttpAppLink) {
return Intent.parseUri(fallbackUrl, URI_ANDROID_APP_SCHEME)
Expand Down
Loading