Пример #1
0
  public Set<Chipset> getDetectedChipsets(Shell shell, LogOutput log) {
    log.log("Scanning for known android hardware");

    Set<Chipset> detected_chipsets = new TreeSet<Chipset>();
    boolean hasNetlink = hasNl80211(shell);
    boolean foundSupported = false;

    File detectScripts = new File(detectPath);
    if (!detectScripts.isDirectory()) return null;

    for (File script : detectScripts.listFiles()) {
      if (!script.getName().endsWith(".detect")) continue;

      Chipset c = Chipset.FromFile(script);
      if (testChipset(c, hasNetlink)) {
        detected_chipsets.add(c);
        if (!c.experimental) foundSupported = true;
      }
    }

    if (!foundSupported) {
      log.log("Hardware may be unknown, scanning for wifi modules");
      inventSupport(detected_chipsets, hasNetlink);
    }
    return detected_chipsets;
  }
Пример #2
0
    @Override
    protected Action doInBackground(Void... arg) {
      wakeLock.acquire();

      try {
        ChipsetDetection detection = ChipsetDetection.getDetection();
        while (true) {
          boolean result = false;
          boolean fatal = currentAction.fatal;
          try {
            Log.v("BatPhone", "Performing action " + currentAction);

            switch (currentAction) {
              case Unpacking:
                app.installFilesIfRequired();
                result = true;
                break;

              case AdhocWPA:
                if (false) {
                  // Get wifi manager
                  WifiManager wm =
                      (WifiManager)
                          ServalBatPhoneApplication.context.getSystemService(Context.WIFI_SERVICE);

                  // enable wifi
                  wm.setWifiEnabled(true);
                  WifiConfiguration wc = new WifiConfiguration();
                  wc.SSID = "*supplicant-test";
                  int res = wm.addNetwork(wc);
                  Log.d("BatPhone", "add Network returned " + res);
                  boolean b = wm.enableNetwork(res, true);
                  Log.d("WifiPreference", "enableNetwork returned " + b);
                }
                break;

              case RootCheck:
                result = ServalBatPhoneApplication.context.coretask.hasRootPermission();
                break;

              case Supported:
                // Start out by only looking for non-experimental
                // chipsets
                detection.identifyChipset();
                result = detection.detected_chipsets.size() > 0;
                break;

              case Experimental:
                if (!results[Action.Supported.ordinal()]) {
                  detection.inventSupport();
                  // this will not select a chipset
                  detection.detect(true);
                  result = detection.detected_chipsets.size() > 0;
                }
                break;

              case CheckSupport:
                result = testSupport();
                break;

              case Finished:
                break;
            }

          } catch (Exception e) {
            result = false;
            Log.e("BatPhone", e.toString(), e);
            app.displayToastMessage(e.getMessage());
            fatal = true;
          }

          results[currentAction.ordinal()] = result;
          Log.v("BatPhone", "Result " + result);

          if (fatal && !result) {
            fatalError = true;
            return currentAction;
          }

          if (currentAction == Action.Finished) {
            ServalBatPhoneApplication.wifiSetup = true;
            return currentAction;
          }

          this.publishProgress(currentAction);
          currentAction = Action.values()[currentAction.ordinal() + 1];
        }
      } finally {
        wakeLock.release();
        dismissTryExperimentalChipsetDialog();
      }
    }