了解systemServer

SystemServer 是Android系统用来创建系统服务的类。

入口: 找到main方法。

    public static void main(String[] args) {
        new SystemServer().run();
   }

在main方法中,创建了一个SystemServer匿名类,调用run()方法。往下看:

 // Start services.
         try {
            startBootstrapServices();
            startCoreServices();
           startOtherServices();
         } catch (Throwable ex) {
             Slog.e("System", "******************************************");
            Slog.e("System", "************ Failure starting system services", ex);
             throw ex;
         }

在run方法的核心代码中有调用了三个start开头的方法,顾名思义分别启动了:引导类服务(BootstrapServices)、核心服务(CoreServices)以及其他服务(OtherServices)。
每一个具体包含哪些:
1): BootstrapServices

       activity管理服务: mActivityManagerService = mSystemServiceManager.startService(                ActivityManagerService.Lifecycle.class).getService();

     电量管理服务:    mPowerManagerService = mSystemServiceManager.startService(PowerManagerService.class);

      页面展示服务:     mDisplayManagerService = mSystemServiceManager.startService(DisplayManagerService.class);

包管理服务:  mPackageManagerService = PackageManagerService.main(mSystemContext, installer,
          mFactoryTestMode != FactoryTest.FACTORY_TEST_OFF, mOnlyCore);

2):CoreService

  mSystemServiceManager.startService(LightsService.class);
370 
371         // Tracks the battery level.  Requires LightService.
372         mSystemServiceManager.startService(BatteryService.class);
373 
374         // Tracks application usage stats.
375         mSystemServiceManager.startService(UsageStatsService.class);
376         mActivityManagerService.setUsageStatsManager(
377                 LocalServices.getService(UsageStatsManagerInternal.class));
378         // Update after UsageStatsService is available, needed before performBootDexOpt.
379         mPackageManagerService.getUsageStatsIfNoPackageUsageInfo();
380 
381         // Tracks whether the updatable WebView is in a ready state and watches for update installs.
382         mSystemServiceManager.startService(WebViewUpdateService.class);
383     }

3)OtherServices:

   final Context context = mSystemContext;
391         AccountManagerService accountManager = null;
392         ContentService contentService = null;
393         VibratorService vibrator = null;
394         IAlarmManager alarm = null;
395         MountService mountService = null;
396         NetworkManagementService networkManagement = null;
397         NetworkStatsService networkStats = null;
398         NetworkPolicyManagerService networkPolicy = null;
399         ConnectivityService connectivity = null;
400         NetworkScoreService networkScore = null;
401         NsdService serviceDiscovery= null;
402         WindowManagerService wm = null;
403         BluetoothManagerService bluetooth = null;
404         UsbService usb = null;
405         SerialService serial = null;
406         NetworkTimeUpdateService networkTimeUpdater = null;
407         CommonTimeManagementService commonTimeMgmtService = null;
408         InputManagerService inputManager = null;
409         TelephonyRegistry telephonyRegistry = null;
410         ConsumerIrService consumerIr = null;
411         AudioService audioService = null;
412         MmsServiceBroker mmsService = null;
413 

源码地址

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值