Created
April 24, 2013 15:23
-
-
Save jekkos/5452965 to your computer and use it in GitHub Desktop.
Patches r555 of the http://code.google.com/p/android-wifi-tether/ project that adds a checkbox option which will turn your phone into a captive portal. To be combined with the botbraw basil httpd package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: .classpath | |
=================================================================== | |
--- .classpath (revision 555) | |
+++ .classpath (working copy) | |
@@ -1,8 +1,8 @@ | |
<?xml version="1.0" encoding="UTF-8"?> | |
<classpath> | |
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | |
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> | |
<classpathentry kind="src" path="src"/> | |
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | |
<classpathentry kind="src" path="gen"/> | |
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> | |
<classpathentry kind="output" path="bin/classes"/> | |
</classpath> | |
Index: project.properties | |
=================================================================== | |
--- project.properties (revision 555) | |
+++ project.properties (working copy) | |
@@ -10,5 +10,5 @@ | |
# Indicates whether an apk should be generated for each density. | |
split.density=false | |
# Project target. | |
-target=android-11 | |
+target=android-16 | |
apk-configurations= | |
Index: res/layout/setupview.xml | |
=================================================================== | |
--- res/layout/setupview.xml (revision 555) | |
+++ res/layout/setupview.xml (working copy) | |
@@ -217,7 +217,12 @@ | |
android:dialogTitle="@string/setup_layout_dnssecondary_dialog_title" | |
android:maxLength="15" | |
android:dialogMessage="@string/setup_layout_dnssecondary_dialog_message" | |
- android:defaultValue="8.8.4.4" /> | |
+ android:defaultValue="8.8.4.4" /> | |
+ <CheckBoxPreference | |
+ android:key="resolvednstogatewaypref" | |
+ android:title="@string/setup_layout_resolvednstogateway" | |
+ android:summary="@string/setup_layout_resolvednstogateway_summary" | |
+ android:defaultValue="true" /> | |
</PreferenceCategory> | |
<PreferenceCategory android:title="@string/setup_layout_category_notifications"> | |
<ListPreference | |
Index: res/raw/tether_edify | |
=================================================================== | |
--- res/raw/tether_edify (revision 555) | |
+++ res/raw/tether_edify (working copy) | |
@@ -307,6 +307,8 @@ | |
# | |
kill_process("dnsmasq"); | |
sleep("2"); | |
+ ifelse((getcfg("dns.resolvetogateway") == "false"),( | |
+ log("Starting dnsmasq the regular way"); | |
run_program("/data/data/com.googlecode.android.wifi.tether/bin/dnsmasq -i " + getcfg("tether.interface") +" --dhcp-authoritative --no-negcache --user=root "+ | |
"--no-resolv --no-hosts "+ | |
"--server="+ getcfg("dns.primary") +" "+ | |
@@ -314,7 +316,16 @@ | |
"--dhcp-range="+ getcfg("dhcp.iprange") +" " + | |
"--dhcp-leasefile=/data/data/com.googlecode.android.wifi.tether/var/dnsmasq.leases " + | |
"--pid-file=/data/data/com.googlecode.android.wifi.tether/var/dnsmasq.pid"); | |
- | |
+ | |
+ ),( | |
+ log("Resolving all requests to gateway ip"); | |
+ run_program("/data/data/com.googlecode.android.wifi.tether/bin/dnsmasq -i " + getcfg("tether.interface") +" --dhcp-authoritative --no-negcache --user=root "+ | |
+ "--no-resolv --no-hosts "+ | |
+ "--address=/#/"+ getcfg("ip.gateway") +" "+ | |
+ "--dhcp-range="+ getcfg("dhcp.iprange") +" " + | |
+ "--dhcp-leasefile=/data/data/com.googlecode.android.wifi.tether/var/dnsmasq.leases " + | |
+ "--pid-file=/data/data/com.googlecode.android.wifi.tether/var/dnsmasq.pid"); | |
+ )); | |
# | |
# Access control | |
# | |
Index: res/values/strings.xml | |
=================================================================== | |
--- res/values/strings.xml (revision 555) | |
+++ res/values/strings.xml (working copy) | |
@@ -177,6 +177,8 @@ | |
<string name="setup_layout_category_dns">Domain-Nameserver</string> | |
<string name="setup_layout_dnsprimary">Change preferred DNS</string> | |
<string name="setup_layout_dnsprimary_summary">Change preferred DNS</string> | |
+ <string name="setup_layout_resolvednstogateway">Resolve DNS to gateway</string> | |
+ <string name="setup_layout_resolvednstogateway_summary">Resolve all DNS queries to this phone</string> | |
<string name="setup_layout_dnsprimary_dialog_title">Preferred Domain-Nameserver</string> | |
<string name="setup_layout_dnsprimary_dialog_message">Use the following DNS server address:</string> | |
<string name="setup_layout_dnssecondary">Change alternate DNS</string> | |
Index: src/com/googlecode/android/wifi/tether/SetupActivity.java | |
=================================================================== | |
--- src/com/googlecode/android/wifi/tether/SetupActivity.java (revision 555) | |
+++ src/com/googlecode/android/wifi/tether/SetupActivity.java (working copy) | |
@@ -70,6 +70,7 @@ | |
private boolean currentRoutefixEnabled; | |
private String currentPrimaryDNS; | |
private String currentSecondaryDNS; | |
+ private boolean resolveDnsToGateway; | |
private boolean currentHideSSID; | |
private boolean currentDriverReload; | |
private String keepaliveshutdown; | |
@@ -106,6 +107,7 @@ | |
this.currentRoutefixEnabled = this.application.settings.getBoolean("routefixpref", true); | |
this.currentPrimaryDNS = this.application.settings.getString("dnsprimarypref", "8.8.8.8"); | |
this.currentSecondaryDNS = this.application.settings.getString("dnssecondarypref", "8.8.4.4"); | |
+ this.resolveDnsToGateway = this.application.settings.getBoolean("resolvednstogatewaypref", true); | |
this.currentHideSSID = this.application.settings.getBoolean("hidessidpref", false); | |
this.currentDriverReload = this.application.settings.getBoolean("driverreloadpref", true); | |
@@ -984,7 +986,28 @@ | |
msg.obj = message; | |
SetupActivity.this.displayToastMessageHandler.sendMessage(msg); | |
} | |
- } | |
+ } | |
+ else if (key.equals("resolvednstogatewaypref")) { | |
+ boolean resolveDnsToGateway = sharedPreferences.getBoolean("resolvednstogatewaypref", true);; | |
+ if (resolveDnsToGateway != SetupActivity.this.resolveDnsToGateway) { | |
+ // Restarting | |
+ try{ | |
+ if (TetherService.singleton != null && TetherService.singleton.getState() == TetherService.STATE_RUNNING) { | |
+ TetherService.singleton.restart(); | |
+ } | |
+ SetupActivity.this.resolveDnsToGateway = resolveDnsToGateway; | |
+ } | |
+ catch (Exception ex) { | |
+ message = getString(R.string.setup_activity_error_restart_tethering); | |
+ Log.e(TAG, "Exception happend while restarting service - Here is what I know: "+ex); | |
+ } | |
+ | |
+ // Send Message | |
+ Message msg = new Message(); | |
+ msg.obj = message; | |
+ SetupActivity.this.displayToastMessageHandler.sendMessage(msg); | |
+ } | |
+ } | |
Looper.loop(); | |
} | |
Index: src/com/googlecode/android/wifi/tether/TetherApplication.java | |
=================================================================== | |
--- src/com/googlecode/android/wifi/tether/TetherApplication.java (revision 555) | |
+++ src/com/googlecode/android/wifi/tether/TetherApplication.java (working copy) | |
@@ -241,6 +241,7 @@ | |
boolean routefixEnabled = this.settings.getBoolean("routefixpref", true); | |
String primaryDns = this.settings.getString("dnsprimarypref", "8.8.8.8"); | |
String secondaryDns = this.settings.getString("dnssecondarypref", "8.8.4.4"); | |
+ boolean revoleDnsToGateway = this.settings.getBoolean("resolvednstogatewaypref", true); | |
boolean hideSSID = this.settings.getBoolean("hidessidpref", false); | |
boolean reloadDriver = this.settings.getBoolean("driverreloadpref", true); | |
boolean reloadDriver2 = this.settings.getBoolean("driverreloadpref2", false); | |
@@ -270,6 +271,7 @@ | |
// dns | |
this.tethercfg.put("dns.primary", primaryDns); | |
this.tethercfg.put("dns.secondary", secondaryDns); | |
+ this.tethercfg.put("dns.resolvetogateway", Boolean.toString(revoleDnsToGateway)); | |
if (mssclampingEnabled) { | |
this.tethercfg.put("mss.clamping", "true"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment