shadows/framework/src/main/java/org/robolectric/shadows/ShadowLocationManager.java
public boolean setBestProvider(String provider, boolean enabled, List<Criteria> criteria) throws Exception {
    if (!getAllProviders().contains(provider)) {
      throw new IllegalStateException("Best provider is not a known provider");
    }
    // If provider is not enabled but it is supposed to be set as the best enabled provider don't set it.
    for (String prvdr : providersEnabled.keySet()) {
      if (provider.equals(prvdr) && providersEnabled.get(prvdr).enabled != enabled) {
        return false;
      }
    }

    if (enabled) {
      bestEnabledProvider = provider;
      if (provider.equals(bestDisabledProvider)) {
        bestDisabledProvider = null;
      }
    } else {
      bestDisabledProvider = provider;
      if (provider.equals(bestEnabledProvider)) {
        bestEnabledProvider = null;
      }
    }
    if (criteria == null) {
      return true;
    }
    LocationProviderEntry entry;
    if (!providersEnabled.containsKey(provider)) {
      entry = new LocationProviderEntry();
      entry.enabled = enabled;
      entry.criteria = criteria;
    } else {
      entry = providersEnabled.get(provider);
    }
    providersEnabled.put(provider, entry);

    return true;
  }
public boolean setBestProvider(String provider, boolean enabled, List<Criteria> criteria) throws Exception {
    if (!getAllProviders().contains(provider)) {
      throw new IllegalStateException("Best provider is not a known provider");
    }
    // If provider is not enabled but it is supposed to be set as the best enabled provider don't set it.
    for (String prvdr : providersEnabled.keySet()) {
      if (provider.equals(prvdr) && providersEnabled.get(prvdr).enabled != enabled) {
        return false;
      }
    }

    if (enabled) {
      bestEnabledProvider = provider;
      if (provider.equals(bestDisabledProvider)) {
        bestDisabledProvider = null;
      }
    } else {
      bestDisabledProvider = provider;
      if (provider.equals(bestEnabledProvider)) {
        bestEnabledProvider = null;
      }
    }
    if (criteria == null) {
      return true;
    }
    LocationProviderEntry entry;
    if (!providersEnabled.containsKey(provider)) {
      entry = new LocationProviderEntry();
      entry.enabled = enabled;
      entry.criteria = criteria;
    } else {
      entry = providersEnabled.get(provider);
    }
    providersEnabled.put(provider, entry);

    return true;
  }
public boolean setBestProvider ( String provider , boolean enabled , List < Criteria > criteria ) throws Exception { if ( ! getAllProviders ( ) . contains ( provider ) ) { throw new IllegalStateException ( "Best provider is not a known provider" ) ; } // If provider is not enabled but it is supposed to be set as the best enabled provider don't set it. for ( String prvdr : providersEnabled . keySet ( ) ) { if ( provider . equals ( prvdr ) && providersEnabled . get ( prvdr ) . enabled != enabled ) { return false ; } } if ( enabled ) { bestEnabledProvider = provider ; if ( provider . equals ( bestDisabledProvider ) ) { bestDisabledProvider = null ; } } else { bestDisabledProvider = provider ; if ( provider . equals ( bestEnabledProvider ) ) { bestEnabledProvider = null ; } } if ( criteria == null ) { return true ; } LocationProviderEntry entry ; if ( ! providersEnabled . containsKey ( provider ) ) { entry = new LocationProviderEntry ( ) ; entry . enabled = enabled ; entry . criteria = criteria ; } else { entry = providersEnabled . get ( provider ) ; } providersEnabled . put ( provider , entry ) ; return true ; }
Sets the value to return from {@link #getBestProvider(android.location.Criteria, boolean)} for the given
{@code provider}

@param provider name of the provider who should be considered best
@param enabled Enabled
@param criteria List of criteria
@throws Exception if provider is not known
@return false If provider is not enabled but it is supposed to be set as the best enabled provider don't set it, otherwise true
Sets the value to return from { @link #getBestProvider ( android . location . Criteria boolean ) } for the given { @code provider }