From 32f40c34ef9468f2b431ff5f116771b9787f8b15 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Tue, 1 Aug 2023 15:13:45 -0700 Subject: [PATCH] fcm_exclude: split HIDL and AIDL predicate. AIDL is going to have a new format in fcm_exclude: android.hardware.foo@1. This cannot be excluded properly when mixing with HIDL, so split. Test: TH Bug: 255383566 Change-Id: I3df9517f12b62f5112df307528d5c3deab12cfa0 --- .../exclude/fcm_exclude.cpp | 75 ++++++++++++++----- .../exclude/include/vintf/fcm_exclude.h | 3 +- 2 files changed, 57 insertions(+), 21 deletions(-) diff --git a/compatibility_matrices/exclude/fcm_exclude.cpp b/compatibility_matrices/exclude/fcm_exclude.cpp index ccce449387..cfc8345922 100644 --- a/compatibility_matrices/exclude/fcm_exclude.cpp +++ b/compatibility_matrices/exclude/fcm_exclude.cpp @@ -24,9 +24,7 @@ namespace android::vintf::details { // The predicate to VintfObject::checkMissingHalsInMatrices. -bool ShouldCheckMissingHalsInFcm(const std::string& package) { - using std::placeholders::_1; - +bool ShouldCheckMissingHidlHalsInFcm(const std::string& packageAndVersion) { static std::vector included_prefixes{ // Other AOSP HALs (e.g. android.frameworks.*) are not added because only framework // matrix is checked. @@ -51,28 +49,11 @@ bool ShouldCheckMissingHalsInFcm(const std::string& package) { "android.hardware.media.bufferpool@1.0", "android.hardware.media.bufferpool@2.0", "android.hardware.radio.config@1.2", - // AIDL - "android.hardware.audio.common", - "android.hardware.audio.core.sounddose", - "android.hardware.biometrics.common", - "android.hardware.camera.metadata", - "android.hardware.camera.device", - "android.hardware.camera.common", - "android.hardware.common", - "android.hardware.common.fmq", - "android.hardware.graphics.common", - "android.hardware.input.common", - "android.hardware.keymaster", - "android.hardware.media.bufferpool2", - "android.hardware.radio", - "android.hardware.uwb.fira_android", // Fastboot HAL is only used by recovery. Recovery is owned by OEM. Framework // does not depend on this HAL, hence it is not declared in any manifests or matrices. "android.hardware.fastboot@1.0", "android.hardware.fastboot@1.1", - // Fastboot AIDL - "android.hardware.fastboot", // Deprecated HALs. // HIDL @@ -105,6 +86,60 @@ bool ShouldCheckMissingHalsInFcm(const std::string& package) { "android.hardware.wifi.offload@1.0", }; + auto package_has_prefix = [&](const std::string& prefix) { + return android::base::StartsWith(packageAndVersion, prefix); + }; + + // Only check packageAndVersions that are in the include list and not in the exclude list. + if (!std::any_of(included_prefixes.begin(), included_prefixes.end(), package_has_prefix)) { + return false; + } + + if (std::find(excluded_exact.begin(), excluded_exact.end(), packageAndVersion) != + excluded_exact.end()) { + return false; + } + + return !std::any_of(excluded_prefixes.begin(), excluded_prefixes.end(), package_has_prefix); +} + +// The predicate to VintfObject::checkMissingHalsInMatrices. +bool ShouldCheckMissingAidlHalsInFcm(const std::string& package) { + static std::vector included_prefixes{ + // Other AOSP HALs (e.g. android.frameworks.*) are not added because only framework + // matrix is checked. + "android.hardware.", + }; + + static std::vector excluded_prefixes{ + // Test packages are exempted. + "android.hardware.tests.", + }; + + static std::vector excluded_exact{ + // Packages without top level interfaces (including types-only packages) are exempted. + + // AIDL + "android.hardware.audio.common", + "android.hardware.audio.core.sounddose", + "android.hardware.biometrics.common", + "android.hardware.camera.metadata", + "android.hardware.camera.device", + "android.hardware.camera.common", + "android.hardware.common", + "android.hardware.common.fmq", + "android.hardware.graphics.common", + "android.hardware.input.common", + "android.hardware.keymaster", + "android.hardware.media.bufferpool2", + "android.hardware.radio", + "android.hardware.uwb.fira_android", + + // Fastboot HAL is only used by recovery. Recovery is owned by OEM. Framework + // does not depend on this HAL, hence it is not declared in any manifests or matrices. + "android.hardware.fastboot", + }; + auto package_has_prefix = [&](const std::string& prefix) { return android::base::StartsWith(package, prefix); }; diff --git a/compatibility_matrices/exclude/include/vintf/fcm_exclude.h b/compatibility_matrices/exclude/include/vintf/fcm_exclude.h index f74c2172e9..9ee057bb5d 100644 --- a/compatibility_matrices/exclude/include/vintf/fcm_exclude.h +++ b/compatibility_matrices/exclude/include/vintf/fcm_exclude.h @@ -25,6 +25,7 @@ namespace android::vintf::details { // |package| can be a HIDL package and version like // "android.hardware.foo@1.0", or an AIDL package name like // "android.hardware.foo". -bool ShouldCheckMissingHalsInFcm(const std::string& package); +bool ShouldCheckMissingHidlHalsInFcm(const std::string& packageAndVersion); +bool ShouldCheckMissingAidlHalsInFcm(const std::string& package); } // namespace android::vintf::details