blob: d92c0b97a3eb6748f00a92fd7c5422483ddc0364 [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",
Yifan Hong4c00d8e2020-09-10 18:40:14 -070087 };
88
89 auto package_has_prefix = [&](const std::string& prefix) {
Yifan Hong32f40c32023-08-01 15:13:45 -070090 return android::base::StartsWith(packageAndVersion, prefix);
91 };
92
93 // Only check packageAndVersions that are in the include list and not in the exclude list.
94 if (!std::any_of(included_prefixes.begin(), included_prefixes.end(), package_has_prefix)) {
95 return false;
96 }
97
98 if (std::find(excluded_exact.begin(), excluded_exact.end(), packageAndVersion) !=
99 excluded_exact.end()) {
100 return false;
101 }
102
103 return !std::any_of(excluded_prefixes.begin(), excluded_prefixes.end(), package_has_prefix);
104}
105
106// The predicate to VintfObject::checkMissingHalsInMatrices.
Yifan Hong68ed69d2023-08-01 15:32:49 -0700107bool ShouldCheckMissingAidlHalsInFcm(const std::string& packageAndVersion) {
Yifan Hong32f40c32023-08-01 15:13:45 -0700108 static std::vector<std::string> included_prefixes{
109 // Other AOSP HALs (e.g. android.frameworks.*) are not added because only framework
110 // matrix is checked.
111 "android.hardware.",
112 };
113
114 static std::vector<std::string> excluded_prefixes{
Yifan Hong68ed69d2023-08-01 15:32:49 -0700115 // Packages without top level interfaces (including types-only packages) are exempted.
116 "android.hardware.audio.common@",
117 "android.hardware.biometrics.common@",
118 "android.hardware.camera.metadata@",
119 "android.hardware.camera.device@",
120 "android.hardware.camera.common@",
121 "android.hardware.common@",
122 "android.hardware.common.fmq@",
Yifan Honga3975a52023-08-01 12:20:12 -0700123 "android.hardware.gnss.measurement_corrections@",
124 "android.hardware.gnss.visibility_control@",
Yifan Hong68ed69d2023-08-01 15:32:49 -0700125 "android.hardware.graphics.common@",
126 "android.hardware.input.common@",
127 "android.hardware.keymaster@",
128 "android.hardware.media.bufferpool2@",
129 "android.hardware.radio@",
130 "android.hardware.uwb.fira_android@",
131
Yifan Hong32f40c32023-08-01 15:13:45 -0700132 // Test packages are exempted.
133 "android.hardware.tests.",
Yifan Hong68ed69d2023-08-01 15:32:49 -0700134
135 // Fastboot HAL is only used by recovery. Recovery is owned by OEM. Framework
136 // does not depend on this HAL, hence it is not declared in any manifests or matrices.
137 "android.hardware.fastboot@",
Yifan Hong32f40c32023-08-01 15:13:45 -0700138 };
139
140 static std::vector<std::string> excluded_exact{
141 // Packages without top level interfaces (including types-only packages) are exempted.
142
143 // AIDL
Yifan Hong68ed69d2023-08-01 15:32:49 -0700144 "android.hardware.audio.core.sounddose@1",
Yifan Hong19d015a2023-08-01 15:35:34 -0700145
146 // Deprecated HALs.
147 "android.hardware.bluetooth.audio@1",
Yifan Hong32f40c32023-08-01 15:13:45 -0700148 };
149
150 auto package_has_prefix = [&](const std::string& prefix) {
Yifan Hong68ed69d2023-08-01 15:32:49 -0700151 return android::base::StartsWith(packageAndVersion, prefix);
Yifan Hong4c00d8e2020-09-10 18:40:14 -0700152 };
153
154 // Only check packageAndVersions that are in the include list and not in the exclude list.
155 if (!std::any_of(included_prefixes.begin(), included_prefixes.end(), package_has_prefix)) {
156 return false;
157 }
158
Yifan Hong68ed69d2023-08-01 15:32:49 -0700159 if (std::find(excluded_exact.begin(), excluded_exact.end(), packageAndVersion) !=
160 excluded_exact.end()) {
Yifan Hong4c00d8e2020-09-10 18:40:14 -0700161 return false;
162 }
163
164 return !std::any_of(excluded_prefixes.begin(), excluded_prefixes.end(), package_has_prefix);
165}
166
167} // namespace android::vintf::details