summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2018-02-07 23:42:19 +0100
committercyBerta <cyberta@riseup.net>2018-02-07 23:42:19 +0100
commit1ec166e66fe65e8642bfb8095d2f8212c355ef92 (patch)
tree031ac7b99a995c9696d8e403273e775328610de4 /app/src/main/java
parent4edff860bf3655db1ebdaa9f80265ff68dcb3c6a (diff)
fixes memory leak #8839
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EIP.java22
1 files changed, 13 insertions, 9 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 eca5b881..23b4f2de 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;
@@ -57,12 +59,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);
@@ -80,7 +82,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;
@@ -241,10 +245,10 @@ public final class EIP extends IntentService {
}
private void tellToReceiver(String action, int resultCode) {
- if (mReceiver != null) {
- Bundle resultData = new Bundle();
- resultData.putString(EIP_REQUEST, action);
- mReceiver.send(resultCode, resultData);
+ Bundle resultData = new Bundle();
+ resultData.putString(EIP_REQUEST, action);
+ if (mReceiverRef.get() != null) {
+ mReceiverRef.get().send(resultCode, resultData);
}
}
}