cordova-plugin-media-capture icon indicating copy to clipboard operation
cordova-plugin-media-capture copied to clipboard

Android: Prevent app crash caused by NPE on intent data or mediaFile

Open ath0mas opened this issue 2 years ago • 0 comments

Platforms affected

Android

Motivation and Context

Prevent app crash after capture and show error if no content or no access to it

Description

  1. minimal fix #227 Unify null checks for all three capture types, first on retrieved intent data uri (failing with CAPTURE_NO_MEDIA_FILES), and then on no mediaFile created (failing with CAPTURE_INTERNAL_ERR)
  2. Simplify how video uri is retrieved from Video capture intent (see #210 comment)

Testing

App crashing because of audio capture in some conditions (see #227 comment) now resolves with failure instead. Not perfect, expecting #215 work on FileProvider to solve the problem but for now it is not an app crash anymore.

Checklist

  • [x] I've run the tests to see all new and existing tests pass
  • [x] I added automated test coverage as appropriate for this change
  • [x] Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • [x] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • [x] I've updated the documentation if necessary

ath0mas avatar Nov 06 '21 01:11 ath0mas