Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1b112642 authored by Yu-Han Yang's avatar Yu-Han Yang
Browse files

Do not hold mLock when calling GNSS HAL

Test: on device
Bug: 156867071
Change-Id: I57c3bfb8148350855af1dc4b662526a4e6043b8e
parent 903e0db4
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -206,7 +206,7 @@ public class LocationManagerService extends ILocationManager.Stub {

    private final GeofenceManager mGeofenceManager;

    @Nullable private GnssManagerService mGnssManagerService = null;
    @Nullable private volatile GnssManagerService mGnssManagerService = null;

    private final PassiveLocationProviderManager mPassiveManager;

@@ -359,6 +359,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) {
@@ -580,16 +584,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, mUserInfoHelper, mSettingsHelper,
                    mAppOpsHelper, mAppForegroundHelper, mLocationUsageLogger);
            mGnssManagerService.onSystemReady();

            LocationProviderManager gnssManager = new LocationProviderManager(GPS_PROVIDER);
            synchronized (mLock) {
                mProviderManagers.add(gnssManager);
            }
            gnssManager.setRealProvider(mGnssManagerService.getGnssLocationProvider());

            // bind to geofence proxy