Snap for 11889377 from 7b7f93d81f8ec0d7e7242b6960eb85d9339fcf47 to 24Q3-release Change-Id: I7d330b9562cac009271c4f011c508fe80e6b759c
diff --git a/treble/vintf/SingleManifestTest.cpp b/treble/vintf/SingleManifestTest.cpp index ed4219a..d47e768 100644 --- a/treble/vintf/SingleManifestTest.cpp +++ b/treble/vintf/SingleManifestTest.cpp
@@ -17,6 +17,7 @@ #include "SingleManifestTest.h" #include <aidl/metadata.h> +#include <android-base/file.h> #include <android-base/hex.h> #include <android-base/properties.h> #include <android-base/strings.h> @@ -41,6 +42,7 @@ using ::testing::AnyOf; using ::testing::Contains; +using ::testing::StartsWith; namespace android { namespace vintf { @@ -682,6 +684,19 @@ checkVintfExtensionInterfaces(extension, is_release); } +// This checks if @updatable-via-apex in VINTF is correct. +void checkVintfUpdatableViaApex(const sp<IBinder> &binder, + const std::string &apex_name) { + pid_t pid; + ASSERT_EQ(OK, binder->getDebugPid(&pid)); + + std::string exe; + ASSERT_TRUE(base::Readlink("/proc/" + std::to_string(pid) + "/exe", &exe)); + + // HAL service should start from the apex + ASSERT_THAT(exe, StartsWith("/apex/" + apex_name + "/")); +} + // An AIDL HAL with VINTF stability can only be registered if it is in the // manifest. However, we still must manually check that every declared HAL is // actually present on the device. @@ -768,6 +783,10 @@ if (GetBoardApiLevel() >= kAndroidApi202404) { checkVintfExtensionInterfaces(binder, is_release); } + + if (updatable_via_apex.has_value()) { + checkVintfUpdatableViaApex(binder, updatable_via_apex.value()); + } } // We don't want to add more same process HALs in Android. We have some 3rd