LocalServicespublic final class LocalServices extends Object This class is used in a similar way as ServiceManager, except the services registered here
are not Binder objects and are only available in the same process.
Once all services are converted to the SystemService interface, this class can be absorbed
into SystemServiceManager.
{@hide} |
Fields Summary |
---|
private static final android.util.ArrayMap | sLocalServiceObjects |
Constructors Summary |
---|
private LocalServices()
|
Methods Summary |
---|
public static void | addService(java.lang.Class type, T service)Adds a service instance of the specified interface to the global registry of local services.
synchronized (sLocalServiceObjects) {
if (sLocalServiceObjects.containsKey(type)) {
throw new IllegalStateException("Overriding service registration");
}
sLocalServiceObjects.put(type, service);
}
| public static T | getService(java.lang.Class type)Returns a local service instance that implements the specified interface.
synchronized (sLocalServiceObjects) {
return (T) sLocalServiceObjects.get(type);
}
|
|