blob: 8eed19532f55fbab629f9c5f865e2bec7d036ad0 [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
17#include <string>
18#include <vector>
19
20#include <android-base/strings.h>
21#include <vintf/fcm_exclude.h>
22
23namespace android::vintf::details {
24
25// The predicate to VintfObject::checkMissingHalsInMatrices.
26bool ShouldCheckMissingHalsInFcm(const std::string& package) {
27 using std::placeholders::_1;
28
29 static std::vector<std::string> included_prefixes{
30 // Other AOSP HALs (e.g. android.frameworks.*) are not added because only framework
31 // matrix is checked.
32 "android.hardware.",
33 };
34
35 static std::vector<std::string> excluded_prefixes{
Yifan Hong113c60b2020-09-15 16:55:14 -070036 // Packages without top level interfaces (including types-only packages) are exempted.
37 "android.hardware.camera.device@",
38 "android.hardware.gnss.measurement_corrections@1.",
Yifan Hong4c00d8e2020-09-10 18:40:14 -070039 "android.hardware.graphics.bufferqueue@",
40
Yifan Hong113c60b2020-09-15 16:55:14 -070041 // Test packages are exempted.
Yifan Hong4c00d8e2020-09-10 18:40:14 -070042 "android.hardware.tests.",
43 };
44
45 static std::vector<std::string> excluded_exact{
Yifan Hong113c60b2020-09-15 16:55:14 -070046 // Packages without top level interfaces (including types-only packages) are exempted.
47 // HIDL
48 "android.hardware.cas.native@1.0",
49 "android.hardware.gnss.visibility_control@1.0",
Yifan Hongb7d29ee2020-09-15 16:55:53 -070050 "android.hardware.media.bufferpool@1.0",
51 "android.hardware.media.bufferpool@2.0",
Yifan Hong113c60b2020-09-15 16:55:14 -070052 "android.hardware.radio.config@1.2",
53 // AIDL
Mikhail Naganov32a8ef32021-10-26 14:00:00 -070054 "android.hardware.audio.common",
Kevin Chyn7d3fdf52020-09-15 13:01:40 -070055 "android.hardware.biometrics.common",
Jayant Chowdhary33e7fef2021-11-03 12:06:08 -070056 "android.hardware.biometrics.common",
57 "android.hardware.camera.metadata",
Devin Moore23a52ec2020-10-09 13:37:12 -070058 "android.hardware.common.fmq",
Yifan Hong4c00d8e2020-09-10 18:40:14 -070059 "android.hardware.graphics.common",
Siarhei Vishniakou600e9132022-01-07 16:27:22 -080060 "android.hardware.input.common",
Yifan Hong113c60b2020-09-15 16:55:14 -070061 "android.hardware.keymaster",
Sarah Chinbd8e4762021-09-20 13:45:18 -070062 "android.hardware.radio",
Roshan Piusf527f8f2021-10-12 09:45:28 -070063 "android.hardware.uwb.fira_android",
Yifan Hongcd3d7cc2020-09-15 17:08:06 -070064
65 // Fastboot HAL is only used by recovery. Recovery is owned by OEM. Framework
66 // does not depend on this HAL, hence it is not declared in any manifests or matrices.
67 "android.hardware.fastboot@1.0",
josephjang72c410d2020-09-24 09:51:08 +080068 "android.hardware.fastboot@1.1",
Yifan Hong6777f8a2020-10-20 19:28:34 +000069
70 // Deprecated HALs.
71 // HIDL
72 // TODO(b/171260360) Remove when HAL definition is removed
73 "android.hardware.audio.effect@2.0",
74 "android.hardware.audio@2.0",
Yifan Hong01eb4072021-01-29 17:57:41 -080075 // Health 1.0 HAL is deprecated. The top level interface are deleted.
Yifan Hong6777f8a2020-10-20 19:28:34 +000076 "android.hardware.health@1.0",
77 // TODO(b/171260670) Remove when HAL definition is removed
78 "android.hardware.nfc@1.0",
79 // TODO(b/171260715) Remove when HAL definition is removed
80 "android.hardware.radio.deprecated@1.0",
Yifan Hong4c00d8e2020-09-10 18:40:14 -070081 };
82
83 auto package_has_prefix = [&](const std::string& prefix) {
84 return android::base::StartsWith(package, prefix);
85 };
86
87 // Only check packageAndVersions that are in the include list and not in the exclude list.
88 if (!std::any_of(included_prefixes.begin(), included_prefixes.end(), package_has_prefix)) {
89 return false;
90 }
91
92 if (std::find(excluded_exact.begin(), excluded_exact.end(), package) != excluded_exact.end()) {
93 return false;
94 }
95
96 return !std::any_of(excluded_prefixes.begin(), excluded_prefixes.end(), package_has_prefix);
97}
98
99} // namespace android::vintf::details