diff --git a/neuralnetworks/1.0/utils/Android.bp b/neuralnetworks/1.0/utils/Android.bp index 71a190e495..8c51c67421 100644 --- a/neuralnetworks/1.0/utils/Android.bp +++ b/neuralnetworks/1.0/utils/Android.bp @@ -49,7 +49,7 @@ cc_test { static_libs: [ "android.hardware.neuralnetworks@1.0", "libgmock", - "libneuralnetworks_common_hidl", + "libneuralnetworks_common", "neuralnetworks_types", "neuralnetworks_utils_hal_common", "neuralnetworks_utils_hal_1_0", diff --git a/neuralnetworks/1.0/vts/functional/Android.bp b/neuralnetworks/1.0/vts/functional/Android.bp index ae9ff0a795..b33c581a34 100644 --- a/neuralnetworks/1.0/vts/functional/Android.bp +++ b/neuralnetworks/1.0/vts/functional/Android.bp @@ -50,7 +50,7 @@ cc_library_static { "libgmock", "libhidlmemory", "libneuralnetworks_generated_test_harness", - "libneuralnetworks_common_hidl", + "libneuralnetworks_utils", ], header_libs: [ "libneuralnetworks_headers", @@ -81,7 +81,7 @@ cc_test { "libgmock", "libhidlmemory", "libneuralnetworks_generated_test_harness", - "libneuralnetworks_common_hidl", + "libneuralnetworks_utils", ], whole_static_libs: [ "neuralnetworks_generated_V1_0_example", diff --git a/neuralnetworks/1.1/utils/Android.bp b/neuralnetworks/1.1/utils/Android.bp index 478a7426d2..737ff58159 100644 --- a/neuralnetworks/1.1/utils/Android.bp +++ b/neuralnetworks/1.1/utils/Android.bp @@ -52,7 +52,7 @@ cc_test { "android.hardware.neuralnetworks@1.0", "android.hardware.neuralnetworks@1.1", "libgmock", - "libneuralnetworks_common_hidl", + "libneuralnetworks_common", "neuralnetworks_types", "neuralnetworks_utils_hal_common", "neuralnetworks_utils_hal_1_0", diff --git a/neuralnetworks/1.1/vts/functional/Android.bp b/neuralnetworks/1.1/vts/functional/Android.bp index 4c577882a7..c0011121d6 100644 --- a/neuralnetworks/1.1/vts/functional/Android.bp +++ b/neuralnetworks/1.1/vts/functional/Android.bp @@ -48,7 +48,7 @@ cc_test { "libgmock", "libhidlmemory", "libneuralnetworks_generated_test_harness", - "libneuralnetworks_common_hidl", + "libneuralnetworks_utils", ], whole_static_libs: [ "neuralnetworks_generated_V1_0_example", diff --git a/neuralnetworks/1.2/utils/Android.bp b/neuralnetworks/1.2/utils/Android.bp index 2a86a0011c..4eefb0f7dc 100644 --- a/neuralnetworks/1.2/utils/Android.bp +++ b/neuralnetworks/1.2/utils/Android.bp @@ -71,7 +71,7 @@ cc_test { "android.hardware.neuralnetworks@1.1", "android.hardware.neuralnetworks@1.2", "libgmock", - "libneuralnetworks_common_hidl", + "libneuralnetworks_common", "neuralnetworks_types", "neuralnetworks_utils_hal_common", "neuralnetworks_utils_hal_1_0", diff --git a/neuralnetworks/1.2/vts/functional/Android.bp b/neuralnetworks/1.2/vts/functional/Android.bp index 15a5d2fcc8..e313b47e1e 100644 --- a/neuralnetworks/1.2/vts/functional/Android.bp +++ b/neuralnetworks/1.2/vts/functional/Android.bp @@ -71,7 +71,7 @@ cc_test { "libgmock", "libhidlmemory", "libneuralnetworks_generated_test_harness", - "libneuralnetworks_common_hidl", + "libneuralnetworks_utils", ], whole_static_libs: [ "neuralnetworks_generated_V1_0_example", diff --git a/neuralnetworks/1.3/utils/Android.bp b/neuralnetworks/1.3/utils/Android.bp index 8ae509f4d0..7acb4fcb30 100644 --- a/neuralnetworks/1.3/utils/Android.bp +++ b/neuralnetworks/1.3/utils/Android.bp @@ -69,7 +69,7 @@ cc_test { "android.hardware.neuralnetworks@1.2", "android.hardware.neuralnetworks@1.3", "libgmock", - "libneuralnetworks_common_hidl", + "libneuralnetworks_common", "neuralnetworks_types", "neuralnetworks_utils_hal_common", "neuralnetworks_utils_hal_1_0", diff --git a/neuralnetworks/1.3/vts/functional/Android.bp b/neuralnetworks/1.3/vts/functional/Android.bp index ca59cc20ec..ab0a0184be 100644 --- a/neuralnetworks/1.3/vts/functional/Android.bp +++ b/neuralnetworks/1.3/vts/functional/Android.bp @@ -66,6 +66,7 @@ cc_test { "VtsHalNeuralNetworksV1_0_utils", "VtsHalNeuralNetworksV1_2_utils", "VtsHalNeuralNetworksV1_3_utils", + "android.hardware.neuralnetworks-V2-ndk", "android.hardware.neuralnetworks@1.0", "android.hardware.neuralnetworks@1.1", "android.hardware.neuralnetworks@1.2", @@ -75,7 +76,7 @@ cc_test { "libgmock", "libhidlmemory", "libneuralnetworks_generated_test_harness", - "libneuralnetworks_common_hidl", + "libneuralnetworks_utils", "libsync", ], whole_static_libs: [ diff --git a/neuralnetworks/aidl/utils/Android.bp b/neuralnetworks/aidl/utils/Android.bp index 64e0378c55..cb67b84bf2 100644 --- a/neuralnetworks/aidl/utils/Android.bp +++ b/neuralnetworks/aidl/utils/Android.bp @@ -23,8 +23,8 @@ package { default_applicable_licenses: ["hardware_interfaces_license"], } -cc_defaults { - name: "neuralnetworks_utils_hal_aidl_defaults", +cc_library_static { + name: "neuralnetworks_utils_hal_aidl", defaults: ["neuralnetworks_utils_defaults"], srcs: ["src/*"], local_include_dirs: ["include/nnapi/hal/aidl/"], @@ -38,6 +38,7 @@ cc_defaults { "neuralnetworks_utils_hal_common", ], shared_libs: [ + "android.hardware.neuralnetworks-V2-ndk", "libbinder_ndk", "libhidlbase", ], @@ -48,49 +49,21 @@ cc_defaults { }, } -cc_library_static { - name: "neuralnetworks_utils_hal_aidl_v1", - defaults: ["neuralnetworks_utils_hal_aidl_defaults"], - shared_libs: [ - "android.hardware.neuralnetworks-V1-ndk", - ], -} - -cc_library_static { - name: "neuralnetworks_utils_hal_aidl_v2", - defaults: ["neuralnetworks_utils_hal_aidl_defaults"], - shared_libs: [ - "android.hardware.neuralnetworks-V2-ndk", - ], -} - -// A cc_defaults that includes the latest non-experimental AIDL utilities and other AIDL libraries -// that are commonly used together. Modules that always depend on the latest non-experimental -// AIDL features can include this cc_defaults to avoid managing dependency versions explicitly. -cc_defaults { - name: "neuralnetworks_use_latest_utils_hal_aidl", - static_libs: [ - "android.hardware.common-V2-ndk", - "android.hardware.graphics.common-V2-ndk", - "android.hardware.neuralnetworks-V2-ndk", - "neuralnetworks_utils_hal_aidl_v2", - ], -} - cc_test { name: "neuralnetworks_utils_hal_aidl_test", - defaults: [ - "neuralnetworks_use_latest_utils_hal_aidl", - "neuralnetworks_utils_defaults", - ], + defaults: ["neuralnetworks_utils_defaults"], srcs: [ "test/*.cpp", ], static_libs: [ + "android.hardware.common-V2-ndk", + "android.hardware.graphics.common-V2-ndk", + "android.hardware.neuralnetworks-V2-ndk", "libaidlcommonsupport", "libgmock", "libneuralnetworks_common", "neuralnetworks_types", + "neuralnetworks_utils_hal_aidl", "neuralnetworks_utils_hal_common", ], shared_libs: [ diff --git a/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/Device.h b/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/Device.h index d558f66b6b..14576468e1 100644 --- a/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/Device.h +++ b/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/Device.h @@ -43,12 +43,11 @@ class Device final : public nn::IDevice { public: static nn::GeneralResult> create( - std::string name, std::shared_ptr device, nn::Version featureLevel); + std::string name, std::shared_ptr device); Device(PrivateConstructorTag tag, std::string name, std::string versionString, - nn::Version featureLevel, nn::DeviceType deviceType, - std::vector extensions, nn::Capabilities capabilities, - std::pair numberOfCacheFilesNeeded, + nn::DeviceType deviceType, std::vector extensions, + nn::Capabilities capabilities, std::pair numberOfCacheFilesNeeded, std::shared_ptr device, DeathHandler deathHandler); const std::string& getName() const override; @@ -85,7 +84,6 @@ class Device final : public nn::IDevice { private: const std::string kName; const std::string kVersionString; - const nn::Version kFeatureLevel; const nn::DeviceType kDeviceType; const std::vector kExtensions; const nn::Capabilities kCapabilities; diff --git a/neuralnetworks/aidl/utils/src/Device.cpp b/neuralnetworks/aidl/utils/src/Device.cpp index 5b7ec4ebd7..e80de0be76 100644 --- a/neuralnetworks/aidl/utils/src/Device.cpp +++ b/neuralnetworks/aidl/utils/src/Device.cpp @@ -125,7 +125,7 @@ nn::GeneralResult> getNumberOfCacheFilesNeededFrom } // namespace nn::GeneralResult> Device::create( - std::string name, std::shared_ptr device, nn::Version featureLevel) { + std::string name, std::shared_ptr device) { if (name.empty()) { return NN_ERROR(nn::ErrorStatus::INVALID_ARGUMENT) << "aidl_hal::utils::Device::create must have non-empty name"; @@ -143,19 +143,18 @@ nn::GeneralResult> Device::create( auto deathHandler = NN_TRY(DeathHandler::create(device)); return std::make_shared( - PrivateConstructorTag{}, std::move(name), std::move(versionString), featureLevel, - deviceType, std::move(extensions), std::move(capabilities), numberOfCacheFilesNeeded, + PrivateConstructorTag{}, std::move(name), std::move(versionString), deviceType, + std::move(extensions), std::move(capabilities), numberOfCacheFilesNeeded, std::move(device), std::move(deathHandler)); } Device::Device(PrivateConstructorTag /*tag*/, std::string name, std::string versionString, - nn::Version featureLevel, nn::DeviceType deviceType, - std::vector extensions, nn::Capabilities capabilities, + nn::DeviceType deviceType, std::vector extensions, + nn::Capabilities capabilities, std::pair numberOfCacheFilesNeeded, std::shared_ptr device, DeathHandler deathHandler) : kName(std::move(name)), kVersionString(std::move(versionString)), - kFeatureLevel(featureLevel), kDeviceType(deviceType), kExtensions(std::move(extensions)), kCapabilities(std::move(capabilities)), @@ -172,7 +171,7 @@ const std::string& Device::getVersionString() const { } nn::Version Device::getFeatureLevel() const { - return kFeatureLevel; + return nn::Version::ANDROID_S; } nn::DeviceType Device::getType() const { diff --git a/neuralnetworks/aidl/utils/src/Service.cpp b/neuralnetworks/aidl/utils/src/Service.cpp index 01772eed53..ac182a205e 100644 --- a/neuralnetworks/aidl/utils/src/Service.cpp +++ b/neuralnetworks/aidl/utils/src/Service.cpp @@ -17,7 +17,6 @@ #include "Service.h" #include -#include #include #include #include @@ -29,33 +28,8 @@ #include #include "Device.h" -#include "Utils.h" namespace aidl::android::hardware::neuralnetworks::utils { -namespace { - -// Map the AIDL version of an IDevice to NNAPI canonical feature level. -nn::GeneralResult getAidlServiceFeatureLevel(IDevice* service) { - CHECK(service != nullptr); - int aidlVersion; - const auto ret = service->getInterfaceVersion(&aidlVersion); - HANDLE_ASTATUS(ret) << "getInterfaceVersion failed"; - - // For service AIDL versions greater than or equal to the AIDL library version that the runtime - // was built against, clamp it to the runtime AIDL library version. - aidlVersion = std::min(aidlVersion, IDevice::version); - - // Map stable AIDL versions to canonical versions. - switch (aidlVersion) { - case 1: - return nn::Version::ANDROID_S; - case 2: - return nn::Version::FEATURE_LEVEL_6; - } - return NN_ERROR() << "Unknown AIDL service version: " << aidlVersion; -} - -} // namespace nn::GeneralResult getDevice(const std::string& instanceName) { auto fullName = std::string(IDevice::descriptor) + "/" + instanceName; @@ -81,8 +55,7 @@ nn::GeneralResult getDevice(const std::string& instanceName) { << " returned nullptr"; } ABinderProcess_startThreadPool(); - const auto featureLevel = NN_TRY(getAidlServiceFeatureLevel(service.get())); - return Device::create(instanceName, std::move(service), featureLevel); + return Device::create(instanceName, std::move(service)); }; return hal::utils::ResilientDevice::create(std::move(makeDevice)); diff --git a/neuralnetworks/aidl/utils/test/DeviceTest.cpp b/neuralnetworks/aidl/utils/test/DeviceTest.cpp index 79abe1b19b..f121acaf7b 100644 --- a/neuralnetworks/aidl/utils/test/DeviceTest.cpp +++ b/neuralnetworks/aidl/utils/test/DeviceTest.cpp @@ -146,45 +146,28 @@ constexpr auto makeDeadObjectFailure = [] { return ndk::ScopedAStatus::fromStatus(STATUS_DEAD_OBJECT); }; -class DeviceTest : public ::testing::TestWithParam { - protected: - const nn::Version kVersion = GetParam(); -}; - -std::string printDeviceTest(const testing::TestParamInfo& info) { - switch (info.param) { - case nn::Version::ANDROID_S: - return "v1"; - case nn::Version::FEATURE_LEVEL_6: - return "v2"; - default: - LOG(FATAL) << "Invalid AIDL version: " << info.param; - return "invalid"; - } -} - } // namespace -TEST_P(DeviceTest, invalidName) { +TEST(DeviceTest, invalidName) { // run test const auto device = MockDevice::create(); - const auto result = Device::create(kInvalidName, device, kVersion); + const auto result = Device::create(kInvalidName, device); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::INVALID_ARGUMENT); } -TEST_P(DeviceTest, invalidDevice) { +TEST(DeviceTest, invalidDevice) { // run test - const auto result = Device::create(kName, kInvalidDevice, kVersion); + const auto result = Device::create(kName, kInvalidDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::INVALID_ARGUMENT); } -TEST_P(DeviceTest, getVersionStringError) { +TEST(DeviceTest, getVersionStringError) { // setup call const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getVersionString(_)) @@ -192,14 +175,14 @@ TEST_P(DeviceTest, getVersionStringError) { .WillOnce(InvokeWithoutArgs(makeGeneralFailure)); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, getVersionStringTransportFailure) { +TEST(DeviceTest, getVersionStringTransportFailure) { // setup call const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getVersionString(_)) @@ -207,14 +190,14 @@ TEST_P(DeviceTest, getVersionStringTransportFailure) { .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, getVersionStringDeadObject) { +TEST(DeviceTest, getVersionStringDeadObject) { // setup call const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getVersionString(_)) @@ -222,27 +205,27 @@ TEST_P(DeviceTest, getVersionStringDeadObject) { .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); } -TEST_P(DeviceTest, getTypeError) { +TEST(DeviceTest, getTypeError) { // setup call const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getType(_)).Times(1).WillOnce(InvokeWithoutArgs(makeGeneralFailure)); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, getTypeTransportFailure) { +TEST(DeviceTest, getTypeTransportFailure) { // setup call const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getType(_)) @@ -250,14 +233,14 @@ TEST_P(DeviceTest, getTypeTransportFailure) { .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, getTypeDeadObject) { +TEST(DeviceTest, getTypeDeadObject) { // setup call const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getType(_)) @@ -265,14 +248,14 @@ TEST_P(DeviceTest, getTypeDeadObject) { .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); } -TEST_P(DeviceTest, getSupportedExtensionsError) { +TEST(DeviceTest, getSupportedExtensionsError) { // setup call const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getSupportedExtensions(_)) @@ -280,14 +263,14 @@ TEST_P(DeviceTest, getSupportedExtensionsError) { .WillOnce(InvokeWithoutArgs(makeGeneralFailure)); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, getSupportedExtensionsTransportFailure) { +TEST(DeviceTest, getSupportedExtensionsTransportFailure) { // setup call const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getSupportedExtensions(_)) @@ -295,14 +278,14 @@ TEST_P(DeviceTest, getSupportedExtensionsTransportFailure) { .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, getSupportedExtensionsDeadObject) { +TEST(DeviceTest, getSupportedExtensionsDeadObject) { // setup call const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getSupportedExtensions(_)) @@ -310,20 +293,20 @@ TEST_P(DeviceTest, getSupportedExtensionsDeadObject) { .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); } -TEST_P(DeviceTest, getNumberOfCacheFilesNeeded) { +TEST(DeviceTest, getNumberOfCacheFilesNeeded) { // setup call const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)).Times(1); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_TRUE(result.has_value()); @@ -332,7 +315,7 @@ TEST_P(DeviceTest, getNumberOfCacheFilesNeeded) { EXPECT_EQ(result.value()->getNumberOfCacheFilesNeeded(), kNumberOfCacheFilesPair); } -TEST_P(DeviceTest, getNumberOfCacheFilesNeededError) { +TEST(DeviceTest, getNumberOfCacheFilesNeededError) { // setup call const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)) @@ -340,14 +323,14 @@ TEST_P(DeviceTest, getNumberOfCacheFilesNeededError) { .WillOnce(InvokeWithoutArgs(makeGeneralFailure)); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, dataCacheFilesExceedsSpecifiedMax) { +TEST(DeviceTest, dataCacheFilesExceedsSpecifiedMax) { // setup test const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)) @@ -358,14 +341,14 @@ TEST_P(DeviceTest, dataCacheFilesExceedsSpecifiedMax) { InvokeWithoutArgs(makeStatusOk))); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, modelCacheFilesExceedsSpecifiedMax) { +TEST(DeviceTest, modelCacheFilesExceedsSpecifiedMax) { // setup test const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)) @@ -376,14 +359,14 @@ TEST_P(DeviceTest, modelCacheFilesExceedsSpecifiedMax) { InvokeWithoutArgs(makeStatusOk))); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, getNumberOfCacheFilesNeededTransportFailure) { +TEST(DeviceTest, getNumberOfCacheFilesNeededTransportFailure) { // setup call const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)) @@ -391,14 +374,14 @@ TEST_P(DeviceTest, getNumberOfCacheFilesNeededTransportFailure) { .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, getNumberOfCacheFilesNeededDeadObject) { +TEST(DeviceTest, getNumberOfCacheFilesNeededDeadObject) { // setup call const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)) @@ -406,14 +389,14 @@ TEST_P(DeviceTest, getNumberOfCacheFilesNeededDeadObject) { .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); } -TEST_P(DeviceTest, getCapabilitiesError) { +TEST(DeviceTest, getCapabilitiesError) { // setup call const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getCapabilities(_)) @@ -421,14 +404,14 @@ TEST_P(DeviceTest, getCapabilitiesError) { .WillOnce(InvokeWithoutArgs(makeGeneralFailure)); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, getCapabilitiesTransportFailure) { +TEST(DeviceTest, getCapabilitiesTransportFailure) { // setup call const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getCapabilities(_)) @@ -436,14 +419,14 @@ TEST_P(DeviceTest, getCapabilitiesTransportFailure) { .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, getCapabilitiesDeadObject) { +TEST(DeviceTest, getCapabilitiesDeadObject) { // setup call const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getCapabilities(_)) @@ -451,17 +434,17 @@ TEST_P(DeviceTest, getCapabilitiesDeadObject) { .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); // run test - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); // verify result ASSERT_FALSE(result.has_value()); EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); } -TEST_P(DeviceTest, getName) { +TEST(DeviceTest, getName) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); // run test const auto& name = device->getName(); @@ -470,19 +453,19 @@ TEST_P(DeviceTest, getName) { EXPECT_EQ(name, kName); } -TEST_P(DeviceTest, getFeatureLevel) { +TEST(DeviceTest, getFeatureLevel) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); // run test const auto featureLevel = device->getFeatureLevel(); // verify result - EXPECT_EQ(featureLevel, kVersion); + EXPECT_EQ(featureLevel, nn::Version::ANDROID_S); } -TEST_P(DeviceTest, getCachedData) { +TEST(DeviceTest, getCachedData) { // setup call const auto mockDevice = createMockDevice(); EXPECT_CALL(*mockDevice, getVersionString(_)).Times(1); @@ -491,7 +474,7 @@ TEST_P(DeviceTest, getCachedData) { EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)).Times(1); EXPECT_CALL(*mockDevice, getCapabilities(_)).Times(1); - const auto result = Device::create(kName, mockDevice, kVersion); + const auto result = Device::create(kName, mockDevice); ASSERT_TRUE(result.has_value()) << "Failed with " << result.error().code << ": " << result.error().message; const auto& device = result.value(); @@ -504,10 +487,10 @@ TEST_P(DeviceTest, getCachedData) { EXPECT_EQ(device->getCapabilities(), device->getCapabilities()); } -TEST_P(DeviceTest, getSupportedOperations) { +TEST(DeviceTest, getSupportedOperations) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); EXPECT_CALL(*mockDevice, getSupportedOperations(_, _)) .Times(1) .WillOnce(DoAll( @@ -525,10 +508,10 @@ TEST_P(DeviceTest, getSupportedOperations) { EXPECT_THAT(supportedOperations, Each(testing::IsTrue())); } -TEST_P(DeviceTest, getSupportedOperationsError) { +TEST(DeviceTest, getSupportedOperationsError) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); EXPECT_CALL(*mockDevice, getSupportedOperations(_, _)) .Times(1) .WillOnce(InvokeWithoutArgs(makeGeneralFailure)); @@ -541,10 +524,10 @@ TEST_P(DeviceTest, getSupportedOperationsError) { EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, getSupportedOperationsTransportFailure) { +TEST(DeviceTest, getSupportedOperationsTransportFailure) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); EXPECT_CALL(*mockDevice, getSupportedOperations(_, _)) .Times(1) .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); @@ -557,10 +540,10 @@ TEST_P(DeviceTest, getSupportedOperationsTransportFailure) { EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, getSupportedOperationsDeadObject) { +TEST(DeviceTest, getSupportedOperationsDeadObject) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); EXPECT_CALL(*mockDevice, getSupportedOperations(_, _)) .Times(1) .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); @@ -573,10 +556,10 @@ TEST_P(DeviceTest, getSupportedOperationsDeadObject) { EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); } -TEST_P(DeviceTest, prepareModel) { +TEST(DeviceTest, prepareModel) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); const auto mockPreparedModel = MockPreparedModel::create(); EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _)) .Times(1) @@ -593,10 +576,10 @@ TEST_P(DeviceTest, prepareModel) { EXPECT_NE(result.value(), nullptr); } -TEST_P(DeviceTest, prepareModelLaunchError) { +TEST(DeviceTest, prepareModelLaunchError) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _)) .Times(1) .WillOnce(Invoke(makePreparedModelReturn(ErrorStatus::GENERAL_FAILURE, @@ -611,10 +594,10 @@ TEST_P(DeviceTest, prepareModelLaunchError) { EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, prepareModelReturnError) { +TEST(DeviceTest, prepareModelReturnError) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _)) .Times(1) .WillOnce(Invoke(makePreparedModelReturn(ErrorStatus::NONE, @@ -629,10 +612,10 @@ TEST_P(DeviceTest, prepareModelReturnError) { EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, prepareModelNullptrError) { +TEST(DeviceTest, prepareModelNullptrError) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _)) .Times(1) .WillOnce( @@ -647,10 +630,10 @@ TEST_P(DeviceTest, prepareModelNullptrError) { EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, prepareModelTransportFailure) { +TEST(DeviceTest, prepareModelTransportFailure) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _)) .Times(1) .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); @@ -664,10 +647,10 @@ TEST_P(DeviceTest, prepareModelTransportFailure) { EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, prepareModelDeadObject) { +TEST(DeviceTest, prepareModelDeadObject) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _)) .Times(1) .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); @@ -681,10 +664,10 @@ TEST_P(DeviceTest, prepareModelDeadObject) { EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); } -TEST_P(DeviceTest, prepareModelAsyncCrash) { +TEST(DeviceTest, prepareModelAsyncCrash) { // setup test const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); const auto ret = [&device]() { DeathMonitor::serviceDied(device->getDeathMonitor()); return ndk::ScopedAStatus::ok(); @@ -702,10 +685,10 @@ TEST_P(DeviceTest, prepareModelAsyncCrash) { EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); } -TEST_P(DeviceTest, prepareModelFromCache) { +TEST(DeviceTest, prepareModelFromCache) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); const auto mockPreparedModel = MockPreparedModel::create(); EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _)) .Times(1) @@ -721,10 +704,10 @@ TEST_P(DeviceTest, prepareModelFromCache) { EXPECT_NE(result.value(), nullptr); } -TEST_P(DeviceTest, prepareModelFromCacheLaunchError) { +TEST(DeviceTest, prepareModelFromCacheLaunchError) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _)) .Times(1) .WillOnce(Invoke(makePreparedModelFromCacheReturn( @@ -738,10 +721,10 @@ TEST_P(DeviceTest, prepareModelFromCacheLaunchError) { EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, prepareModelFromCacheReturnError) { +TEST(DeviceTest, prepareModelFromCacheReturnError) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _)) .Times(1) .WillOnce(Invoke(makePreparedModelFromCacheReturn( @@ -755,10 +738,10 @@ TEST_P(DeviceTest, prepareModelFromCacheReturnError) { EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, prepareModelFromCacheNullptrError) { +TEST(DeviceTest, prepareModelFromCacheNullptrError) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _)) .Times(1) .WillOnce(Invoke(makePreparedModelFromCacheReturn(ErrorStatus::NONE, ErrorStatus::NONE, @@ -772,10 +755,10 @@ TEST_P(DeviceTest, prepareModelFromCacheNullptrError) { EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, prepareModelFromCacheTransportFailure) { +TEST(DeviceTest, prepareModelFromCacheTransportFailure) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _)) .Times(1) .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); @@ -788,10 +771,10 @@ TEST_P(DeviceTest, prepareModelFromCacheTransportFailure) { EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, prepareModelFromCacheDeadObject) { +TEST(DeviceTest, prepareModelFromCacheDeadObject) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _)) .Times(1) .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); @@ -804,10 +787,10 @@ TEST_P(DeviceTest, prepareModelFromCacheDeadObject) { EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); } -TEST_P(DeviceTest, prepareModelFromCacheAsyncCrash) { +TEST(DeviceTest, prepareModelFromCacheAsyncCrash) { // setup test const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); const auto ret = [&device]() { DeathMonitor::serviceDied(device->getDeathMonitor()); return ndk::ScopedAStatus::ok(); @@ -824,10 +807,10 @@ TEST_P(DeviceTest, prepareModelFromCacheAsyncCrash) { EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); } -TEST_P(DeviceTest, allocate) { +TEST(DeviceTest, allocate) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); const auto mockBuffer = DeviceBuffer{.buffer = MockBuffer::create(), .token = 1}; EXPECT_CALL(*mockDevice, allocate(_, _, _, _, _)) .Times(1) @@ -842,10 +825,10 @@ TEST_P(DeviceTest, allocate) { EXPECT_NE(result.value(), nullptr); } -TEST_P(DeviceTest, allocateError) { +TEST(DeviceTest, allocateError) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); EXPECT_CALL(*mockDevice, allocate(_, _, _, _, _)) .Times(1) .WillOnce(InvokeWithoutArgs(makeGeneralFailure)); @@ -858,10 +841,10 @@ TEST_P(DeviceTest, allocateError) { EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, allocateTransportFailure) { +TEST(DeviceTest, allocateTransportFailure) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); EXPECT_CALL(*mockDevice, allocate(_, _, _, _, _)) .Times(1) .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); @@ -874,10 +857,10 @@ TEST_P(DeviceTest, allocateTransportFailure) { EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); } -TEST_P(DeviceTest, allocateDeadObject) { +TEST(DeviceTest, allocateDeadObject) { // setup call const auto mockDevice = createMockDevice(); - const auto device = Device::create(kName, mockDevice, kVersion).value(); + const auto device = Device::create(kName, mockDevice).value(); EXPECT_CALL(*mockDevice, allocate(_, _, _, _, _)) .Times(1) .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); @@ -890,8 +873,4 @@ TEST_P(DeviceTest, allocateDeadObject) { EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); } -INSTANTIATE_TEST_SUITE_P(TestDevice, DeviceTest, - ::testing::Values(nn::Version::ANDROID_S, nn::Version::FEATURE_LEVEL_6), - printDeviceTest); - } // namespace aidl::android::hardware::neuralnetworks::utils diff --git a/neuralnetworks/aidl/vts/functional/Android.bp b/neuralnetworks/aidl/vts/functional/Android.bp index a09cdab36f..4dc2ed0f8c 100644 --- a/neuralnetworks/aidl/vts/functional/Android.bp +++ b/neuralnetworks/aidl/vts/functional/Android.bp @@ -26,7 +26,6 @@ package { cc_test { name: "VtsHalNeuralnetworksTargetTest", defaults: [ - "neuralnetworks_use_latest_utils_hal_aidl", "neuralnetworks_vts_functional_defaults", "use_libaidlvintf_gtest_helper_static", ], @@ -52,14 +51,16 @@ cc_test { static_libs: [ "android.hardware.common-V2-ndk", "android.hardware.graphics.common-V2-ndk", + "android.hardware.neuralnetworks-V2-ndk", "android.hidl.allocator@1.0", "android.hidl.memory@1.0", "libaidlcommonsupport", "libgmock", "libhidlmemory", - "libneuralnetworks_common", "libneuralnetworks_generated_test_harness", + "libneuralnetworks_utils", "libsync", + "neuralnetworks_utils_hal_aidl", ], whole_static_libs: [ "neuralnetworks_generated_V1_0_example", diff --git a/neuralnetworks/utils/common/Android.bp b/neuralnetworks/utils/common/Android.bp index c0645b0257..f88e407923 100644 --- a/neuralnetworks/utils/common/Android.bp +++ b/neuralnetworks/utils/common/Android.bp @@ -35,6 +35,7 @@ cc_library_static { "neuralnetworks_types", ], shared_libs: [ + "android.hardware.neuralnetworks-V2-ndk", "libhidlbase", "libbinder_ndk", ], @@ -52,7 +53,7 @@ cc_test { static_libs: [ "android.hardware.neuralnetworks@1.0", "libgmock", - "libneuralnetworks_common_hidl", + "libneuralnetworks_common", "neuralnetworks_types", "neuralnetworks_utils_hal_common", ], diff --git a/neuralnetworks/utils/service/Android.bp b/neuralnetworks/utils/service/Android.bp index 3288d05145..fbb8679508 100644 --- a/neuralnetworks/utils/service/Android.bp +++ b/neuralnetworks/utils/service/Android.bp @@ -25,10 +25,7 @@ package { cc_library_static { name: "neuralnetworks_utils_hal_service", - defaults: [ - "neuralnetworks_use_latest_utils_hal_aidl", - "neuralnetworks_utils_defaults", - ], + defaults: ["neuralnetworks_utils_defaults"], srcs: ["src/*"], local_include_dirs: ["include/nnapi/hal"], export_include_dirs: ["include"], @@ -38,9 +35,11 @@ cc_library_static { "neuralnetworks_utils_hal_1_1", "neuralnetworks_utils_hal_1_2", "neuralnetworks_utils_hal_1_3", + "neuralnetworks_utils_hal_aidl", "neuralnetworks_utils_hal_common", ], shared_libs: [ + "android.hardware.neuralnetworks-V2-ndk", "android.hardware.neuralnetworks@1.0", "android.hardware.neuralnetworks@1.1", "android.hardware.neuralnetworks@1.2",