@@ -337,6 +337,7 @@ static class LocationUpdateListener implements LocationListener {
337
337
338
338
private GoogleApiClient mGoogleApiClient ;
339
339
340
+ // this initializer method is already synchronized from LocationGMS with respect to the GoogleApiClient lock
340
341
LocationUpdateListener (GoogleApiClient googleApiClient ) {
341
342
mGoogleApiClient = googleApiClient ;
342
343
@@ -364,17 +365,21 @@ static class FusedLocationApiWrapper {
364
365
@ SuppressWarnings ("MissingPermission" )
365
366
static void requestLocationUpdates (GoogleApiClient googleApiClient , LocationRequest locationRequest , LocationListener locationListener ) {
366
367
try {
367
- if (googleApiClient .isConnected ())
368
- LocationServices .FusedLocationApi .requestLocationUpdates (googleApiClient , locationRequest , locationListener );
368
+ synchronized (LocationGMS .syncLock ) {
369
+ if (googleApiClient .isConnected ())
370
+ LocationServices .FusedLocationApi .requestLocationUpdates (googleApiClient , locationRequest , locationListener );
371
+ }
369
372
} catch (Throwable t ) {
370
373
OneSignal .Log (OneSignal .LOG_LEVEL .WARN , "FusedLocationApi.requestLocationUpdates failed!" , t );
371
374
}
372
375
}
373
376
374
377
@ SuppressWarnings ("MissingPermission" )
375
378
static Location getLastLocation (GoogleApiClient googleApiClient ) {
376
- if (googleApiClient .isConnected ())
377
- return LocationServices .FusedLocationApi .getLastLocation (googleApiClient );
379
+ synchronized (LocationGMS .syncLock ) {
380
+ if (googleApiClient .isConnected ())
381
+ return LocationServices .FusedLocationApi .getLastLocation (googleApiClient );
382
+ }
378
383
return null ;
379
384
}
380
385
}
0 commit comments