apache / cordova-plugin-camera

Apache Cordova Plugin camera
https://cordova.apache.org/
Apache License 2.0
966 stars 1.55k forks source link

fix(android): Improper serialization of image uri in save instance state #903

Closed breautek closed 1 month ago

breautek commented 1 month ago

Platforms affected

Android

Motivation and Context

The imageUri field is not properly restored if the activity is killed, which can cause further issues.

This is because imageFilePath was used instead for the imageUri which only contains the path of the original URI, losing the scheme in the process.

Description

Serialize using imageUri.toString() instead of using the imageFilePath

Testing

paramedic testing + testing with Don't Keep Activities developer option enabled.

Checklist

breautek commented 1 month ago

For clarity... The difference is imageUri will start off with a Uri object representing content://some-path/... or file:///some-path/... but if the activity was destroyed, it will get restored with an Uri representing /some-path/, missing the Uri scheme.