diff options
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); } |