上下文提供了getSystemService(serviceName)获取Manager
ContextImpl通过内部的SYSTEM_SERVICE_MAP(HashMap
static class ServiceFetcher {
public Object getService(ContextImpl ctx) {
ArrayList<Object> cache = ctx.mServiceCache;
Object service;
synchronized (cache) {
if (cache.size() == 0) {
for (int i = 0; i < sNextPerContextServiceCacheIndex; i++) {
cache.add(null);
}
} else {
service = cache.get(mContextCacheIndex);
if (service != null) {
return service;
}
}
service = createService(ctx);
cache.set(mContextCacheIndex, service);
return service;
}
}
public Object createService(ContextImpl ctx) {
throw new RuntimeException("Not implemented");
}