Repository navigation
fix(mobile): open the gallery without the system photo picker - #823
Merged
Merged
Conversation
AndroidX's PickVisualMedia contract only presents a real picker where Android 13's system photo picker — or the Play-services backport that older versions can receive — exists. Everywhere else it silently resolves to ACTION_OPEN_DOCUMENT, which is the document picker: on a Huawei phone without Play services, 相册 opened the file browser while 相机 and 选择手机文件 behaved exactly as labelled. Below API 33, ask the phone's own gallery for one image instead: ACTION_PICK on MediaStore's image collection, without CATEGORY_OPENABLE, so the document picker has no matching filter and the call stays on gallery apps. Copy the returned photo into the cache while the read grant is live, then hand it to the shared attachment pipeline like any other image. The contract remains the fallback for devices with no gallery app at all, and Android 13+ keeps the system photo picker with its multi-select. Neither route asks for a full-album permission or requests the media permission the OS shows in app info: the picker grants the selected photos alone.
huichen
enabled auto-merge (squash)
September 25, 2026 09:28
huichen
added a commit
that referenced
this pull request
Sep 25, 2026
…wser (#829) #823 opened the gallery below API 33 and still let AndroidX's photo-picker contract run when no gallery answered. On the Huawei phone that reported the bug the album item keeps showing the document picker — the file browser the report was about — because the contract degrades to ACTION_OPEN_DOCUMENT wherever no system photo picker exists, and because nothing tells us whether the gallery intent reaches a gallery or a file manager. Resolve the candidates first instead of guessing from the API level: - future-file-handler gains resolveImagePickRoutes, which reports the apps that would answer the album intent, Android 13's photo picker, the AOSP photo picker backport, and (for diagnostics) the document picker. Its manifest declares those intents in <queries>, without which package visibility hides user-installed galleries from the query and the router would read them as absent. - The album router then decides: Android 13+ keeps the system photo picker (multi-select) when it answers; below 33 a gallery that advertises ACTION_PICK on MediaStore's image collection wins and is launched explicitly by component, so a file manager that also advertises the pick cannot stand in for it; a real backport photo picker is next; otherwise the album reports itself unavailable. It never opens the document picker — that is what "Choose files" is for, and opening one under the album label is the failure being fixed. - Gallery recognition uses package-name hints, since Android has no "is this a gallery" flag. An unknown package is not treated as a gallery: a missed gallery degrades to the honest message, while a false positive reproduces the original complaint. The resolution is logged when nothing can present the album, so a device report can tell "no album app" from "only a file manager". - App binaries without the probe keep the previous order, so a JS/native version skew does not change behaviour.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On a Huawei phone without Play services, tapping 相册 in the attachment menu opened the document picker (Download folder / file browser). Media permission for the app was granted and had no effect on it; 拍照 and 选择手机文件 behaved exactly as labelled.
Root cause:
pickFromAlbumpasseslegacy: falsetoexpo-image-picker, which hands the call to AndroidXPickVisualMedia. That contract only presents a real picker where Android 13's system photo picker exists, or where the Play-services / R-extension photo-picker backport has landed on API 30-32. Where neither holds,PickVisualMedia.createIntentsilently resolves toACTION_OPEN_DOCUMENT— the document picker — which is what the phone showed. The full-album media permission cannot influence this path: neither picker asks for it, by design.Fixes for that class of device:
ACTION_PICKoncontent://media/external/images/media, withoutCATEGORY_OPENABLEso DocumentsUI (whoseACTION_PICKfilter requires openable documents) cannot take the call instead.Neither route requests a full-album permission or the media permission shown in app info — both grant the selected photos alone.
Validation
tsc --noEmitandeslintclean; full mobile suite 125 suites / 1910 tests passed (3 new cases: gallery-first below API 33, cancellation, no-gallery fallback).expo-intent-launcherwas already used by the update flow), so JS only — no native rebuild needed for the fix to take effect on an existing install.docs/internals/mobile/harmonyos-compatibility.zh-CN.md: if a compatibility runtime exposes no app handlingACTION_PICKon the MediaStore image collection (i.e. only the document picker), the album is unavailable from the APK and the picker falls back to the file browser — that needs a HarmonyOS-nativephotoAccessHelper.PhotoViewPickertarget, not an APK-side change.Docs updated:
docs/internals/mobile/README.md,README.zh-CN.md,harmonyos-compatibility.zh-CN.md.