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", |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | auto package_has_prefix = [&](const std::string& prefix) { |
Yifan Hong | 32f40c3 | 2023-08-01 15:13:45 -0700 | [diff] [blame] | 90 | 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 Hong | 68ed69d | 2023-08-01 15:32:49 -0700 | [diff] [blame] | 107 | bool ShouldCheckMissingAidlHalsInFcm(const std::string& packageAndVersion) { |
Yifan Hong | 32f40c3 | 2023-08-01 15:13:45 -0700 | [diff] [blame] | 108 | 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 Hong | 68ed69d | 2023-08-01 15:32:49 -0700 | [diff] [blame] | 115 | // 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 Hong | a3975a5 | 2023-08-01 12:20:12 -0700 | [diff] [blame^] | 123 | "android.hardware.gnss.measurement_corrections@", |
| 124 | "android.hardware.gnss.visibility_control@", |
Yifan Hong | 68ed69d | 2023-08-01 15:32:49 -0700 | [diff] [blame] | 125 | "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 Hong | 32f40c3 | 2023-08-01 15:13:45 -0700 | [diff] [blame] | 132 | // Test packages are exempted. |
| 133 | "android.hardware.tests.", |
Yifan Hong | 68ed69d | 2023-08-01 15:32:49 -0700 | [diff] [blame] | 134 | |
| 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 Hong | 32f40c3 | 2023-08-01 15:13:45 -0700 | [diff] [blame] | 138 | }; |
| 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 Hong | 68ed69d | 2023-08-01 15:32:49 -0700 | [diff] [blame] | 144 | "android.hardware.audio.core.sounddose@1", |
Yifan Hong | 32f40c3 | 2023-08-01 15:13:45 -0700 | [diff] [blame] | 145 | }; |
| 146 | |
| 147 | auto package_has_prefix = [&](const std::string& prefix) { |
Yifan Hong | 68ed69d | 2023-08-01 15:32:49 -0700 | [diff] [blame] | 148 | return android::base::StartsWith(packageAndVersion, prefix); |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 149 | }; |
| 150 | |
| 151 | // Only check packageAndVersions that are in the include list and not in the exclude list. |
| 152 | if (!std::any_of(included_prefixes.begin(), included_prefixes.end(), package_has_prefix)) { |
| 153 | return false; |
| 154 | } |
| 155 | |
Yifan Hong | 68ed69d | 2023-08-01 15:32:49 -0700 | [diff] [blame] | 156 | if (std::find(excluded_exact.begin(), excluded_exact.end(), packageAndVersion) != |
| 157 | excluded_exact.end()) { |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 158 | return false; |
| 159 | } |
| 160 | |
| 161 | return !std::any_of(excluded_prefixes.begin(), excluded_prefixes.end(), package_has_prefix); |
| 162 | } |
| 163 | |
| 164 | } // namespace android::vintf::details |