• 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 <string>
18 #include <vector>
19 
20 #include <android-base/strings.h>
21 #include <vintf/fcm_exclude.h>
22 
23 namespace android::vintf::details {
24 
25 // The predicate to VintfObject::checkMissingHalsInMatrices.
ShouldCheckMissingHalsInFcm(const std::string & package)26 bool 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{
36             // Packages without top level interfaces (including types-only packages) are exempted.
37             "android.hardware.camera.device@",
38             "android.hardware.gnss.measurement_corrections@1.",
39             "android.hardware.graphics.bufferqueue@",
40 
41             // Test packages are exempted.
42             "android.hardware.tests.",
43     };
44 
45     static std::vector<std::string> excluded_exact{
46             // 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",
50             "android.hardware.media.bufferpool@1.0",
51             "android.hardware.media.bufferpool@2.0",
52             "android.hardware.radio.config@1.2",
53             // AIDL
54             "android.hardware.audio.common",
55             "android.hardware.audio.core.sounddose",
56             "android.hardware.biometrics.common",
57             "android.hardware.camera.metadata",
58             "android.hardware.camera.device",
59             "android.hardware.camera.common",
60             "android.hardware.common",
61             "android.hardware.common.fmq",
62             "android.hardware.graphics.common",
63             "android.hardware.input.common",
64             "android.hardware.keymaster",
65             "android.hardware.media.bufferpool2",
66             "android.hardware.radio",
67             "android.hardware.threadnetwork",
68             "android.hardware.uwb.fira_android",
69 
70             // Fastboot HAL is only used by recovery. Recovery is owned by OEM. Framework
71             // does not depend on this HAL, hence it is not declared in any manifests or matrices.
72             "android.hardware.fastboot@1.0",
73             "android.hardware.fastboot@1.1",
74             // Fastboot AIDL
75             "android.hardware.fastboot",
76 
77             // Deprecated HALs.
78             // HIDL
79             // TODO(b/171260360) Remove when HAL definition is removed
80             "android.hardware.audio.effect@2.0",
81             "android.hardware.audio@2.0",
82             // Health 1.0 HAL is deprecated. The top level interface are deleted.
83             "android.hardware.health@1.0",
84             // TODO(b/171260670) Remove when HAL definition is removed
85             "android.hardware.nfc@1.0",
86             // TODO(b/171260715) Remove when HAL definition is removed
87             "android.hardware.radio.deprecated@1.0",
88 
89             // TODO(b/205175891): File individual bugs for these HALs deprecated in P
90             "android.hardware.audio.effect@4.0",
91             "android.hardware.audio@4.0",
92             "android.hardware.bluetooth.a2dp@1.0",
93             "android.hardware.cas@1.0",
94             "android.hardware.configstore@1.0",
95             "android.hardware.gnss@1.0",
96             "android.hardware.gnss@1.1",
97             "android.hardware.graphics.mapper@2.0",
98             "android.hardware.nfc@1.1",
99             "android.hardware.radio.config@1.0",
100             "android.hardware.radio@1.0",
101             "android.hardware.radio@1.1",
102             "android.hardware.radio@1.3",
103             "android.hardware.thermal@1.0",
104             "android.hardware.thermal@1.1",
105             "android.hardware.wifi.offload@1.0",
106 
107             // Under hardware/interfaces/staging, still in development
108             // AIDL
109             "android.hardware.media.c2",
110     };
111 
112     auto package_has_prefix = [&](const std::string& prefix) {
113         return android::base::StartsWith(package, prefix);
114     };
115 
116     // Only check packageAndVersions that are in the include list and not in the exclude list.
117     if (!std::any_of(included_prefixes.begin(), included_prefixes.end(), package_has_prefix)) {
118         return false;
119     }
120 
121     if (std::find(excluded_exact.begin(), excluded_exact.end(), package) != excluded_exact.end()) {
122         return false;
123     }
124 
125     return !std::any_of(excluded_prefixes.begin(), excluded_prefixes.end(), package_has_prefix);
126 }
127 
128 }  // namespace android::vintf::details
129