Skip to content

Commit 235fa59

Browse files
committed
[21826] Ensure mobilePickPhoto works in all Android devices
1 parent 9af01e9 commit 235fa59

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

docs/notes/bugfix-21826.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Ensure mobilePickPhoto "camera" does not fail in some Android 8+ devices

engine/src/java/com/runrev/android/Engine.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,18 @@ public void showCamera()
20472047
return;
20482048
}
20492049

2050-
String t_path = m_temp_image_file.getPath();
2050+
// getPath() returns a path starting with /, e.g. /storage/emulated/0/Android/data/<app_id>/cache/..
2051+
// This path is appended to content://<app_id>.fileprovider/share/, resulting in an URI like:
2052+
//
2053+
// content://<app_id>.fileprovider//storage/emulated/0/Android/data/<app_id>/cache/..
2054+
//
2055+
// This is not a problem in general, but in _some_ devices (e.g. Huawei nova e3) this URI is
2056+
// normalized to:
2057+
//
2058+
// content://<app_id>.fileprovider/storage/emulated/0/Android/data/<app_id>/cache/..
2059+
//
2060+
// This results in the URI not being found. So use .substring(1) to remove the first slash
2061+
String t_path = m_temp_image_file.getPath().substring(1);
20512062

20522063
Uri t_uri;
20532064
t_uri = FileProvider.getProvider(getContext()).addPath(t_path, t_path, "image/jpeg", true, ParcelFileDescriptor.MODE_WRITE_ONLY);

0 commit comments

Comments
 (0)