blob: e7a31e626aeda5758af34dae175da555f0fbb66a [file] [log] [blame]
Yifan Hong4c00d8e2020-09-10 18:40:14 -07001/*
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
Ryan Prichardc8fc80c2023-07-21 16:15:08 -070017#include <functional>
Yifan Hong4c00d8e2020-09-10 18:40:14 -070018#include <string>
19#include <vector>
20
21#include <android-base/strings.h>
22#include <vintf/fcm_exclude.h>
23
24namespace android::vintf::details {
25
26// The predicate to VintfObject::checkMissingHalsInMatrices.
Yifan Hong32f40c32023-08-01 15:13:45 -070027bool ShouldCheckMissingHidlHalsInFcm(const std::string& packageAndVersion) {
Yifan Hong4c00d8e2020-09-10 18:40:14 -070028 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{
Yifan Hong113c60b2020-09-15 16:55:14 -070035 // Packages without top level interfaces (including types-only packages) are exempted.
36 "android.hardware.camera.device@",
37 "android.hardware.gnss.measurement_corrections@1.",
Yifan Hong4c00d8e2020-09-10 18:40:14 -070038 "android.hardware.graphics.bufferqueue@",
39
Yifan Hong113c60b2020-09-15 16:55:14 -070040 // Test packages are exempted.
Yifan Hong4c00d8e2020-09-10 18:40:14 -070041 "android.hardware.tests.",
42 };
43
44 static std::vector<std::string> excluded_exact{
Yifan Hong113c60b2020-09-15 16:55:14 -070045 // 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",
Yifan Hongb7d29ee2020-09-15 16:55:53 -070049 "android.hardware.media.bufferpool@1.0",
50 "android.hardware.media.bufferpool@2.0",
Yifan Hong113c60b2020-09-15 16:55:14 -070051 "android.hardware.radio.config@1.2",
Yifan Hongcd3d7cc2020-09-15 17:08:06 -070052
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",
josephjang72c410d2020-09-24 09:51:08 +080056 "android.hardware.fastboot@1.1",
Yifan Hong6777f8a2020-10-20 19:28:34 +000057
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",
Yifan Hong01eb4072021-01-29 17:57:41 -080063 // Health 1.0 HAL is deprecated. The top level interface are deleted.
Yifan Hong6777f8a2020-10-20 19:28:34 +000064 "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",
Yifan Hong909db8a2023-01-27 16:43:26 -080069
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",
Devin Moore7ad57972024-01-29 21:36:05 +000087
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",
Yifan Hong4c00d8e2020-09-10 18:40:14 -0700107 };
108
109 auto package_has_prefix = [&](const std::string& prefix) {
Yifan Hong32f40c32023-08-01 15:13:45 -0700110 return android::base::StartsWith(packageAndVersion, prefix);
111 };
112
113 // Only check packageAndVersions that are in the include list and not in the exclude list.
114 if (!std::any_of(included_prefixes.begin(), included_prefixes.end(), package_has_prefix)) {
115 return false;
116 }
117
118 if (std::find(excluded_exact.begin(), excluded_exact.end(), packageAndVersion) !=
119 excluded_exact.end()) {
120 return false;
121 }
122
123 return !std::any_of(excluded_prefixes.begin(), excluded_prefixes.end(), package_has_prefix);
124}
125
126// The predicate to VintfObject::checkMissingHalsInMatrices.
Yifan Hong68ed69d2023-08-01 15:32:49 -0700127bool ShouldCheckMissingAidlHalsInFcm(const std::string& packageAndVersion) {
Yifan Hong32f40c32023-08-01 15:13:45 -0700128 static std::vector<std::string> included_prefixes{
129 // Other AOSP HALs (e.g. android.frameworks.*) are not added because only framework
130 // matrix is checked.
131 "android.hardware.",
132 };
133
134 static std::vector<std::string> excluded_prefixes{
Yifan Hong68ed69d2023-08-01 15:32:49 -0700135 // Packages without top level interfaces (including types-only packages) are exempted.
136 "android.hardware.audio.common@",
137 "android.hardware.biometrics.common@",
138 "android.hardware.camera.metadata@",
139 "android.hardware.camera.device@",
140 "android.hardware.camera.common@",
141 "android.hardware.common@",
142 "android.hardware.common.fmq@",
Yifan Honga3975a52023-08-01 12:20:12 -0700143 "android.hardware.gnss.measurement_corrections@",
144 "android.hardware.gnss.visibility_control@",
Yifan Hong68ed69d2023-08-01 15:32:49 -0700145 "android.hardware.graphics.common@",
146 "android.hardware.input.common@",
147 "android.hardware.keymaster@",
148 "android.hardware.media.bufferpool2@",
149 "android.hardware.radio@",
150 "android.hardware.uwb.fira_android@",
Gabriel Biren7c79f702023-09-13 22:52:37 +0000151 "android.hardware.wifi.common@",
Jeff Pue0263c42024-07-17 12:33:29 -0400152 "android.hardware.biometrics.fingerprint.virtualhal@",
Yifan Hong68ed69d2023-08-01 15:32:49 -0700153
Yifan Hong32f40c32023-08-01 15:13:45 -0700154 // Test packages are exempted.
155 "android.hardware.tests.",
Yifan Hong68ed69d2023-08-01 15:32:49 -0700156
157 // Fastboot HAL is only used by recovery. Recovery is owned by OEM. Framework
158 // does not depend on this HAL, hence it is not declared in any manifests or matrices.
159 "android.hardware.fastboot@",
Yifan Hong32f40c32023-08-01 15:13:45 -0700160 };
161
162 static std::vector<std::string> excluded_exact{
163 // Packages without top level interfaces (including types-only packages) are exempted.
164
165 // AIDL
Yifan Hong68ed69d2023-08-01 15:32:49 -0700166 "android.hardware.audio.core.sounddose@1",
Shunkai Yao0d523092023-10-10 19:26:07 +0000167 "android.hardware.audio.core.sounddose@2",
François Gaffiedab7ab02024-06-26 18:13:56 +0000168 "android.hardware.audio.core.sounddose@3",
Yifan Hong19d015a2023-08-01 15:35:34 -0700169
170 // Deprecated HALs.
Vlad Popae2a71fb2024-08-20 23:31:33 +0000171 "android.hardware.audio.sounddose@3",
Yifan Hong19d015a2023-08-01 15:35:34 -0700172 "android.hardware.bluetooth.audio@1",
Yifan Hong32f40c32023-08-01 15:13:45 -0700173 };
174
175 auto package_has_prefix = [&](const std::string& prefix) {
Yifan Hong68ed69d2023-08-01 15:32:49 -0700176 return android::base::StartsWith(packageAndVersion, prefix);
Yifan Hong4c00d8e2020-09-10 18:40:14 -0700177 };
178
179 // Only check packageAndVersions that are in the include list and not in the exclude list.
180 if (!std::any_of(included_prefixes.begin(), included_prefixes.end(), package_has_prefix)) {
181 return false;
182 }
183
Yifan Hong68ed69d2023-08-01 15:32:49 -0700184 if (std::find(excluded_exact.begin(), excluded_exact.end(), packageAndVersion) !=
185 excluded_exact.end()) {
Yifan Hong4c00d8e2020-09-10 18:40:14 -0700186 return false;
187 }
188
189 return !std::any_of(excluded_prefixes.begin(), excluded_prefixes.end(), package_has_prefix);
190}
191
192} // namespace android::vintf::details