diff options
Diffstat (limited to 'src/se/leap/bitmaskclient/EIP.java')
-rw-r--r-- | src/se/leap/bitmaskclient/EIP.java | 19 |
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); + } } } |