/**
   * Initializes settings. This must be called after addExtraPages(), which created a settings page.
   * Iterate through all the pages to find the first (and supposedly unique) setting page, and use
   * it to load and apply these settings.
   */
  private void initializeSettings() {
    SettingsController c = mUpdaterData.getSettingsController();
    c.loadSettings();
    c.applySettings();

    for (Object page : mPages) {
      if (page instanceof ISettingsPage) {
        ISettingsPage settingsPage = (ISettingsPage) page;

        c.setSettingsPage(settingsPage);
        break;
      }
    }
  }
Ejemplo n.º 2
0
  /**
   * Creates an UpdateNoWindow object that will update using the given SDK root and outputs to the
   * given SDK logger.
   *
   * @param osSdkRoot The OS path of the SDK folder to update.
   * @param sdkManager An existing SDK manager to list current platforms and addons.
   * @param sdkLog A logger object, that should ideally output to a write-only console.
   * @param force The reply to any question asked by the update process. Currently this will be
   *     yes/no for ability to replace modified samples or restart ADB.
   * @param useHttp True to force using HTTP instead of HTTPS for downloads.
   * @param proxyPort An optional HTTP/HTTPS proxy port. Can be null.
   * @param proxyHost An optional HTTP/HTTPS proxy host. Can be null.
   */
  public SdkUpdaterNoWindow(
      String osSdkRoot,
      SdkManager sdkManager,
      ISdkLog sdkLog,
      boolean force,
      boolean useHttp,
      String proxyHost,
      String proxyPort) {
    mSdkLog = sdkLog;
    mForce = force;
    mUpdaterData = new UpdaterData(osSdkRoot, sdkLog);

    // Read and apply settings from settings file, so that http/https proxy is set
    // and let the command line args override them as necessary.
    SettingsController settingsController = mUpdaterData.getSettingsController();
    settingsController.loadSettings();
    settingsController.applySettings();
    setupProxy(proxyHost, proxyPort);

    // Change the in-memory settings to force the http/https mode
    settingsController.setSetting(ISettingsPage.KEY_FORCE_HTTP, useHttp);

    // Use a factory that only outputs to the given ISdkLog.
    mUpdaterData.setTaskFactory(new ConsoleTaskFactory());

    // Check that the AVD Manager has been correctly initialized. This is done separately
    // from the constructor in the GUI-based UpdaterWindowImpl to give time to the UI to
    // initialize before displaying a message box. Since we don't have any GUI here
    // we can call it whenever we want.
    if (mUpdaterData.checkIfInitFailed()) {
      return;
    }

    // Setup the default sources including the getenv overrides.
    mUpdaterData.setupDefaultSources();

    mUpdaterData.getLocalSdkParser().parseSdk(osSdkRoot, sdkManager, new NullTaskMonitor(sdkLog));
  }