This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Import libraries and variable declarations | |
*/ | |
public TestService(Context context) { | |
super(); | |
mContext = context; | |
mWorker = new TestWorkerThread("TestServiceWorker"); | |
mWorker.start(); | |
Log.i(TAG, "Spawned worker thread"); | |
//Initialize the locationManager when the TestService starts | |
locationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE); | |
} | |
/* | |
Other functions | |
*/ |
The 'test' service requires that the 'LocationManagerService' is running before 'test' is created so that it can successfully initialize a location manager.
When Android is started, 'init' is a component of the bootloader sequence which initializes a number of daemons which run continuously whilst the operating system is running.
One of those daemons 'Zygote' is the process responsible for starting system services. It does this by executing the initAndLoop() function of the SystemServer Class.
SystemServer located in frameworks/base/services/java/com/android/server/SystemServer.java
In order to ensure 'LocationManagerService' is running before 'test' service, place the 'test' service's addService code anywhere below that of the 'LocationManagerService'.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Within initAndLoop() | |
if (!disableLocation) { | |
try { | |
Slog.i(TAG, "Location Manager"); | |
location = new LocationManagerService(context); | |
ServiceManager.addService(Context.LOCATION_SERVICE, location); | |
} catch (Throwable e) { | |
reportWtf("starting Location Manager", e); | |
} | |
try { | |
Slog.i(TAG, "Country Detector"); | |
countryDetector = new CountryDetectorService(context); | |
ServiceManager.addService(Context.COUNTRY_DETECTOR, countryDetector); | |
} catch (Throwable e) { | |
reportWtf("starting Country Detector", e); | |
} | |
} | |
/* | |
Register Other Services | |
*/ | |
//Register Test Service | |
try { | |
Slog.i(TAG, "Test Service"); | |
ServiceManager.addService("test", new TestService(context)); | |
} catch (Throwable e) { | |
Slog.e(TAG, "Failure starting TestService Service", e); | |
} |
1 comments:
Iron Knuckle - Titanium Shift knob | Titanium Arts
Iron Knuckle titanium muffler - welding titanium Titanium Shift titanium prices knob titanium trim walmart | Titanium sunscreen with zinc oxide and titanium dioxide Arts
Post a Comment