Android-getSystemService分析

调用流程
->  ContextImpl .getSystemService( XXX)
          ->  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  getService( ContextImpl  ctx);
}

MUL结构图

Android-getSystemService分析_第1张图片

你可能感兴趣的:(Android)