commit dcf798ed06da5f3d512373f750e5f0adc1bd557d parent 62d872baa17c3aa50ac168121b3bf041a87a1d1e Author: Kagami Sascha Rosylight <krosylight@proton.me> Date: Thu, 9 Oct 2025 17:40:32 +0000 Bug 1975933 - Ask and show camera/microphone picker when accept attribute is empty r=android-reviewers,nalexander This aligns with Chrome behavior. Note that the behavior is still different when accept/capture attribute exists: 1. Firefox has been and will still be showing camera/microphone if accept attribute exists, while Chrome decides not to. I'm keeping the current behavior, because the media picker does not allow camera and I don't see why that's good for users. 2. Firefox is ignoring capture attribute if accept attribute has wildcard in subtype (`image/*`), while Chrome does not. I think we should follow Chrome but in a separate patch. Differential Revision: https://phabricator.services.mozilla.com/D266053 Diffstat:
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/mobile/android/android-components/components/feature/prompts/src/main/java/mozilla/components/feature/prompts/file/MimeType.kt b/mobile/android/android-components/components/feature/prompts/src/main/java/mozilla/components/feature/prompts/file/MimeType.kt @@ -135,10 +135,10 @@ internal sealed class MimeType( /** * True if any of the given mime values match this type. If no values are specified, then - * there will not be a match. + * it will match any mime type. */ open fun matches(mimeTypes: Array<out String>) = - mimeTypes.isNotEmpty() && mimeTypes.any { it.startsWith(type) } + mimeTypes.isEmpty() || mimeTypes.any { it.startsWith(type) } open fun shouldCapture(mimeTypes: Array<out String>, capture: File.FacingMode) = capture != File.FacingMode.NONE && diff --git a/mobile/android/android-components/components/feature/prompts/src/test/java/mozilla/components/feature/prompts/file/MimeTypeTest.kt b/mobile/android/android-components/components/feature/prompts/src/test/java/mozilla/components/feature/prompts/file/MimeTypeTest.kt @@ -64,7 +64,7 @@ class MimeTypeTest { @Test fun `matches empty list of mime types`() { - assertTypes(setOf(MimeType.Wildcard)) { + assertTypes(setOf(MimeType.Image(), MimeType.Audio, MimeType.Video, MimeType.Wildcard)) { it.matches(emptyArray()) } }