// The system service cache for the system services that are cached per-ContextImpl.finalObject[]mServiceCache=SystemServiceRegistry.createServiceCache();
registerService(Context.POWER_SERVICE,PowerManager.class,newCachedServiceFetcher<PowerManager>(){@OverridepublicPowerManagercreateService(ContextImplctx){IBinderb=ServiceManager.getService(Context.POWER_SERVICE);IPowerManagerservice=IPowerManager.Stub.asInterface(b);if(service==null){Log.wtf(TAG,"Failed to get power manager service.");}returnnewPowerManager(ctx.getOuterContext(),service,ctx.mMainThread.getHandler());}});
@OverridepublicObjectgetSystemService(@ServiceName@NonNullStringname){if(getBaseContext()==null){thrownewIllegalStateException("System services not available to Activities before onCreate()");}if(WINDOW_SERVICE.equals(name)){returnmWindowManager;}elseif(SEARCH_SERVICE.equals(name)){ensureSearchManager();returnmSearchManager;}returnsuper.getSystemService(name);}