Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 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 | |
Ryan Prichard | c8fc80c | 2023-07-21 16:15:08 -0700 | [diff] [blame] | 17 | #include <functional> |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 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. |
Yifan Hong | 32f40c3 | 2023-08-01 15:13:45 -0700 | [diff] [blame] | 27 | bool ShouldCheckMissingHidlHalsInFcm(const std::string& packageAndVersion) { |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 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{ |
Yifan Hong | 113c60b | 2020-09-15 16:55:14 -0700 | [diff] [blame] | 35 | // Packages without top level interfaces (including types-only packages) are exempted. |
| 36 | "android.hardware.camera.device@", |
| 37 | "android.hardware.gnss.measurement_corrections@1.", |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 38 | "android.hardware.graphics.bufferqueue@", |
| 39 | |
Yifan Hong | 113c60b | 2020-09-15 16:55:14 -0700 | [diff] [blame] | 40 | // Test packages are exempted. |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 41 | "android.hardware.tests.", |
| 42 | }; |
| 43 | |
| 44 | static std::vector<std::string> excluded_exact{ |
Yifan Hong | 113c60b | 2020-09-15 16:55:14 -0700 | [diff] [blame] | 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", |
Yifan Hong | b7d29ee | 2020-09-15 16:55:53 -0700 | [diff] [blame] | 49 | "android.hardware.media.bufferpool@1.0", |
| 50 | "android.hardware.media.bufferpool@2.0", |
Yifan Hong | 113c60b | 2020-09-15 16:55:14 -0700 | [diff] [blame] | 51 | "android.hardware.radio.config@1.2", |
Yifan Hong | cd3d7cc | 2020-09-15 17:08:06 -0700 | [diff] [blame] | 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", |
josephjang | 72c410d | 2020-09-24 09:51:08 +0800 | [diff] [blame] | 56 | "android.hardware.fastboot@1.1", |
Yifan Hong | 6777f8a | 2020-10-20 19:28:34 +0000 | [diff] [blame] | 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", |
Yifan Hong | 01eb407 | 2021-01-29 17:57:41 -0800 | [diff] [blame] | 63 | // Health 1.0 HAL is deprecated. The top level interface are deleted. |
Yifan Hong | 6777f8a | 2020-10-20 19:28:34 +0000 | [diff] [blame] | 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", |
Yifan Hong | 909db8a | 2023-01-27 16:43:26 -0800 | [diff] [blame] | 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", |
Devin Moore | 7ad5797 | 2024-01-29 21:36:05 +0000 | [diff] [blame] | 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", |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | auto package_has_prefix = [&](const std::string& prefix) { |
Yifan Hong | 32f40c3 | 2023-08-01 15:13:45 -0700 | [diff] [blame] | 110 | 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 Hong | 68ed69d | 2023-08-01 15:32:49 -0700 | [diff] [blame] | 127 | bool ShouldCheckMissingAidlHalsInFcm(const std::string& packageAndVersion) { |
Yifan Hong | 32f40c3 | 2023-08-01 15:13:45 -0700 | [diff] [blame] | 128 | 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 Hong | 68ed69d | 2023-08-01 15:32:49 -0700 | [diff] [blame] | 135 | // 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 Hong | a3975a5 | 2023-08-01 12:20:12 -0700 | [diff] [blame] | 143 | "android.hardware.gnss.measurement_corrections@", |
| 144 | "android.hardware.gnss.visibility_control@", |
Yifan Hong | 68ed69d | 2023-08-01 15:32:49 -0700 | [diff] [blame] | 145 | "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 Biren | 7c79f70 | 2023-09-13 22:52:37 +0000 | [diff] [blame] | 151 | "android.hardware.wifi.common@", |
Yifan Hong | 68ed69d | 2023-08-01 15:32:49 -0700 | [diff] [blame] | 152 | |
Yifan Hong | 32f40c3 | 2023-08-01 15:13:45 -0700 | [diff] [blame] | 153 | // Test packages are exempted. |
| 154 | "android.hardware.tests.", |
Yifan Hong | 68ed69d | 2023-08-01 15:32:49 -0700 | [diff] [blame] | 155 | |
| 156 | // Fastboot HAL is only used by recovery. Recovery is owned by OEM. Framework |
| 157 | // does not depend on this HAL, hence it is not declared in any manifests or matrices. |
| 158 | "android.hardware.fastboot@", |
Weston Carvalho | c0df841 | 2024-11-12 13:19:56 -0600 | [diff] [blame] | 159 | "android.hardware.security.see.storage", |
Yifan Hong | 32f40c3 | 2023-08-01 15:13:45 -0700 | [diff] [blame] | 160 | }; |
| 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 Hong | 68ed69d | 2023-08-01 15:32:49 -0700 | [diff] [blame] | 166 | "android.hardware.audio.core.sounddose@1", |
Shunkai Yao | 0d52309 | 2023-10-10 19:26:07 +0000 | [diff] [blame] | 167 | "android.hardware.audio.core.sounddose@2", |
François Gaffie | dab7ab0 | 2024-06-26 18:13:56 +0000 | [diff] [blame] | 168 | "android.hardware.audio.core.sounddose@3", |
Hasini Gunasinghe | 46df15b | 2024-08-13 01:09:32 +0000 | [diff] [blame] | 169 | // This is only used by a trusty VM |
| 170 | "android.hardware.security.see.authmgr@1", |
Yifan Hong | 19d015a | 2023-08-01 15:35:34 -0700 | [diff] [blame] | 171 | |
| 172 | // Deprecated HALs. |
Vlad Popa | e2a71fb | 2024-08-20 23:31:33 +0000 | [diff] [blame] | 173 | "android.hardware.audio.sounddose@3", |
Yifan Hong | 19d015a | 2023-08-01 15:35:34 -0700 | [diff] [blame] | 174 | "android.hardware.bluetooth.audio@1", |
Yifan Hong | 32f40c3 | 2023-08-01 15:13:45 -0700 | [diff] [blame] | 175 | }; |
| 176 | |
| 177 | auto package_has_prefix = [&](const std::string& prefix) { |
Yifan Hong | 68ed69d | 2023-08-01 15:32:49 -0700 | [diff] [blame] | 178 | return android::base::StartsWith(packageAndVersion, prefix); |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 179 | }; |
| 180 | |
| 181 | // Only check packageAndVersions that are in the include list and not in the exclude list. |
| 182 | if (!std::any_of(included_prefixes.begin(), included_prefixes.end(), package_has_prefix)) { |
| 183 | return false; |
| 184 | } |
| 185 | |
Yifan Hong | 68ed69d | 2023-08-01 15:32:49 -0700 | [diff] [blame] | 186 | if (std::find(excluded_exact.begin(), excluded_exact.end(), packageAndVersion) != |
| 187 | excluded_exact.end()) { |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 188 | return false; |
| 189 | } |
| 190 | |
| 191 | return !std::any_of(excluded_prefixes.begin(), excluded_prefixes.end(), package_has_prefix); |
| 192 | } |
| 193 | |
| 194 | } // namespace android::vintf::details |