From 65bfc183ca1893a0020d152493d3f2b5180ce68b Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Sat, 27 Apr 2019 16:31:46 +0300 Subject: [PATCH] Minor fixes --- build.gradle | 4 ++-- src/main/java/com/ap/transmission/btc/Utils.java | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 6d4db9a..9b034ce 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ -def version = '1.3.0' -def versionNum = 64 +def version = '1.3.1' +def versionNum = 65 def basic_version = '1.0.0' def basic_versionNum = 1 diff --git a/src/main/java/com/ap/transmission/btc/Utils.java b/src/main/java/com/ap/transmission/btc/Utils.java index e1a65f9..8e6e0b9 100644 --- a/src/main/java/com/ap/transmission/btc/Utils.java +++ b/src/main/java/com/ap/transmission/btc/Utils.java @@ -22,7 +22,6 @@ import android.support.annotation.Nullable; import android.support.design.widget.Snackbar; import android.support.v4.provider.DocumentFile; -import android.system.ErrnoException; import android.system.Os; import android.util.DisplayMetrics; import android.util.Log; @@ -104,7 +103,7 @@ public static String getIPAddress(Context context) { public static InetAddress getInterfaceAddress(Context context) { InetAddress result = ifaddr; - if(result != null) return result; + if (result != null) return result; Context ctx = context.getApplicationContext(); ConnectivityManager cmgr = (ConnectivityManager) ctx.getSystemService(CONNECTIVITY_SERVICE); @@ -242,7 +241,7 @@ public static String getRealDirPath(Context ctx, Uri dirUri) { } else { err(TAG, "getRealDirPath: pfd is null"); } - } catch (IOException | ErrnoException ex) { + } catch (Exception ex) { Log.e(TAG, "Failed to resolve real path: " + dirUri, ex); } finally { if (pfd != null) try { pfd.close(); } catch (IOException ignored) {} @@ -253,7 +252,7 @@ public static String getRealDirPath(Context ctx, Uri dirUri) { } @TargetApi(VERSION_CODES.LOLLIPOP) - public static String getDescriptorPath(ParcelFileDescriptor fd) throws ErrnoException { + public static String getDescriptorPath(ParcelFileDescriptor fd) throws Exception { String path = Os.readlink("/proc/self/fd/" + fd.getFd()); if (path.startsWith("/mnt/media_rw/")) { @@ -428,9 +427,9 @@ public static void copyAssets(AssetManager amgr, String src, File dstDir, boolea private static void copyAssets(AssetManager amgr, String src, File dstDir, byte[] buf) throws IOException { - String ls[] = amgr.list(src); + String[] ls = amgr.list(src); - if (ls.length > 0) { + if ((ls != null) && (ls.length > 0)) { for (String f : ls) { copyAssets(amgr, src + '/' + f, dstDir, buf); } @@ -859,7 +858,7 @@ public static void enableMenuIcons(PopupMenu popup) { f.setAccessible(true); Object h = f.get(popup); h.getClass().getDeclaredMethod("setForceShowIcon", boolean.class).invoke(h, true); - } catch (Exception ignore) {ignore.printStackTrace();} + } catch (Exception ignore) { } } public static void openUri(Activity a, Uri uri, String mime) {