Permalink
Browse files

Improve logging for wifi test failures

  • Loading branch information...
1 parent ee4f2c2 commit 2a10bf05a18d498fa4361bb385d0b7373a959186 @lakeman lakeman committed Mar 6, 2012
@@ -1,9 +1,10 @@
-module_loaded("dhd") || log(insmod("/lib/modules/dhd.ko","dhd_pkt_filter_enable=0 firmware_path=/system/etc/wifi/bcm4330_sta.bin nvram_path=/system/etc/wifi/nvram_net.txt"),"Loading /lib/modules/dhd.ko module");
+module_loaded("dhd") && rmmod("dhd");
+log(insmod("/lib/modules/dhd.ko","dhd_pkt_filter_enable=0 firmware_path=/system/etc/wifi/bcm4330_sta.bin nvram_path=/system/etc/wifi/nvram_net.txt"),"Loading /lib/modules/dhd.ko module");
sleep("3");
log(run_program("/data/data/org.servalproject/bin/iwconfig " + getcfg("wifi.interface")
+ " mode ad-hoc"), "Setting ad-hoc mode");
log(run_program("/data/data/org.servalproject/bin/iwconfig " + getcfg("wifi.interface")
- + " essid " + getcfg("wifi.essid")), "Setting essid");
+ + " essid \"" + getcfg("wifi.essid")+"\""), "Setting essid");
log(run_program("/data/data/org.servalproject/bin/iwconfig " + getcfg("wifi.interface")
+ " channel " + getcfg("wifi.channel")), "Setting channel");
run_program("/data/data/org.servalproject/bin/iwconfig " + getcfg("wifi.interface")
@@ -248,7 +248,7 @@ private int internalRunCommand(boolean root, boolean wait, String command,
StringBuilder out, boolean logOutput) throws IOException {
ProcessBuilder pb = new ProcessBuilder();
String shell = (root ? suLocation : "/system/bin/sh");
- Log.v("CoreTask", "Running: " + shell + "-c" + command, null);
+ Log.v("CoreTask", "Running: " + shell + " -c " + command, null);
pb.command(shell, "-c", command);
pb.redirectErrorStream(true);
Process proc = pb.start();
@@ -289,11 +289,14 @@ public int runCommandForOutput(boolean root, boolean wait, String command,
if (!"".equals(command) && !hasRootPermission())
throw new IOException("Permission denied");
- String suFile = DATA_FILE_PATH + "/sucmd";
- this.writeLinesToFile(suFile, "#!/system/bin/sh\n" + command);
+ File suFile = new File(DATA_FILE_PATH, "sucmd");
+ boolean chmod = !suFile.exists();
- this.chmod(suFile, "755");
- command = suFile;
+ this.writeLinesToFile(suFile.getCanonicalPath(),
+ "#!/system/bin/sh\n" + command);
+ if (chmod)
+ this.chmod(suFile.getCanonicalPath(), "755");
+ command = suFile.getCanonicalPath();
}
boolean logOutput = out == null;
@@ -738,7 +738,10 @@ public synchronized void testAdhoc() throws IOException {
setWiFiMode(WifiMode.Off);
try {
- startAdhoc("Testing Mesh Support " + Math.random());
+ String ssid = "TestingMesh" + Math.random();
+ if (ssid.length() > 32)
+ ssid = ssid.substring(0, 32);
+ startAdhoc(ssid);
} finally {
stopAdhoc();
}
@@ -770,10 +773,12 @@ private void startAdhoc(String ssid) throws IOException {
}
}
- if (actualMode != WifiMode.Adhoc && actualMode != WifiMode.Unknown)
+ if (actualMode != WifiMode.Adhoc && actualMode != WifiMode.Unknown) {
+ Log.v("BatPhone", "iwconfig;\n" + WifiMode.lastIwconfigOutput);
throw new IOException(
"Failed to start Adhoc mode, mode ended up being '"
+ actualMode + "'");
+ }
}
private void stopAdhoc() throws IOException {
@@ -75,6 +75,7 @@ public static WifiMode nextMode(WifiMode m) {
return values[m.ordinal() + 1];
}
+ public static String lastIwconfigOutput;
public static WifiMode getWiFiMode() {
// find out what mode the wifi interface is in by asking iwconfig
if (ChipsetDetection.getDetection().getWifiChipset()
@@ -109,6 +110,7 @@ public static WifiMode getWiFiMode() {
}
} else {
String iw = iwstatus();
+ lastIwconfigOutput = iw;
if (iw.contains("Mode:")) {
// not sure why, but if not run as root, mode is incorrect
// (this is because iwconfig needs to be run as root to

0 comments on commit 2a10bf0

Please sign in to comment.