From 0c76f15cb2bf6af094e8ee852ee4c954c0b3fbf4 Mon Sep 17 00:00:00 2001 From: Anil Admal Date: Wed, 6 Feb 2019 19:06:07 -0800 Subject: [PATCH] Merge partner fix for ComprehensiveCountryDetector deadlock The fix is in comment #1 in b/70679249 Bug: 70679249 Test: Code inspection. Existing tests pass. Change-Id: I4a195239da2f5b82e273cb259bea1c9c79dc4d52 --- .../server/location/LocationBasedCountryDetector.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/services/core/java/com/android/server/location/LocationBasedCountryDetector.java b/services/core/java/com/android/server/location/LocationBasedCountryDetector.java index 6527899f29790..8ee1285b41f22 100644 --- a/services/core/java/com/android/server/location/LocationBasedCountryDetector.java +++ b/services/core/java/com/android/server/location/LocationBasedCountryDetector.java @@ -235,18 +235,15 @@ public class LocationBasedCountryDetector extends CountryDetectorBase { * Start a new thread to query the country from Geocoder. */ private synchronized void queryCountryCode(final Location location) { - if (location == null) { - notifyListener(null); - return; - } if (mQueryThread != null) return; mQueryThread = new Thread(new Runnable() { @Override public void run() { - String countryIso = null; - if (location != null) { - countryIso = getCountryFromLocation(location); + if (location == null) { + notifyListener(null); + return; } + String countryIso = getCountryFromLocation(location); if (countryIso != null) { mDetectedCountry = new Country(countryIso, Country.COUNTRY_SOURCE_LOCATION); } else {