From 881d82ebd5cdd5588ef41cb1cacacb27988f61a6 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Thu, 7 Oct 2021 15:39:28 +0200 Subject: Fix two small issues reported in crashes from Play Console --- .../main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java | 2 +- main/src/ui/java/de/blinkt/openvpn/activities/ConfigConverter.kt | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/main/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java b/main/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java index bcf0e898..74244c35 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java +++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVpnManagementThread.java @@ -453,7 +453,7 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement { String proxyname = null; boolean proxyUseAuth = false; - if (mProfile.mConnections != null && mProfile.mConnections.length > connectionEntryNumber) { + if (mProfile != null && mProfile.mConnections != null && mProfile.mConnections.length > connectionEntryNumber) { Connection connection = mProfile.mConnections[connectionEntryNumber]; proxyType = connection.mProxyType; proxyname = connection.mProxyName; diff --git a/main/src/ui/java/de/blinkt/openvpn/activities/ConfigConverter.kt b/main/src/ui/java/de/blinkt/openvpn/activities/ConfigConverter.kt index 73a3f75e..725f466c 100644 --- a/main/src/ui/java/de/blinkt/openvpn/activities/ConfigConverter.kt +++ b/main/src/ui/java/de/blinkt/openvpn/activities/ConfigConverter.kt @@ -12,6 +12,7 @@ import android.app.AlertDialog import android.content.ActivityNotFoundException import android.content.Intent import android.content.pm.PackageManager +import android.database.Cursor import android.net.Uri import android.os.AsyncTask import android.os.Build @@ -650,9 +651,9 @@ class ConfigConverter : BaseActivity(), FileSelectCallback, View.OnClickListener mPathsegments = data.pathSegments - val cursor = contentResolver.query(data, null, null, null, null) - + var cursor:Cursor? = null try { + cursor = contentResolver.query(data, null, null, null, null) if (cursor != null && cursor.moveToFirst()) { var columnIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME) @@ -667,6 +668,9 @@ class ConfigConverter : BaseActivity(), FileSelectCallback, View.OnClickListener log("Mime type: " + cursor.getString(columnIndex)) } } + } + catch (se:SecurityException) { + log("Importing failed: ${se.localizedMessage}") } finally { cursor?.close() } -- cgit v1.2.3