Check Media c2 AIDL flag only for older devices
For new devices targeting 202404 vendor level, they must use AIDL, so we
shouldn't get the framework readiness on an aconfig flag for those
devices.
Cuttlefish is the only device targeting 202404 at this time.
Test: lunch aosp_cf_x86_64_phone-trunk-userdebug && launch_cvd
Test: make sure media C2 AIDL is being used
Test: lunch aosp_cf_x86_64_phone-next-userdebug && launch_cvd
Test: atest CtsMediaCodecTestCases
Bug: 218588089
Change-Id: I9358354ce4c710006034bf11fa4c04131714dfa7
diff --git a/media/codec2/hal/common/HalSelection.cpp b/media/codec2/hal/common/HalSelection.cpp
index 761a409..d3ea181 100644
--- a/media/codec2/hal/common/HalSelection.cpp
+++ b/media/codec2/hal/common/HalSelection.cpp
@@ -28,7 +28,12 @@
namespace android {
bool IsCodec2AidlHalSelected() {
- if (!com::android::media::codec::flags::provider_->aidl_hal()) {
+ // For new devices with vendor software targeting 202404, we always want to
+ // use AIDL if it exists
+ constexpr int kAndroidApi202404 = 202404;
+ int vendorVersion = ::android::base::GetIntProperty("ro.vendor.api_level", -1);
+ if (!com::android::media::codec::flags::provider_->aidl_hal() &&
+ vendorVersion < kAndroidApi202404) {
// Cannot select AIDL if not enabled
return false;
}