From 3869fa63f256ee6daf351eefab6e84e69495f852 Mon Sep 17 00:00:00 2001 From: Sean Dooher Date: Mon, 12 Jun 2023 20:14:00 +0000 Subject: [PATCH] thermal: Add support for Rust AIDL backend Updates the VTS test to allow a NULL_POINTER exception when a null pointer is passed as an argument. This matches the behavior of the Rust libbinder_rs while maintaining backwards compatibility by still allowing ILLEGAL_ARGUMENT exceptions in this case. This support is necessary for a new emulated Thermal HAL for Cuttlefish written in Rust. Tested: VtsHalThermalTest in Cuttlefish Bug: 286106286 Change-Id: Iccbebb416f31555da328f752d661660b77125ed3 --- thermal/aidl/Android.bp | 3 +++ thermal/aidl/vts/VtsHalThermalTargetTest.cpp | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/thermal/aidl/Android.bp b/thermal/aidl/Android.bp index efc763c388..9382b941b0 100644 --- a/thermal/aidl/Android.bp +++ b/thermal/aidl/Android.bp @@ -35,6 +35,9 @@ aidl_interface { java: { platform_apis: true, }, + rust: { + enabled: true, + }, }, versions_with_info: [ { diff --git a/thermal/aidl/vts/VtsHalThermalTargetTest.cpp b/thermal/aidl/vts/VtsHalThermalTargetTest.cpp index 835fbfa85a..4b0eb655b5 100644 --- a/thermal/aidl/vts/VtsHalThermalTargetTest.cpp +++ b/thermal/aidl/vts/VtsHalThermalTargetTest.cpp @@ -128,7 +128,8 @@ TEST_P(ThermalAidlTest, RegisterThermalChangedCallbackTest) { ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); // Expect to fail with null callback status = mThermal->registerThermalChangedCallback(nullptr); - ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); + ASSERT_TRUE(status.getExceptionCode() == EX_ILLEGAL_ARGUMENT + || status.getExceptionCode() == EX_NULL_POINTER); std::shared_ptr localThermalCallback = ndk::SharedRefBase::make(); // Expect to succeed with different callback @@ -139,7 +140,8 @@ TEST_P(ThermalAidlTest, RegisterThermalChangedCallbackTest) { ASSERT_TRUE(status.isOk()) << status.getMessage(); // Expect to fail with null callback status = mThermal->unregisterThermalChangedCallback(nullptr); - ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); + ASSERT_TRUE(status.getExceptionCode() == EX_ILLEGAL_ARGUMENT + || status.getExceptionCode() == EX_NULL_POINTER); } // Test Thermal->registerThermalChangedCallbackWithType. @@ -150,7 +152,8 @@ TEST_P(ThermalAidlTest, RegisterThermalChangedCallbackWithTypeTest) { ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); // Expect to fail with null callback status = mThermal->registerThermalChangedCallbackWithType(nullptr, TemperatureType::SKIN); - ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); + ASSERT_TRUE(status.getExceptionCode() == EX_ILLEGAL_ARGUMENT + || status.getExceptionCode() == EX_NULL_POINTER); std::shared_ptr localThermalCallback = ndk::SharedRefBase::make(); // Expect to succeed with different callback @@ -162,7 +165,8 @@ TEST_P(ThermalAidlTest, RegisterThermalChangedCallbackWithTypeTest) { ASSERT_TRUE(status.isOk()) << status.getMessage(); // Expect to fail with null callback status = mThermal->unregisterThermalChangedCallback(nullptr); - ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); + ASSERT_TRUE(status.getExceptionCode() == EX_ILLEGAL_ARGUMENT + || status.getExceptionCode() == EX_NULL_POINTER); } // Test Thermal->getCurrentTemperatures().