xref: /aosp_15_r20/hardware/interfaces/compatibility_matrices/exclude/fcm_exclude.cpp (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1*4d7e907cSAndroid Build Coastguard Worker /*
2*4d7e907cSAndroid Build Coastguard Worker  * Copyright (C) 2020 The Android Open Source Project
3*4d7e907cSAndroid Build Coastguard Worker  *
4*4d7e907cSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*4d7e907cSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*4d7e907cSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*4d7e907cSAndroid Build Coastguard Worker  *
8*4d7e907cSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*4d7e907cSAndroid Build Coastguard Worker  *
10*4d7e907cSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*4d7e907cSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*4d7e907cSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*4d7e907cSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*4d7e907cSAndroid Build Coastguard Worker  * limitations under the License.
15*4d7e907cSAndroid Build Coastguard Worker  */
16*4d7e907cSAndroid Build Coastguard Worker 
17*4d7e907cSAndroid Build Coastguard Worker #include <functional>
18*4d7e907cSAndroid Build Coastguard Worker #include <string>
19*4d7e907cSAndroid Build Coastguard Worker #include <vector>
20*4d7e907cSAndroid Build Coastguard Worker 
21*4d7e907cSAndroid Build Coastguard Worker #include <android-base/strings.h>
22*4d7e907cSAndroid Build Coastguard Worker #include <vintf/fcm_exclude.h>
23*4d7e907cSAndroid Build Coastguard Worker 
24*4d7e907cSAndroid Build Coastguard Worker namespace android::vintf::details {
25*4d7e907cSAndroid Build Coastguard Worker 
26*4d7e907cSAndroid Build Coastguard Worker // The predicate to VintfObject::checkMissingHalsInMatrices.
ShouldCheckMissingHidlHalsInFcm(const std::string & packageAndVersion)27*4d7e907cSAndroid Build Coastguard Worker bool ShouldCheckMissingHidlHalsInFcm(const std::string& packageAndVersion) {
28*4d7e907cSAndroid Build Coastguard Worker     static std::vector<std::string> included_prefixes{
29*4d7e907cSAndroid Build Coastguard Worker             // Other AOSP HALs (e.g. android.frameworks.*) are not added because only framework
30*4d7e907cSAndroid Build Coastguard Worker             // matrix is checked.
31*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.",
32*4d7e907cSAndroid Build Coastguard Worker     };
33*4d7e907cSAndroid Build Coastguard Worker 
34*4d7e907cSAndroid Build Coastguard Worker     static std::vector<std::string> excluded_prefixes{
35*4d7e907cSAndroid Build Coastguard Worker             // Packages without top level interfaces (including types-only packages) are exempted.
36*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.camera.device@",
37*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.gnss.measurement_corrections@1.",
38*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.graphics.bufferqueue@",
39*4d7e907cSAndroid Build Coastguard Worker 
40*4d7e907cSAndroid Build Coastguard Worker             // Test packages are exempted.
41*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.tests.",
42*4d7e907cSAndroid Build Coastguard Worker     };
43*4d7e907cSAndroid Build Coastguard Worker 
44*4d7e907cSAndroid Build Coastguard Worker     static std::vector<std::string> excluded_exact{
45*4d7e907cSAndroid Build Coastguard Worker             // Packages without top level interfaces (including types-only packages) are exempted.
46*4d7e907cSAndroid Build Coastguard Worker             // HIDL
47*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
48*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
49*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
50*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
51*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
52*4d7e907cSAndroid Build Coastguard Worker 
53*4d7e907cSAndroid Build Coastguard Worker             // Fastboot HAL is only used by recovery. Recovery is owned by OEM. Framework
54*4d7e907cSAndroid Build Coastguard Worker             // does not depend on this HAL, hence it is not declared in any manifests or matrices.
55*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
56*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
57*4d7e907cSAndroid Build Coastguard Worker 
58*4d7e907cSAndroid Build Coastguard Worker             // Deprecated HALs.
59*4d7e907cSAndroid Build Coastguard Worker             // HIDL
60*4d7e907cSAndroid Build Coastguard Worker             // TODO(b/171260360) Remove when HAL definition is removed
61*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
62*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
63*4d7e907cSAndroid Build Coastguard Worker             // Health 1.0 HAL is deprecated. The top level interface are deleted.
64*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
65*4d7e907cSAndroid Build Coastguard Worker             // TODO(b/171260670) Remove when HAL definition is removed
66*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
67*4d7e907cSAndroid Build Coastguard Worker             // TODO(b/171260715) Remove when HAL definition is removed
68*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
69*4d7e907cSAndroid Build Coastguard Worker 
70*4d7e907cSAndroid Build Coastguard Worker             // TODO(b/205175891): File individual bugs for these HALs deprecated in P
71*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
72*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
73*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
74*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
75*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
76*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
77*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
78*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
79*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
80*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
81*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
82*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
83*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
84*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
85*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
86*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
87*4d7e907cSAndroid Build Coastguard Worker 
88*4d7e907cSAndroid Build Coastguard Worker             // b/279809679 for HALS deprecated in Q
89*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
90*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
91*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
92*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
93*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
94*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
95*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
96*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
97*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
98*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
99*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
100*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
101*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
102*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
103*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
104*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
105*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
106*4d7e907cSAndroid Build Coastguard Worker             "[email protected]",
107*4d7e907cSAndroid Build Coastguard Worker     };
108*4d7e907cSAndroid Build Coastguard Worker 
109*4d7e907cSAndroid Build Coastguard Worker     auto package_has_prefix = [&](const std::string& prefix) {
110*4d7e907cSAndroid Build Coastguard Worker         return android::base::StartsWith(packageAndVersion, prefix);
111*4d7e907cSAndroid Build Coastguard Worker     };
112*4d7e907cSAndroid Build Coastguard Worker 
113*4d7e907cSAndroid Build Coastguard Worker     // Only check packageAndVersions that are in the include list and not in the exclude list.
114*4d7e907cSAndroid Build Coastguard Worker     if (!std::any_of(included_prefixes.begin(), included_prefixes.end(), package_has_prefix)) {
115*4d7e907cSAndroid Build Coastguard Worker         return false;
116*4d7e907cSAndroid Build Coastguard Worker     }
117*4d7e907cSAndroid Build Coastguard Worker 
118*4d7e907cSAndroid Build Coastguard Worker     if (std::find(excluded_exact.begin(), excluded_exact.end(), packageAndVersion) !=
119*4d7e907cSAndroid Build Coastguard Worker         excluded_exact.end()) {
120*4d7e907cSAndroid Build Coastguard Worker         return false;
121*4d7e907cSAndroid Build Coastguard Worker     }
122*4d7e907cSAndroid Build Coastguard Worker 
123*4d7e907cSAndroid Build Coastguard Worker     return !std::any_of(excluded_prefixes.begin(), excluded_prefixes.end(), package_has_prefix);
124*4d7e907cSAndroid Build Coastguard Worker }
125*4d7e907cSAndroid Build Coastguard Worker 
126*4d7e907cSAndroid Build Coastguard Worker // The predicate to VintfObject::checkMissingHalsInMatrices.
ShouldCheckMissingAidlHalsInFcm(const std::string & packageAndVersion)127*4d7e907cSAndroid Build Coastguard Worker bool ShouldCheckMissingAidlHalsInFcm(const std::string& packageAndVersion) {
128*4d7e907cSAndroid Build Coastguard Worker     static std::vector<std::string> included_prefixes{
129*4d7e907cSAndroid Build Coastguard Worker             // Other AOSP HALs (e.g. android.frameworks.*) are not added because only framework
130*4d7e907cSAndroid Build Coastguard Worker             // matrix is checked.
131*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.",
132*4d7e907cSAndroid Build Coastguard Worker     };
133*4d7e907cSAndroid Build Coastguard Worker 
134*4d7e907cSAndroid Build Coastguard Worker     static std::vector<std::string> excluded_prefixes{
135*4d7e907cSAndroid Build Coastguard Worker             // Packages without top level interfaces (including types-only packages) are exempted.
136*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.audio.common@",
137*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.biometrics.common@",
138*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.camera.metadata@",
139*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.camera.device@",
140*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.camera.common@",
141*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.common@",
142*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.common.fmq@",
143*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.gnss.gnss_assistance@",
144*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.gnss.measurement_corrections@",
145*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.gnss.visibility_control@",
146*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.graphics.common@",
147*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.input.common@",
148*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.keymaster@",
149*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.media.bufferpool2@",
150*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.radio@",
151*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.uwb.fira_android@",
152*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.wifi.common@",
153*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.biometrics.fingerprint.virtualhal@",
154*4d7e907cSAndroid Build Coastguard Worker 
155*4d7e907cSAndroid Build Coastguard Worker             // Test packages are exempted.
156*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.tests.",
157*4d7e907cSAndroid Build Coastguard Worker 
158*4d7e907cSAndroid Build Coastguard Worker             // Fastboot HAL is only used by recovery. Recovery is owned by OEM. Framework
159*4d7e907cSAndroid Build Coastguard Worker             // does not depend on this HAL, hence it is not declared in any manifests or matrices.
160*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.fastboot@",
161*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.security.see.hwcrypto.types",
162*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.security.see.storage",
163*4d7e907cSAndroid Build Coastguard Worker     };
164*4d7e907cSAndroid Build Coastguard Worker 
165*4d7e907cSAndroid Build Coastguard Worker     static std::vector<std::string> excluded_exact{
166*4d7e907cSAndroid Build Coastguard Worker             // Packages without top level interfaces (including types-only packages) are exempted.
167*4d7e907cSAndroid Build Coastguard Worker 
168*4d7e907cSAndroid Build Coastguard Worker             // AIDL
169*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.audio.core.sounddose@1",
170*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.audio.core.sounddose@2",
171*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.audio.core.sounddose@3",
172*4d7e907cSAndroid Build Coastguard Worker             // This is only used by a trusty VM
173*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.security.see.authmgr@1",
174*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.security.see.hdcp@1",
175*4d7e907cSAndroid Build Coastguard Worker 
176*4d7e907cSAndroid Build Coastguard Worker             // Deprecated HALs.
177*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.audio.sounddose@3",
178*4d7e907cSAndroid Build Coastguard Worker             "android.hardware.bluetooth.audio@1",
179*4d7e907cSAndroid Build Coastguard Worker     };
180*4d7e907cSAndroid Build Coastguard Worker 
181*4d7e907cSAndroid Build Coastguard Worker     auto package_has_prefix = [&](const std::string& prefix) {
182*4d7e907cSAndroid Build Coastguard Worker         return android::base::StartsWith(packageAndVersion, prefix);
183*4d7e907cSAndroid Build Coastguard Worker     };
184*4d7e907cSAndroid Build Coastguard Worker 
185*4d7e907cSAndroid Build Coastguard Worker     // Only check packageAndVersions that are in the include list and not in the exclude list.
186*4d7e907cSAndroid Build Coastguard Worker     if (!std::any_of(included_prefixes.begin(), included_prefixes.end(), package_has_prefix)) {
187*4d7e907cSAndroid Build Coastguard Worker         return false;
188*4d7e907cSAndroid Build Coastguard Worker     }
189*4d7e907cSAndroid Build Coastguard Worker 
190*4d7e907cSAndroid Build Coastguard Worker     if (std::find(excluded_exact.begin(), excluded_exact.end(), packageAndVersion) !=
191*4d7e907cSAndroid Build Coastguard Worker         excluded_exact.end()) {
192*4d7e907cSAndroid Build Coastguard Worker         return false;
193*4d7e907cSAndroid Build Coastguard Worker     }
194*4d7e907cSAndroid Build Coastguard Worker 
195*4d7e907cSAndroid Build Coastguard Worker     return !std::any_of(excluded_prefixes.begin(), excluded_prefixes.end(), package_has_prefix);
196*4d7e907cSAndroid Build Coastguard Worker }
197*4d7e907cSAndroid Build Coastguard Worker 
198*4d7e907cSAndroid Build Coastguard Worker }  // namespace android::vintf::details
199