FileDocCategorySizeDatePackage
LocalServices.javaAPI DocAndroid 5.1 API2022Thu Mar 12 22:22:10 GMT 2015com.android.server

LocalServices

public 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 voidaddService(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 TgetService(java.lang.Class type)
Returns a local service instance that implements the specified interface.

param
type The type of service.
return
The service object.

        synchronized (sLocalServiceObjects) {
            return (T) sLocalServiceObjects.get(type);
        }