Android: don't drop shares when provider lacks _display_name or video thumbnail fails#404
Open
13nin wants to merge 1 commit into
Open
Android: don't drop shares when provider lacks _display_name or video thumbnail fails#40413nin wants to merge 1 commit into
13nin wants to merge 1 commit into
Conversation
… 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>
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
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, leavinginitialMedia == null:FileDirectory.getDataColumnusedcursor.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.ReceiveSharingIntentPlugin.toJsonObjectcalledgetThumbnailAndDurationfor videos, which runsMediaMetadataRetriever.setDataSource(path). For some videos this throwsRuntimeException: setDataSource failed: status = 0xFFFFFFEA. Thumbnail/duration are optional, but the throw killed the share.Changes
getDataColumn: usegetColumnIndex(not...OrThrow) with a>= 0guard, guard against empty names, wrap the column query and theopenInputStream/copy intry/catch(a failed item returnsnullinstead of crashing the batch).toJsonObject: wrapgetAbsolutePathandgetThumbnailAndDurationintry/catch; a failed thumbnail yieldsthumbnail = nullrather than aborting. Skip an item only when there is neither a path nor text.No public API change. For the few videos
MediaMetadataRetrievercan't read, only the thumbnail isnull— 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:
getInitialMediareturned empty. After: the 21 MB file is delivered; logcat shows the thumbnail failure handled gracefully: