Fix launcher intent detection for share intents

Problem:
 Share intents with CATEGORY_DEFAULT were incorrectly treated as
 launcher intents

ET-6136
This commit is contained in:
Serdar Ozturk
2026-04-21 12:08:18 +01:00
committed by MargeBot
parent 6ea6981386
commit 24af188f76
2 changed files with 31 additions and 2 deletions
@@ -61,8 +61,10 @@ class IntentMapper @Inject constructor() {
}
private fun Intent.isLauncherIntent(): Boolean = action == Intent.ACTION_MAIN &&
categories?.contains(Intent.CATEGORY_LAUNCHER) == true ||
categories?.contains(Intent.CATEGORY_DEFAULT) == true
(
categories?.contains(Intent.CATEGORY_LAUNCHER) == true ||
categories?.contains(Intent.CATEGORY_DEFAULT) == true
)
private fun Intent.isShareIntent(): Boolean = action == Intent.ACTION_SEND ||
action == Intent.ACTION_SEND_MULTIPLE ||
@@ -181,6 +181,33 @@ class IntentMapperTest {
assertTrue(result is HomeNavigationEvent.UnknownIntentReceived)
}
@Test
fun `map external image share intent with category default`() {
// Given
val streamUri = mockk<Uri> {
every { scheme } returns "content"
}
every { streamUri.toString() } returns "content://media/1"
val intent = mockIntent(
action = Intent.ACTION_SEND,
type = "image/jpeg",
data = null,
externalBoolean = true,
categories = setOf(Intent.CATEGORY_DEFAULT),
extraSubject = sampleShareInfoExternal.emailSubject,
extraRecipientTo = sampleShareInfoExternal.emailRecipientTo.toTypedArray(),
extraText = sampleShareInfoExternal.emailBody,
extraStreamUri = streamUri
)
// When
val result = mapper.map(intent)
// Then
assertIs<HomeNavigationEvent.ExternalShareIntentReceived>(result)
assertEquals(sampleShareInfoExternal, result.shareInfo)
}
private fun mockIntent(
action: String = "",