I’m trying to trace AOSP code from the grepcode site.
When I call getSystemService(Context.WIFI_P2P_SERVICE), it gets to the following code:
@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);
}
And since WIFI_P2P_SERVICE declared as public static final String WIFI_P2P_SERVICE = "wifip2p";, if will not fall in one of the conditions and will go to the 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);
}
Here also, the required service name will not match, mBase is an instance of Context so the code in Context is:
public abstract Object getSystemService(String name);
which means that classes which extends from it must handle that functionality.
Well, Where my request is being treated?
As far as i know the implementation code of Context is under the package android.app with class name ContextImpl
Here is getSystemService from that class –
Edit –
The entry point for WIFI_P2P_SERVICE –