I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 6d6123df authored by str4d's avatar str4d
Browse files

Inform user that changing uPnP setting will require a router restart

parent 321a4915
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,7 @@ import android.preference.PreferenceActivity; ...@@ -9,6 +9,7 @@ import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory; import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.widget.Toast;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.android.router.service.StatSummarizer; import net.i2p.android.router.service.StatSummarizer;
...@@ -160,6 +161,8 @@ public class SettingsActivity extends PreferenceActivity { ...@@ -160,6 +161,8 @@ public class SettingsActivity extends PreferenceActivity {
Properties props = lProps.get(0); Properties props = lProps.get(0);
Properties logSettings = lProps.get(1); Properties logSettings = lProps.get(1);
boolean restartRequired = Util.checkAndCorrectRouterConfig(this, props);
// Apply new config if we are running. // Apply new config if we are running.
RouterContext rCtx = Util.getRouterContext(); RouterContext rCtx = Util.getRouterContext();
if (rCtx != null) { if (rCtx != null) {
...@@ -177,6 +180,9 @@ public class SettingsActivity extends PreferenceActivity { ...@@ -177,6 +180,9 @@ public class SettingsActivity extends PreferenceActivity {
// Store the settings in Android // Store the settings in Android
super.onPause(); super.onPause();
if (restartRequired)
Toast.makeText(this, R.string.settings_router_restart_required, Toast.LENGTH_LONG).show();
} }
private void saveLoggingChanges(I2PAppContext ctx, Properties logSettings) { private void saveLoggingChanges(I2PAppContext ctx, Properties logSettings) {
......
...@@ -10,6 +10,7 @@ import android.preference.PreferenceManager; ...@@ -10,6 +10,7 @@ import android.preference.PreferenceManager;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.data.DataHelper; import net.i2p.data.DataHelper;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
import net.i2p.router.transport.TransportManager;
import net.i2p.util.OrderedProperties; import net.i2p.util.OrderedProperties;
import java.io.File; import java.io.File;
...@@ -179,6 +180,37 @@ public abstract class Util { ...@@ -179,6 +180,37 @@ public abstract class Util {
return pList; return pList;
} }
/**
* This function performs two tasks:
* <ul><li>
* The Properties object is modified to ensure that all options are valid
* for the current state of the Android device (e.g. what type of network
* the device is connected to).
* </li><li>
* The Properties object is checked to determine whether any options have
* changed that will require a router restart.
* </li></ul>
*
* @param props a Properties object containing the router.config
* @return true if the router needs to be restarted.
*/
public static boolean checkAndCorrectRouterConfig(Context context, Properties props) {
// Disable UPnP on mobile networks, ignoring user's configuration
boolean upnpEnabled = Boolean.parseBoolean(props.getProperty(TransportManager.PROP_ENABLE_UPNP, Boolean.toString(true)));
if (Connectivity.isConnectedMobile(context)) {
upnpEnabled = false;
props.setProperty(TransportManager.PROP_ENABLE_UPNP, Boolean.toString(upnpEnabled));
}
// Now check if a restart is required
boolean restartRequired = false;
RouterContext rCtx = getRouterContext();
if (rCtx != null) {
restartRequired = upnpEnabled != rCtx.getBooleanPropertyDefaultTrue(TransportManager.PROP_ENABLE_UPNP);
}
return restartRequired;
}
public static String getFileDir(Context context) { public static String getFileDir(Context context) {
// This needs to be changed so that we can have an alternative place // This needs to be changed so that we can have an alternative place
return context.getFilesDir().getAbsolutePath(); return context.getFilesDir().getAbsolutePath();
......
...@@ -116,6 +116,8 @@ ...@@ -116,6 +116,8 @@
<string name="settings_summ_expl_backupQuantity">%s tunnels</string> <string name="settings_summ_expl_backupQuantity">%s tunnels</string>
<string name="settings_desc_expl_backupQuantity">How many tunnel backups</string> <string name="settings_desc_expl_backupQuantity">How many tunnel backups</string>
<string name="settings_router_restart_required">Please restart I2P to apply the changes</string>
<string name="menu_about">About</string> <string name="menu_about">About</string>
<string name="about_version">Version:</string> <string name="about_version">Version:</string>
<string name="about_project">Project Home:</string> <string name="about_project">Project Home:</string>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment