summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjimmy zhang <jimmyzhang6070@gmail.com>2023-02-23 09:42:11 +0800
committerjimmy zhang <jimmyzhang6070@gmail.com>2023-02-23 09:42:11 +0800
commit1a2b57cdcfa221a1aeccedd1d91fcb9f9f52f8df (patch)
tree1728dbc3ef5cd07a3b3e9277e0fc68f7ef581575
parenta0e019b29f2f68f14be254379eb47d731bec782a (diff)
downloadlibhidl-1a2b57cdcfa221a1aeccedd1d91fcb9f9f52f8df.tar.gz
vts_ibase_test: check transport to support hardware sku
To support hardware SKU, manufacturer may custom hardware sku vintf to /odm/etc/vintf/manifest_${ro.boot.hardware.sku}.xml, and then enable/disable hal service in rc file via hardware properties, e.g. update "/vendor/etc/init/android.hardware.camera.provider@2.4-external-service.rc" don't start vendor.camera-provider-2-4-ext if current SKU doesn't support USB camera. if a hal service is diabled in the current hardware SKU, vts_ibase_test will fail and alert "service is not running". so update vts_ibase_test to check transport from manifest, Don't assert if the interface that service declared is not in manifest. Bug ID: b/269974148 Test: vts -m vts_ibase_test Test: vts -m vts_treble_vintf_vendor_test Change-Id: I1f4ae300e78e063d1597fe24b49e78778c88b141
-rw-r--r--transport/base/1.0/vts/functional/vts_ibase_test.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/transport/base/1.0/vts/functional/vts_ibase_test.cpp b/transport/base/1.0/vts/functional/vts_ibase_test.cpp
index 6372631..96125d0 100644
--- a/transport/base/1.0/vts/functional/vts_ibase_test.cpp
+++ b/transport/base/1.0/vts/functional/vts_ibase_test.cpp
@@ -81,7 +81,7 @@ pid_t GetServiceDebugPid(const std::string& service) {
std::map<std::string, std::vector<Hal>> gDeclaredServiceHalMap;
std::mutex gDeclaredServiceHalMapMutex;
-void GetHal(const std::string& service, const FqInstance& instance) {
+void GetHal(const sp<IServiceManager> &manager, const std::string& service, const FqInstance& instance) {
if (instance.getFqName().string() == IBase::descriptor) {
return;
}
@@ -89,6 +89,23 @@ void GetHal(const std::string& service, const FqInstance& instance) {
sp<IBase> hal = android::hardware::details::getRawServiceInternal(
instance.getFqName().string(), instance.getInstance(), true /*retry*/,
false /*getStub*/);
+
+ // Check transport of manifest to support hardware SKU:
+ // Don't add service to gDeclaredServiceHalMap if hal instance is null and
+ // the transport of the declared interface is not present in manifest. Because
+ // manufacturer may disable this hal service in the current hardware SKU,
+ // but enable it in the other hardware SKU.
+ if (hal == nullptr && manager != nullptr) {
+ auto transport = manager->getTransport(instance.getFqName().string(),
+ instance.getInstance());
+ if(transport == IServiceManager::Transport::EMPTY){
+ LOG(WARNING)
+ << "Ignore, because Service '" << service << "' is not running,"
+ << " its interface '" << instance.string() << "' is not present in manifest.";
+ return;
+ }
+ }
+
// Add to gDeclaredServiceHalMap if getRawServiceInternal() returns (even if
// the returned HAL is null). getRawServiceInternal() won't return if the
// HAL is in the VINTF but unable to start.
@@ -235,6 +252,7 @@ TEST_F(VtsHalBaseV1_0TargetTest, ServiceProvidesAndDeclaresTheSameInterfaces) {
const Result<ServiceInterfacesMap> service_interfaces_map =
android::init::GetOnDeviceServiceInterfacesMap();
ASSERT_RESULT_OK(service_interfaces_map);
+ auto service_manager = ::android::hardware::defaultServiceManager();
std::map<std::string, std::set<FqInstance>> hidl_interfaces_map;
@@ -253,7 +271,7 @@ TEST_F(VtsHalBaseV1_0TargetTest, ServiceProvidesAndDeclaresTheSameInterfaces) {
ASSERT_TRUE(fqInstance.setTo(interface))
<< "Unable to parse interface: '" << interface << "'";
- std::thread(GetHal, service, fqInstance).detach();
+ std::thread(GetHal, service_manager, service, fqInstance).detach();
hidl_interfaces_map[service].insert(fqInstance);
}
}