mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Fix AIDL sensors VTS test
- According to the AIDL backends, return values are not propagated when the status is !ok(). Update the VTS test, HAL implementation, and ISensors definition to remove the requirement that the handle is populated to -1 on failure for registerDirectChannel. - Also update VTS tests for some error code checks to reflect the actual expecataions according to the ISensors documentation. Bug: 228645167 Test: VTS passes Change-Id: I5d4d4d0af3b033b34a58d8462aa40214d89fa442
This commit is contained in:
@@ -229,8 +229,7 @@ interface ISensors {
|
||||
*
|
||||
* @param mem shared memory info data structure.
|
||||
* @param out channelHandle The registered channel handle.
|
||||
* @return The direct channel handle, which is positive if successfully registered, and -1
|
||||
* otherwise.
|
||||
* @return The direct channel handle, which is positive if successfully registered.
|
||||
* @return Status::ok on success
|
||||
* EX_ILLEGAL_ARGUMENT if the shared memory information is not consistent.
|
||||
* EX_UNSUPPORTED_OPERATION if this functionality is unsupported.
|
||||
@@ -245,7 +244,7 @@ interface ISensors {
|
||||
* @see OperationMode
|
||||
* @param mode The operation mode.
|
||||
* @return Status::ok on success
|
||||
* EX_UNSUPPORTED_OPERATION if requested mode is not supported.
|
||||
* EX_UNSUPPORTED_OPERATION or EX_ILLEGAL_ARGUMENT if requested mode is not supported.
|
||||
* EX_SECURITY if the operation is not allowed.
|
||||
*/
|
||||
void setOperationMode(in OperationMode mode);
|
||||
|
||||
@@ -141,10 +141,6 @@ ScopedAStatus HalProxyAidl::configDirectReport(int32_t in_sensorHandle,
|
||||
*_aidl_return = reportToken;
|
||||
});
|
||||
|
||||
if (!status.isOk()) {
|
||||
*_aidl_return = -1;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -216,10 +212,6 @@ HalProxyAidl::registerDirectChannel(const ISensors::SharedMemInfo &in_mem,
|
||||
native_handle_delete(const_cast<native_handle_t *>(
|
||||
sharedMemInfo.memoryHandle.getNativeHandle()));
|
||||
|
||||
if (!status.isOk()) {
|
||||
*_aidl_return = -1;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -599,10 +599,12 @@ TEST_P(SensorsAidlTest, SetOperationMode) {
|
||||
ASSERT_TRUE(getSensors()->setOperationMode(ISensors::OperationMode::DATA_INJECTION).isOk());
|
||||
ASSERT_TRUE(getSensors()->setOperationMode(ISensors::OperationMode::NORMAL).isOk());
|
||||
} else {
|
||||
ASSERT_EQ(getSensors()
|
||||
->setOperationMode(ISensors::OperationMode::DATA_INJECTION)
|
||||
.getExceptionCode(),
|
||||
EX_UNSUPPORTED_OPERATION);
|
||||
int errorCode =
|
||||
getSensors()
|
||||
->setOperationMode(ISensors::OperationMode::DATA_INJECTION)
|
||||
.getExceptionCode();
|
||||
ASSERT_TRUE((errorCode == EX_UNSUPPORTED_OPERATION) ||
|
||||
(errorCode == EX_ILLEGAL_ARGUMENT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -938,10 +940,10 @@ void SensorsAidlTest::checkRateLevel(const SensorInfo& sensor, int32_t directCha
|
||||
if (isDirectReportRateSupported(sensor, rateLevel)) {
|
||||
ASSERT_TRUE(status.isOk());
|
||||
if (rateLevel != ISensors::RateLevel::STOP) {
|
||||
ASSERT_GT(*reportToken, 0);
|
||||
} else {
|
||||
ASSERT_EQ(status.getExceptionCode(), EX_ILLEGAL_ARGUMENT);
|
||||
ASSERT_GT(*reportToken, 0);
|
||||
}
|
||||
} else {
|
||||
ASSERT_EQ(status.getExceptionCode(), EX_ILLEGAL_ARGUMENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -982,11 +984,15 @@ void SensorsAidlTest::verifyRegisterDirectChannel(
|
||||
::ndk::ScopedAStatus status = registerDirectChannel(mem->getSharedMemInfo(), &channelHandle);
|
||||
if (supportsSharedMemType) {
|
||||
ASSERT_TRUE(status.isOk());
|
||||
ASSERT_EQ(channelHandle, 0);
|
||||
ASSERT_GT(channelHandle, 0);
|
||||
|
||||
// Verify that the memory has been zeroed
|
||||
for (size_t i = 0; i < mem->getSize(); i++) {
|
||||
ASSERT_EQ(buffer[i], 0x00);
|
||||
}
|
||||
} else {
|
||||
int32_t error = supportsAnyDirectChannel ? EX_ILLEGAL_ARGUMENT : EX_UNSUPPORTED_OPERATION;
|
||||
ASSERT_EQ(status.getExceptionCode(), error);
|
||||
ASSERT_EQ(channelHandle, -1);
|
||||
}
|
||||
*directChannelHandle = channelHandle;
|
||||
}
|
||||
@@ -1038,7 +1044,7 @@ void SensorsAidlTest::verifyConfigure(const SensorInfo& sensor,
|
||||
// Verify that a sensor handle of -1 is only acceptable when using RateLevel::STOP
|
||||
ndk::ScopedAStatus status = configDirectReport(-1 /* sensorHandle */, directChannelHandle,
|
||||
ISensors::RateLevel::NORMAL, &reportToken);
|
||||
ASSERT_EQ(status.getServiceSpecificError(), android::BAD_VALUE);
|
||||
ASSERT_EQ(status.getExceptionCode(), EX_ILLEGAL_ARGUMENT);
|
||||
|
||||
status = configDirectReport(-1 /* sensorHandle */, directChannelHandle,
|
||||
ISensors::RateLevel::STOP, &reportToken);
|
||||
|
||||
Reference in New Issue
Block a user