• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <chrono>
20 #include <string>
21 #include <unordered_map>
22 #include <unordered_set>
23 #include <vector>
24 
25 namespace android {
26 namespace apex {
27 
28 enum class ApexPartition { System, SystemExt, Product, Vendor, Odm };
29 
30 static constexpr const char* kApexDataDir = "/data/apex";
31 static constexpr const char* kActiveApexPackagesDataDir = "/data/apex/active";
32 static constexpr const char* kApexBackupDir = "/data/apex/backup";
33 static constexpr const char* kApexDecompressedDir = "/data/apex/decompressed";
34 static constexpr const char* kOtaReservedDir = "/data/apex/ota_reserved";
35 static constexpr const char* kMetadataImagesDir = "/metadata/apex/images";
36 static constexpr const char* kDataImagesDir = "/data/apex/images";
37 static constexpr const char* kApexPackageSystemDir = "/system/apex";
38 static constexpr const char* kApexPackageSystemExtDir = "/system_ext/apex";
39 static constexpr const char* kApexPackageProductDir = "/product/apex";
40 static constexpr const char* kApexPackageVendorDir = "/vendor/apex";
41 static constexpr const char* kApexPackageOdmDir = "/odm/apex";
42 static const std::unordered_map<ApexPartition, std::string>
43     kBuiltinApexPackageDirs = {
44         {ApexPartition::System, kApexPackageSystemDir},
45         {ApexPartition::SystemExt, kApexPackageSystemExtDir},
46         {ApexPartition::Product, kApexPackageProductDir},
47         {ApexPartition::Vendor, kApexPackageVendorDir},
48         {ApexPartition::Odm, kApexPackageOdmDir},
49 };
50 static const std::vector<std::string> kApexPackageBuiltinDirs = {
51     kApexPackageSystemDir, kApexPackageSystemExtDir, kApexPackageProductDir,
52     kApexPackageVendorDir, kApexPackageOdmDir};
53 static constexpr const char* kApexRoot = "/apex";
54 static constexpr const char* kStagedSessionsDir = "/data/app-staging";
55 
56 static constexpr const char* kApexDataSubDir = "apexdata";
57 static constexpr const char* kApexSharedLibsSubDir = "sharedlibs";
58 static constexpr const char* kApexSnapshotSubDir = "apexrollback";
59 static constexpr const char* kPreRestoreSuffix = "-prerestore";
60 
61 static constexpr const char* kDeSysDataDir = "/data/misc";
62 static constexpr const char* kDeNDataDir = "/data/misc_de";
63 static constexpr const char* kCeDataDir = "/data/misc_ce";
64 
65 static constexpr const char* kApexPackageSuffix = ".apex";
66 static constexpr const char* kCompressedApexPackageSuffix = ".capex";
67 static constexpr const char* kDecompressedApexPackageSuffix =
68     ".decompressed.apex";
69 static constexpr const char* kOtaApexPackageSuffix = ".ota.apex";
70 
71 static constexpr const char* kManifestFilenameJson = "apex_manifest.json";
72 static constexpr const char* kManifestFilenamePb = "apex_manifest.pb";
73 
74 static constexpr const char* kApexInfoList = "/apex/apex-info-list.xml";
75 
76 // These should be in-sync with system/sepolicy/private/property_contexts
77 static constexpr const char* kApexStatusSysprop = "apexd.status";
78 static constexpr const char* kApexStatusStarting = "starting";
79 static constexpr const char* kApexStatusActivated = "activated";
80 static constexpr const char* kApexStatusReady = "ready";
81 
82 static constexpr const char* kMultiApexSelectPersistPrefix =
83     "persist.vendor.apex.";
84 static constexpr const char* kMultiApexSelectBootconfigPrefix =
85     "ro.boot.vendor.apex.";
86 static const std::vector<std::string> kMultiApexSelectPrefix = {
87     // Check persist props first, to allow users to override bootconfig.
88     kMultiApexSelectPersistPrefix,
89     kMultiApexSelectBootconfigPrefix,
90 };
91 
92 static constexpr const char* kVmPayloadMetadataPartitionProp =
93     "apexd.payload_metadata.path";
94 static constexpr const std::chrono::seconds kBlockApexWaitTime(10);
95 
96 static constexpr const char* kApexAllReadyProp = "apex.all.ready";
97 static constexpr const char* kCtlApexLoadSysprop = "ctl.apex_load";
98 static constexpr const char* kCtlApexUnloadSysprop = "ctl.apex_unload";
99 
100 // Constants for brand-new APEX
101 static constexpr const char* kBrandNewApexPublicKeySuffix = ".avbpubkey";
102 static constexpr const char* kBrandNewApexBlocklistFileName = "blocklist.json";
103 static constexpr const char* kBrandNewApexConfigSystemDir =
104     "/system/etc/brand_new_apex";
105 static constexpr const char* kBrandNewApexConfigSystemExtDir =
106     "/system_ext/etc/brand_new_apex";
107 static constexpr const char* kBrandNewApexConfigProductDir =
108     "/product/etc/brand_new_apex";
109 static constexpr const char* kBrandNewApexConfigVendorDir =
110     "/vendor/etc/brand_new_apex";
111 static constexpr const char* kBrandNewApexConfigOdmDir =
112     "/odm/etc/brand_new_apex";
113 static const std::unordered_map<ApexPartition, std::string>
114     kPartitionToBrandNewApexConfigDirs = {
115         {ApexPartition::System, kBrandNewApexConfigSystemDir},
116         {ApexPartition::SystemExt, kBrandNewApexConfigSystemExtDir},
117         {ApexPartition::Product, kBrandNewApexConfigProductDir},
118         {ApexPartition::Vendor, kBrandNewApexConfigVendorDir},
119         {ApexPartition::Odm, kBrandNewApexConfigOdmDir},
120 };
121 
122 // Banned APEX names
123 static const std::unordered_set<std::string> kBannedApexName = {
124     kApexSharedLibsSubDir,  // To avoid conflicts with predefined
125                             // /apex/sharedlibs directory
126 };
127 }  // namespace apex
128 }  // namespace android
129