From e86a9a41d289e107bf235baaac766c109f23a5c6 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Tue, 17 Sep 2013 10:59:33 +0200 Subject: Fix a few market console errors --- icsopenvpn.iml | 5 +++-- src/de/blinkt/openvpn/ConfigConverter.java | 5 +++-- src/de/blinkt/openvpn/FileSelect.java | 3 ++- src/de/blinkt/openvpn/VpnProfile.java | 23 ++++++++++++---------- .../openvpn/core/OpenVpnManagementThread.java | 2 +- src/de/blinkt/openvpn/fragments/AboutFragment.java | 21 +++++++++++++------- 6 files changed, 36 insertions(+), 23 deletions(-) diff --git a/icsopenvpn.iml b/icsopenvpn.iml index 71d16c50..cdd93af4 100644 --- a/icsopenvpn.iml +++ b/icsopenvpn.iml @@ -5,9 +5,11 @@ @@ -59,7 +61,6 @@ - diff --git a/src/de/blinkt/openvpn/ConfigConverter.java b/src/de/blinkt/openvpn/ConfigConverter.java index 22109f81..75620455 100644 --- a/src/de/blinkt/openvpn/ConfigConverter.java +++ b/src/de/blinkt/openvpn/ConfigConverter.java @@ -35,7 +35,7 @@ public class ConfigConverter extends ListActivity { public static final String IMPORT_PROFILE = "de.blinkt.openvpn.IMPORT_PROFILE"; - private VpnProfile mResult; + private VpnProfile mResult; private ArrayAdapter mArrayAdapter; private List mPathsegments; @@ -306,7 +306,8 @@ public class ConfigConverter extends ListActivity { InputStream input = new FileInputStream(file); long len= file.length(); - + if (len > VpnProfile.MAX_EMBED_FILE_SIZE) + throw new IOException("File size of file to import too large."); // Create the byte array to hold the data byte[] bytes = new byte[(int) len]; diff --git a/src/de/blinkt/openvpn/FileSelect.java b/src/de/blinkt/openvpn/FileSelect.java index 88a9abdd..8389a2ab 100644 --- a/src/de/blinkt/openvpn/FileSelect.java +++ b/src/de/blinkt/openvpn/FileSelect.java @@ -155,7 +155,8 @@ public class FileSelect extends Activity { InputStream input = new FileInputStream(file); long len= file.length(); - + if (len > VpnProfile.MAX_EMBED_FILE_SIZE) + throw new IOException("selected file size too big to embed into profile"); // Create the byte array to hold the data byte[] bytes = new byte[(int) len]; diff --git a/src/de/blinkt/openvpn/VpnProfile.java b/src/de/blinkt/openvpn/VpnProfile.java index 3a2f2bbf..ed19cd17 100644 --- a/src/de/blinkt/openvpn/VpnProfile.java +++ b/src/de/blinkt/openvpn/VpnProfile.java @@ -44,6 +44,19 @@ public class VpnProfile implements Serializable { // The Serializable documentation mentions that class name change are possible // but the how is unclear // + transient static final long MAX_EMBED_FILE_SIZE = 2048*1024; // 2048kB + // Don't change this, not all parts of the program use this constant + public static final String EXTRA_PROFILEUUID = "de.blinkt.openvpn.profileUUID"; + public static final String INLINE_TAG = "[[INLINE]]"; + public static final String MINIVPN = "miniopenvpn"; + private static final long serialVersionUID = 7085688938959334563L; + private static final String OVPNCONFIGFILE = "android.conf"; + public static String DEFAULT_DNS1 = "8.8.8.8"; + public static String DEFAULT_DNS2 = "8.8.4.4"; + + public transient String mTransientPW = null; + public transient String mTransientPCKS12PW = null; + public static final int TYPE_CERTIFICATES = 0; public static final int TYPE_PKCS12 = 1; @@ -58,16 +71,6 @@ public class VpnProfile implements Serializable { public static final int X509_VERIFY_TLSREMOTE_DN = 2; public static final int X509_VERIFY_TLSREMOTE_RDN = 3; public static final int X509_VERIFY_TLSREMOTE_RDN_PREFIX = 4; - // Don't change this, not all parts of the program use this constant - public static final String EXTRA_PROFILEUUID = "de.blinkt.openvpn.profileUUID"; - public static final String INLINE_TAG = "[[INLINE]]"; - public static final String MINIVPN = "miniopenvpn"; - private static final long serialVersionUID = 7085688938959334563L; - private static final String OVPNCONFIGFILE = "android.conf"; - public static String DEFAULT_DNS1 = "8.8.8.8"; - public static String DEFAULT_DNS2 = "8.8.4.4"; - public transient String mTransientPW = null; - public transient String mTransientPCKS12PW = null; // variable named wrong and should haven beeen transient // but needs to keep wrong name to guarante loading of old // profiles diff --git a/src/de/blinkt/openvpn/core/OpenVpnManagementThread.java b/src/de/blinkt/openvpn/core/OpenVpnManagementThread.java index 9497f18b..4fe54217 100644 --- a/src/de/blinkt/openvpn/core/OpenVpnManagementThread.java +++ b/src/de/blinkt/openvpn/core/OpenVpnManagementThread.java @@ -93,7 +93,7 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement { } public void managmentCommand(String cmd) { - if(mSocket!=null) { + if(mSocket!=null && mSocket.getOutputStream() !=null) { try { mSocket.getOutputStream().write(cmd.getBytes()); mSocket.getOutputStream().flush(); diff --git a/src/de/blinkt/openvpn/fragments/AboutFragment.java b/src/de/blinkt/openvpn/fragments/AboutFragment.java index ce57afda..c4f27ee1 100644 --- a/src/de/blinkt/openvpn/fragments/AboutFragment.java +++ b/src/de/blinkt/openvpn/fragments/AboutFragment.java @@ -111,13 +111,15 @@ public class AboutFragment extends Fragment implements View.OnClickListener { final ArrayList responseList = skuDetails.getStringArrayList("DETAILS_LIST"); - getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - createPlayBuyOptions(ownedSkus, responseList); - - } - }); + if (getActivity() != null) { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + createPlayBuyOptions(ownedSkus, responseList); + + } + }); + } } catch (RemoteException e) { e.printStackTrace(); @@ -274,6 +276,11 @@ public class AboutFragment extends Fragment implements View.OnClickListener { } + @Override + public void onActivityCreated(Bundle savedInstanceState) { + if (mService!=null) + initGooglePlayDonation(); + } @Override public void onClick(View v) { -- cgit v1.2.3