From a1e50073476124040d36775e1e7ff720bce2746d Mon Sep 17 00:00:00 2001 From: Roman Tsisyk Date: Sat, 12 Jun 2021 08:41:11 +0300 Subject: [PATCH] [android] Don't ignore /storage/emulated Environment.isExternalStorageEmulated() throws IllegalArgumentException on some Androids. Don't call isExternalStorageEmulated() and don't ignore emulated storage. Fixes #538 Signed-off-by: Roman Tsisyk --- .../maps/settings/StoragePathManager.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/android/src/com/mapswithme/maps/settings/StoragePathManager.java b/android/src/com/mapswithme/maps/settings/StoragePathManager.java index 9895a80aca..ef3dc13501 100644 --- a/android/src/com/mapswithme/maps/settings/StoragePathManager.java +++ b/android/src/com/mapswithme/maps/settings/StoragePathManager.java @@ -158,7 +158,18 @@ public class StoragePathManager // then there is little benefit to apps storing data here instead of the private directories // returned by Context#getFilesDir(), etc. // - if (!Environment.isExternalStorageEmulated(dir)) + boolean isStorageEmulated; + try + { + isStorageEmulated = Environment.isExternalStorageEmulated(dir); + } + catch (IllegalArgumentException e) + { + // isExternalStorageEmulated may throw IllegalArgumentException + // https://github.com/organicmaps/organicmaps/issues/538 + isStorageEmulated = false; + } + if (!isStorageEmulated) candidates.add(dir); }