一.SystemServer的main方法
/** * The main entry point from zygote. */ public static void main(String[] args) { new SystemServer().run(); }
二.SystemServer 的startBootstrapServices()方法::
SystemServer中run()方法会初始化一系列的服务,PackageManagerService就是其中之一run()方法回调用
startBootstrapServices()
这个时候就会调用以下方法,来初始化PackageManagerService.
PackageManagerService.main()
三.PackageManagerService的初始化:(针对用户应用展开分析,系统应用和用户应用目录结构不同)
mian()方法被调用后会new出PackageManagerService 在其中可以发现以下目录
File dataDir = Environment.getDataDirectory(); mAppInstallDir = new File(dataDir, "app"); mAppLib32InstallDir = new File(dataDir, "app-lib"); mEphemeralInstallDir = new File(dataDir, "app-ephemeral"); mAsecInternalPath = new File(dataDir, "app-asec").getPath(); mDrmAppPrivateInstallDir = new File(dataDir, "app-private");