DO NOT MERGE: Do not hold mLock when calling GNSS HAL

Test: on device
Bug: 156867071
Change-Id: I57c3bfb8148350855af1dc4b662526a4e6043b8e
This commit is contained in:
Yu-Han Yang
2020-06-09 11:40:09 -07:00
parent 275248ddfe
commit 5a0a1d95ab

View File

@@ -231,7 +231,7 @@ public class LocationManagerService extends ILocationManager.Stub {
private final AppForegroundHelper mAppForegroundHelper;
private final LocationUsageLogger mLocationUsageLogger;
@Nullable private GnssManagerService mGnssManagerService = null;
@Nullable private volatile GnssManagerService mGnssManagerService = null;
private final PassiveLocationProviderManager mPassiveManager;
@@ -381,6 +381,10 @@ public class LocationManagerService extends ILocationManager.Stub {
// prepare providers
initializeProvidersLocked();
}
// initialize gnss last because it has no awareness of boot phases and blindly assumes that
// all other location providers are loaded at initialization
initializeGnss();
}
private void onAppOpChanged(String packageName) {
@@ -602,16 +606,19 @@ public class LocationManagerService extends ILocationManager.Stub {
}
manager.setMockProvider(new MockProvider(properties));
}
}
// initialize gnss last because it has no awareness of boot phases and blindly assumes that
// all other location providers are loaded at initialization
private void initializeGnss() {
// Do not hold mLock when calling GnssManagerService#isGnssSupported() which calls into HAL.
if (GnssManagerService.isGnssSupported()) {
mGnssManagerService = new GnssManagerService(mContext, mAppOpsHelper, mSettingsHelper,
mAppForegroundHelper, mLocationUsageLogger);
mGnssManagerService.onSystemReady();
LocationProviderManager gnssManager = new LocationProviderManager(GPS_PROVIDER);
mProviderManagers.add(gnssManager);
synchronized (mLock) {
mProviderManagers.add(gnssManager);
}
gnssManager.setRealProvider(mGnssManagerService.getGnssLocationProvider());
// bind to geofence proxy