From 2fc0453127f992f9afa2490c151cad7d56207367 Mon Sep 17 00:00:00 2001 From: Konstantin Pastbin Date: Sun, 24 Apr 2022 08:35:42 +0300 Subject: [PATCH] [android] Remove extra mkdir() writability test needed for KitKat Signed-off-by: Konstantin Pastbin --- .../maps/settings/StoragePathManager.java | 5 ++--- .../src/com/mapswithme/util/StorageUtils.java | 20 ------------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/android/src/com/mapswithme/maps/settings/StoragePathManager.java b/android/src/com/mapswithme/maps/settings/StoragePathManager.java index 03ebe99643..84e71458e5 100644 --- a/android/src/com/mapswithme/maps/settings/StoragePathManager.java +++ b/android/src/com/mapswithme/maps/settings/StoragePathManager.java @@ -222,8 +222,7 @@ public class StoragePathManager LOGGER.i(TAG, "Rejected " + path + ": not a directory"); continue; } - - if (!dir.canWrite() || !StorageUtils.isDirWritable(path)) + if (!dir.canWrite()) { LOGGER.i(TAG, "Rejected " + path + ": not writable"); continue; @@ -443,7 +442,7 @@ public class StoragePathManager throw new IllegalStateException("Cannot move maps. New path is not a directory. New path : " + newDir); if (!oldDir.isDirectory()) throw new IllegalStateException("Cannot move maps. Old path is not a directory. Old path : " + oldDir); - if (!StorageUtils.isDirWritable(fullNewPath)) + if (!newDir.canWrite()) throw new IllegalStateException("Cannot move maps. New path is not writable. New path : " + fullNewPath); } diff --git a/android/src/com/mapswithme/util/StorageUtils.java b/android/src/com/mapswithme/util/StorageUtils.java index 888c3e75b0..3441c760d7 100644 --- a/android/src/com/mapswithme/util/StorageUtils.java +++ b/android/src/com/mapswithme/util/StorageUtils.java @@ -250,26 +250,6 @@ public class StorageUtils } } - /** - * Check if directory is writable. On some devices with KitKat (eg, Samsung S4) simple File.canWrite() returns - * true for some actually read only directories on sdcard. - * see https://code.google.com/p/android/issues/detail?id=66369 for details - * - * @param path path to ckeck - * @return result - */ - @SuppressWarnings("ResultOfMethodCallIgnored") - public static boolean isDirWritable(String path) - { - File f = new File(path, "mapsme_test_dir"); - f.mkdir(); - if (!f.exists()) - return false; - - f.delete(); - return true; - } - public static long getFreeBytesAtPath(String path) { long size = 0;