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 | |
| 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. |
| 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{ |
Yifan Hong | 113c60b | 2020-09-15 16:55:14 -0700 | [diff] [blame] | 36 | // Packages without top level interfaces (including types-only packages) are exempted. |
| 37 | "android.hardware.camera.device@", |
| 38 | "android.hardware.gnss.measurement_corrections@1.", |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 39 | "android.hardware.graphics.bufferqueue@", |
| 40 | |
Yifan Hong | 113c60b | 2020-09-15 16:55:14 -0700 | [diff] [blame] | 41 | // Test packages are exempted. |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 42 | "android.hardware.tests.", |
| 43 | }; |
| 44 | |
| 45 | static std::vector<std::string> excluded_exact{ |
Yifan Hong | 113c60b | 2020-09-15 16:55:14 -0700 | [diff] [blame] | 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", |
Yifan Hong | b7d29ee | 2020-09-15 16:55:53 -0700 | [diff] [blame] | 50 | "android.hardware.media.bufferpool@1.0", |
| 51 | "android.hardware.media.bufferpool@2.0", |
Yifan Hong | 113c60b | 2020-09-15 16:55:14 -0700 | [diff] [blame] | 52 | "android.hardware.radio.config@1.2", |
| 53 | // AIDL |
Mikhail Naganov | 32a8ef3 | 2021-10-26 14:00:00 -0700 | [diff] [blame] | 54 | "android.hardware.audio.common", |
Vlad Popa | 2afbd1e | 2022-12-28 17:04:58 +0100 | [diff] [blame] | 55 | "android.hardware.audio.core.sounddose", |
Kevin Chyn | 7d3fdf5 | 2020-09-15 13:01:40 -0700 | [diff] [blame] | 56 | "android.hardware.biometrics.common", |
Jayant Chowdhary | 33e7fef | 2021-11-03 12:06:08 -0700 | [diff] [blame] | 57 | "android.hardware.camera.metadata", |
Jayant Chowdhary | fd3b3c6 | 2021-11-03 12:23:41 -0700 | [diff] [blame] | 58 | "android.hardware.camera.device", |
Jayant Chowdhary | 0b0d733 | 2021-11-03 12:41:32 -0700 | [diff] [blame] | 59 | "android.hardware.camera.common", |
Jayant Chowdhary | fd3b3c6 | 2021-11-03 12:23:41 -0700 | [diff] [blame] | 60 | "android.hardware.common", |
Devin Moore | 23a52ec | 2020-10-09 13:37:12 -0700 | [diff] [blame] | 61 | "android.hardware.common.fmq", |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 62 | "android.hardware.graphics.common", |
Siarhei Vishniakou | 600e913 | 2022-01-07 16:27:22 -0800 | [diff] [blame] | 63 | "android.hardware.input.common", |
Yifan Hong | 113c60b | 2020-09-15 16:55:14 -0700 | [diff] [blame] | 64 | "android.hardware.keymaster", |
Sungtak Lee | 1468ddf | 2022-09-06 16:05:58 +0000 | [diff] [blame] | 65 | "android.hardware.media.bufferpool2", |
Sarah Chin | bd8e476 | 2021-09-20 13:45:18 -0700 | [diff] [blame] | 66 | "android.hardware.radio", |
Roshan Pius | f527f8f | 2021-10-12 09:45:28 -0700 | [diff] [blame] | 67 | "android.hardware.uwb.fira_android", |
Yifan Hong | cd3d7cc | 2020-09-15 17:08:06 -0700 | [diff] [blame] | 68 | |
| 69 | // Fastboot HAL is only used by recovery. Recovery is owned by OEM. Framework |
| 70 | // does not depend on this HAL, hence it is not declared in any manifests or matrices. |
| 71 | "android.hardware.fastboot@1.0", |
josephjang | 72c410d | 2020-09-24 09:51:08 +0800 | [diff] [blame] | 72 | "android.hardware.fastboot@1.1", |
Sandeep Dhavale | 7bc10fb | 2022-10-04 21:44:18 +0000 | [diff] [blame] | 73 | // Fastboot AIDL |
| 74 | "android.hardware.fastboot", |
Yifan Hong | 6777f8a | 2020-10-20 19:28:34 +0000 | [diff] [blame] | 75 | |
| 76 | // Deprecated HALs. |
| 77 | // HIDL |
| 78 | // TODO(b/171260360) Remove when HAL definition is removed |
| 79 | "android.hardware.audio.effect@2.0", |
| 80 | "android.hardware.audio@2.0", |
Yifan Hong | 01eb407 | 2021-01-29 17:57:41 -0800 | [diff] [blame] | 81 | // Health 1.0 HAL is deprecated. The top level interface are deleted. |
Yifan Hong | 6777f8a | 2020-10-20 19:28:34 +0000 | [diff] [blame] | 82 | "android.hardware.health@1.0", |
| 83 | // TODO(b/171260670) Remove when HAL definition is removed |
| 84 | "android.hardware.nfc@1.0", |
| 85 | // TODO(b/171260715) Remove when HAL definition is removed |
| 86 | "android.hardware.radio.deprecated@1.0", |
Yifan Hong | 909db8a | 2023-01-27 16:43:26 -0800 | [diff] [blame^] | 87 | |
| 88 | // TODO(b/205175891): File individual bugs for these HALs deprecated in P |
| 89 | "android.hardware.audio.effect@4.0", |
| 90 | "android.hardware.audio@4.0", |
| 91 | "android.hardware.bluetooth.a2dp@1.0", |
| 92 | "android.hardware.cas@1.0", |
| 93 | "android.hardware.configstore@1.0", |
| 94 | "android.hardware.gnss@1.0", |
| 95 | "android.hardware.gnss@1.1", |
| 96 | "android.hardware.graphics.mapper@2.0", |
| 97 | "android.hardware.nfc@1.1", |
| 98 | "android.hardware.radio.config@1.0", |
| 99 | "android.hardware.radio@1.0", |
| 100 | "android.hardware.radio@1.1", |
| 101 | "android.hardware.radio@1.3", |
| 102 | "android.hardware.thermal@1.0", |
| 103 | "android.hardware.thermal@1.1", |
| 104 | "android.hardware.wifi.offload@1.0", |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 105 | }; |
| 106 | |
| 107 | auto package_has_prefix = [&](const std::string& prefix) { |
| 108 | return android::base::StartsWith(package, prefix); |
| 109 | }; |
| 110 | |
| 111 | // Only check packageAndVersions that are in the include list and not in the exclude list. |
| 112 | if (!std::any_of(included_prefixes.begin(), included_prefixes.end(), package_has_prefix)) { |
| 113 | return false; |
| 114 | } |
| 115 | |
| 116 | if (std::find(excluded_exact.begin(), excluded_exact.end(), package) != excluded_exact.end()) { |
| 117 | return false; |
| 118 | } |
| 119 | |
| 120 | return !std::any_of(excluded_prefixes.begin(), excluded_prefixes.end(), package_has_prefix); |
| 121 | } |
| 122 | |
| 123 | } // namespace android::vintf::details |