diff options
author | Arne Schwabe <arne@rfc2549.org> | 2013-02-05 09:49:06 +0100 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2013-02-05 09:49:06 +0100 |
commit | 1a65622af5d97bfcf56c84e90e40bfd0b214e43b (patch) | |
tree | d4ba0b20e995fd9cfc5030c3d889c2a963b10b73 /src/de/blinkt/openvpn | |
parent | 84ccab8d6510835316b0a89085dae31801bd50dc (diff) |
Fix Locale related errors/bugs. Update … to unicode replacement. Fix the speed display.
Diffstat (limited to 'src/de/blinkt/openvpn')
-rw-r--r-- | src/de/blinkt/openvpn/CIDRIP.java | 4 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/FileSelectionFragment.java | 5 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/OpenVPN.java | 1 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/OpenVpnManagementThread.java | 3 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/OpenVpnService.java | 19 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/Settings_Basic.java | 17 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/VpnProfile.java | 8 |
7 files changed, 29 insertions, 28 deletions
diff --git a/src/de/blinkt/openvpn/CIDRIP.java b/src/de/blinkt/openvpn/CIDRIP.java index ccb3836a..d3939dfc 100644 --- a/src/de/blinkt/openvpn/CIDRIP.java +++ b/src/de/blinkt/openvpn/CIDRIP.java @@ -1,5 +1,7 @@ package de.blinkt.openvpn; +import java.util.Locale; + class CIDRIP{ String mIp; int len; @@ -26,7 +28,7 @@ class CIDRIP{ } @Override public String toString() { - return String.format("%s/%d",mIp,len); + return String.format(Locale.ENGLISH,"%s/%d",mIp,len); } public boolean normalise(){ diff --git a/src/de/blinkt/openvpn/FileSelectionFragment.java b/src/de/blinkt/openvpn/FileSelectionFragment.java index 2d8110e1..5badc6e0 100644 --- a/src/de/blinkt/openvpn/FileSelectionFragment.java +++ b/src/de/blinkt/openvpn/FileSelectionFragment.java @@ -4,6 +4,7 @@ import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.TreeMap; import android.app.AlertDialog; @@ -180,12 +181,12 @@ public class FileSelectionFragment extends ListFragment { dirsPathMap.put(dirName, file.getPath()); } else { final String fileName = file.getName(); - final String fileNameLwr = fileName.toLowerCase(); + final String fileNameLwr = fileName.toLowerCase(Locale.getDefault()); // se ha um filtro de formatos, utiliza-o if (formatFilter != null) { boolean contains = false; for (int i = 0; i < formatFilter.length; i++) { - final String formatLwr = formatFilter[i].toLowerCase(); + final String formatLwr = formatFilter[i].toLowerCase(Locale.getDefault()); if (fileNameLwr.endsWith(formatLwr)) { contains = true; break; diff --git a/src/de/blinkt/openvpn/OpenVPN.java b/src/de/blinkt/openvpn/OpenVPN.java index 9cfaf1e8..c1616f2d 100644 --- a/src/de/blinkt/openvpn/OpenVPN.java +++ b/src/de/blinkt/openvpn/OpenVPN.java @@ -4,7 +4,6 @@ import java.util.LinkedList; import java.util.Locale; import java.util.Vector; - import android.content.Context; import android.os.Build; diff --git a/src/de/blinkt/openvpn/OpenVpnManagementThread.java b/src/de/blinkt/openvpn/OpenVpnManagementThread.java index c67d027d..381fee82 100644 --- a/src/de/blinkt/openvpn/OpenVpnManagementThread.java +++ b/src/de/blinkt/openvpn/OpenVpnManagementThread.java @@ -11,6 +11,7 @@ import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.util.LinkedList;
+import java.util.Locale;
import java.util.Vector;
import javax.crypto.BadPaddingException;
@@ -261,7 +262,7 @@ public class OpenVpnManagementThread implements Runnable { OpenVPN.logInfo(R.string.using_proxy, isa.getHostName(),isa.getPort());
- String proxycmd = String.format("proxy HTTP %s %d\n", isa.getHostName(),isa.getPort());
+ String proxycmd = String.format(Locale.ENGLISH,"proxy HTTP %s %d\n", isa.getHostName(),isa.getPort());
managmentCommand(proxycmd);
} else {
managmentCommand("proxy NONE\n");
diff --git a/src/de/blinkt/openvpn/OpenVpnService.java b/src/de/blinkt/openvpn/OpenVpnService.java index 0ac57406..71cc5cd2 100644 --- a/src/de/blinkt/openvpn/OpenVpnService.java +++ b/src/de/blinkt/openvpn/OpenVpnService.java @@ -17,6 +17,7 @@ package de.blinkt.openvpn;import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.Locale; import java.util.Vector; import android.annotation.TargetApi; @@ -37,10 +38,10 @@ import android.os.Handler.Callback; import android.os.IBinder; import android.os.Message; import android.os.ParcelFileDescriptor; - +import de.blinkt.openvpn.OpenVPN.ByteCountListener; import de.blinkt.openvpn.OpenVPN.StateListener; -public class OpenVpnService extends VpnService implements StateListener, Callback { +public class OpenVpnService extends VpnService implements StateListener, Callback, ByteCountListener { public static final String START_SERVICE = "de.blinkt.openvpn.START_SERVICE"; public static final String START_SERVICE_STICKY = "de.blinkt.openvpn.START_SERVICE_STICKY"; public static final String ALWAYS_SHOW_NOTIFICATION = "de.blinkt.openvpn.NOTIFICATION_ALWAYS_VISIBLE"; @@ -116,6 +117,8 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac private void endVpnService() { mProcessThread=null; OpenVPN.logBuilderConfig(null); + OpenVPN.removeStateListener(this); + OpenVPN.removeByteCountListener(this); ProfileManager.setConntectedVpnProfileDisconnected(this); if(!mStarting) { stopSelf(); @@ -158,6 +161,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac startForeground(OPENVPN_STATUS, notification); } + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void jbNotificationExtras(boolean lowpriority, android.app.Notification.Builder nbuilder) { @@ -217,6 +221,12 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac return lss; } catch (IOException e) { e.printStackTrace(); + } finally { + try { + sock.close(); + } catch (IOException e) { + e.printStackTrace(); + } } return null; @@ -238,6 +248,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac mNotificationalwaysVisible=true; OpenVPN.addStateListener(this); + OpenVPN.addByteCountListener(this); if(intent != null && intent.getAction() !=null &&intent.getAction().equals(START_SERVICE)) return START_NOT_STICKY; @@ -517,7 +528,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac } } - + @Override public void updateByteCount(long in, long out, long diffin, long diffout) { if(mDisplayBytecount) { String netstat = String.format(getString(R.string.statusline_bytecount), @@ -538,7 +549,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac if (bytes < unit) return bytes + " B"; int exp = (int) (Math.log(bytes) / Math.log(unit)); String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp-1) + (si ? "" : "i"); - return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre); + return String.format(Locale.getDefault(),"%.1f %sB", bytes / Math.pow(unit, exp), pre); } @Override diff --git a/src/de/blinkt/openvpn/Settings_Basic.java b/src/de/blinkt/openvpn/Settings_Basic.java index 9c85094a..137e75c5 100644 --- a/src/de/blinkt/openvpn/Settings_Basic.java +++ b/src/de/blinkt/openvpn/Settings_Basic.java @@ -58,29 +58,15 @@ public class Settings_Basic extends Fragment implements View.OnClickListener, On private Spinner mType; private FileSelectLayout mpkcs12; private TextView mPKCS12Password; - private Handler mHandler; - - - - - - private SparseArray<FileSelectLayout> fileselects = new SparseArray<FileSelectLayout>(); - - private EditText mUserName; - - private EditText mPassword; - - private View mView; - - private VpnProfile mProfile; private EditText mProfileName; private EditText mKeyPassword; + private SparseArray<FileSelectLayout> fileselects = new SparseArray<FileSelectLayout>(); private void addFileSelectLayout (FileSelectLayout fsl) { @@ -129,7 +115,6 @@ public class Settings_Basic extends Fragment implements View.OnClickListener, On mpkcs12.setBase64Encode(); mCaCert.setShowClear(); - mType.setOnItemSelectedListener(this); mView.findViewById(R.id.select_keystore_button).setOnClickListener(this); diff --git a/src/de/blinkt/openvpn/VpnProfile.java b/src/de/blinkt/openvpn/VpnProfile.java index 6f21397e..37e9b2ff 100644 --- a/src/de/blinkt/openvpn/VpnProfile.java +++ b/src/de/blinkt/openvpn/VpnProfile.java @@ -15,6 +15,7 @@ import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.Collection; +import java.util.Locale; import java.util.UUID; import java.util.Vector; @@ -391,12 +392,13 @@ public class VpnProfile implements Serializable{ //! Put inline data inline and other data as normal escaped filename private String insertFileData(String cfgentry, String filedata) { if(filedata==null) { + // TODO: generate good error return String.format("%s %s\n",cfgentry,"missing"); }else if(filedata.startsWith(VpnProfile.INLINE_TAG)){ String datawoheader = filedata.substring(VpnProfile.INLINE_TAG.length()); - return String.format("<%s>\n%s\n</%s>\n",cfgentry,datawoheader,cfgentry); + return String.format(Locale.ENGLISH,"<%s>\n%s\n</%s>\n",cfgentry,datawoheader,cfgentry); } else { - return String.format("%s %s\n",cfgentry,openVpnEscape(filedata)); + return String.format(Locale.ENGLISH,"%s %s\n",cfgentry,openVpnEscape(filedata)); } } @@ -465,7 +467,7 @@ public class VpnProfile implements Serializable{ long nm = 0xffffffffl; nm = (nm << (32-len)) & 0xffffffffl; - String netmask =String.format("%d.%d.%d.%d", (nm & 0xff000000) >> 24,(nm & 0xff0000) >> 16, (nm & 0xff00) >> 8 ,nm & 0xff ); + String netmask =String.format(Locale.ENGLISH,"%d.%d.%d.%d", (nm & 0xff000000) >> 24,(nm & 0xff0000) >> 16, (nm & 0xff00) >> 8 ,nm & 0xff ); return parts[0] + " " + netmask; } |