xref: /aosp_15_r20/system/apex/apexd/apex_constants.h (revision 33f3758387333dbd2962d7edbd98681940d895da)
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* kApexPackageSystemDir = "/system/apex";
36 static constexpr const char* kApexPackageSystemExtDir = "/system_ext/apex";
37 static constexpr const char* kApexPackageProductDir = "/product/apex";
38 static constexpr const char* kApexPackageVendorDir = "/vendor/apex";
39 static constexpr const char* kApexPackageOdmDir = "/odm/apex";
40 static const std::unordered_map<ApexPartition, std::string>
41     kBuiltinApexPackageDirs = {
42         {ApexPartition::System, kApexPackageSystemDir},
43         {ApexPartition::SystemExt, kApexPackageSystemExtDir},
44         {ApexPartition::Product, kApexPackageProductDir},
45         {ApexPartition::Vendor, kApexPackageVendorDir},
46         {ApexPartition::Odm, kApexPackageOdmDir},
47 };
48 static const std::vector<std::string> kApexPackageBuiltinDirs = {
49     kApexPackageSystemDir, kApexPackageSystemExtDir, kApexPackageProductDir,
50     kApexPackageVendorDir, kApexPackageOdmDir};
51 static constexpr const char* kApexRoot = "/apex";
52 static constexpr const char* kStagedSessionsDir = "/data/app-staging";
53 
54 static constexpr const char* kApexDataSubDir = "apexdata";
55 static constexpr const char* kApexSharedLibsSubDir = "sharedlibs";
56 static constexpr const char* kApexSnapshotSubDir = "apexrollback";
57 static constexpr const char* kPreRestoreSuffix = "-prerestore";
58 
59 static constexpr const char* kDeSysDataDir = "/data/misc";
60 static constexpr const char* kDeNDataDir = "/data/misc_de";
61 static constexpr const char* kCeDataDir = "/data/misc_ce";
62 
63 static constexpr const char* kApexPackageSuffix = ".apex";
64 static constexpr const char* kCompressedApexPackageSuffix = ".capex";
65 static constexpr const char* kDecompressedApexPackageSuffix =
66     ".decompressed.apex";
67 static constexpr const char* kOtaApexPackageSuffix = ".ota.apex";
68 
69 static constexpr const char* kManifestFilenameJson = "apex_manifest.json";
70 static constexpr const char* kManifestFilenamePb = "apex_manifest.pb";
71 
72 static constexpr const char* kApexInfoList = "apex-info-list.xml";
73 
74 // These should be in-sync with system/sepolicy/private/property_contexts
75 static constexpr const char* kApexStatusSysprop = "apexd.status";
76 static constexpr const char* kApexStatusStarting = "starting";
77 static constexpr const char* kApexStatusActivated = "activated";
78 static constexpr const char* kApexStatusReady = "ready";
79 
80 static constexpr const char* kMultiApexSelectPersistPrefix =
81     "persist.vendor.apex.";
82 static constexpr const char* kMultiApexSelectBootconfigPrefix =
83     "ro.boot.vendor.apex.";
84 static const std::vector<std::string> kMultiApexSelectPrefix = {
85     // Check persist props first, to allow users to override bootconfig.
86     kMultiApexSelectPersistPrefix,
87     kMultiApexSelectBootconfigPrefix,
88 };
89 
90 static constexpr const char* kVmPayloadMetadataPartitionProp =
91     "apexd.payload_metadata.path";
92 static constexpr const std::chrono::seconds kBlockApexWaitTime(10);
93 
94 static constexpr const char* kApexAllReadyProp = "apex.all.ready";
95 static constexpr const char* kCtlApexLoadSysprop = "ctl.apex_load";
96 static constexpr const char* kCtlApexUnloadSysprop = "ctl.apex_unload";
97 
98 // Constants for brand-new APEX
99 static constexpr const char* kBrandNewApexPublicKeySuffix = ".avbpubkey";
100 static constexpr const char* kBrandNewApexBlocklistFileName = "blocklist.json";
101 static constexpr const char* kBrandNewApexConfigSystemDir =
102     "/system/etc/brand_new_apex";
103 static constexpr const char* kBrandNewApexConfigSystemExtDir =
104     "/system_ext/etc/brand_new_apex";
105 static constexpr const char* kBrandNewApexConfigProductDir =
106     "/product/etc/brand_new_apex";
107 static constexpr const char* kBrandNewApexConfigVendorDir =
108     "/vendor/etc/brand_new_apex";
109 static constexpr const char* kBrandNewApexConfigOdmDir =
110     "/odm/etc/brand_new_apex";
111 static const std::unordered_map<ApexPartition, std::string>
112     kPartitionToBrandNewApexConfigDirs = {
113         {ApexPartition::System, kBrandNewApexConfigSystemDir},
114         {ApexPartition::SystemExt, kBrandNewApexConfigSystemExtDir},
115         {ApexPartition::Product, kBrandNewApexConfigProductDir},
116         {ApexPartition::Vendor, kBrandNewApexConfigVendorDir},
117         {ApexPartition::Odm, kBrandNewApexConfigOdmDir},
118 };
119 
120 // Banned APEX names
121 static const std::unordered_set<std::string> kBannedApexName = {
122     kApexSharedLibsSubDir,  // To avoid conflicts with predefined
123                             // /apex/sharedlibs directory
124 };
125 }  // namespace apex
126 }  // namespace android
127