Skip to content

fix(mobile): pick the album through the gallery contract, not a raw intent - #838

Merged
huichen merged 1 commit into
mainfrom
fix/album-gallery-contract
Sep 25, 2026
Merged

huichen merged 1 commit into
mainfrom
fix/album-gallery-contract

Conversation

@huichen

@huichen huichen commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

Found while investigating the album's system routes for a device report: the system-gallery route could never return a usable photo. It launched ACTION_PICK through expo-intent-launcher and read result.data as a file URI — but that field is the result Intent's string ("Intent { act=… dat=content://… }"; see IntentLauncherModule.OnActivityResult, which stores payload.data.toString()). The pick therefore decoded nothing. It went unnoticed because the reporting phone has no gallery app and takes the in-app grid instead (added in #836); every other device on that route would have failed.

Now:

  • That route uses expo-image-picker's legacy contract — ACTION_GET_CONTENT for images — which returns the chosen URIs correctly, single or multi. Each pick is copied into the cache before the shared attachment pipeline sees it, exactly like an album-grid pick, because a gallery grants read access to the photos rather than a durable file.
  • The router keeps its guarantees, adjusted to what a contract can do: it cannot target one component, so the gallery route is only taken when a recognized gallery answers the intent the app actually launches (image ACTION_GET_CONTENT). A gallery that only advertises ACTION_PICK on MediaStore's image collection falls through to the photo-picker contract or the in-app grid, rather than risking a file browser under the album label.
  • Nothing else changes: photo pickers still win, and a device with no picker at all still gets the grid. expo-intent-launcher is no longer used for picking.

Validation

  • tsc --noEmit, eslint clean, mobile 128 suites / 2035 tests pass. The album tests now assert the gallery contract (legacy: true, multi-select, selection limit) and the classification/degradation cases; the expo-intent-launcher mock is gone from files.test.ts.
  • Docs updated: docs/internals/mobile/README.md, README.zh-CN.md, harmonyos-compatibility.zh-CN.md (including why a raw intent pick must not be reintroduced).
  • Not device-verified — the fix affects devices that have a gallery app but no system photo picker, which the reporting phone is not.

…ntent

The system-gallery album route launched ACTION_PICK through
expo-intent-launcher and read `result.data` as a file URI. expo-intent-launcher
resolves that field to the result Intent's string — `"Intent { act=… dat=… }"` —
so the chosen photo could never open: the pick would fail to decode instead.
The route only appeared to work because the reporting phone has no gallery and
falls to the in-app grid.

Use expo-image-picker's legacy contract for that route: it is ACTION_GET_CONTENT
for images, and it returns the chosen URIs (single or multi) properly. Each pick
is copied into the cache before the shared attachment pipeline sees it, exactly
like an album-grid pick, because a gallery grants read access to the photos, not
a durable file.

The router keeps the same guarantees, adjusted for what a contract can do: the
contract cannot target one component, so the gallery route is only taken when a
recognized gallery answers the intent the app actually launches (image
ACTION_GET_CONTENT). A gallery that only advertises ACTION_PICK on MediaStore's
image collection falls through to the photo-picker contract or the in-app grid
rather than risking a file browser under the album label. Nothing else changes:
photo pickers still win, and a device with no picker at all still gets the grid.
@huichen
huichen enabled auto-merge (squash) September 25, 2026 14:04
@huichen
huichen merged commit d776bfb into main Sep 25, 2026
12 checks passed
@huichen
huichen deleted the fix/album-gallery-contract branch September 25, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant