Stop serving HIDL media.c2 software instance in 202404 devices
New launching devices targeting 202404 vendor interface will not use
HIDL, so mediaserver can stop serving it.
max-level="8" means that the entry is removed from the manifest on
devices targeting vendor interfaces after 8 (Android U), so
hwservicemanager will now prevent it from being registered on those
devices.
Mediaserver checks to see if the HIDL service is declared, if it is
declared then it throws an error when there is an issue with registering
the service with hwservicemanager. If it is not declared, it does not
try to register the service.
Test: atest CtsMediaCodecTestCases
Bug: 218588089
Change-Id: I97858271ef60e4c11e4fce28acc68439b31a49ec
diff --git a/media/mediaserver/manifest_media_c2_software.xml b/media/mediaserver/manifest_media_c2_software.xml
index d7fb1a0..31dfafb 100644
--- a/media/mediaserver/manifest_media_c2_software.xml
+++ b/media/mediaserver/manifest_media_c2_software.xml
@@ -1,5 +1,5 @@
<manifest version="1.0" type="framework">
- <hal>
+ <hal format="hidl" max-level="8">
<name>android.hardware.media.c2</name>
<transport>hwbinder</transport>
<version>1.2</version>
diff --git a/media/module/codecserviceregistrant/CodecServiceRegistrant.cpp b/media/module/codecserviceregistrant/CodecServiceRegistrant.cpp
index f95fc4d..caf2524 100644
--- a/media/module/codecserviceregistrant/CodecServiceRegistrant.cpp
+++ b/media/module/codecserviceregistrant/CodecServiceRegistrant.cpp
@@ -25,6 +25,7 @@
#include <C2Component.h>
#include <C2PlatformSupport.h>
+#include <android/hidl/manager/1.2/IServiceManager.h>
#include <codec2/hidl/1.0/ComponentStore.h>
#include <codec2/hidl/1.1/ComponentStore.h>
#include <codec2/hidl/1.2/ComponentStore.h>
@@ -834,15 +835,26 @@
}
}
- if (!hidlStore) {
- hidlStore = ::android::sp<V1_2::utils::ComponentStore>::make(
- std::make_shared<H2C2ComponentStore>(nullptr));
- hidlVer = "1.2";
- }
- if (hidlStore->registerAsService("software") == android::OK) {
- registered = true;
+ // If the software component store isn't declared in the manifest, we don't
+ // need to create the service and register it.
+ using ::android::hidl::manager::V1_2::IServiceManager;
+ IServiceManager::Transport transport =
+ android::hardware::defaultServiceManager1_2()->getTransport(
+ V1_2::utils::ComponentStore::descriptor, "software");
+ if (transport == IServiceManager::Transport::HWBINDER) {
+ if (!hidlStore) {
+ hidlStore = ::android::sp<V1_2::utils::ComponentStore>::make(
+ std::make_shared<H2C2ComponentStore>(nullptr));
+ hidlVer = "1.2";
+ }
+ if (hidlStore->registerAsService("software") == android::OK) {
+ registered = true;
+ } else {
+ LOG(ERROR) << "Cannot register software Codec2 v" << hidlVer << " service.";
+ }
} else {
- LOG(ERROR) << "Cannot register software Codec2 v" << hidlVer << " service.";
+ LOG(INFO) << "The HIDL software Codec2 service is deprecated"
+ " so it is not being registered with hwservicemanager.";
}
if (registered) {