Merge "Update vts test to support automotive devices" into android14-tests-dev
diff --git a/bluetooth/aidl/vts/VtsHalBluetoothTargetTest.cpp b/bluetooth/aidl/vts/VtsHalBluetoothTargetTest.cpp
index 24eb4d0..6e18648 100644
--- a/bluetooth/aidl/vts/VtsHalBluetoothTargetTest.cpp
+++ b/bluetooth/aidl/vts/VtsHalBluetoothTargetTest.cpp
@@ -73,11 +73,9 @@
static constexpr uint8_t kMinLeResolvingListForBt5 = 8;
static constexpr size_t kNumHciCommandsBandwidth = 100;
-static constexpr size_t kNumScoPacketsBandwidth = 100;
static constexpr size_t kNumAclPacketsBandwidth = 100;
static constexpr std::chrono::milliseconds kWaitForInitTimeout(2000);
static constexpr std::chrono::milliseconds kWaitForHciEventTimeout(2000);
-static constexpr std::chrono::milliseconds kWaitForScoDataTimeout(1000);
static constexpr std::chrono::milliseconds kWaitForAclDataTimeout(1000);
static constexpr std::chrono::milliseconds kInterfaceCloseDelayMs(200);
@@ -206,7 +204,6 @@
// Functions called from within tests in loopback mode
void sendAndCheckHci(int num_packets);
- void sendAndCheckSco(int num_packets, size_t size, uint16_t handle);
void sendAndCheckAcl(int num_packets, size_t size, uint16_t handle);
// Helper functions to try to get a handle on verbosity
@@ -549,38 +546,6 @@
logger.setTotalBytes(command_size * num_packets * 2);
}
-// Send a SCO data packet (in Loopback mode) and check the response.
-void BluetoothAidlTest::sendAndCheckSco(int num_packets, size_t size,
- uint16_t handle) {
- ThroughputLogger logger{__func__};
- for (int n = 0; n < num_packets; n++) {
- // Send a SCO packet
- std::vector<uint8_t> sco_packet;
- std::vector<uint8_t> payload;
- for (size_t i = 0; i < size; i++) {
- payload.push_back(static_cast<uint8_t>(i + n));
- }
- ::bluetooth::packet::BitInserter bi{sco_packet};
- ::bluetooth::hci::ScoBuilder::Create(
- handle, ::bluetooth::hci::PacketStatusFlag::CORRECTLY_RECEIVED, payload)
- ->Serialize(bi);
- hci->sendScoData(sco_packet);
-
- // Check the loopback of the SCO packet
- std::vector<uint8_t> sco_loopback;
- ASSERT_TRUE(
- sco_queue.tryPopWithTimeout(sco_loopback, kWaitForScoDataTimeout));
-
- if (sco_loopback.size() < size) {
- // The packets may have been split for USB. Reassemble before checking.
- reassemble_sco_loopback_pkt(sco_loopback, size);
- }
-
- ASSERT_EQ(sco_packet, sco_loopback);
- }
- logger.setTotalBytes(num_packets * size * 2);
-}
-
// Send an ACL data packet (in Loopback mode) and check the response.
void BluetoothAidlTest::sendAndCheckAcl(int num_packets, size_t size,
uint16_t handle) {
@@ -710,22 +675,6 @@
wait_for_command_complete_event(view.GetOpCode(), cmd_complete));
}
-// Handle the loopback packet.
-void BluetoothAidlTest::reassemble_sco_loopback_pkt(std::vector<uint8_t>& scoPackets,
- size_t size) {
- std::vector<uint8_t> sco_packet_whole;
- sco_packet_whole.assign(scoPackets.begin(), scoPackets.end());
- while (size + 3 > sco_packet_whole.size()) {
- std::vector<uint8_t> sco_packets;
- ASSERT_TRUE(
- sco_queue.tryPopWithTimeout(sco_packets, kWaitForScoDataTimeout));
- sco_packet_whole.insert(sco_packet_whole.end(), sco_packets.begin() + 3,
- sco_packets.end());
- }
- scoPackets.assign(sco_packet_whole.begin(), sco_packet_whole.end());
- scoPackets[2] = size;
-}
-
// Empty test: Initialize()/Close() are called in SetUp()/TearDown().
TEST_P(BluetoothAidlTest, InitializeAndClose) {}
@@ -815,26 +764,6 @@
sendAndCheckHci(1);
}
-// Enter loopback mode and send a single SCO packet.
-TEST_P(BluetoothAidlTest, LoopbackModeSingleSco) {
- setBufferSizes();
- setSynchronousFlowControlEnable();
-
- enterLoopbackMode();
-
- if (!sco_connection_handles.empty()) {
- ASSERT_LT(0, max_sco_data_packet_length);
- sendAndCheckSco(1, max_sco_data_packet_length, sco_connection_handles[0]);
- int sco_packets_sent = 1;
- int completed_packets =
- wait_for_completed_packets_event(sco_connection_handles[0]);
- if (sco_packets_sent != completed_packets) {
- ALOGW("%s: packets_sent (%d) != completed_packets (%d)", __func__,
- sco_packets_sent, completed_packets);
- }
- }
-}
-
// Enter loopback mode and send a single ACL packet.
TEST_P(BluetoothAidlTest, LoopbackModeSingleAcl) {
setBufferSizes();
@@ -865,27 +794,6 @@
sendAndCheckHci(kNumHciCommandsBandwidth);
}
-// Enter loopback mode and send SCO packets for bandwidth measurements.
-TEST_P(BluetoothAidlTest, LoopbackModeScoBandwidth) {
- setBufferSizes();
- setSynchronousFlowControlEnable();
-
- enterLoopbackMode();
-
- if (!sco_connection_handles.empty()) {
- ASSERT_LT(0, max_sco_data_packet_length);
- sendAndCheckSco(kNumScoPacketsBandwidth, max_sco_data_packet_length,
- sco_connection_handles[0]);
- int sco_packets_sent = kNumScoPacketsBandwidth;
- int completed_packets =
- wait_for_completed_packets_event(sco_connection_handles[0]);
- if (sco_packets_sent != completed_packets) {
- ALOGW("%s: packets_sent (%d) != completed_packets (%d)", __func__,
- sco_packets_sent, completed_packets);
- }
- }
-}
-
// Enter loopback mode and send packets for ACL bandwidth measurements.
TEST_P(BluetoothAidlTest, LoopbackModeAclBandwidth) {
setBufferSizes();
@@ -974,7 +882,16 @@
ASSERT_EQ(status, std::future_status::ready);
}
+// @VsrTest = 5.3.14-001
+// @VsrTest = 5.3.14-002
+// @VsrTest = 5.3.14-004
TEST_P(BluetoothAidlTest, Vsr_Bluetooth5Requirements) {
+ int api_level = get_vsr_api_level();
+ if (api_level < __ANDROID_API_U__) {
+ GTEST_SKIP() << "API level is lower than 34";
+ return;
+ }
+
std::vector<uint8_t> version_event;
send_and_wait_for_cmd_complete(ReadLocalVersionInformationBuilder::Create(),
version_event);
@@ -984,10 +901,12 @@
ASSERT_TRUE(version_view.IsValid());
ASSERT_EQ(::bluetooth::hci::ErrorCode::SUCCESS, version_view.GetStatus());
auto version = version_view.GetLocalVersionInformation();
+
if (version.hci_version_ < ::bluetooth::hci::HciVersion::V_5_0) {
- // This test does not apply to controllers below 5.0
+ GTEST_SKIP() << "Bluetooth version is lower than 5.0";
return;
- };
+ }
+
// When HCI version is 5.0, LMP version must also be at least 5.0
ASSERT_GE(static_cast<int>(version.lmp_version_),
static_cast<int>(version.hci_version_));
@@ -1000,6 +919,16 @@
std::make_shared<std::vector<uint8_t>>(le_features_event)))));
ASSERT_TRUE(le_features_view.IsValid());
ASSERT_EQ(::bluetooth::hci::ErrorCode::SUCCESS, le_features_view.GetStatus());
+
+ // CHIPSETs that set ro.board.api_level to 34 and report 5.0 or higher for
+ // the Bluetooth version through the IBluetoothHci HAL:
+ //
+ // [VSR-5.3.14-001] Must return TRUE for
+ // - LE 2M PHY
+ // - LE Coded PHY
+ // - LE Advertising Extension
+ // - LE Periodic Advertising
+ // - LE Link Layer Privacy
auto le_features = le_features_view.GetLeFeatures();
ASSERT_TRUE(le_features & static_cast<uint64_t>(LLFeaturesBits::LL_PRIVACY));
ASSERT_TRUE(le_features & static_cast<uint64_t>(LLFeaturesBits::LE_2M_PHY));
@@ -1007,6 +936,8 @@
static_cast<uint64_t>(LLFeaturesBits::LE_CODED_PHY));
ASSERT_TRUE(le_features &
static_cast<uint64_t>(LLFeaturesBits::LE_EXTENDED_ADVERTISING));
+ ASSERT_TRUE(le_features &
+ static_cast<uint64_t>(LLFeaturesBits::LE_PERIODIC_ADVERTISING));
std::vector<uint8_t> num_adv_set_event;
send_and_wait_for_cmd_complete(
@@ -1020,6 +951,10 @@
ASSERT_EQ(::bluetooth::hci::ErrorCode::SUCCESS, num_adv_set_view.GetStatus());
auto num_adv_set = num_adv_set_view.GetNumberSupportedAdvertisingSets();
+ // CHIPSETs that set ro.board.api_level to 34 and report 5.0 or higher for
+ // the Bluetooth version through the IBluetoothHci HAL:
+ //
+ // [VSR-5.3.14-002] MUST support at least 10 advertising sets.
if (isTv() && get_vsr_api_level() == __ANDROID_API_U__) {
ASSERT_GE(num_adv_set, kMinLeAdvSetForBt5FoTv);
} else {
@@ -1036,6 +971,11 @@
ASSERT_EQ(::bluetooth::hci::ErrorCode::SUCCESS,
num_resolving_list_view.GetStatus());
auto num_resolving_list = num_resolving_list_view.GetResolvingListSize();
+
+ // CHIPSETs that set ro.board.api_level to 34 and report 5.0 or higher for
+ // the Bluetooth version through the IBluetoothHci HAL:
+ //
+ // [VSR-5.3.14-004] MUST support a resolving list size of at least 8 entries.
ASSERT_GE(num_resolving_list, kMinLeResolvingListForBt5);
}
diff --git a/broadcastradio/aidl/vts/src/VtsHalBroadcastradioAidlTargetTest.cpp b/broadcastradio/aidl/vts/src/VtsHalBroadcastradioAidlTargetTest.cpp
index 790d60b..6e0dcd1 100644
--- a/broadcastradio/aidl/vts/src/VtsHalBroadcastradioAidlTargetTest.cpp
+++ b/broadcastradio/aidl/vts/src/VtsHalBroadcastradioAidlTargetTest.cpp
@@ -704,12 +704,13 @@
}
ProgramSelector sel = {};
- uint64_t freq = 0;
+ uint64_t dabSidExt = 0;
bool dabStationPresent = false;
for (auto&& programInfo : *programList) {
if (!utils::hasId(programInfo.selector, IdentifierType::DAB_FREQUENCY_KHZ)) {
continue;
}
+ uint64_t freq = 0;
for (auto&& config_entry : config) {
if (config_entry.frequencyKhz ==
utils::getId(programInfo.selector, IdentifierType::DAB_FREQUENCY_KHZ, 0)) {
@@ -722,7 +723,7 @@
if (freq == 0) {
continue;
}
- int64_t dabSidExt = utils::getId(programInfo.selector, IdentifierType::DAB_SID_EXT, 0);
+ dabSidExt = utils::getId(programInfo.selector, IdentifierType::DAB_SID_EXT, 0);
int64_t dabEns = utils::getId(programInfo.selector, IdentifierType::DAB_ENSEMBLE, 0);
sel = makeSelectorDab(dabSidExt, (int32_t)dabEns, freq);
dabStationPresent = true;
@@ -735,7 +736,7 @@
}
// try tuning
-
+ mCallback->reset();
auto result = mModule->tune(sel);
// expect a failure if it's not supported
@@ -752,9 +753,9 @@
LOG(DEBUG) << "Current program info: " << infoCb.toString();
// it should tune exactly to what was requested
- vector<int> freqs = bcutils::getAllIds(infoCb.selector, IdentifierType::DAB_FREQUENCY_KHZ);
- EXPECT_NE(freqs.end(), find(freqs.begin(), freqs.end(), freq))
- << "DAB freq " << freq << " kHz is not sent back by callback.";
+ vector<int> sidExts = bcutils::getAllIds(infoCb.selector, IdentifierType::DAB_SID_EXT);
+ EXPECT_NE(sidExts.end(), find(sidExts.begin(), sidExts.end(), dabSidExt))
+ << "DAB SID ext " << std::hex << dabSidExt << " is not sent back by callback.";
}
/**
diff --git a/compatibility_matrices/compatibility_matrix.7.xml b/compatibility_matrices/compatibility_matrix.7.xml
index bc5a5c4..a1a2010 100644
--- a/compatibility_matrices/compatibility_matrix.7.xml
+++ b/compatibility_matrices/compatibility_matrix.7.xml
@@ -43,6 +43,7 @@
</hal>
<hal format="aidl" optional="true">
<name>android.hardware.automotive.audiocontrol</name>
+ <version>1-2</version>
<interface>
<name>IAudioControl</name>
<instance>default</instance>
diff --git a/graphics/composer/aidl/vts/RenderEngineVts.cpp b/graphics/composer/aidl/vts/RenderEngineVts.cpp
index 66779c8..d0bc689 100644
--- a/graphics/composer/aidl/vts/RenderEngineVts.cpp
+++ b/graphics/composer/aidl/vts/RenderEngineVts.cpp
@@ -29,9 +29,7 @@
mRenderEngine = ::android::renderengine::RenderEngine::create(args);
}
-TestRenderEngine::~TestRenderEngine() {
- mRenderEngine.release();
-}
+TestRenderEngine::~TestRenderEngine() {}
void TestRenderEngine::setRenderLayers(std::vector<std::shared_ptr<TestLayer>> layers) {
sort(layers.begin(), layers.end(),
diff --git a/power/aidl/vts/VtsHalPowerTargetTest.cpp b/power/aidl/vts/VtsHalPowerTargetTest.cpp
index c2216f8..22ab050 100644
--- a/power/aidl/vts/VtsHalPowerTargetTest.cpp
+++ b/power/aidl/vts/VtsHalPowerTargetTest.cpp
@@ -29,7 +29,6 @@
namespace aidl::android::hardware::power {
namespace {
-using ::android::base::GetUintProperty;
using android::hardware::power::Boost;
using android::hardware::power::IPower;
using android::hardware::power::IPowerHintSession;
@@ -73,8 +72,6 @@
const std::vector<int32_t> kEmptyTids = {};
-const std::vector<WorkDuration> kNoDurations = {};
-
const std::vector<WorkDuration> kDurationsWithZero = {
DurationWrapper(1000L, 1L),
DurationWrapper(0L, 2L),
@@ -92,36 +89,38 @@
DurationWrapper(1000000000L, 4L),
};
-// DEVICEs launching with Android 11 MUST meet the requirements for the
-// target-level=5 compatibility_matrix file.
-const uint64_t kCompatibilityMatrix5ApiLevel = 30;
-
-// DEVICEs launching with Android 13 MUST meet the requirements for the
-// target-level=7 compatibility_matrix file.
-const uint64_t kCompatibilityMatrix7ApiLevel = 33;
-
-// DEVICEs launching with Android 14 MUST meet the requirements for the
-// target-level=8 compatibility_matrix file.
-const uint64_t kCompatibilityMatrix8ApiLevel = 34;
-
-inline bool isUnknownOrUnsupported(const ndk::ScopedAStatus& status) {
- return status.getStatus() == STATUS_UNKNOWN_TRANSACTION ||
- status.getExceptionCode() == EX_UNSUPPORTED_OPERATION;
-}
-
class PowerAidl : public testing::TestWithParam<std::string> {
public:
virtual void SetUp() override {
AIBinder* binder = AServiceManager_waitForService(GetParam().c_str());
ASSERT_NE(binder, nullptr);
power = IPower::fromBinder(ndk::SpAIBinder(binder));
-
- mApiLevel = GetUintProperty<uint64_t>("ro.vendor.api_level", 0);
- ASSERT_NE(mApiLevel, 0);
+ auto status = power->getInterfaceVersion(&mServiceVersion);
+ ASSERT_TRUE(status.isOk());
+ if (mServiceVersion >= 2) {
+ status = power->createHintSession(getpid(), getuid(), kSelfTids, 16666666L, &mSession);
+ mSessionSupport = status.isOk();
+ }
}
std::shared_ptr<IPower> power;
- uint64_t mApiLevel;
+ int32_t mServiceVersion;
+ std::shared_ptr<IPowerHintSession> mSession;
+ bool mSessionSupport = false;
+};
+
+class HintSessionAidl : public PowerAidl {
+ public:
+ virtual void SetUp() override {
+ PowerAidl::SetUp();
+ if (mServiceVersion < 2) {
+ GTEST_SKIP() << "DEVICE not launching with Power V2 and beyond.";
+ }
+ if (!mSessionSupport) {
+ GTEST_SKIP() << "DEVICE not support Hint Session.";
+ }
+ ASSERT_NE(nullptr, mSession);
+ }
};
TEST_P(PowerAidl, setMode) {
@@ -175,113 +174,98 @@
}
TEST_P(PowerAidl, getHintSessionPreferredRate) {
- int64_t rate = -1;
- auto status = power->getHintSessionPreferredRate(&rate);
- if (mApiLevel < kCompatibilityMatrix7ApiLevel && !status.isOk()) {
- EXPECT_TRUE(isUnknownOrUnsupported(status));
- GTEST_SKIP() << "DEVICE not launching with Android 13 and beyond.";
+ if (!mSessionSupport) {
+ GTEST_SKIP() << "DEVICE not support Hint Session.";
}
- ASSERT_TRUE(status.isOk());
+ if (mServiceVersion < 2) {
+ GTEST_SKIP() << "DEVICE not launching with Power V2 and beyond.";
+ }
+
+ int64_t rate = -1;
+ ASSERT_TRUE(power->getHintSessionPreferredRate(&rate).isOk());
// At least 1ms rate limit from HAL
ASSERT_GE(rate, 1000000);
}
-TEST_P(PowerAidl, createAndCloseHintSession) {
- std::shared_ptr<IPowerHintSession> session;
- auto status = power->createHintSession(getpid(), getuid(), kSelfTids, 16666666L, &session);
- if (mApiLevel < kCompatibilityMatrix7ApiLevel && !status.isOk()) {
- EXPECT_TRUE(isUnknownOrUnsupported(status));
- GTEST_SKIP() << "DEVICE not launching with Android 13 and beyond.";
+TEST_P(HintSessionAidl, createAndCloseHintSession) {
+ if (!mSessionSupport) {
+ GTEST_SKIP() << "DEVICE not support Hint Session.";
}
- ASSERT_TRUE(status.isOk());
- ASSERT_NE(nullptr, session);
- ASSERT_TRUE(session->pause().isOk());
- ASSERT_TRUE(session->resume().isOk());
+ ASSERT_TRUE(mSession->pause().isOk());
+ ASSERT_TRUE(mSession->resume().isOk());
// Test normal destroy operation
- ASSERT_TRUE(session->close().isOk());
- session.reset();
+ ASSERT_TRUE(mSession->close().isOk());
+ mSession.reset();
}
-TEST_P(PowerAidl, createHintSessionFailed) {
+TEST_P(HintSessionAidl, createHintSessionFailed) {
+ if (!mSessionSupport) {
+ GTEST_SKIP() << "DEVICE not support Hint Session.";
+ }
std::shared_ptr<IPowerHintSession> session;
auto status = power->createHintSession(getpid(), getuid(), kEmptyTids, 16666666L, &session);
// Regardless of whether V2 and beyond is supported, the status is always not STATUS_OK.
ASSERT_FALSE(status.isOk());
-
- // If device not launching with Android 13 and beyond, check whether it's supported,
- // if not, skip the test.
- if (mApiLevel < kCompatibilityMatrix7ApiLevel && isUnknownOrUnsupported(status)) {
- GTEST_SKIP() << "DEVICE not launching with Android 13 and beyond.";
- }
ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
}
-TEST_P(PowerAidl, updateAndReportDurations) {
- std::shared_ptr<IPowerHintSession> session;
- auto status = power->createHintSession(getpid(), getuid(), kSelfTids, 16666666L, &session);
- if (mApiLevel < kCompatibilityMatrix7ApiLevel && !status.isOk()) {
- EXPECT_TRUE(isUnknownOrUnsupported(status));
- GTEST_SKIP() << "DEVICE not launching with Android 13 and beyond.";
+TEST_P(HintSessionAidl, updateAndReportDurations) {
+ if (!mSessionSupport) {
+ GTEST_SKIP() << "DEVICE not support Hint Session.";
}
- ASSERT_TRUE(status.isOk());
- ASSERT_NE(nullptr, session);
-
- ASSERT_TRUE(session->updateTargetWorkDuration(16666667LL).isOk());
- ASSERT_TRUE(session->reportActualWorkDuration(kDurations).isOk());
+ ASSERT_TRUE(mSession->updateTargetWorkDuration(16666667LL).isOk());
+ ASSERT_TRUE(mSession->reportActualWorkDuration(kDurations).isOk());
}
-TEST_P(PowerAidl, sendSessionHint) {
- std::shared_ptr<IPowerHintSession> session;
- auto status = power->createHintSession(getpid(), getuid(), kSelfTids, 16666666L, &session);
- if (!status.isOk()) {
- EXPECT_TRUE(isUnknownOrUnsupported(status));
- return;
+TEST_P(HintSessionAidl, sendSessionHint) {
+ if (!mSessionSupport) {
+ GTEST_SKIP() << "DEVICE not support Hint Session.";
}
+ if (mServiceVersion < 4) {
+ GTEST_SKIP() << "DEVICE not launching with Power V4 and beyond.";
+ }
+
for (const auto& sessionHint : kSessionHints) {
- ASSERT_TRUE(session->sendHint(sessionHint).isOk());
+ ASSERT_TRUE(mSession->sendHint(sessionHint).isOk());
}
for (const auto& sessionHint : kInvalidSessionHints) {
- ASSERT_TRUE(session->sendHint(sessionHint).isOk());
+ ASSERT_TRUE(mSession->sendHint(sessionHint).isOk());
}
}
-TEST_P(PowerAidl, setThreads) {
- std::shared_ptr<IPowerHintSession> session;
- auto status = power->createHintSession(getpid(), getuid(), kSelfTids, 16666666L, &session);
- if (mApiLevel < kCompatibilityMatrix7ApiLevel && !status.isOk()) {
- EXPECT_TRUE(isUnknownOrUnsupported(status));
- GTEST_SKIP() << "DEVICE not launching with Android 13 and beyond.";
+TEST_P(HintSessionAidl, setThreads) {
+ if (!mSessionSupport) {
+ GTEST_SKIP() << "DEVICE not support Hint Session.";
}
- ASSERT_TRUE(status.isOk());
+ if (mServiceVersion < 4) {
+ GTEST_SKIP() << "DEVICE not launching with Power V4 and beyond.";
+ }
- status = session->setThreads(kEmptyTids);
- if (mApiLevel < kCompatibilityMatrix8ApiLevel && isUnknownOrUnsupported(status)) {
- GTEST_SKIP() << "DEVICE not launching with Android 14 and beyond.";
- }
+ auto status = mSession->setThreads(kEmptyTids);
ASSERT_FALSE(status.isOk());
ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
- status = session->setThreads(kSelfTids);
- ASSERT_TRUE(status.isOk());
+ ASSERT_TRUE(mSession->setThreads(kSelfTids).isOk());
}
// FIXED_PERFORMANCE mode is required for all devices which ship on Android 11
// or later
TEST_P(PowerAidl, hasFixedPerformance) {
- if (mApiLevel < kCompatibilityMatrix5ApiLevel) {
- GTEST_SKIP() << "FIXED_PERFORMANCE mode is only required for all devices launching Android "
- "11 or later.";
- }
bool supported;
ASSERT_TRUE(power->isModeSupported(Mode::FIXED_PERFORMANCE, &supported).isOk());
ASSERT_TRUE(supported);
}
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(PowerAidl);
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(HintSessionAidl);
+
INSTANTIATE_TEST_SUITE_P(Power, PowerAidl,
testing::ValuesIn(::android::getAidlHalInstanceNames(IPower::descriptor)),
::android::PrintInstanceNameToString);
+INSTANTIATE_TEST_SUITE_P(Power, HintSessionAidl,
+ testing::ValuesIn(::android::getAidlHalInstanceNames(IPower::descriptor)),
+ ::android::PrintInstanceNameToString);
} // namespace
} // namespace aidl::android::hardware::power
diff --git a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
index 433857c..cafed01 100644
--- a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
@@ -199,10 +199,10 @@
/**
* An API to determine device IDs attestation is required or not,
- * which is mandatory for KeyMint version 2 or first_api_level 33 or greater.
+ * which is mandatory for KeyMint version 2 and first_api_level 33 or greater.
*/
bool KeyMintAidlTestBase::isDeviceIdAttestationRequired() {
- return AidlVersion() >= 2 || property_get_int32("ro.vendor.api_level", 0) >= __ANDROID_API_T__;
+ return AidlVersion() >= 2 && property_get_int32("ro.vendor.api_level", 0) >= __ANDROID_API_T__;
}
/**
diff --git a/sensors/aidl/vts/SensorsAidlTestSharedMemory.h b/sensors/aidl/vts/SensorsAidlTestSharedMemory.h
index 4b5916a..200f26f 100644
--- a/sensors/aidl/vts/SensorsAidlTestSharedMemory.h
+++ b/sensors/aidl/vts/SensorsAidlTestSharedMemory.h
@@ -17,7 +17,11 @@
#ifndef ANDROID_SENSORS_AIDL_TEST_SHARED_MEMORY_H
#define ANDROID_SENSORS_AIDL_TEST_SHARED_MEMORY_H
-#include "sensors-vts-utils/GrallocWrapper.h"
+#include <aidl/android/hardware/graphics/common/BufferUsage.h>
+#include <aidl/android/hardware/graphics/common/PixelFormat.h>
+#include <ui/GraphicBuffer.h>
+#include <ui/GraphicBufferAllocator.h>
+#include <ui/GraphicBufferMapper.h>
#include <aidlcommonsupport/NativeHandle.h>
#include <android-base/macros.h>
@@ -28,6 +32,8 @@
#include <cutils/ashmem.h>
+using ::aidl::android::hardware::graphics::common::BufferUsage;
+using ::aidl::android::hardware::graphics::common::PixelFormat;
using ::aidl::android::hardware::sensors::BnSensors;
using ::aidl::android::hardware::sensors::Event;
using ::aidl::android::hardware::sensors::ISensors;
@@ -53,12 +59,22 @@
}
ISensors::SharedMemInfo getSharedMemInfo() const {
- ISensors::SharedMemInfo mem = {
- .type = mType,
- .format = ISensors::SharedMemInfo::SharedMemFormat::SENSORS_EVENT,
- .size = static_cast<int32_t>(mSize),
- .memoryHandle = android::dupToAidl(mNativeHandle)};
- return mem;
+ if (mType == ISensors::SharedMemInfo::SharedMemType::GRALLOC) {
+ ISensors::SharedMemInfo mem = {
+ .type = mType,
+ .format = ISensors::SharedMemInfo::SharedMemFormat::SENSORS_EVENT,
+ .size = static_cast<int32_t>(mSize),
+ .memoryHandle = android::dupToAidl(mBufferHandle)};
+ return mem;
+
+ } else {
+ ISensors::SharedMemInfo mem = {
+ .type = mType,
+ .format = ISensors::SharedMemInfo::SharedMemFormat::SENSORS_EVENT,
+ .size = static_cast<int32_t>(mSize),
+ .memoryHandle = android::dupToAidl(mNativeHandle)};
+ return mem;
+ }
}
char* getBuffer() const { return mBuffer; }
size_t getSize() const { return mSize; }
@@ -141,17 +157,26 @@
}
case ISensors::SharedMemInfo::SharedMemType::GRALLOC: {
if (mSize != 0) {
- mGrallocWrapper->freeBuffer(mNativeHandle);
- mNativeHandle = nullptr;
+ android::status_t status =
+ android::GraphicBufferAllocator::get().free(mBufferHandle);
+ if (status != android::OK) {
+ ALOGE("SensorsAidlTestSharedMemory Gralloc failed to free buffer. Status: "
+ "%s",
+ android::statusToString(status).c_str());
+ }
+ mBufferHandle = nullptr;
+ mBuffer = nullptr;
mSize = 0;
}
break;
}
default: {
- if (mNativeHandle != nullptr || mSize != 0 || mBuffer != nullptr) {
+ if (mNativeHandle != nullptr || mSize != 0 || mBuffer != nullptr ||
+ mBufferHandle != nullptr) {
ALOGE("SensorsAidlTestSharedMemory %p not properly destructed: "
- "type %d, native handle %p, size %zu, buffer %p",
- this, static_cast<int>(mType), mNativeHandle, mSize, mBuffer);
+ "type %d, native handle %p, size %zu, buffer %p, buffer handle %p",
+ this, static_cast<int>(mType), mNativeHandle, mSize, mBuffer,
+ mBufferHandle);
}
break;
}
@@ -185,14 +210,33 @@
break;
}
case ISensors::SharedMemInfo::SharedMemType::GRALLOC: {
- mGrallocWrapper = std::make_unique<::android::GrallocWrapper>();
- if (!mGrallocWrapper->isInitialized()) {
+ static constexpr uint64_t kBufferUsage =
+ static_cast<uint64_t>(BufferUsage::SENSOR_DIRECT_DATA) |
+ static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN) |
+ static_cast<uint64_t>(BufferUsage::CPU_WRITE_RARELY);
+
+ uint32_t stride = 0;
+ buffer_handle_t bufferHandle;
+ android::status_t status = android::GraphicBufferAllocator::get().allocate(
+ size, 1, static_cast<int>(PixelFormat::BLOB), 1, kBufferUsage,
+ &bufferHandle, &stride, "SensorVts");
+ if (status != android::OK) {
+ ALOGE("SensorsAidlTestSharedMemory failed to allocate memory. Status: %s",
+ android::statusToString(status).c_str());
break;
}
-
- std::pair<native_handle_t*, void*> buf = mGrallocWrapper->allocate(size);
- handle = buf.first;
- buffer = static_cast<char*>(buf.second);
+ // Per the HAL, all-zeros Rect means the entire buffer
+ android::Rect rect = {0, 0, 0, 0};
+ void* ret;
+ status = android::GraphicBufferMapper::get().lock(bufferHandle, kBufferUsage, rect,
+ &ret);
+ if (status != android::OK) {
+ ALOGE("SensorsAidlTestSharedMemory failed to import buffer: Status: %s",
+ android::statusToString(status).c_str());
+ } else {
+ buffer = static_cast<char*>(ret);
+ mBufferHandle = bufferHandle;
+ }
break;
}
default:
@@ -208,9 +252,9 @@
ISensors::SharedMemInfo::SharedMemType mType;
native_handle_t* mNativeHandle;
+ buffer_handle_t mBufferHandle;
size_t mSize;
char* mBuffer;
- std::unique_ptr<::android::GrallocWrapper> mGrallocWrapper;
DISALLOW_COPY_AND_ASSIGN(SensorsAidlTestSharedMemory);
};
diff --git a/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h b/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h
index b17ecb8..eb626ff37 100644
--- a/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h
+++ b/sensors/common/vts/2_X/VtsHalSensorsV2_XTargetTest.h
@@ -52,8 +52,6 @@
using ::android::hardware::sensors::V1_0::Vec3;
using ::android::hardware::sensors::V2_1::implementation::convertToOldSensorInfos;
using std::chrono::duration_cast;
-using std::chrono::microseconds;
-using std::chrono::milliseconds;
using std::chrono::nanoseconds;
using EventV1_0 = ::android::hardware::sensors::V1_0::Event;
@@ -91,7 +89,7 @@
}
void waitForFlushEvents(const std::vector<SensorInfoType>& sensorsToWaitFor,
- int32_t numCallsToFlush, milliseconds timeout) {
+ int32_t numCallsToFlush, std::chrono::milliseconds timeout) {
std::unique_lock<std::recursive_mutex> lock(mFlushMutex);
mFlushCV.wait_for(lock, timeout,
[&] { return flushesReceived(sensorsToWaitFor, numCallsToFlush); });
@@ -102,7 +100,8 @@
return mEventMap[sensorHandle];
}
- void waitForEvents(const std::vector<SensorInfoType>& sensorsToWaitFor, milliseconds timeout) {
+ void waitForEvents(const std::vector<SensorInfoType>& sensorsToWaitFor,
+ std::chrono::milliseconds timeout) {
std::unique_lock<std::recursive_mutex> lock(mEventMutex);
mEventCV.wait_for(lock, timeout, [&] { return eventsReceived(sensorsToWaitFor); });
}
@@ -472,7 +471,7 @@
}
// Wait for events to be written back to the Event FMQ
- callback.waitForEvents(sensors, milliseconds(1000) /* timeout */);
+ callback.waitForEvents(sensors, std::chrono::milliseconds(1000) /* timeout */);
getEnvironment()->unregisterCallback();
for (const auto& s : sensors) {
@@ -633,7 +632,7 @@
}
// Wait up to one second for the flush events
- callback.waitForFlushEvents(sensorGroup, flushCalls, milliseconds(1000) /* timeout */);
+ callback.waitForFlushEvents(sensorGroup, flushCalls, std::chrono::milliseconds(1000) /* timeout */);
// Deactivate all sensors after waiting for flush events so pending flush events are not
// abandoned by the HAL.
@@ -760,8 +759,8 @@
}
TEST_P(SensorsHidlTest, NoStaleEvents) {
- constexpr milliseconds kFiveHundredMs(500);
- constexpr milliseconds kOneSecond(1000);
+ constexpr std::chrono::milliseconds kFiveHundredMs(500);
+ constexpr std::chrono::milliseconds kOneSecond(1000);
// Register the callback to receive sensor events
EventCallback callback;
@@ -769,10 +768,11 @@
// This test is not valid for one-shot, on-change or special-report-mode sensors
const std::vector<SensorInfoType> sensors = getNonOneShotAndNonOnChangeAndNonSpecialSensors();
- milliseconds maxMinDelay(0);
+ std::chrono::milliseconds maxMinDelay(0);
for (const SensorInfoType& sensor : sensors) {
- milliseconds minDelay = duration_cast<milliseconds>(microseconds(sensor.minDelay));
- maxMinDelay = milliseconds(std::max(maxMinDelay.count(), minDelay.count()));
+ std::chrono::milliseconds minDelay = duration_cast<std::chrono::milliseconds>(
+ std::chrono::microseconds(sensor.minDelay));
+ maxMinDelay = std::chrono::milliseconds(std::max(maxMinDelay.count(), minDelay.count()));
}
// Activate the sensors so that they start generating events
@@ -799,7 +799,7 @@
}
// Allow some time to pass, reset the callback, then reactivate the sensors
- usleep(duration_cast<microseconds>(kOneSecond + (5 * maxMinDelay)).count());
+ usleep(duration_cast<std::chrono::microseconds>(kOneSecond + (5 * maxMinDelay)).count());
callback.reset();
activateAllSensors(true);
callback.waitForEvents(sensors, kFiveHundredMs + (5 * maxMinDelay));
@@ -821,9 +821,10 @@
// Ensure that the first event received is not stale by ensuring that its timestamp is
// sufficiently different from the previous event
const EventType newEvent = callback.getEvents(sensor.sensorHandle).front();
- milliseconds delta = duration_cast<milliseconds>(
+ std::chrono::milliseconds delta = duration_cast<std::chrono::milliseconds>(
nanoseconds(newEvent.timestamp - lastEventTimestampMap[sensor.sensorHandle]));
- milliseconds sensorMinDelay = duration_cast<milliseconds>(microseconds(sensor.minDelay));
+ std::chrono::milliseconds sensorMinDelay = duration_cast<std::chrono::milliseconds>(
+ std::chrono::microseconds(sensor.minDelay));
ASSERT_GE(delta, kFiveHundredMs + (3 * sensorMinDelay));
}
}
diff --git a/sensors/common/vts/utils/Android.bp b/sensors/common/vts/utils/Android.bp
index b35280a..ab3984c 100644
--- a/sensors/common/vts/utils/Android.bp
+++ b/sensors/common/vts/utils/Android.bp
@@ -35,6 +35,7 @@
"libbinder_ndk",
"libutils",
"libvndksupport",
+ "libui",
],
static_libs: [
"libaidlcommonsupport",
@@ -50,9 +51,6 @@
"android.hardware.graphics.common-ndk_shared",
],
cflags: ["-DLOG_TAG=\"sensors_hidl_hal_test\""],
- srcs: [
- "GrallocWrapper.cpp",
- ],
export_include_dirs: [
"include",
],
@@ -64,6 +62,7 @@
"libbinder_ndk",
"libutils",
"libvndksupport",
+ "libui",
],
static_libs: [
"android.hardware.sensors@1.0",
@@ -71,13 +70,4 @@
"android.hardware.sensors@2.1",
"libaidlcommonsupport",
],
- whole_static_libs: [
- "android.hardware.graphics.allocator@2.0",
- "android.hardware.graphics.allocator@3.0",
- "android.hardware.graphics.allocator@4.0",
- "android.hardware.graphics.mapper@2.0",
- "android.hardware.graphics.mapper@2.1",
- "android.hardware.graphics.mapper@3.0",
- "android.hardware.graphics.mapper@4.0",
- ],
}
diff --git a/sensors/common/vts/utils/GrallocWrapper.cpp b/sensors/common/vts/utils/GrallocWrapper.cpp
deleted file mode 100644
index e6e0888..0000000
--- a/sensors/common/vts/utils/GrallocWrapper.cpp
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "GrallocWrapper.h"
-
-#include <aidl/android/hardware/graphics/allocator/IAllocator.h>
-#include <aidlcommonsupport/NativeHandle.h>
-#include <android/binder_manager.h>
-#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
-#include <android/hardware/graphics/allocator/3.0/IAllocator.h>
-#include <android/hardware/graphics/allocator/4.0/IAllocator.h>
-#include <android/hardware/graphics/mapper/2.0/IMapper.h>
-#include <android/hardware/graphics/mapper/2.1/IMapper.h>
-#include <android/hardware/graphics/mapper/3.0/IMapper.h>
-#include <android/hardware/graphics/mapper/4.0/IMapper.h>
-
-#include <utils/Log.h>
-
-#include <cinttypes>
-#include <memory>
-#include <type_traits>
-
-using IAllocatorAidl = ::aidl::android::hardware::graphics::allocator::IAllocator;
-using IAllocator2 = ::android::hardware::graphics::allocator::V2_0::IAllocator;
-using IAllocator3 = ::android::hardware::graphics::allocator::V3_0::IAllocator;
-using IAllocator4 = ::android::hardware::graphics::allocator::V4_0::IAllocator;
-using IMapper2 = ::android::hardware::graphics::mapper::V2_0::IMapper;
-using IMapper2_1 = ::android::hardware::graphics::mapper::V2_1::IMapper;
-using IMapper3 = ::android::hardware::graphics::mapper::V3_0::IMapper;
-using IMapper4 = ::android::hardware::graphics::mapper::V4_0::IMapper;
-
-using Error2 = ::android::hardware::graphics::mapper::V2_0::Error;
-using Error3 = ::android::hardware::graphics::mapper::V3_0::Error;
-using Error4 = ::android::hardware::graphics::mapper::V4_0::Error;
-
-using ::aidl::android::hardware::common::NativeHandle;
-using ::aidl::android::hardware::graphics::allocator::AllocationResult;
-
-using ::android::hardware::graphics::common::V1_0::BufferUsage;
-using ::android::hardware::graphics::common::V1_0::PixelFormat;
-
-using ::android::hardware::hidl_handle;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-
-namespace android {
-
-// Since we use the same APIs across allocator/mapper HALs but they have major
-// version differences (meaning they are not related through inheritance), we
-// create a common interface abstraction for the IAllocator + IMapper combination
-// (major versions need to match in the current HALs, e.g. IAllocator 3.0 needs to
-// be paired with IMapper 3.0, so these are tied together)
-class IGrallocHalWrapper {
- public:
- virtual ~IGrallocHalWrapper() = default;
-
- // IAllocator
- virtual native_handle_t* allocate(uint32_t size) = 0;
- virtual void freeBuffer(native_handle_t* bufferHandle) = 0;
-
- // IMapper
- virtual void* lock(native_handle_t* bufferHandle) = 0;
- virtual void unlock(native_handle_t* bufferHandle) = 0;
-};
-
-namespace {
-
-bool failed(Error2 error) {
- return (error != Error2::NONE);
-}
-bool failed(Error3 error) {
- return (error != Error3::NONE);
-}
-bool failed(Error4 error) {
- return (error != Error4::NONE);
-}
-
-template <typename>
-struct FirstArg;
-
-// Template specialization for pointer to a non-static member function, which exposes
-// the type of the first argument given to said function
-template <typename ReturnType, typename ClassT, typename Arg1, typename... OtherArgs>
-struct FirstArg<ReturnType (ClassT::*)(Arg1, OtherArgs...)> {
- using type = Arg1;
-};
-
-// Alias to FirstArg which also removes any reference type and const associated
-template <typename T>
-using BaseTypeOfFirstArg = typename std::remove_const<
- typename std::remove_reference<typename FirstArg<T>::type>::type>::type;
-
-// Since all the type and function names are the same for the things we use across the major HAL
-// versions, we use template magic to avoid repeating ourselves.
-template <typename AllocatorT, typename MapperT,
- template <typename> typename AllocatorWrapperT = sp>
-class GrallocHalWrapper : public IGrallocHalWrapper {
- public:
- GrallocHalWrapper(const AllocatorWrapperT<AllocatorT>& allocator, const sp<MapperT>& mapper)
- : mAllocator(allocator), mMapper(mapper) {
- if (mapper->isRemote()) {
- ALOGE("Mapper is in passthrough mode");
- }
- }
-
- virtual native_handle_t* allocate(uint32_t size) override;
- virtual void freeBuffer(native_handle_t* bufferHandle) override;
-
- virtual void* lock(native_handle_t* bufferHandle) override;
- virtual void unlock(native_handle_t* bufferHandle) override;
-
- private:
- static constexpr uint64_t kBufferUsage =
- static_cast<uint64_t>(BufferUsage::SENSOR_DIRECT_DATA | BufferUsage::CPU_READ_OFTEN);
- AllocatorWrapperT<AllocatorT> mAllocator;
- sp<MapperT> mMapper;
-
- // v2.0 and v3.0 use vec<uint32_t> for BufferDescriptor, but v4.0 uses vec<uint8_t>, so use
- // some template magic to deduce the right type based off of the first argument to allocate(),
- // which is always the version-specific BufferDescriptor type
- typedef BaseTypeOfFirstArg<decltype(&AllocatorT::allocate)> BufferDescriptorT;
-
- BufferDescriptorT getDescriptor(uint32_t size);
- native_handle_t* importBuffer(const hidl_handle& rawHandle);
-};
-
-template <>
-native_handle_t* GrallocHalWrapper<IAllocatorAidl, IMapper4, std::shared_ptr>::allocate(
- uint32_t size) {
- constexpr uint32_t kBufferCount = 1;
- BufferDescriptorT descriptor = getDescriptor(size);
- native_handle_t* bufferHandle = nullptr;
-
- AllocationResult result;
- auto status = mAllocator->allocate(descriptor, kBufferCount, &result);
- if (!status.isOk()) {
- status_t error = status.getExceptionCode();
- ALOGE("Failed to allocate buffer: %" PRId32, static_cast<int32_t>(error));
- } else if (result.buffers.size() != kBufferCount) {
- ALOGE("Invalid buffer array size (got %zu, expected %" PRIu32 ")", result.buffers.size(),
- kBufferCount);
- } else {
- // Convert from AIDL NativeHandle to native_handle_t to hidl_handle
- hidl_handle hidlHandle;
- hidlHandle.setTo(dupFromAidl(result.buffers[0]), /*shouldOwn*/ true);
- bufferHandle = importBuffer(hidlHandle);
- }
-
- return bufferHandle;
-}
-
-template <typename AllocatorT, typename MapperT, template <typename> typename AllocatorWrapperT>
-native_handle_t* GrallocHalWrapper<AllocatorT, MapperT, AllocatorWrapperT>::allocate(
- uint32_t size) {
- constexpr uint32_t kBufferCount = 1;
- BufferDescriptorT descriptor = getDescriptor(size);
- native_handle_t* bufferHandle = nullptr;
-
- auto callback = [&](auto error, uint32_t /*stride*/, const hidl_vec<hidl_handle>& buffers) {
- if (failed(error)) {
- ALOGE("Failed to allocate buffer: %" PRId32, static_cast<int32_t>(error));
- } else if (buffers.size() != kBufferCount) {
- ALOGE("Invalid buffer array size (got %zu, expected %" PRIu32 ")", buffers.size(),
- kBufferCount);
- } else {
- bufferHandle = importBuffer(buffers[0]);
- }
- };
-
- mAllocator->allocate(descriptor, kBufferCount, callback);
- return bufferHandle;
-}
-
-template <typename AllocatorT, typename MapperT, template <typename> typename AllocatorWrapperT>
-void GrallocHalWrapper<AllocatorT, MapperT, AllocatorWrapperT>::freeBuffer(
- native_handle_t* bufferHandle) {
- auto error = mMapper->freeBuffer(bufferHandle);
- if (!error.isOk() || failed(error)) {
- ALOGE("Failed to free buffer %p", bufferHandle);
- }
-}
-
-template <typename AllocatorT, typename MapperT, template <typename> typename AllocatorWrapperT>
-typename GrallocHalWrapper<AllocatorT, MapperT, AllocatorWrapperT>::BufferDescriptorT
-GrallocHalWrapper<AllocatorT, MapperT, AllocatorWrapperT>::getDescriptor(uint32_t size) {
- typename MapperT::BufferDescriptorInfo descriptorInfo = {
- .width = size,
- .height = 1,
- .layerCount = 1,
- .format = static_cast<decltype(descriptorInfo.format)>(PixelFormat::BLOB),
- .usage = kBufferUsage,
- };
-
- BufferDescriptorT descriptor;
- auto callback = [&](auto error, const BufferDescriptorT& tmpDescriptor) {
- if (failed(error)) {
- ALOGE("Failed to create descriptor: %" PRId32, static_cast<int32_t>(error));
- } else {
- descriptor = tmpDescriptor;
- }
- };
-
- mMapper->createDescriptor(descriptorInfo, callback);
- return descriptor;
-}
-
-template <typename AllocatorT, typename MapperT, template <typename> typename AllocatorWrapperT>
-native_handle_t* GrallocHalWrapper<AllocatorT, MapperT, AllocatorWrapperT>::importBuffer(
- const hidl_handle& rawHandle) {
- native_handle_t* bufferHandle = nullptr;
-
- mMapper->importBuffer(rawHandle, [&](auto error, void* tmpBuffer) {
- if (failed(error)) {
- ALOGE("Failed to import buffer %p: %" PRId32, rawHandle.getNativeHandle(),
- static_cast<int32_t>(error));
- } else {
- bufferHandle = static_cast<native_handle_t*>(tmpBuffer);
- }
- });
-
- return bufferHandle;
-}
-
-template <typename AllocatorT, typename MapperT, template <typename> typename AllocatorWrapperT>
-void* GrallocHalWrapper<AllocatorT, MapperT, AllocatorWrapperT>::lock(
- native_handle_t* bufferHandle) {
- // Per the HAL, all-zeros Rect means the entire buffer
- typename MapperT::Rect accessRegion = {};
- hidl_handle acquireFenceHandle; // No fence needed, already safe to lock
-
- void* data = nullptr;
- mMapper->lock(bufferHandle, kBufferUsage, accessRegion, acquireFenceHandle,
- [&](auto error, void* tmpData, ...) { // V3/4 pass extra args we don't use
- if (failed(error)) {
- ALOGE("Failed to lock buffer %p: %" PRId32, bufferHandle,
- static_cast<int32_t>(error));
- } else {
- data = tmpData;
- }
- });
-
- return data;
-}
-
-template <typename AllocatorT, typename MapperT, template <typename> typename AllocatorWrapperT>
-void GrallocHalWrapper<AllocatorT, MapperT, AllocatorWrapperT>::unlock(
- native_handle_t* bufferHandle) {
- mMapper->unlock(bufferHandle, [&](auto error, const hidl_handle& /*releaseFence*/) {
- if (failed(error)) {
- ALOGE("Failed to unlock buffer %p: %" PRId32, bufferHandle,
- static_cast<int32_t>(error));
- }
- });
-}
-
-} // anonymous namespace
-
-GrallocWrapper::GrallocWrapper() {
- sp<IAllocator4> allocator4 = IAllocator4::getService();
- sp<IMapper4> mapper4 = IMapper4::getService();
-
- const auto kAllocatorSvc = std::string(IAllocatorAidl::descriptor) + "/default";
- std::shared_ptr<IAllocatorAidl> allocatorAidl;
- if (AServiceManager_isDeclared(kAllocatorSvc.c_str())) {
- allocatorAidl = IAllocatorAidl::fromBinder(
- ndk::SpAIBinder(AServiceManager_checkService(kAllocatorSvc.c_str())));
- }
-
- // As of T, AIDL Allocator is supported only with HIDL Mapper4
- // (ref: VtsHalGraphicsAllocatorAidl_TargetTest.cpp)
- if (allocatorAidl != nullptr && mapper4 != nullptr) {
- ALOGD("Using AIDL IAllocator + HIDL IMapper v4.0");
- mGrallocHal = std::unique_ptr<IGrallocHalWrapper>(
- new GrallocHalWrapper<IAllocatorAidl, IMapper4, std::shared_ptr>(allocatorAidl,
- mapper4));
- } else if (allocator4 != nullptr && mapper4 != nullptr) {
- ALOGD("AIDL IAllocator not found, using HIDL IAllocator/IMapper v4.0");
- mGrallocHal = std::unique_ptr<IGrallocHalWrapper>(
- new GrallocHalWrapper<IAllocator4, IMapper4>(allocator4, mapper4));
- } else {
- ALOGD("Graphics HALs 4.0 not found (allocator %d mapper %d), falling back to 3.0",
- (allocator4 != nullptr), (mapper4 != nullptr));
-
- sp<IAllocator3> allocator3 = IAllocator3::getService();
- sp<IMapper3> mapper3 = IMapper3::getService();
-
- if (allocator3 != nullptr && mapper3 != nullptr) {
- mGrallocHal = std::unique_ptr<IGrallocHalWrapper>(
- new GrallocHalWrapper<IAllocator3, IMapper3>(allocator3, mapper3));
- } else {
- ALOGD("Graphics HALs 3.0 not found (allocator %d mapper %d), falling back to 2.x",
- (allocator3 != nullptr), (mapper3 != nullptr));
-
- sp<IAllocator2> allocator2 = IAllocator2::getService();
- sp<IMapper2> mapper2 = IMapper2_1::getService();
- if (mapper2 == nullptr) {
- mapper2 = IMapper2::getService();
- }
-
- if (allocator2 != nullptr && mapper2 != nullptr) {
- mGrallocHal = std::unique_ptr<IGrallocHalWrapper>(
- new GrallocHalWrapper<IAllocator2, IMapper2>(allocator2, mapper2));
- } else {
- ALOGE("Couldn't open graphics HALs (2.x allocator %d mapper %d)",
- (allocator2 != nullptr), (mapper2 != nullptr));
- }
- }
- }
-}
-
-GrallocWrapper::~GrallocWrapper() {
- for (auto bufferHandle : mAllocatedBuffers) {
- mGrallocHal->unlock(bufferHandle);
- mGrallocHal->freeBuffer(bufferHandle);
- }
- mAllocatedBuffers.clear();
-}
-
-std::pair<native_handle_t*, void*> GrallocWrapper::allocate(uint32_t size) {
- native_handle_t* bufferHandle = mGrallocHal->allocate(size);
- void* buffer = nullptr;
- if (bufferHandle) {
- buffer = mGrallocHal->lock(bufferHandle);
- if (buffer) {
- mAllocatedBuffers.insert(bufferHandle);
- } else {
- mGrallocHal->freeBuffer(bufferHandle);
- bufferHandle = nullptr;
- }
- }
- return std::make_pair<>(bufferHandle, buffer);
-}
-
-void GrallocWrapper::freeBuffer(native_handle_t* bufferHandle) {
- if (mAllocatedBuffers.erase(bufferHandle)) {
- mGrallocHal->unlock(bufferHandle);
- mGrallocHal->freeBuffer(bufferHandle);
- }
-}
-
-} // namespace android
diff --git a/sensors/common/vts/utils/include/sensors-vts-utils/GrallocWrapper.h b/sensors/common/vts/utils/include/sensors-vts-utils/GrallocWrapper.h
deleted file mode 100644
index ebbcb2c..0000000
--- a/sensors/common/vts/utils/include/sensors-vts-utils/GrallocWrapper.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <utils/NativeHandle.h>
-
-#include <memory>
-#include <string>
-#include <unordered_set>
-#include <utility>
-
-namespace android {
-
-class IGrallocHalWrapper;
-
-// Reference: hardware/interfaces/graphics/mapper/2.0/vts/functional/
-class GrallocWrapper {
- public:
- GrallocWrapper();
- ~GrallocWrapper();
-
- // After constructing this object, this function must be called to check the result. If it
- // returns false, other methods are not safe to call.
- bool isInitialized() const { return (mGrallocHal != nullptr); };
-
- // Allocates a gralloc buffer suitable for direct channel sensors usage with the given size.
- // The buffer should be freed using freeBuffer when it's not needed anymore; otherwise it'll
- // be freed when this object is destroyed.
- // Returns a handle to the buffer, and a CPU-accessible pointer for reading. On failure, both
- // will be set to nullptr.
- std::pair<native_handle_t*, void*> allocate(uint32_t size);
-
- // Releases a gralloc buffer previously returned by allocate()
- void freeBuffer(native_handle_t* bufferHandle);
-
- private:
- std::unique_ptr<IGrallocHalWrapper> mGrallocHal;
-
- // Keep track of all cloned and imported handles. When a test fails with
- // ASSERT_*, the destructor will free the handles for the test.
- std::unordered_set<native_handle_t*> mAllocatedBuffers;
-};
-
-} // namespace android
diff --git a/sensors/common/vts/utils/include/sensors-vts-utils/SensorsTestSharedMemory.h b/sensors/common/vts/utils/include/sensors-vts-utils/SensorsTestSharedMemory.h
index 39084a4..b96adb3 100644
--- a/sensors/common/vts/utils/include/sensors-vts-utils/SensorsTestSharedMemory.h
+++ b/sensors/common/vts/utils/include/sensors-vts-utils/SensorsTestSharedMemory.h
@@ -17,7 +17,11 @@
#ifndef ANDROID_SENSORS_TEST_SHARED_MEMORY_H
#define ANDROID_SENSORS_TEST_SHARED_MEMORY_H
-#include "GrallocWrapper.h"
+#include <aidl/android/hardware/graphics/common/BufferUsage.h>
+#include <aidl/android/hardware/graphics/common/PixelFormat.h>
+#include <ui/GraphicBuffer.h>
+#include <ui/GraphicBufferAllocator.h>
+#include <ui/GraphicBufferMapper.h>
#include <android-base/macros.h>
#include <log/log.h>
@@ -28,6 +32,8 @@
#include <cutils/ashmem.h>
using namespace ::android::hardware::sensors::V1_0;
+using ::aidl::android::hardware::graphics::common::BufferUsage;
+using ::aidl::android::hardware::graphics::common::PixelFormat;
template <class SensorTypeVersion, class EventType>
class SensorsTestSharedMemory {
@@ -48,11 +54,20 @@
}
SharedMemInfo getSharedMemInfo() const {
- SharedMemInfo mem = {.type = mType,
- .format = SharedMemFormat::SENSORS_EVENT,
- .size = static_cast<uint32_t>(mSize),
- .memoryHandle = mNativeHandle};
- return mem;
+ if (mType == SharedMemType::GRALLOC) {
+ SharedMemInfo mem = {.type = mType,
+ .format = SharedMemFormat::SENSORS_EVENT,
+ .size = static_cast<uint32_t>(mSize),
+ .memoryHandle = mBufferHandle};
+ return mem;
+
+ } else {
+ SharedMemInfo mem = {.type = mType,
+ .format = SharedMemFormat::SENSORS_EVENT,
+ .size = static_cast<uint32_t>(mSize),
+ .memoryHandle = mNativeHandle};
+ return mem;
+ }
}
char* getBuffer() const { return mBuffer; }
size_t getSize() const { return mSize; }
@@ -128,17 +143,26 @@
}
case SharedMemType::GRALLOC: {
if (mSize != 0) {
- mGrallocWrapper->freeBuffer(mNativeHandle);
- mNativeHandle = nullptr;
+ android::status_t status =
+ android::GraphicBufferAllocator::get().free(mBufferHandle);
+ if (status != android::OK) {
+ ALOGE("SensorsAidlTestSharedMemory Gralloc failed to free buffer. Status: "
+ "%s",
+ android::statusToString(status).c_str());
+ }
+ mBufferHandle = nullptr;
+ mBuffer = nullptr;
mSize = 0;
}
break;
}
default: {
- if (mNativeHandle != nullptr || mSize != 0 || mBuffer != nullptr) {
- ALOGE("SensorsTestSharedMemory %p not properly destructed: "
- "type %d, native handle %p, size %zu, buffer %p",
- this, static_cast<int>(mType), mNativeHandle, mSize, mBuffer);
+ if (mNativeHandle != nullptr || mSize != 0 || mBuffer != nullptr ||
+ mBufferHandle != nullptr) {
+ ALOGE("SensorsAidlTestSharedMemory %p not properly destructed: "
+ "type %d, native handle %p, size %zu, buffer %p, buffer handle %p",
+ this, static_cast<int>(mType), mNativeHandle, mSize, mBuffer,
+ mBufferHandle);
}
break;
}
@@ -171,14 +195,33 @@
break;
}
case SharedMemType::GRALLOC: {
- mGrallocWrapper = std::make_unique<::android::GrallocWrapper>();
- if (!mGrallocWrapper->isInitialized()) {
+ static constexpr uint64_t kBufferUsage =
+ static_cast<uint64_t>(BufferUsage::SENSOR_DIRECT_DATA) |
+ static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN) |
+ static_cast<uint64_t>(BufferUsage::CPU_WRITE_RARELY);
+
+ uint32_t stride = 0;
+ buffer_handle_t bufferHandle;
+ android::status_t status = android::GraphicBufferAllocator::get().allocate(
+ size, 1, static_cast<int>(PixelFormat::BLOB), 1, kBufferUsage,
+ &bufferHandle, &stride, "SensorVts");
+ if (status != android::OK) {
+ ALOGE("SensorsAidlTestSharedMemory failed to allocate memory. Status: %s",
+ android::statusToString(status).c_str());
break;
}
-
- std::pair<native_handle_t*, void*> buf = mGrallocWrapper->allocate(size);
- handle = buf.first;
- buffer = static_cast<char*>(buf.second);
+ // Per the HAL, all-zeros Rect means the entire buffer
+ android::Rect rect = {0, 0, 0, 0};
+ void* ret;
+ status = android::GraphicBufferMapper::get().lock(bufferHandle, kBufferUsage, rect,
+ &ret);
+ if (status != android::OK) {
+ ALOGE("SensorsAidlTestSharedMemory failed to import buffer: Status: %s",
+ android::statusToString(status).c_str());
+ } else {
+ buffer = static_cast<char*>(ret);
+ mBufferHandle = bufferHandle;
+ }
break;
}
default:
@@ -194,9 +237,9 @@
SharedMemType mType;
native_handle_t* mNativeHandle;
+ buffer_handle_t mBufferHandle;
size_t mSize;
char* mBuffer;
- std::unique_ptr<::android::GrallocWrapper> mGrallocWrapper;
DISALLOW_COPY_AND_ASSIGN(SensorsTestSharedMemory);
};
diff --git a/tv/tuner/aidl/vts/functional/VtsHalTvTunerTargetTest.cpp b/tv/tuner/aidl/vts/functional/VtsHalTvTunerTargetTest.cpp
index 766814f..401142b 100644
--- a/tv/tuner/aidl/vts/functional/VtsHalTvTunerTargetTest.cpp
+++ b/tv/tuner/aidl/vts/functional/VtsHalTvTunerTargetTest.cpp
@@ -100,7 +100,9 @@
ASSERT_TRUE(mFilterTests.configFilter(filterReconf.settings, filterId));
ASSERT_TRUE(mFilterTests.startFilter(filterId));
ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
- ASSERT_TRUE(mFilterTests.startIdTest(filterId));
+ if (!isPassthroughFilter(filterReconf)) {
+ ASSERT_TRUE(mFilterTests.startIdTest(filterId));
+ }
ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
ASSERT_TRUE(mFilterTests.stopFilter(filterId));
ASSERT_TRUE(mFilterTests.closeFilter(filterId));
@@ -152,7 +154,9 @@
ASSERT_TRUE(mFilterTests.startFilter(filterId));
// tune test
ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
- ASSERT_TRUE(filterDataOutputTest());
+ if (!isPassthroughFilter(filterConf)) {
+ ASSERT_TRUE(filterDataOutputTest());
+ }
ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
ASSERT_TRUE(mFilterTests.stopFilter(filterId));
ASSERT_TRUE(mFilterTests.closeFilter(filterId));
@@ -1357,6 +1361,10 @@
auto live_configs = generateLiveConfigurations();
for (auto& configuration : live_configs) {
live = configuration;
+ // shared memory handle is not used by a passthrough filter at all
+ if (isPassthroughFilter(filterMap[live.videoFilterId])) {
+ continue;
+ }
mediaFilterUsingSharedMemoryTest(filterMap[live.videoFilterId],
frontendMap[live.frontendId]);
}
diff --git a/tv/tuner/aidl/vts/functional/VtsHalTvTunerTargetTest.h b/tv/tuner/aidl/vts/functional/VtsHalTvTunerTargetTest.h
index be9b996..5fdc3dc 100644
--- a/tv/tuner/aidl/vts/functional/VtsHalTvTunerTargetTest.h
+++ b/tv/tuner/aidl/vts/functional/VtsHalTvTunerTargetTest.h
@@ -89,6 +89,28 @@
sectionFilterIds.clear();
}
+bool isPassthroughFilter(FilterConfig filterConfig) {
+ auto type = filterConfig.type;
+ if (type.mainType == DemuxFilterMainType::TS) {
+ auto subType = type.subType.get<DemuxFilterSubType::Tag::tsFilterType>();
+ if (subType == DemuxTsFilterType::AUDIO || subType == DemuxTsFilterType::VIDEO) {
+ auto tsFilterSettings = filterConfig.settings.get<DemuxFilterSettings::Tag::ts>();
+ auto avSettings = tsFilterSettings.filterSettings
+ .get<DemuxTsFilterSettingsFilterSettings::Tag::av>();
+ return avSettings.isPassthrough;
+ }
+ } else if (filterConfig.type.mainType != DemuxFilterMainType::MMTP) {
+ auto subType = type.subType.get<DemuxFilterSubType::Tag::mmtpFilterType>();
+ if (subType == DemuxMmtpFilterType::AUDIO || subType == DemuxMmtpFilterType::VIDEO) {
+ auto mmtpFilterSettings = filterConfig.settings.get<DemuxFilterSettings::Tag::mmtp>();
+ auto avSettings = mmtpFilterSettings.filterSettings
+ .get<DemuxMmtpFilterSettingsFilterSettings::Tag::av>();
+ return avSettings.isPassthrough;
+ }
+ }
+ return false;
+}
+
enum class Dataflow_Context { LNBRECORD, RECORD, DESCRAMBLING, LNBDESCRAMBLING };
class TunerLnbAidlTest : public testing::TestWithParam<std::string> {
diff --git a/wifi/aidl/vts/functional/wifi_sta_iface_aidl_test.cpp b/wifi/aidl/vts/functional/wifi_sta_iface_aidl_test.cpp
index e456e49..2ee960f 100644
--- a/wifi/aidl/vts/functional/wifi_sta_iface_aidl_test.cpp
+++ b/wifi/aidl/vts/functional/wifi_sta_iface_aidl_test.cpp
@@ -175,9 +175,9 @@
EXPECT_TRUE(isFeatureSupported(IWifiStaIface::FeatureSetMask::APF));
StaApfPacketFilterCapabilities apf_caps = {};
EXPECT_TRUE(wifi_sta_iface_->getApfPacketFilterCapabilities(&apf_caps).isOk());
- // The APF version must be 4 and the usable memory must be at least
+ // The APF version must be 4 or higher and the usable memory must be at least
// 1024 bytes.
- EXPECT_EQ(apf_caps.version, 4);
+ EXPECT_GE(apf_caps.version, 4);
EXPECT_GE(apf_caps.maxLength, 1024);
}
}