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{ |
| 46 | // TODO(b/110261831): reduce items in this list |
| 47 | "android.hardware.audio@7.0", |
| 48 | "android.hardware.audio.effect@7.0", |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 49 | "android.hardware.fastboot@1.0", |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 50 | "android.hardware.media.bufferpool@1.0", |
| 51 | "android.hardware.media.bufferpool@2.0", |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 52 | "android.hardware.tv.cec@2.0", |
| 53 | "android.hardware.tv.tuner@1.0", |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 54 | |
Yifan Hong | 113c60b | 2020-09-15 16:55:14 -0700 | [diff] [blame] | 55 | // Packages without top level interfaces (including types-only packages) are exempted. |
| 56 | // HIDL |
| 57 | "android.hardware.cas.native@1.0", |
| 58 | "android.hardware.gnss.visibility_control@1.0", |
| 59 | "android.hardware.radio.config@1.2", |
| 60 | // AIDL |
Kevin Chyn | 7d3fdf5 | 2020-09-15 13:01:40 -0700 | [diff] [blame^] | 61 | "android.hardware.biometrics.common", |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 62 | "android.hardware.common", |
| 63 | "android.hardware.graphics.common", |
Yifan Hong | 113c60b | 2020-09-15 16:55:14 -0700 | [diff] [blame] | 64 | "android.hardware.keymaster", |
Yifan Hong | 4c00d8e | 2020-09-10 18:40:14 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | auto package_has_prefix = [&](const std::string& prefix) { |
| 68 | return android::base::StartsWith(package, prefix); |
| 69 | }; |
| 70 | |
| 71 | // Only check packageAndVersions that are in the include list and not in the exclude list. |
| 72 | if (!std::any_of(included_prefixes.begin(), included_prefixes.end(), package_has_prefix)) { |
| 73 | return false; |
| 74 | } |
| 75 | |
| 76 | if (std::find(excluded_exact.begin(), excluded_exact.end(), package) != excluded_exact.end()) { |
| 77 | return false; |
| 78 | } |
| 79 | |
| 80 | return !std::any_of(excluded_prefixes.begin(), excluded_prefixes.end(), package_has_prefix); |
| 81 | } |
| 82 | |
| 83 | } // namespace android::vintf::details |