summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java39
1 files changed, 31 insertions, 8 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
index 77038492..68ad78e4 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
@@ -21,7 +21,9 @@ import android.app.Notification;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.VpnService;
+import android.os.Binder;
import android.os.Build;
+import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.system.OsConstants;
import android.util.Log;
@@ -53,12 +55,27 @@ public class VoidVpnService extends VpnService implements Observer, VpnNotificat
private EipStatus eipStatus;
private VpnNotificationManager notificationManager;
+ private final IBinder binder = new VoidVpnServiceBinder();
+ public class VoidVpnServiceBinder extends Binder {
+ VoidVpnService getService() {
+ // Return this instance of LocalService so clients can call public methods
+ return VoidVpnService.this;
+ }
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return binder;
+ }
+
+
+
@Override
public void onCreate() {
super.onCreate();
eipStatus = EipStatus.getInstance();
eipStatus.addObserver(this);
- notificationManager = new VpnNotificationManager(this, this);
+ notificationManager = new VpnNotificationManager(this);
notificationManager.createVoidVpnNotificationChannel();
}
@@ -99,14 +116,19 @@ public class VoidVpnService extends VpnService implements Observer, VpnNotificat
closeFd();
}
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ notificationManager.deleteVoidVpnNotificationChannel();
+ }
+
private void stop() {
- notificationManager.stopNotifications(NOTIFICATION_CHANNEL_NEWSTATUS_ID);
- notificationManager.deleteNotificationChannel(NOTIFICATION_CHANNEL_NEWSTATUS_ID);
if (thread != null) {
thread.interrupt();
}
closeFd();
VpnStatus.updateStateString("NOPROCESS", "BLOCKING VPN STOPPED", R.string.state_noprocess, ConnectionStatus.LEVEL_NOTCONNECTED);
+ stopForeground(true);
}
public static boolean isRunning() throws NullPointerException {
@@ -185,9 +207,11 @@ public class VoidVpnService extends VpnService implements Observer, VpnNotificat
notificationManager.buildVoidVpnNotification(
blockingMessage,
blockingMessage,
- eipStatus.getLevel());
+ eipStatus.getLevel(),
+ this
+ );
} else {
- notificationManager.stopNotifications(NOTIFICATION_CHANNEL_NEWSTATUS_ID);
+ stopForeground(true);
}
}
@@ -196,9 +220,8 @@ public class VoidVpnService extends VpnService implements Observer, VpnNotificat
startForeground(notificationId, notification);
}
- @Override
- public void onNotificationStop() {
- stopForeground(true);
+ public void startWithForegroundNotification() {
+
}
}