summaryrefslogtreecommitdiffhomepage
path: root/app/src/main
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2017-08-15 17:37:06 -0500
committerSamuel Holland <samuel@sholland.org>2017-08-15 17:37:06 -0500
commite9de916d69acf4b9242d3561403bb25e995cc4b7 (patch)
treeb36ec3d085e85a164bd26fb1ad0c40c046a9aedb /app/src/main
parent7f864badb2ee0a1878459c9e533e10eb13dcc5ca (diff)
BaseConfigActivity: Set initial config when service available
This was accidentally missed earlier when adding the optimization to omit binding the service when unnecessary. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/com/wireguard/android/BaseConfigActivity.java20
-rw-r--r--app/src/main/java/com/wireguard/android/ConfigActivity.java1
2 files changed, 11 insertions, 10 deletions
diff --git a/app/src/main/java/com/wireguard/android/BaseConfigActivity.java b/app/src/main/java/com/wireguard/android/BaseConfigActivity.java
index 8fa2a7f0..82605f1f 100644
--- a/app/src/main/java/com/wireguard/android/BaseConfigActivity.java
+++ b/app/src/main/java/com/wireguard/android/BaseConfigActivity.java
@@ -32,16 +32,16 @@ abstract class BaseConfigActivity extends Activity {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // Trigger starting the service as early as possible
- if (VpnService.getInstance() != null)
- onServiceAvailable();
- else
- bindService(new Intent(this, VpnService.class), callbacks, Context.BIND_AUTO_CREATE);
// Restore the saved configuration if there is one; otherwise grab it from the intent.
if (savedInstanceState != null)
initialConfig = savedInstanceState.getString(KEY_CURRENT_CONFIG);
else
initialConfig = getIntent().getStringExtra(KEY_CURRENT_CONFIG);
+ // Trigger starting the service as early as possible
+ if (VpnService.getInstance() != null)
+ onServiceAvailable();
+ else
+ bindService(new Intent(this, VpnService.class), callbacks, Context.BIND_AUTO_CREATE);
}
protected abstract void onCurrentConfigChanged(Config config);
@@ -53,7 +53,11 @@ abstract class BaseConfigActivity extends Activity {
outState.putString(KEY_CURRENT_CONFIG, currentConfig.getName());
}
- protected abstract void onServiceAvailable();
+ protected void onServiceAvailable() {
+ // Make sure the subclass activity is initialized before setting its config.
+ if (initialConfig != null && currentConfig == null)
+ setCurrentConfig(VpnService.getInstance().get(initialConfig));
+ }
public void setCurrentConfig(final Config config) {
currentConfig = config;
@@ -65,11 +69,7 @@ abstract class BaseConfigActivity extends Activity {
public void onServiceConnected(final ComponentName component, final IBinder binder) {
// We don't actually need a binding, only notification that the service is started.
unbindService(callbacks);
- // Tell the subclass that it is now safe to use the service.
onServiceAvailable();
- // Make sure the subclass activity is initialized before setting its config.
- if (initialConfig != null && currentConfig == null)
- setCurrentConfig(VpnService.getInstance().get(initialConfig));
}
@Override
diff --git a/app/src/main/java/com/wireguard/android/ConfigActivity.java b/app/src/main/java/com/wireguard/android/ConfigActivity.java
index baa29766..1500e08f 100644
--- a/app/src/main/java/com/wireguard/android/ConfigActivity.java
+++ b/app/src/main/java/com/wireguard/android/ConfigActivity.java
@@ -139,6 +139,7 @@ public class ConfigActivity extends BaseConfigActivity {
@Override
protected void onServiceAvailable() {
+ super.onServiceAvailable();
isServiceAvailable = true;
// Create the initial fragment set.
final Fragment masterFragment = fm.findFragmentById(R.id.master_fragment);