• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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 #include <functional>
18 #include <string>
19 #include <vector>
20 
21 #include <android-base/strings.h>
22 #include <vintf/fcm_exclude.h>
23 
24 namespace android::vintf::details {
25 
26 // The predicate to VintfObject::checkMissingHalsInMatrices.
ShouldCheckMissingHidlHalsInFcm(const std::string & packageAndVersion)27 bool ShouldCheckMissingHidlHalsInFcm(const std::string& packageAndVersion) {
28     static std::vector<std::string> included_prefixes{
29             // Other AOSP HALs (e.g. android.frameworks.*) are not added because only framework
30             // matrix is checked.
31             "android.hardware.",
32     };
33 
34     static std::vector<std::string> excluded_prefixes{
35             // Packages without top level interfaces (including types-only packages) are exempted.
36             "android.hardware.camera.device@",
37             "android.hardware.gnss.measurement_corrections@1.",
38             "android.hardware.graphics.bufferqueue@",
39 
40             // Test packages are exempted.
41             "android.hardware.tests.",
42     };
43 
44     static std::vector<std::string> excluded_exact{
45             // Packages without top level interfaces (including types-only packages) are exempted.
46             // HIDL
47             "android.hardware.cas.native@1.0",
48             "android.hardware.gnss.visibility_control@1.0",
49             "android.hardware.media.bufferpool@1.0",
50             "android.hardware.media.bufferpool@2.0",
51             "android.hardware.radio.config@1.2",
52 
53             // Fastboot HAL is only used by recovery. Recovery is owned by OEM. Framework
54             // does not depend on this HAL, hence it is not declared in any manifests or matrices.
55             "android.hardware.fastboot@1.0",
56             "android.hardware.fastboot@1.1",
57 
58             // Deprecated HALs.
59             // HIDL
60             // TODO(b/171260360) Remove when HAL definition is removed
61             "android.hardware.audio.effect@2.0",
62             "android.hardware.audio@2.0",
63             // Health 1.0 HAL is deprecated. The top level interface are deleted.
64             "android.hardware.health@1.0",
65             // TODO(b/171260670) Remove when HAL definition is removed
66             "android.hardware.nfc@1.0",
67             // TODO(b/171260715) Remove when HAL definition is removed
68             "android.hardware.radio.deprecated@1.0",
69 
70             // TODO(b/205175891): File individual bugs for these HALs deprecated in P
71             "android.hardware.audio.effect@4.0",
72             "android.hardware.audio@4.0",
73             "android.hardware.bluetooth.a2dp@1.0",
74             "android.hardware.cas@1.0",
75             "android.hardware.configstore@1.0",
76             "android.hardware.gnss@1.0",
77             "android.hardware.gnss@1.1",
78             "android.hardware.graphics.mapper@2.0",
79             "android.hardware.nfc@1.1",
80             "android.hardware.radio.config@1.0",
81             "android.hardware.radio@1.0",
82             "android.hardware.radio@1.1",
83             "android.hardware.radio@1.3",
84             "android.hardware.thermal@1.0",
85             "android.hardware.thermal@1.1",
86             "android.hardware.wifi.offload@1.0",
87 
88             // b/279809679 for HALS deprecated in Q
89             "android.hardware.audio.effect@5.0",
90             "android.hardware.audio@5.0",
91             "android.hardware.boot@1.0",
92             "android.hardware.configstore@1.1",
93             "android.hardware.drm@1.0",
94             "android.hardware.drm@1.1",
95             "android.hardware.drm@1.2",
96             "android.hardware.dumpstate@1.0",
97             "android.hardware.health@2.0",
98             "android.hardware.light@2.0",
99             "android.hardware.power@1.0",
100             "android.hardware.power@1.1",
101             "android.hardware.power@1.2",
102             "android.hardware.power@1.3",
103             "android.hardware.vibrator@1.0",
104             "android.hardware.vibrator@1.1",
105             "android.hardware.vibrator@1.2",
106             "android.hardware.vibrator@1.3",
107 
108             // b/392700935 for HALs deprecated in R
109             "android.hardware.automotive.audiocontrol@1.0",
110             "android.hardware.automotive.audiocontrol@2.0",
111             "android.hardware.boot@1.1",
112             "android.hardware.contexthub@1.0",
113             "android.hardware.contexthub@1.1",
114             "android.hardware.health.storage@1.0",
115             "android.hardware.memtrack@1.0",
116             "android.hardware.power.stats@1.0",
117             "android.hardware.radio@1.4",
118             "android.hardware.radio@1.5",
119             "android.hardware.soundtrigger@2.0",
120             "android.hardware.soundtrigger@2.1",
121             "android.hardware.soundtrigger@2.2",
122             "android.hardware.tetheroffload.control@1.0",
123             "android.hardware.vr@1.0",
124             "android.hardware.wifi.supplicant@1.0",
125             "android.hardware.wifi.supplicant@1.1",
126             "android.hardware.wifi@1.0",
127             "android.hardware.wifi@1.1",
128             "android.hardware.wifi@1.2",
129     };
130 
131     auto package_has_prefix = [&](const std::string& prefix) {
132         return android::base::StartsWith(packageAndVersion, prefix);
133     };
134 
135     // Only check packageAndVersions that are in the include list and not in the exclude list.
136     if (!std::any_of(included_prefixes.begin(), included_prefixes.end(), package_has_prefix)) {
137         return false;
138     }
139 
140     if (std::find(excluded_exact.begin(), excluded_exact.end(), packageAndVersion) !=
141         excluded_exact.end()) {
142         return false;
143     }
144 
145     return !std::any_of(excluded_prefixes.begin(), excluded_prefixes.end(), package_has_prefix);
146 }
147 
148 // The predicate to VintfObject::checkMissingHalsInMatrices.
ShouldCheckMissingAidlHalsInFcm(const std::string & packageAndVersion)149 bool ShouldCheckMissingAidlHalsInFcm(const std::string& packageAndVersion) {
150     static std::vector<std::string> included_prefixes{
151             // Other AOSP HALs (e.g. android.frameworks.*) are not added because only framework
152             // matrix is checked.
153             "android.hardware.",
154     };
155 
156     static std::vector<std::string> excluded_prefixes{
157             // Packages without top level interfaces (including types-only packages) are exempted.
158             "android.hardware.audio.common@",
159             "android.hardware.biometrics.common@",
160             "android.hardware.camera.metadata@",
161             "android.hardware.camera.device@",
162             "android.hardware.camera.common@",
163             "android.hardware.common@",
164             "android.hardware.common.fmq@",
165             "android.hardware.gnss.gnss_assistance@",
166             "android.hardware.gnss.measurement_corrections@",
167             "android.hardware.gnss.visibility_control@",
168             "android.hardware.graphics.common@",
169             "android.hardware.input.common@",
170             "android.hardware.keymaster@",
171             "android.hardware.media.bufferpool2@",
172             "android.hardware.radio@",
173             "android.hardware.uwb.fira_android@",
174             "android.hardware.wifi.common@",
175             "android.hardware.biometrics.fingerprint.virtualhal@",
176 
177             // Test packages are exempted.
178             "android.hardware.tests.",
179 
180             // Fastboot HAL is only used by recovery. Recovery is owned by OEM. Framework
181             // does not depend on this HAL, hence it is not declared in any manifests or matrices.
182             "android.hardware.fastboot@",
183             "android.hardware.security.see.hwcrypto.types",
184             "android.hardware.security.see.storage",
185     };
186 
187     static std::vector<std::string> excluded_exact{
188             // Packages without top level interfaces (including types-only packages) are exempted.
189 
190             // AIDL
191             "android.hardware.audio.core.sounddose@1",
192             "android.hardware.audio.core.sounddose@2",
193             "android.hardware.audio.core.sounddose@3",
194             // This is only used by a trusty VM
195             "android.hardware.security.see.authmgr@1",
196             "android.hardware.security.see.hdcp@1",
197 
198             // Deprecated HALs.
199             "android.hardware.audio.sounddose@3",
200             "android.hardware.bluetooth.audio@1",
201     };
202 
203     auto package_has_prefix = [&](const std::string& prefix) {
204         return android::base::StartsWith(packageAndVersion, prefix);
205     };
206 
207     // Only check packageAndVersions that are in the include list and not in the exclude list.
208     if (!std::any_of(included_prefixes.begin(), included_prefixes.end(), package_has_prefix)) {
209         return false;
210     }
211 
212     if (std::find(excluded_exact.begin(), excluded_exact.end(), packageAndVersion) !=
213         excluded_exact.end()) {
214         return false;
215     }
216 
217     return !std::any_of(excluded_prefixes.begin(), excluded_prefixes.end(), package_has_prefix);
218 }
219 
220 }  // namespace android::vintf::details
221