Merge "Refactor LMS to use SystemService"
This commit is contained in:
committed by
Android (Google) Code Review
commit
62340690af
@@ -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();
|
||||
}
|
||||
|
||||
@@ -1135,7 +1135,6 @@ public final class SystemServer {
|
||||
|
||||
StatusBarManagerService statusBar = null;
|
||||
INotificationManager notification = null;
|
||||
LocationManagerService location = null;
|
||||
CountryDetectorService countryDetector = null;
|
||||
ILockSettings lockSettings = null;
|
||||
MediaRouterService mediaRouter = null;
|
||||
@@ -1432,12 +1431,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");
|
||||
@@ -2021,7 +2015,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;
|
||||
@@ -2177,16 +2170,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) {
|
||||
|
||||
Reference in New Issue
Block a user