code: void chooseFirstProvider() {
          if (spi != null) {
              return;
          }
          synchronized (lock) {
              if (spi != null) {
                  return;
              }
              /* Android-removed: this debugging mechanism is not used in Android.
              if (debug != null) {
                  int w = --warnCount;
                  if (w >= 0) {
                      debug.println("KeyAgreement.init() not first method "
                          + "called, disabling delayed provider selection");
                      if (w == 0) {
                          debug.println("Further warnings of this type will "
                              + "be suppressed");
                      }
                      new Exception("Call trace").printStackTrace();
                  }
              }
              */
              Exception lastException = null;
              for (Service s : GetInstance.getServices("KeyAgreement", algorithm)) {
                  if (JceSecurity.canUseProvider(s.getProvider()) == false) {
                      continue;
                  }
                  try {
                      Object obj = s.newInstance(null);
                      if (obj instanceof KeyAgreementSpi == false) {
                          continue;
                      }
                      spi = (KeyAgreementSpi)obj;
                      provider = s.getProvider();
                      // not needed any more
                      return;
                  } catch (Exception e) {
                      lastException = e;
                  }
              }
              ProviderException e = new ProviderException
                      ("Could not construct KeyAgreementSpi instance");
              if (lastException != null) {
                  e.initCause(lastException);
              }
              throw e;
          }
      }
docs: Choose the Spi from the first provider available. Used if
  delayed provider selection is not possible because init()
  is not the first method called.