private void updateProgress() { for (Action a : Action.values()) { if (a == currentAction) { // this is the current action showInProgress(a.viewId); } else if (a.ordinal() < currentAction.ordinal()) { // this action has completed showResult(a.viewId, results[a.ordinal()]); } else { // this action hasn't started showNotStarted(a.viewId); } } ChipsetDetection detection = ChipsetDetection.getDetection(); if (currentAction == Action.Finished) if (detection == null || detection.getWifiChipset() == null || detection.getWifiChipset().supportedModes == null || detection.getWifiChipset().supportedModes.contains(WifiMode.Adhoc) == false) { app.showNoAdhocDialog = true; LogActivity.logMessage( "detect", "Could not work out how to control your WiFi chipset. Relying on operating system, so no ad-hoc WiFi.", false); } }
private boolean testSupport() { ChipsetDetection detection = ChipsetDetection.getDetection(); List<Chipset> l = detection.detected_chipsets; boolean tryExperimental = false; while (true) { for (int i = 0; i < l.size(); i++) { Chipset c = l.get(i); if (c.isExperimental() != tryExperimental) continue; // only test scripts if we have root access, otherwise // assume the first one is correct if (results[Action.RootCheck.ordinal()]) { if (!c.supportedModes.contains(WifiMode.Adhoc)) continue; // Write a disable file that suppresses attempting // this detection again so that re-running the BatPhone // preparation wizard will not get stuck on the same // chipset every time File attemptFlag = new File(app.coretask.DATA_FILE_PATH + "/var/attempt_" + c.chipset); if (attemptFlag.exists()) { Log.v("BatPhone", "Skipping " + c.chipset + " as I think it failed before"); continue; } // If a chipset is marked experimental, then tell the // user. if (tryExperimental) PreparationWizard.showTryExperimentalChipsetDialog(); try { attemptFlag.createNewFile(); Log.v("BatPhone", "Trying to use chipset " + c.chipset); detection.setChipset(c); if (app.wifiRadio == null) app.wifiRadio = WiFiRadio.getWiFiRadio(app); // make sure we aren't still in adhoc mode from a // previous // install / test if (WifiMode.getWiFiMode() != WifiMode.Off) app.wifiRadio.setWiFiMode(WifiMode.Off); if (WifiMode.getWiFiMode() != WifiMode.Off) { throw new IllegalStateException("Could not turn wifi off"); } // test adhoc on & off try { app.wifiRadio.setWiFiMode(WifiMode.Adhoc); app.wifiRadio.setWiFiMode(WifiMode.Off); } finally { if (WifiMode.getWiFiMode() != WifiMode.Off) { attemptFlag = null; throw new IllegalStateException("Could not turn wifi off"); } } } catch (IOException e) { Log.e("BatPhone", e.toString(), e); } finally { // If we couldn't turn off wifi, just fail completely if (attemptFlag != null) attemptFlag.delete(); } } else { Log.v("BatPhone", "Assuming chipset " + c.chipset + " as there is no root access."); detection.setChipset(c); } Editor ed = app.settings.edit(); ed.putString("detectedChipset", c.chipset); ed.commit(); LogActivity.logMessage( "detect", "We will use the '" + c.chipset + "' script to control WiFi.", false); return true; } tryExperimental = !tryExperimental; if (tryExperimental == false) break; } detection.setChipset(null); Editor ed = app.settings.edit(); ed.putString("detectedChipset", "UnKnown"); ed.commit(); return false; }