Skip to content

Report a failed save instead of crashing when MediaStore rejects it - #2251

Draft
mpretty-cyro wants to merge 1 commit into
devfrom
fix/save-attachment-insert-failure
Draft

mpretty-cyro wants to merge 1 commit into
devfrom
fix/save-attachment-insert-failure

Conversation

@mpretty-cyro

Copy link
Copy Markdown
Collaborator

Contributor checklist

  • I have tested my contribution on these devices:
  • Compiled only; not exercised on a device (see Testing below)
  • My contribution is fully baked and ready to be merged as is
  • I ensure that all the open issues my contribution fixes are mentioned in the commit message of my first commit using the Fixes #1234 syntax

Description

Crash cluster: IllegalArgumentException from ContentResolver.insert in SaveAttachmentTask.createOutputUri, escaping
doInBackground, which caught only IOException. A null insert result was also dereferenced with !!.

Both now end in the existing "save failed" toast.

Testing: compiled. A MediaStore rejection wasn't reproduced.

ContentResolver.insert throws IllegalArgumentException for values
MediaStore won't accept, and can return null; SaveAttachmentTask caught
only IOException and dereferenced the result with !!, so saving such an
attachment from a conversation or the media preview crashed. Both now
end in the existing "save failed" toast.

@mpretty-cyro mpretty-cyro left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

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