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

Commit 141417ac authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

Refactor LMS to use SystemService

Adopt SystemService based initialization for LocationManagerService. No behavioral changes, just
adopts the existing initialization framework for LMS.

Test: manual
Change-Id: Ic03e5e3fdacb1d3d79e7ba739b673a1c6146c673
parent cabc32d2
Loading
Loading
Loading
Loading
+28 −3
Original line number Diff line number Diff line
@@ -128,6 +128,32 @@ import java.util.concurrent.TimeUnit;
 * updates and alerts.
 */
public class LocationManagerService extends ILocationManager.Stub {

    /**
     * Controls lifecycle of LocationManagerService.
     */
    public static class Lifecycle extends SystemService {

        private LocationManagerService mService;

        public Lifecycle(Context context) {
            super(context);
            mService = new LocationManagerService(context);
        }

        @Override
        public void onStart() {
            publishBinderService(Context.LOCATION_SERVICE, mService);
        }

        @Override
        public void onBootPhase(int phase) {
            if (phase == SystemService.PHASE_THIRD_PARTY_APPS_CAN_START) {
                mService.systemRunning();
            }
        }
    }

    private static final String TAG = "LocationManagerService";
    public static final boolean D = Log.isLoggable(TAG, Log.DEBUG);

@@ -234,8 +260,7 @@ public class LocationManagerService extends ILocationManager.Stub {
    @GuardedBy("mLock")
    private final LocationUsageLogger mLocationUsageLogger;

    public LocationManagerService(Context context) {
        super();
    private LocationManagerService(Context context) {
        mContext = context;
        mHandler = FgThread.getHandler();
        mLocationUsageLogger = new LocationUsageLogger();
@@ -254,7 +279,7 @@ public class LocationManagerService extends ILocationManager.Stub {
        // most startup is deferred until systemRunning()
    }

    public void systemRunning() {
    private void systemRunning() {
        synchronized (mLock) {
            initializeLocked();
        }
+1 −18
Original line number Diff line number Diff line
@@ -1133,7 +1133,6 @@ public final class SystemServer {

        StatusBarManagerService statusBar = null;
        INotificationManager notification = null;
        LocationManagerService location = null;
        CountryDetectorService countryDetector = null;
        ILockSettings lockSettings = null;
        MediaRouterService mediaRouter = null;
@@ -1430,12 +1429,7 @@ public final class SystemServer {
            t.traceEnd();

            t.traceBegin("StartLocationManagerService");
            try {
                location = new LocationManagerService(context);
                ServiceManager.addService(Context.LOCATION_SERVICE, location);
            } catch (Throwable e) {
                reportWtf("starting Location Manager", e);
            }
            mSystemServiceManager.startService(LocationManagerService.Lifecycle.class);
            t.traceEnd();

            t.traceBegin("StartCountryDetectorService");
@@ -2019,7 +2013,6 @@ public final class SystemServer {
        final NetworkStatsService networkStatsF = networkStats;
        final NetworkPolicyManagerService networkPolicyF = networkPolicy;
        final ConnectivityService connectivityF = connectivity;
        final LocationManagerService locationF = location;
        final CountryDetectorService countryDetectorF = countryDetector;
        final NetworkTimeUpdateService networkTimeUpdaterF = networkTimeUpdater;
        final InputManagerService inputManagerF = inputManager;
@@ -2175,16 +2168,6 @@ public final class SystemServer {
            }
            t.traceEnd();


            t.traceBegin("MakeLocationServiceReady");
            try {
                if (locationF != null) {
                    locationF.systemRunning();
                }
            } catch (Throwable e) {
                reportWtf("Notifying Location Service running", e);
            }
            t.traceEnd();
            t.traceBegin("MakeCountryDetectionServiceReady");
            try {
                if (countryDetectorF != null) {