做电影网站考什么产品软文怎么写
Apex的由来,我们都知道普通的apk我们可以通过应用商店playstore等进行更新,apex的引入是google希望也能通过playstore更新bin文件.so etc配置文件等类型文件. 这些文件的安装实际通过apexd来进行,现在我们来解析一下apexd, apexd的启动分为两个阶段,bootstrap和普通apexd启动,下面分析apexd bootstrap
1. rc文件启动
/system/core/rootdir/init.rc#80
本阶段启动三个bootstrap apex,分别为com.android.i18n,com.android.runtime com.android.tzdata,在bootstrap 阶段主要就是提供 critical shared libraries
77 # Run apexd-bootstrap so that APEXes that provide critical libraries
78 # become available. Note that this is executed as exec_start to ensure that
79 # the libraries are available to the processes started after this statement.
80 exec_start apexd-bootstrap
2. main函数
/system/apex/apexd/apexd_main.cpp#118
int main(int /*argc*/, char** argv) {
...
118 android::apex::SetConfig(android::apex::kDefaultConfig); → 全局config
...
151 if (has_subcommand) {
152 return HandleSubcommand(argv); → 这里走 apexd --bootstrap
153 }
全局config 就是这些常量:
61 static const ApexdConfig kDefaultConfig = {
62 kApexStatusSysprop, → kApexStatusSysprop = "apexd.status" apex的状态
63 kApexPackageBuiltinDirs, → 所有apex文件所在的目录data、product、system、system_ext、vendor
64 kActiveApexPackagesDataDir, → kActiveApexPackagesDataDir = "/data/apex/active"
65 kApexDecompressedDir, → kApexDecompressedDir = "/data/apex/decompressed";
66 kOtaReservedDir, → kOtaReservedDir = "/data/apex/ota_reserved";
67 kApexHashTreeDir, → kApexHashTreeDir = "/data/apex/hashtree";
68 kStagedSessionsDir, → StagedSessionsDir = "/data/app-staging"
69 kMetadataSepolicyStagedDir, → kMetadataSepolicyStagedDir = "/metadata/sepolicy/staged";
70 kVmPayloadMetadataPartitionProp, → kVmPayloadMetadataPartitionProp = "apexd.payload_metadata.path"
71 "u:object_r:staging_data_file", → staging_data_file的 file contexts
72 };
3. OnBootstrap()
/system/apex/apexd/apexd_main.cpp#38
36 int HandleSubcommand(char** argv) {
37 if (strcmp("--bootstrap", argv[1]) == 0) {
38 SetDefaultTag("apexd-bootstrap");
39 LOG(INFO) << "Bootstrap subcommand detected";
40 return android::apex::OnBootstrap();
41 }/system/apex/apexd/apexd.cpp#2566
2566 int OnBootstrap() {
2567 ATRACE_NAME("OnBootstrap");
2568 auto time_started = boot_clock::now();
2569
2570 ApexFileRepository& instance = ApexFileRepository::GetInstance(); → 创建个实例 啥也没做
2571 Result<void> status =
2572 instance.AddPreInstalledApex(gConfig->apex_built_in_dirs); → 3.1 scan kApexPackageBuiltinDirs下的所有apex, 详见3.1.1
2573 if (!status.ok()) {
2574 LOG(ERROR) << "Failed to collect APEX keys : " << status.error();
2575 return 1;
2576 }
2577
2578 const auto& pre_installed_apexes = instance.GetPreInstalledApexFiles(); → 从全局变量中得到 pre_installed_store_
2579 int loop_device_cnt = pre_installed_apexes.size();
2580 // Find all bootstrap apexes
2581 std::vector<ApexFileRef> bootstrap_apexes;
2582 for (const auto& apex : pre_installed_apexes) { → 遍历 所有apexfile
2583 if (IsBootstrapApex(apex.get())) { → 判断是否是bootstrap apex,有三个com.android.i18n com.android.runtime com.android.tzdata
2584 LOG(INFO) << "Found bootstrap APEX " << apex.get().GetPath();
2585 bootstrap_apexes.push_back(apex);
2586 loop_device_cnt++;
2587 }
2588 if (apex.get().GetManifest().providesharedapexlibs()) {
2589 LOG(INFO) << "Found sharedlibs APEX " << apex.get().GetPath();
2590 // Sharedlis APEX might be mounted 2 times:
2591 // * Pre-installed sharedlibs APEX will be mounted in OnStart
2592 // * Updated sharedlibs APEX (if it exists) will be mounted in OnStart
2593 //
2594 // We already counted a loop device for one of these 2 mounts, need to add
2595 // 1 more.
2596 loop_device_cnt++;
2597 }
259