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
This commit is contained in:
Sean Dooher
2023-06-12 20:14:00 +00:00
parent 54996257f1
commit 3869fa63f2
2 changed files with 11 additions and 4 deletions

View File

@@ -35,6 +35,9 @@ aidl_interface {
java: {
platform_apis: true,
},
rust: {
enabled: true,
},
},
versions_with_info: [
{

View File

@@ -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<ThermalCallback> localThermalCallback =
ndk::SharedRefBase::make<ThermalCallback>();
// 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<ThermalCallback> localThermalCallback =
ndk::SharedRefBase::make<ThermalCallback>();
// 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().