From f8be58791ef6089707c5fb29dd0eefdc5e1b25e3 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 3 Mar 2014 10:24:41 -0800 Subject: Fix samsung returning File.canWrite true when false --- .../daneren2005/dsub/activity/SubsonicFragmentActivity.java | 2 +- src/github/daneren2005/dsub/util/FileUtil.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java index 186f19c2..a55abfc0 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -443,7 +443,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity { } else { String path = prefs.getString(Constants.PREFERENCES_KEY_CACHE_LOCATION, null); File cacheLocation = new File(path); - if(!FileUtil.ensureDirectoryExistsAndIsReadWritable(cacheLocation)) { + if(!FileUtil.verifyCanWrite(cacheLocation)) { resetCacheLocation(prefs); Util.info(this, R.string.common_warning, R.string.settings_cache_location_reset); } diff --git a/src/github/daneren2005/dsub/util/FileUtil.java b/src/github/daneren2005/dsub/util/FileUtil.java index 95917429..197a0149 100644 --- a/src/github/daneren2005/dsub/util/FileUtil.java +++ b/src/github/daneren2005/dsub/util/FileUtil.java @@ -368,6 +368,19 @@ public class FileUtil { } return true; } + public static boolean verifyCanWrite(File dir) { + if(ensureDirectoryExistsAndIsReadWritable(dir) { + try { + File tmp = File.createTempFile("tmp", "tmp", dir); + tmp.delete(); + return true; + } catch(Exception e) { + return false; + } + } else { + return false; + } + } /** * Makes a given filename safe by replacing special characters like slashes ("/" and "\") -- cgit v1.2.3 From d1da3fcf362584224aba0dbf6ba77cc47f079b14 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 3 Mar 2014 17:49:10 -0800 Subject: DSub 4.5.4 Released --- AndroidManifest.xml | 4 ++-- res/raw/changelog.xml | 3 +++ src/github/daneren2005/dsub/util/FileUtil.java | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 6858e64c..f2d4740d 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="94" + android:versionName="4.5.4"> diff --git a/res/raw/changelog.xml b/res/raw/changelog.xml index 1bf5d58a..fb208892 100644 --- a/res/raw/changelog.xml +++ b/res/raw/changelog.xml @@ -1,5 +1,8 @@ + + Fix cache location reset for Samsung upgrades + WARNING: Please read the first change! Google changed Android so that apps can only write to a specific location on a SD card for 4.4+. Samsung is currently upgrading their phones to 4.4, so if you have a Galaxy phone you will probably receive a notification that the cache location has been changed to the only place DSub can write to now. Everyone else's settings will be left alone, but the default cache location has also been changed. diff --git a/src/github/daneren2005/dsub/util/FileUtil.java b/src/github/daneren2005/dsub/util/FileUtil.java index 197a0149..a1983fde 100644 --- a/src/github/daneren2005/dsub/util/FileUtil.java +++ b/src/github/daneren2005/dsub/util/FileUtil.java @@ -369,7 +369,7 @@ public class FileUtil { return true; } public static boolean verifyCanWrite(File dir) { - if(ensureDirectoryExistsAndIsReadWritable(dir) { + if(ensureDirectoryExistsAndIsReadWritable(dir)) { try { File tmp = File.createTempFile("tmp", "tmp", dir); tmp.delete(); -- cgit v1.2.3