]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Make sure every listener at the VPN state service is only registered once
authorTobias Brunner <tobias@strongswan.org>
Fri, 21 Apr 2017 11:54:51 +0000 (13:54 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 30 Jun 2017 07:32:27 +0000 (09:32 +0200)
We register when the service connects but also in onStart() (as we
unregister in onStop() to avoid updates when not shown).  So this could
theoretically cause the listener to get registered twice if the service
is connected before onStart() is called (it seems it usually isn't).

src/frontends/android/app/src/main/java/org/strongswan/android/logic/VpnStateService.java

index e35277d8c0ae087886e54fc8efe25b808e90cca2..01c1452af1098b1efc95722c68ad97d6c5fcbe2e 100644 (file)
 
 package org.strongswan.android.logic;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.Callable;
-
-import org.strongswan.android.data.VpnProfile;
-import org.strongswan.android.logic.imc.ImcState;
-import org.strongswan.android.logic.imc.RemediationInstruction;
-
 import android.app.Service;
 import android.content.Context;
 import android.content.Intent;
@@ -32,9 +22,19 @@ import android.os.Binder;
 import android.os.Handler;
 import android.os.IBinder;
 
+import org.strongswan.android.data.VpnProfile;
+import org.strongswan.android.logic.imc.ImcState;
+import org.strongswan.android.logic.imc.RemediationInstruction;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.Callable;
+
 public class VpnStateService extends Service
 {
-       private final List<VpnStateListener> mListeners = new ArrayList<VpnStateListener>();
+       private final HashSet<VpnStateListener> mListeners = new HashSet<VpnStateListener>();
        private final IBinder mBinder = new LocalBinder();
        private long mConnectionID = 0;
        private Handler mHandler;