diff options
author | Fup Duck <fupduck@sacknagel.com> | 2018-02-08 15:21:55 +0100 |
---|---|---|
committer | Fup Duck <fupduck@sacknagel.com> | 2018-02-08 15:21:55 +0100 |
commit | a14bfd300dccd79dbd3685710e5d8b40b5906a41 (patch) | |
tree | 996be52accafc408b84d68fc89a6b0731ceed729 /app/src/main/java/se/leap/bitmaskclient/eip | |
parent | ae2813a0fe77c265a42221f6153d8f5bca26a467 (diff) | |
parent | ae938c20a11b6195936f97eebd32abd35335bceb (diff) |
Merge branch 'leap_0.9.8' into 8827_handle_switch_provider
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/eip')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/eip/EIP.java | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java index e53d81d9..cec917f7 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -27,6 +27,8 @@ import android.util.Log; import org.json.JSONException; import org.json.JSONObject; +import java.lang.ref.WeakReference; + import de.blinkt.openvpn.LaunchVPN; import se.leap.bitmaskclient.OnBootReceiver; @@ -60,12 +62,12 @@ public final class EIP extends IntentService { public final static String TAG = EIP.class.getSimpleName(); public final static String SERVICE_API_PATH = "config/eip-service.json"; - private static ResultReceiver mReceiver; - private static SharedPreferences preferences; + private WeakReference<ResultReceiver> mReceiverRef = new WeakReference<>(null); + private SharedPreferences preferences; - private static JSONObject eipDefinition; + private JSONObject eipDefinition; private GatewaysManager gatewaysManager = new GatewaysManager(); - private static Gateway gateway; + private Gateway gateway; public EIP() { super(TAG); @@ -83,7 +85,9 @@ public final class EIP extends IntentService { @Override protected void onHandleIntent(Intent intent) { String action = intent.getAction(); - mReceiver = intent.getParcelableExtra(EIP_RECEIVER); + if (intent.getParcelableExtra(EIP_RECEIVER) != null) { + mReceiverRef = new WeakReference<>((ResultReceiver) intent.getParcelableExtra(EIP_RECEIVER)); + } if (action == null) { return; @@ -246,8 +250,8 @@ public final class EIP extends IntentService { private void tellToReceiverOrBroadcast(String action, int resultCode) { Bundle resultData = new Bundle(); resultData.putString(EIP_REQUEST, action); - if (mReceiver != null) { - mReceiver.send(resultCode, resultData); + if (mReceiverRef.get() != null) { + mReceiverRef.get().send(resultCode, resultData); } else { broadcastEvent(resultCode, resultData); } |