summaryrefslogtreecommitdiff
path: root/src/se
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-10-09 12:46:34 +0200
committercyBerta <richy@cyborgsociety.org>2013-11-15 23:53:51 +0100
commitdf580ff4ca160bee13bb071e1db86c0a0945557e (patch)
treef95fe39639d3438d0d3094266dbae0b5687b1d1b /src/se
parentd9c8729bfdead18aa695ceddac3a12efe6c8b568 (diff)
Real VPN status is returned from Eip.isRunning().
retrieveVpnService now uses BIND_AUTO_CREATE flag, so that if the OpenVpnService has not been started, the state is still notified. retrieveVpnService now returns a boolean, so that if bindService fails false is returned.
Diffstat (limited to 'src/se')
-rw-r--r--src/se/leap/bitmaskclient/EIP.java19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/se/leap/bitmaskclient/EIP.java b/src/se/leap/bitmaskclient/EIP.java
index 84a0ce59..f9384ff6 100644
--- a/src/se/leap/bitmaskclient/EIP.java
+++ b/src/se/leap/bitmaskclient/EIP.java
@@ -134,10 +134,10 @@ public final class EIP extends IntentService {
* Sends an Intent to bind OpenVpnService.
* Used when OpenVpnService isn't bound but might be running.
*/
- private void retreiveVpnService() {
+ private boolean retreiveVpnService() {
Intent bindIntent = new Intent(this,OpenVpnService.class);
bindIntent.setAction(OpenVpnService.RETRIEVE_SERVICE);
- bindService(bindIntent, mVpnServiceConn, 0);
+ return bindService(bindIntent, mVpnServiceConn, BIND_AUTO_CREATE);
}
private static ServiceConnection mVpnServiceConn = new ServiceConnection() {
@@ -161,7 +161,7 @@ public final class EIP extends IntentService {
resultCode = (running) ? Activity.RESULT_CANCELED
: Activity.RESULT_OK;
Bundle resultData = new Bundle();
- resultData.putString(REQUEST_TAG, EIP_NOTIFICATION);
+ resultData.putString(REQUEST_TAG, ACTION_IS_EIP_RUNNING);
mReceiver.send(resultCode, resultData);
mPending = null;
@@ -196,13 +196,16 @@ public final class EIP extends IntentService {
int resultCode = Activity.RESULT_CANCELED;
if (mBound) {
resultCode = (mVpnService.isRunning()) ? Activity.RESULT_OK : Activity.RESULT_CANCELED;
+
+ if (mReceiver != null){
+ mReceiver.send(resultCode, resultData);
+ }
} else {
mPending = ACTION_IS_EIP_RUNNING;
- this.retreiveVpnService();
- }
-
- if (mReceiver != null){
- mReceiver.send(resultCode, resultData);
+ boolean retrieved_vpn_service = retreiveVpnService();
+ if(!retrieved_vpn_service && mReceiver != null) {
+ mReceiver.send(resultCode, resultData);
+ }
}
}