调用流程
->
ContextImpl
.getSystemService(
XXX)
-> SystemServiceRegistry .getSystemService(this, name);
-> ServiceFetcher .getService(context)
-> SystemServiceRegistry .getSystemService(this, name);
-> ServiceFetcher .getService(context)
方法内容
ContextImpl
.java
@ Override
public Object getSystemService( String name) {
return SystemServiceRegistry .getSystemService( this, name);
}
SystemServiceRegistry .java
public static Object getSystemService( ContextImpl ctx, String name) {
ServiceFetcher<?> fetcher = SYSTEM_SERVICE_FETCHERS .get(name);
return fetcher != null ? fetcher .getService(ctx) : null;
}
SystemServiceRegistry# ServiceFetcher .java
static abstract interface ServiceFetcher<T> {
T getService( ContextImpl ctx);
}
@ Override
public Object getSystemService( String name) {
return SystemServiceRegistry .getSystemService( this, name);
}
SystemServiceRegistry .java
public static Object getSystemService( ContextImpl ctx, String name) {
ServiceFetcher<?> fetcher = SYSTEM_SERVICE_FETCHERS .get(name);
return fetcher != null ? fetcher .getService(ctx) : null;
}
SystemServiceRegistry# ServiceFetcher .java
static abstract interface ServiceFetcher<T> {
T getService( ContextImpl ctx);
}
MUL结构图