Skip to content

fix(mobile): route the album from resolved handlers, never a file browser - #829

Merged
huichen merged 2 commits into
mainfrom
fix/album-routes
Sep 25, 2026
Merged

huichen merged 2 commits into
mainfrom
fix/album-routes

Conversation

@huichen

@huichen huichen commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

The report after #823: on a Huawei phone without Play services the album item still opens the document picker (the file browser). Two reasons, both now addressed by resolving the candidates before launching anything instead of guessing from the API level:

  • The album intent may be answered by a file manager rather than a gallery — nothing distinguished them.
  • When no gallery answers, the code still handed the job to AndroidX's photo-picker contract, which silently degrades to ACTION_OPEN_DOCUMENT wherever no system photo picker exists. That is the document picker, and it is what "Choose files" is for.

Now:

  • future-file-handler gains resolveImagePickRoutes, which reports the apps answering the album intent, Android 13's system photo picker, the AOSP photo-picker backport (androidx.activity.result.contract.action.PICK_IMAGES), and — diagnostics only — the document picker. The module manifest declares those intents in <queries>; without it package visibility hides user-installed galleries from the query and the router would read them as absent.
  • The album router decides from that: Android 13+ keeps the system photo picker (multi-select) when it answers; below 33 a gallery advertising ACTION_PICK on MediaStore's image collection wins and is launched by explicit component, so a file manager that also advertises the pick cannot stand in for it; a real backport photo picker comes next; otherwise the album reports itself unavailable (existing attachment_album_unavailable string, now aligned with the "选择手机文件" label).
  • Gallery recognition is by package-name hints — Android has no "is this a gallery" flag. An unknown package is not treated as a gallery: a missed gallery shows the honest message, while a false positive would reproduce the original complaint. When nothing can present the album the resolution is logged, so a device report distinguishes "no album app" from "only a file manager advertises the pick".
  • App binaries without the probe keep the previous order, so a JS/native version skew does not change behaviour. No route asks for a full-album permission.

Validation

  • tsc --noEmit, eslint clean; 125 suites / 1938 tests pass, including new cases for: targeting the gallery when a file manager also answers, reporting unavailable when only a file manager (or nothing) answers, Android 13 keeping the system picker, the backport picker replacing the document picker, and a package-classification table with real OEM names (com.huawei.photos, com.miui.gallery, com.huawei.hidisk, com.android.documentsui, …).
  • Native side compiled locally: :future-file-handler:compileReleaseKotlin BUILD SUCCESSFUL, and :app:processReleaseManifest merged the new <queries> (verified present in the merged release manifest).
  • Not verified on a physical device. This is a native change: the fix reaches the phone only through a rebuilt APK (JS-only reload is not enough).

Docs updated: docs/internals/mobile/README.md, README.zh-CN.md, harmonyos-compatibility.zh-CN.md (including how to read the two possible device outcomes).

…wser

#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.
@huichen
huichen enabled auto-merge (squash) September 25, 2026 10:40
@huichen
huichen merged commit 415b9a8 into main Sep 25, 2026
12 checks passed
@huichen
huichen deleted the fix/album-routes branch September 25, 2026 10:43
huichen added a commit that referenced this pull request Sep 25, 2026
* feat(mobile): draw the album grid when no system picker exists

A Mate XT on HarmonyOS 6.1 runs the APK inside 卓易通, an Android
compatibility container that exposes neither a gallery app nor a photo picker.
#829 turned that into an honest "album unavailable" message, but the phone
reports the user's own files through shared storage, so the album can simply be
drawn here.

- future-file-handler gains listAlbumImages: MediaStore's image collection
  (newest first, bounded), falling back to walking the usual photo directories
  when the container maps storage without a media database.
- The album router keeps every system route ahead of it and adds two: a gallery
  that only answers ACTION_GET_CONTENT, and the Play-services photo picker.
  Only when nothing can present an album does the app show AlbumPickerModal —
  a plain newest-first grid, no albums, editing or paging — and only that route
  asks for the media permission, saying so inside the grid when it is refused.
- The chosen images go through the same pipeline as a gallery pick: copied into
  the cache while the read grant is live, then size/format/quota checked.
- The probe's <queries> now name the scheme as well as the MIME type, and each
  picker action is declared with and without data. Package visibility hides a
  target whose filter declares android:scheme="content" from a rule that only
  names a type, and a filter that declares no data is matched only by a data-less
  intent — either way the router would have read the phone as "no album app".

* test(mobile): unmount the album grid so jest can exit

The full suite reported 128/128 suites passing and still exited non-zero: a
live FlatList keeps its batching timer, which outlives the run. Unmount every
tree the modal test renders.
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