我正在尝试从grepcode 站点跟踪 AOSP 代码。
当我打电话时getSystemService(Context.WIFI_P2P_SERVICE)
,它会得到以下代码:
@Override public Object getSystemService(String name) {
if (getBaseContext() == null) {
throw new IllegalStateException(
"System services not available to Activities before onCreate()");
}
if (WINDOW_SERVICE.equals(name)) {
return mWindowManager;
} else if (SEARCH_SERVICE.equals(name)) {
ensureSearchManager();
return mSearchManager;
}
return super.getSystemService(name);
}
并且由于WIFI_P2P_SERVICE
声明为public static final String WIFI_P2P_SERVICE = "wifip2p";
, if 将不属于其中一个条件,并将转到super.getSystemService(name);
Activity extends ContextThemeWrapper, the code there is:
@Override public Object getSystemService(String name) {
if (LAYOUT_INFLATER_SERVICE.equals(name)) {
if (mInflater == null) {
mInflater = LayoutInflater.from(mBase).cloneInContext(this);
}
return mInflater;
}
return mBase.getSystemService(name);
}
在这里,所需的服务名称也将不匹配,mBase
是一个实例,Context
因此 Context 中的代码是:
public abstract Object getSystemService(String name);
这意味着从它扩展的类必须处理该功能。 那么,我的请求在哪里得到处理?