diff options
author | Arne Schwabe <arne@rfc2549.org> | 2014-06-30 13:24:38 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2014-06-30 13:24:38 +0200 |
commit | fac9b474fb71a90945882652eb52f17c95032665 (patch) | |
tree | f949fcd2b1d738f967cbed73cbb7a0c37527c4f6 | |
parent | 1a948f44064b66603eb7f6dca66108cef7b5c81a (diff) |
Fix bugs reported by Google Play Console
3 files changed, 23 insertions, 19 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/activities/DisconnectVPN.java b/main/src/main/java/de/blinkt/openvpn/activities/DisconnectVPN.java index c2d4c599..2cd876b5 100644 --- a/main/src/main/java/de/blinkt/openvpn/activities/DisconnectVPN.java +++ b/main/src/main/java/de/blinkt/openvpn/activities/DisconnectVPN.java @@ -43,8 +43,8 @@ public class DisconnectVPN extends Activity implements DialogInterface.OnClickLi } @Override - protected void onStop() { - super.onStop(); + protected void onPause() { + super.onPause(); unbindService(mConnection); } diff --git a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java index 09f9a916..28d10094 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java +++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNThread.java @@ -48,8 +48,6 @@ public class OpenVPNThread implements Runnable { public void stopProcess() {
mProcess.destroy();
}
-
-
@Override
public void run() {
diff --git a/main/src/main/java/de/blinkt/openvpn/core/OpenVpnService.java b/main/src/main/java/de/blinkt/openvpn/core/OpenVpnService.java index 550429a1..4735305c 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/OpenVpnService.java +++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVpnService.java @@ -71,6 +71,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac private OpenVPNManagement mManagement; private String mLastTunCfg; private String mRemoteGW; + private Object mProcessLock = new Object(); // From: http://stackoverflow.com/questions/3758606/how-to-convert-byte-size-into-human-readable-format-in-java public static String humanReadableByteCount(long bytes, boolean mbit) { @@ -109,7 +110,9 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac } private void endVpnService() { - mProcessThread = null; + synchronized (mProcessLock) { + mProcessThread = null; + } VpnStatus.removeByteCountListener(this); unregisterDeviceStateReceiver(); ProfileManager.setConntectedVpnProfileDisconnected(this); @@ -329,13 +332,14 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac //ignore } - - if (mProcessThread != null) { - mProcessThread.interrupt(); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - //ignore + synchronized (mProcessLock) { + if (mProcessThread != null) { + mProcessThread.interrupt(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + //ignore + } } } // An old running VPN should now be exited @@ -379,9 +383,10 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac processThread = new OpenVPNThread(this, argv, env, nativelibdir); } - mProcessThread = new Thread(processThread, "OpenVPNProcessThread"); - mProcessThread.start(); - + synchronized (mProcessLock) { + mProcessThread = new Thread(processThread, "OpenVPNProcessThread"); + mProcessThread.start(); + } if (mDeviceStateReceiver != null) unregisterDeviceStateReceiver(); @@ -415,11 +420,12 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac @Override public void onDestroy() { - if (mProcessThread != null) { - mManagement.stopVPN(); - - mProcessThread.interrupt(); + synchronized (mProcessLock) { + if (mProcessThread != null) { + mManagement.stopVPN(); + } } + if (mDeviceStateReceiver != null) { this.unregisterReceiver(mDeviceStateReceiver); } |