Skip to content

Android: don't drop shares when provider lacks _display_name or video thumbnail fails#404

Open
13nin wants to merge 1 commit into
KasemJaffer:masterfrom
13nin:fix/android-content-provider-share
Open

Android: don't drop shares when provider lacks _display_name or video thumbnail fails#404
13nin wants to merge 1 commit into
KasemJaffer:masterfrom
13nin:fix/android-content-provider-share

Conversation

@13nin

@13nin 13nin commented Jun 9, 2026

Copy link
Copy Markdown

Summary

Fixes #403.

On Android, sharing a video from Google Photos (and other providers with the same traits) silently dropped the file: the host app opened but getInitialMedia() / the media stream returned empty.

The cause is two unguarded throws in the Android intake that abort the whole intent — the exception propagates out of handleIntent, leaving initialMedia == null:

  1. FileDirectory.getDataColumn used cursor.getColumnIndexOrThrow("_display_name"). Providers that don't expose _display_name (Google Photos' com.google.android.apps.photos.contentprovider) throw here, before the existing generated-name fallback can run.
  2. ReceiveSharingIntentPlugin.toJsonObject called getThumbnailAndDuration for videos, which runs MediaMetadataRetriever.setDataSource(path). For some videos this throws RuntimeException: setDataSource failed: status = 0xFFFFFFEA. Thumbnail/duration are optional, but the throw killed the share.

Changes

  • getDataColumn: use getColumnIndex (not ...OrThrow) with a >= 0 guard, guard against empty names, wrap the column query and the openInputStream/copy in try/catch (a failed item returns null instead of crashing the batch).
  • toJsonObject: wrap getAbsolutePath and getThumbnailAndDuration in try/catch; a failed thumbnail yields thumbnail = null rather than aborting. Skip an item only when there is neither a path nor text.

No public API change. For the few videos MediaMetadataRetriever can't read, only the thumbnail is null — the file itself is copied and delivered.

Testing

Verified on a Samsung Galaxy S24 (Android 14), cold-start share of a video from Google Photos. Before: getInitialMedia returned empty. After: the 21 MB file is delivered; logcat shows the thumbnail failure handled gracefully:

I/FileDirectory: File name: <video>.mp4
W/ReceiveSharingIntent: getThumbnailAndDuration failed: java.lang.RuntimeException: setDataSource failed: status = 0xFFFFFFEA

… thumbnail fails

Guard getDataColumn (getColumnIndex + try/catch around query and copy) and
toJsonObject (try/catch around getAbsolutePath and getThumbnailAndDuration).
Fixes silent loss of files shared from Google Photos.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Android: Google Photos share silently drops the file (getInitialMedia empty) due to unguarded throws

1 participant