title: Setting mock location in FusedLocationProviderApi
body: <p>I'm trying to get mock updates from <code>FusedLocationProviderApi</code>, but I can't seem to make it work. This my set up method in android instrumentation test:</p>
  
  <pre><code>locationProvider = new LocationProvider(InstrumentationRegistry.getTargetContext().getApplicationContext(), settings);
  
  // Connect first, so that we don't receive 'true' location
  locationProvider.googleApiClient.blockingConnect();
  // Set mock mode, to receive only mock locations
  LocationServices.FusedLocationApi.setMockMode(locationProvider.googleApiClient, true);
  
  InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
      @Override
      public void run() {
          // Start receiving locations; this call will connect api client, and if it's already connected (or after it connects) it will register for location updates
          locationProvider.start();
      }
  });
  // wait until we can request location updates
  while (!locationProvider.isReceivingLocationUpdates) {
      Thread.sleep(10);
  }
  </code></pre>
  
  <p>After this point I would expect any calls to <code>LocationServices.fusedLocationApi.setMockLocation(apiClient, location)</code> to set mock location that my listener would receive. Unfortunately this is not the case, and the listener stays silent.</p>
  
  <p>My foolproof (or so I thought) method to set mock location looks like this:</p>
  
  <pre><code>private void setMockLocation(final Location location) throws Exception {
      assertTrue(locationProvider.googleApiClient.isConnected());
      assertTrue(locationProvider.isReceivingLocationUpdates);
  
      final CountDownLatch countDownLatch = new CountDownLatch(1);
      LocationServices.FusedLocationApi.setMockMode(locationProvider.googleApiClient, true)
              .setResultCallback(new ResultCallback&lt;Status&gt;() {
                  @Override
                  public void onResult(Status status) {
                      assertTrue(status.isSuccess());
                      LocationServices.FusedLocationApi.setMockLocation(locationProvider.googleApiClient, location)
                              .setResultCallback(new ResultCallback&lt;Status&gt;() {
                                  @Override
                                  public void onResult(Status status) {
                                      assertTrue(status.isSuccess());
                                      countDownLatch.countDown();
                                  }
                              });
                  }
              });
      assertTrue(countDownLatch.await(500, TimeUnit.MILLISECONDS));
  }
  </code></pre>
  
  <p>Method returns successfully, but no location is received by the listener. I'm really at a loss here. The worst part is sometimes the test would pass, but extremely randomly (to a point when the same code executed several times would pass and fail in subsequent calls). My debug manifest, for completeness, has following permissions:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /&gt;
  </code></pre>
  
  <p>I have allowed mock locations in settings.</p>