Bug 1930300 - Use fallback URL if it's Google PlayStore URL and the app is not installed already a=dmeehan

Original Revision: https://phabricator.services.mozilla.com/D228987

Differential Revision: https://phabricator.services.mozilla.com/D229034
This commit is contained in:
Titouan Thibaud 2024-11-16 14:41:31 +00:00
parent d896d894ad
commit 5d7a36d15c
2 changed files with 13 additions and 2 deletions

View File

@ -123,7 +123,7 @@ class AppLinksUseCases(
// Only set fallback URL if url is not a Google PlayStore URL
// The reason here is we already handled that case with the market place URL
val fallbackUrl = redirectData.fallbackIntent?.data?.takeIf {
it.isHttpOrHttps && !isPlayStoreURL(it.toString())
it.isHttpOrHttps && (!isPlayStoreURL(it.toString()) || redirectData.resolveInfo == null)
}?.toString()
val appIntent = when {

View File

@ -54,7 +54,7 @@ class AppLinksUseCasesTest {
private val appIntentWithPackageAndFallback =
"intent://com.example.app#Intent;package=com.example.com;S.browser_fallback_url=https://example.com;end"
private val appIntentWithPackageAndPlayStoreFallback =
"intent://com.example.app#Intent;package=com.example.com;S.browser_fallback_url=https?://play.google.com/store/abc;end"
"intent://com.example.app#Intent;package=com.example.com;S.browser_fallback_url=https://play.google.com/store/abc;end"
@Before
fun setup() {
@ -686,4 +686,15 @@ class AppLinksUseCasesTest {
assertTrue(redirect.marketplaceIntent != null)
assertNull(redirect.fallbackUrl)
}
@Test
fun `WHEN opening a app scheme uri WITHOUT package installed WHERE the URL is Google PlayStore THEN use fallback URL`() {
val context = createContext()
val subject = AppLinksUseCases(context, { false })
val redirect = subject.interceptedAppLinkRedirect(appIntentWithPackageAndPlayStoreFallback)
assertFalse(redirect.hasExternalApp())
assertTrue(redirect.hasFallback())
assertEquals("https://play.google.com/store/abc", redirect.fallbackUrl)
}
}