GoBackend: Use the android VpnService to encapsulate the go backend

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Aurélien Chabot
2018-04-17 02:15:24 +02:00
committed by Jason A. Donenfeld
parent 19aec7c5c6
commit 9dfab4d60f
3 changed files with 99 additions and 7 deletions
@@ -1,11 +1,13 @@
package com.wireguard.android.activity;
import android.app.Activity;
import android.content.Intent;
import android.databinding.CallbackRegistry;
import android.databinding.CallbackRegistry.NotifierCallback;
import android.os.Bundle;
import com.wireguard.android.Application;
import com.wireguard.android.backend.GoBackend;
import com.wireguard.android.model.Tunnel;
import com.wireguard.android.model.TunnelManager;
@@ -42,8 +44,16 @@ public abstract class BaseActivity extends Activity {
final TunnelManager tunnelManager = Application.getComponent().getTunnelManager();
selectedTunnel = tunnelManager.getTunnels().get(savedTunnelName);
}
// The selected tunnel must be set before the superclass method recreates fragments.
super.onCreate(savedInstanceState);
if (Application.getComponent().getBackendType() == GoBackend.class) {
Intent intent = GoBackend.VpnService.prepare(this);
if (intent != null) {
startActivityForResult(intent, 0);
}
}
}
@Override