Skip to content

Commit

Permalink
Changed to work with my htc one m7
Browse files Browse the repository at this point in the history
  • Loading branch information
souramoo committed Aug 30, 2015
1 parent 10d76ed commit 2031703
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ It was necessary to turn it off the Android(TM) way, i.e.
svc wifi disable
```
Which kills wpa_supplicant, allowing us to swap out the mac address and turn wifi back on (which restarts wpa_supplicant, forcing it to re-read the mac address into memory). I have kept the commands running in a root shell to a minimum, since the wifi start/stop can be achieved in java.

## Extension: HTC one
For my HTC one, the above method does not work because on wifi restart, the device is brought down and up before wpa_supplicant is called. /dev is mounted as tmpfs so to save flash read-write cycles, I made a script that replaces wpa_supplicant. Move /system/bin/wpa_supplicant to /system/bin/wpa_supplicant_real and adb push scripts/wpa_supplicant /system/bin/wpa_supplicant - the git version of the app will now push the mac address to /dev/mac and it will be set just before calling wpa_supplicant for realz.
3 changes: 2 additions & 1 deletion app/src/main/java/com/moosd/netghost/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public static void setMAC(String rmac, Context context) {
} catch(Exception e){}

System.out.println("setting MAC: " + rmac);
runCmd(new CommandCapture(0, "busybox ifconfig wlan0 hw ether " + rmac));
//runCmd(new CommandCapture(0, "busybox ifconfig wlan0 hw ether " + rmac));
runCmd(new CommandCapture(0, "echo \"" + rmac + "\" > /dev/mac"));
try {
Thread.sleep(200);
} catch(Exception e){}
Expand Down
4 changes: 4 additions & 0 deletions scripts/wpa_supplicant
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/system/xbin/bash

/system/xbin/busybox ifconfig wlan0 up hw ether $(cat /dev/mac)
/system/bin/wpa_supplicant_real $@

0 comments on commit 2031703

Please sign in to comment.