Merge "Add quant8 variant of VTS CompilationCachingTest." into qt-dev
diff --git a/current.txt b/current.txt
index 3083947..1f32263 100644
--- a/current.txt
+++ b/current.txt
@@ -401,7 +401,7 @@
65a021fa89085b62fc96b2b6d3bef2f9103cf4d63379c68bc154fd9eef672852 android.hardware.health@1.0::types
b7ecf29927055ec422ec44bf776223f07d79ad9f92ccf9becf167e62c2607e7a android.hardware.keymaster@4.0::IKeymasterDevice
574e8f1499436fb4075894dcae0b36682427956ecb114f17f1fe22d116a83c6b android.hardware.neuralnetworks@1.0::IPreparedModel
-e75759b40a1c5f97b463b30aab91954012c9ea9e454dde308db853a56796e5a6 android.hardware.neuralnetworks@1.0::types
+1e3576c07006d82ba5bc6ddbf87c101414d361c41afe7a82713750844c488725 android.hardware.neuralnetworks@1.0::types
eb754b58c93e5591613208b4c972811288b0fa16a82430d602f107c91a908b22 android.hardware.neuralnetworks@1.1::types
1d4a5776614c08b5d794a5ec5ab04697260cbd4b3441d5935cd53ee71d19da02 android.hardware.radio@1.0::IRadioResponse
ed9da80ec0c96991fd03f0a46107815d0e50f764656e49dba4980fa5c31d5bc3 android.hardware.radio@1.0::types
@@ -459,9 +459,9 @@
5b1f4a4fb88c239e07d76026467a1f2ee0d08f4d52c1805bd93bd7c05e3fe69c android.hardware.drm@1.2::ICryptoFactory
4895f98e9ef210e9acb01982f5d07b654538377e1404b8db5e19e7858835e9d8 android.hardware.drm@1.2::ICryptoPlugin
976116b9033b2c222b940109fdf0ffcc29b77cbe631ef6b4fcc2ad5ce8e605f7 android.hardware.drm@1.2::IDrmFactory
-b2efccc6425085f84795a2ca15a09d9a81ffd02f9dc3d30ba21d1a59bdfa253f android.hardware.drm@1.2::IDrmPlugin
-39ca9e88404b6c090f7650455a7ed3fdee9cce4e3a356c9d547f8ff02f2e7fc8 android.hardware.drm@1.2::IDrmPluginListener
-f27baaa587bc3dd9b740cb6928ab812b9b7d105b5187663938aee578105f3c39 android.hardware.drm@1.2::types
+8ef1caf921c3e83a00180f770e3b8e8ff65d8a5c806482e51aa45e6d55f1aec1 android.hardware.drm@1.2::IDrmPlugin
+b778fcce93eb6294446a940e1bae0200da7bd97b91b91977be2dcd31ca58374f android.hardware.drm@1.2::IDrmPluginListener
+564732cbfe5c0895cfbd2bdf84c3f2b0f760ea20f2237c0d388aaeeaef2dd0a9 android.hardware.drm@1.2::types
44480c912e4ab90b9ed17e56569cd5ca98413a8a2372efb028f4181204b6b73e android.hardware.fastboot@1.0::IFastboot
7b2989744e3c555292d4b5b829acd09a7b40f96ead62ce54174cd959503b64bb android.hardware.fastboot@1.0::types
7f460e795f5d1ed5e378935f98c6db4d39497de988aef1b4c2a4a07a6c400392 android.hardware.gnss@2.0::IAGnss
@@ -515,7 +515,7 @@
92714960d1a53fc2ec557302b41c7cc93d2636d8364a44bd0f85be0c92927ff8 android.hardware.neuralnetworks@1.2::IExecutionCallback
36e1064c869965dee533c537cefbe87e54db8bd8cd45be7e0e93e00e8a43863a android.hardware.neuralnetworks@1.2::IPreparedModel
e1c734d1545e1a4ae749ff1dd9704a8e594c59aea7c8363159dc258e93e0df3b android.hardware.neuralnetworks@1.2::IPreparedModelCallback
-e3b6176e3bf235c4e0e4e451b0166e396c7ee176cfe167c9147c3d46d7b34f0c android.hardware.neuralnetworks@1.2::types
+d18bba0b6c8d2d1da3cfb52b14f556d2e04eb91551d97ee60a3524cf993a3e0e android.hardware.neuralnetworks@1.2::types
cf7a4ba516a638f9b82a249c91fb603042c2d9ca43fd5aad9cf6c0401ed2a5d7 android.hardware.nfc@1.2::INfc
abf98c2ae08bf765db54edc8068e36d52eb558cff6706b6fd7c18c65a1f3fc18 android.hardware.nfc@1.2::types
4cb252dc6372a874aef666b92a6e9529915aa187521a700f0789065c3c702ead android.hardware.power.stats@1.0::IPowerStats
diff --git a/drm/1.2/IDrmPlugin.hal b/drm/1.2/IDrmPlugin.hal
index 7d266f4..df09ccf 100644
--- a/drm/1.2/IDrmPlugin.hal
+++ b/drm/1.2/IDrmPlugin.hal
@@ -226,4 +226,22 @@
* @param sessionId identifies the session the event originated from
*/
sendSessionLostState(SessionId sessionId);
+
+ /**
+ * Send a keys change event to the listener. The keys change event
+ * indicates the status of each key in the session. Keys can be
+ * indicated as being usable, expired, outputnotallowed or statuspending.
+ *
+ * This method only differs from @1.0 version by the addition of new
+ * KeyStatusType(s) in keyStatusList.
+ *
+ * @param sessionId identifies the session the event originated from
+ * @param keyStatusList indicates the status for each key ID in the
+ * session.
+ * @param hasNewUsableKey indicates if the event includes at least one
+ * key that has become usable.
+ */
+ sendKeysChange_1_2(SessionId sessionId, vec<KeyStatus> keyStatusList,
+ bool hasNewUsableKey);
+
};
diff --git a/drm/1.2/IDrmPluginListener.hal b/drm/1.2/IDrmPluginListener.hal
index a6bd6c9..e8cb91a 100644
--- a/drm/1.2/IDrmPluginListener.hal
+++ b/drm/1.2/IDrmPluginListener.hal
@@ -36,4 +36,22 @@
* @param sessionId identifies the session that has been invalidated
*/
oneway sendSessionLostState(SessionId sessionId);
+
+ /**
+ * Send a keys change event to the listener. The keys change event
+ * indicates the status of each key in the session. Keys can be
+ * indicated as being usable, expired, outputnotallowed or statuspending.
+ *
+ * This method only differs from @1.0 version by the addition of new
+ * KeyStatusType(s) in keyStatusList.
+ *
+ * @param sessionId identifies the session the event originated from
+ * @param keyStatusList indicates the status for each key ID in the
+ * session.
+ * @param hasNewUsableKey indicates if the event includes at least one
+ * key that has become usable.
+ */
+ oneway sendKeysChange_1_2(SessionId sessionId, vec<KeyStatus> keyStatusList,
+ bool hasNewUsableKey);
+
};
diff --git a/drm/1.2/types.hal b/drm/1.2/types.hal
index 28c8e67..87218a4 100644
--- a/drm/1.2/types.hal
+++ b/drm/1.2/types.hal
@@ -16,6 +16,7 @@
package android.hardware.drm@1.2;
+import @1.0::KeyStatusType;
import @1.0::Status;
import @1.1::HdcpLevel;
@@ -93,3 +94,25 @@
* set in methods that take a KeySetId as an input parameter.
*/
typedef vec<uint8_t> KeySetId;
+
+enum KeyStatusType : @1.0::KeyStatusType {
+ /**
+ * The key is not yet usable to decrypt media because the start
+ * time is in the future. The key must become usable when
+ * its start time is reached.
+ */
+ USABLEINFUTURE
+};
+
+/**
+ * Used by sendKeysChange_1_2 to report the usability status of each key to the
+ * app.
+ *
+ * This struct only differs from @1.0 version by the addition of new
+ * KeyStatusType(s).
+ *
+ */
+struct KeyStatus {
+ KeySetId keyId;
+ KeyStatusType type;
+};
diff --git a/drm/1.2/vts/functional/drm_hal_common.cpp b/drm/1.2/vts/functional/drm_hal_common.cpp
index b9a8425..bfffbe8 100644
--- a/drm/1.2/vts/functional/drm_hal_common.cpp
+++ b/drm/1.2/vts/functional/drm_hal_common.cpp
@@ -56,6 +56,7 @@
namespace vts {
const char *kCallbackLostState = "LostState";
+const char *kCallbackKeysChange = "KeysChange";
drm_vts::VendorModules *DrmHalTest::gVendorModules = nullptr;
@@ -64,7 +65,19 @@
*/
Return<void> DrmHalPluginListener::sendSessionLostState(const hidl_vec<uint8_t>& sessionId) {
- NotifyFromCallback(kCallbackLostState, sessionId);
+ ListenerEventArgs args;
+ args.sessionId = sessionId;
+ NotifyFromCallback(kCallbackLostState, args);
+ return Void();
+}
+
+Return<void> DrmHalPluginListener::sendKeysChange_1_2(const hidl_vec<uint8_t>& sessionId,
+ const hidl_vec<KeyStatus>& keyStatusList, bool hasNewUsableKey) {
+ ListenerEventArgs args;
+ args.sessionId = sessionId;
+ args.keyStatusList = keyStatusList;
+ args.hasNewUsableKey = hasNewUsableKey;
+ NotifyFromCallback(kCallbackKeysChange, args);
return Void();
}
diff --git a/drm/1.2/vts/functional/drm_hal_common.h b/drm/1.2/vts/functional/drm_hal_common.h
index 1b95dde..e348664 100644
--- a/drm/1.2/vts/functional/drm_hal_common.h
+++ b/drm/1.2/vts/functional/drm_hal_common.h
@@ -37,7 +37,7 @@
using ::android::hardware::drm::V1_0::EventType;
using ::android::hardware::drm::V1_0::KeyedVector;
-using ::android::hardware::drm::V1_0::KeyStatus;
+using KeyStatusV1_0 = ::android::hardware::drm::V1_0::KeyStatus;
using ::android::hardware::drm::V1_0::KeyType;
using ::android::hardware::drm::V1_0::Mode;
using ::android::hardware::drm::V1_0::Pattern;
@@ -46,10 +46,6 @@
using ::android::hardware::drm::V1_1::ICryptoFactory;
-using ::android::hardware::drm::V1_2::ICryptoPlugin;
-using ::android::hardware::drm::V1_2::IDrmFactory;
-using ::android::hardware::drm::V1_2::IDrmPlugin;
-using ::android::hardware::drm::V1_2::IDrmPluginListener;
using StatusV1_2 = ::android::hardware::drm::V1_2::Status;
using ::android::hardware::hidl_array;
@@ -166,9 +162,16 @@
* Event Handling tests
*/
extern const char *kCallbackLostState;
+extern const char *kCallbackKeysChange;
+
+struct ListenerEventArgs {
+ SessionId sessionId;
+ hidl_vec<KeyStatus> keyStatusList;
+ bool hasNewUsableKey;
+};
class DrmHalPluginListener
- : public ::testing::VtsHalHidlTargetCallbackBase<SessionId>,
+ : public ::testing::VtsHalHidlTargetCallbackBase<ListenerEventArgs>,
public IDrmPluginListener {
public:
DrmHalPluginListener() {
@@ -183,10 +186,13 @@
int64_t) override { return Void(); }
virtual Return<void> sendKeysChange(const hidl_vec<uint8_t>&,
- const hidl_vec<KeyStatus>&, bool) override { return Void(); }
+ const hidl_vec<KeyStatusV1_0>&, bool) override { return Void(); }
virtual Return<void> sendSessionLostState(const hidl_vec<uint8_t>& sessionId) override;
+ virtual Return<void> sendKeysChange_1_2(const hidl_vec<uint8_t>&,
+ const hidl_vec<KeyStatus>&, bool) override;
+
};
} // namespace vts
diff --git a/drm/1.2/vts/functional/drm_hal_test.cpp b/drm/1.2/vts/functional/drm_hal_test.cpp
index 252ebb9..37ecc25 100644
--- a/drm/1.2/vts/functional/drm_hal_test.cpp
+++ b/drm/1.2/vts/functional/drm_hal_test.cpp
@@ -28,6 +28,8 @@
using ::android::hardware::drm::V1_1::SecurityLevel;
using ::android::hardware::drm::V1_2::HdcpLevel;
using ::android::hardware::drm::V1_2::KeySetId;
+using ::android::hardware::drm::V1_2::KeyStatus;
+using ::android::hardware::drm::V1_2::KeyStatusType;
using ::android::hardware::drm::V1_2::OfflineLicenseState;
using ::android::hardware::drm::V1_2::vts::DrmHalClearkeyTest;
@@ -35,6 +37,7 @@
using ::android::hardware::drm::V1_2::vts::DrmHalTest;
using ::android::hardware::drm::V1_2::vts::DrmHidlEnvironment;
using ::android::hardware::drm::V1_2::vts::kCallbackLostState;
+using ::android::hardware::drm::V1_2::vts::kCallbackKeysChange;
using ::android::hardware::hidl_string;
@@ -275,6 +278,35 @@
}
/**
+ * Simulate the plugin sending keys change and make sure
+ * the listener gets them.
+ */
+TEST_P(DrmHalTest, ListenerKeysChange) {
+ RETURN_IF_SKIPPED;
+ sp<DrmHalPluginListener> listener = new DrmHalPluginListener();
+ auto res = drmPlugin->setListener(listener);
+ EXPECT_OK(res);
+
+ auto sessionId = openSession();
+ const hidl_vec<KeyStatus> keyStatusList = {
+ {{1}, KeyStatusType::USABLE},
+ {{2}, KeyStatusType::EXPIRED},
+ {{3}, KeyStatusType::OUTPUTNOTALLOWED},
+ {{4}, KeyStatusType::STATUSPENDING},
+ {{5}, KeyStatusType::INTERNALERROR},
+ {{6}, KeyStatusType::USABLEINFUTURE},
+ };
+
+ drmPlugin->sendKeysChange_1_2(sessionId, keyStatusList, true);
+ auto result = listener->WaitForCallback(kCallbackKeysChange);
+ EXPECT_TRUE(result.no_timeout);
+ EXPECT_TRUE(result.args);
+ EXPECT_EQ(sessionId, result.args->sessionId);
+ EXPECT_EQ(keyStatusList, result.args->keyStatusList);
+ closeSession(sessionId);
+}
+
+/**
* CryptoPlugin Decrypt tests
*/
@@ -452,7 +484,7 @@
auto result = listener->WaitForCallback(kCallbackLostState);
EXPECT_TRUE(result.no_timeout);
EXPECT_TRUE(result.args);
- EXPECT_EQ(sessionId, *(result.args));
+ EXPECT_EQ(sessionId, result.args->sessionId);
}
/**
diff --git a/gnss/2.0/vts/functional/gnss_hal_test.cpp b/gnss/2.0/vts/functional/gnss_hal_test.cpp
index febd0f1..a9f858c 100644
--- a/gnss/2.0/vts/functional/gnss_hal_test.cpp
+++ b/gnss/2.0/vts/functional/gnss_hal_test.cpp
@@ -23,8 +23,6 @@
using ::android::hardware::gnss::common::Utils;
// Implementations for the main test class for GNSS HAL
-GnssHalTest::GnssHalTest() {}
-
void GnssHalTest::SetUp() {
gnss_hal_ = ::testing::VtsHalHidlTargetTestBase::getService<IGnss>(
GnssHidlEnvironment::Instance()->getServiceName<IGnss>());
@@ -36,25 +34,15 @@
void GnssHalTest::TearDown() {
if (gnss_hal_ != nullptr) {
gnss_hal_->cleanup();
+ gnss_hal_ = nullptr;
}
- int unprocessedEventsCount = measurement_cbq_.size() + location_cbq_.size();
- if (unprocessedEventsCount > 0) {
- ALOGW("%d unprocessed callbacks discarded", unprocessedEventsCount);
- }
-
- // Reset all callback event queues.
- info_cbq_.reset();
- name_cbq_.reset();
- top_hal_capabilities_cbq_.reset();
- measurement_corrections_capabilities_cbq_.reset();
- measurement_cbq_.reset();
- location_cbq_.reset();
- sv_info_cbq_.reset();
+ // Set to nullptr to destruct the callback event queues and warn of any unprocessed events.
+ gnss_cb_ = nullptr;
}
void GnssHalTest::SetUpGnssCallback() {
- gnss_cb_ = new GnssCallback(*this);
+ gnss_cb_ = new GnssCallback();
ASSERT_NE(gnss_cb_, nullptr);
auto result = gnss_hal_->setCallback_2_0(gnss_cb_);
@@ -68,13 +56,13 @@
/*
* All capabilities, name and systemInfo callbacks should trigger
*/
- EXPECT_TRUE(top_hal_capabilities_cbq_.retrieve(last_capabilities_, TIMEOUT_SEC));
- EXPECT_TRUE(info_cbq_.retrieve(last_info_, TIMEOUT_SEC));
- EXPECT_TRUE(name_cbq_.retrieve(last_name_, TIMEOUT_SEC));
+ EXPECT_TRUE(gnss_cb_->capabilities_cbq_.retrieve(gnss_cb_->last_capabilities_, TIMEOUT_SEC));
+ EXPECT_TRUE(gnss_cb_->info_cbq_.retrieve(gnss_cb_->last_info_, TIMEOUT_SEC));
+ EXPECT_TRUE(gnss_cb_->name_cbq_.retrieve(gnss_cb_->last_name_, TIMEOUT_SEC));
- EXPECT_EQ(top_hal_capabilities_cbq_.calledCount(), 1);
- EXPECT_EQ(info_cbq_.calledCount(), 1);
- EXPECT_EQ(name_cbq_.calledCount(), 1);
+ EXPECT_EQ(gnss_cb_->capabilities_cbq_.calledCount(), 1);
+ EXPECT_EQ(gnss_cb_->info_cbq_.calledCount(), 1);
+ EXPECT_EQ(gnss_cb_->name_cbq_.calledCount(), 1);
}
void GnssHalTest::StopAndClearLocations() {
@@ -88,8 +76,9 @@
* the last reply for final startup messages to arrive (esp. system
* info.)
*/
- location_cbq_.waitUntilEmpty(TIMEOUT_SEC);
- location_cbq_.reset();
+ while (gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_, TIMEOUT_SEC)) {
+ }
+ gnss_cb_->location_cbq_.reset();
}
void GnssHalTest::SetPositionMode(const int min_interval_msec, const bool low_power_mode) {
@@ -116,20 +105,22 @@
*/
const int kFirstGnssLocationTimeoutSeconds = 75;
- EXPECT_TRUE(location_cbq_.retrieve(last_location_, kFirstGnssLocationTimeoutSeconds));
- int locationCalledCount = location_cbq_.calledCount();
+ EXPECT_TRUE(gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_,
+ kFirstGnssLocationTimeoutSeconds));
+ int locationCalledCount = gnss_cb_->location_cbq_.calledCount();
EXPECT_EQ(locationCalledCount, 1);
if (locationCalledCount > 0) {
// don't require speed on first fix
- CheckLocation(last_location_, false);
+ CheckLocation(gnss_cb_->last_location_, false);
return true;
}
return false;
}
void GnssHalTest::CheckLocation(const GnssLocation_2_0& location, bool check_speed) {
- const bool check_more_accuracies = (info_cbq_.calledCount() > 0 && last_info_.yearOfHw >= 2017);
+ const bool check_more_accuracies =
+ (gnss_cb_->info_cbq_.calledCount() > 0 && gnss_cb_->last_info_.yearOfHw >= 2017);
Utils::checkLocation(location.v1_0, check_speed, check_more_accuracies);
}
@@ -144,39 +135,47 @@
EXPECT_TRUE(StartAndCheckFirstLocation());
for (int i = 1; i < count; i++) {
- EXPECT_TRUE(location_cbq_.retrieve(last_location_, kLocationTimeoutSubsequentSec));
- int locationCalledCount = location_cbq_.calledCount();
+ EXPECT_TRUE(gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_,
+ kLocationTimeoutSubsequentSec));
+ int locationCalledCount = gnss_cb_->location_cbq_.calledCount();
EXPECT_EQ(locationCalledCount, i + 1);
// Don't cause confusion by checking details if no location yet
if (locationCalledCount > 0) {
// Should be more than 1 location by now, but if not, still don't check first fix speed
- CheckLocation(last_location_, locationCalledCount > 1);
+ CheckLocation(gnss_cb_->last_location_, locationCalledCount > 1);
}
}
}
+GnssHalTest::GnssCallback::GnssCallback()
+ : info_cbq_("system_info"),
+ name_cbq_("name"),
+ capabilities_cbq_("capabilities"),
+ location_cbq_("location"),
+ sv_info_cbq_("sv_info") {}
+
Return<void> GnssHalTest::GnssCallback::gnssSetSystemInfoCb(
const IGnssCallback_1_0::GnssSystemInfo& info) {
ALOGI("Info received, year %d", info.yearOfHw);
- parent_.info_cbq_.store(info);
+ info_cbq_.store(info);
return Void();
}
Return<void> GnssHalTest::GnssCallback::gnssSetCapabilitesCb(uint32_t capabilities) {
ALOGI("Capabilities received %d", capabilities);
- parent_.top_hal_capabilities_cbq_.store(capabilities);
+ capabilities_cbq_.store(capabilities);
return Void();
}
Return<void> GnssHalTest::GnssCallback::gnssSetCapabilitiesCb_2_0(uint32_t capabilities) {
ALOGI("Capabilities (v2.0) received %d", capabilities);
- parent_.top_hal_capabilities_cbq_.store(capabilities);
+ capabilities_cbq_.store(capabilities);
return Void();
}
Return<void> GnssHalTest::GnssCallback::gnssNameCb(const android::hardware::hidl_string& name) {
ALOGI("Name received: %s", name.c_str());
- parent_.name_cbq_.store(name);
+ name_cbq_.store(name);
return Void();
}
@@ -193,7 +192,7 @@
}
Return<void> GnssHalTest::GnssCallback::gnssLocationCbImpl(const GnssLocation_2_0& location) {
- parent_.location_cbq_.store(location);
+ location_cbq_.store(location);
return Void();
}
@@ -202,23 +201,23 @@
return Void();
}
+Return<void> GnssHalTest::GnssCallback::gnssSvStatusCb_2_0(
+ const hidl_vec<IGnssCallback_2_0::GnssSvInfo>& svInfoList) {
+ ALOGI("gnssSvStatusCb_2_0. Size = %d", (int)svInfoList.size());
+ sv_info_cbq_.store(svInfoList);
+ return Void();
+}
+
Return<void> GnssHalTest::GnssMeasurementCallback::gnssMeasurementCb_2_0(
const IGnssMeasurementCallback_2_0::GnssData& data) {
ALOGD("GnssMeasurement received. Size = %d", (int)data.measurements.size());
- parent_.measurement_cbq_.store(data);
+ measurement_cbq_.store(data);
return Void();
}
Return<void> GnssHalTest::GnssMeasurementCorrectionsCallback::setCapabilitiesCb(
uint32_t capabilities) {
ALOGI("GnssMeasurementCorrectionsCallback capabilities received %d", capabilities);
- parent_.measurement_corrections_capabilities_cbq_.store(capabilities);
- return Void();
-}
-
-Return<void> GnssHalTest::GnssCallback::gnssSvStatusCb_2_0(
- const hidl_vec<IGnssCallback_2_0::GnssSvInfo>& svInfoList) {
- ALOGI("gnssSvStatusCb_2_0. Size = %d", (int)svInfoList.size());
- parent_.sv_info_cbq_.store(svInfoList);
+ capabilities_cbq_.store(capabilities);
return Void();
}
diff --git a/gnss/2.0/vts/functional/gnss_hal_test.h b/gnss/2.0/vts/functional/gnss_hal_test.h
index 8e440ff..05e37d3 100644
--- a/gnss/2.0/vts/functional/gnss_hal_test.h
+++ b/gnss/2.0/vts/functional/gnss_hal_test.h
@@ -65,27 +65,61 @@
// The main test class for GNSS HAL.
class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase {
public:
- GnssHalTest();
-
virtual void SetUp() override;
virtual void TearDown() override;
- /* Used as a mechanism to inform the test that a callback has occurred */
- void notify();
+ /* Producer/consumer queue for storing/retrieving callback events from GNSS HAL */
+ template <class T>
+ class CallbackQueue {
+ public:
+ CallbackQueue(const std::string& name) : name_(name), called_count_(0){};
+ ~CallbackQueue() { reset(); }
- /* Test code calls this function to wait for a callback */
- std::cv_status wait(int timeout_seconds);
+ /* Adds callback event to the end of the queue. */
+ void store(const T& event);
- std::cv_status waitForMeasurementCorrectionsCapabilities(int timeout_seconds);
+ /*
+ * Removes the callack event at the front of the queue, stores it in event parameter
+ * and returns true. Returns false on timeout and event is not populated.
+ */
+ bool retrieve(T& event, int timeout_seconds);
+
+ /* Returns the number of events pending to be retrieved from the callback event queue. */
+ int size() const;
+
+ /* Returns the number of callback events received since last reset(). */
+ int calledCount() const;
+
+ /* Clears the callback event queue and resets the calledCount() to 0. */
+ void reset();
+
+ private:
+ CallbackQueue(const CallbackQueue&) = delete;
+ CallbackQueue& operator=(const CallbackQueue&) = delete;
+
+ std::string name_;
+ int called_count_;
+ mutable std::recursive_mutex mtx_;
+ std::condition_variable_any cv_;
+ std::deque<T> events_;
+ };
/* Callback class for data & Event. */
class GnssCallback : public IGnssCallback_2_0 {
public:
- GnssHalTest& parent_;
+ IGnssCallback_1_0::GnssSystemInfo last_info_;
+ android::hardware::hidl_string last_name_;
+ uint32_t last_capabilities_;
+ GnssLocation_2_0 last_location_;
- GnssCallback(GnssHalTest& parent) : parent_(parent){};
+ CallbackQueue<IGnssCallback_1_0::GnssSystemInfo> info_cbq_;
+ CallbackQueue<android::hardware::hidl_string> name_cbq_;
+ CallbackQueue<uint32_t> capabilities_cbq_;
+ CallbackQueue<GnssLocation_2_0> location_cbq_;
+ CallbackQueue<hidl_vec<IGnssCallback_2_0::GnssSvInfo>> sv_info_cbq_;
+ GnssCallback();
virtual ~GnssCallback() = default;
// Dummy callback handlers
@@ -126,8 +160,9 @@
/* Callback class for GnssMeasurement. */
class GnssMeasurementCallback : public IGnssMeasurementCallback_2_0 {
public:
- GnssHalTest& parent_;
- GnssMeasurementCallback(GnssHalTest& parent) : parent_(parent){};
+ CallbackQueue<IGnssMeasurementCallback_2_0::GnssData> measurement_cbq_;
+
+ GnssMeasurementCallback() : measurement_cbq_("measurement"){};
virtual ~GnssMeasurementCallback() = default;
// Methods from V1_0::IGnssMeasurementCallback follow.
@@ -147,85 +182,16 @@
/* Callback class for GnssMeasurementCorrections. */
class GnssMeasurementCorrectionsCallback : public IMeasurementCorrectionsCallback {
public:
- GnssHalTest& parent_;
- GnssMeasurementCorrectionsCallback(GnssHalTest& parent) : parent_(parent){};
+ uint32_t last_capabilities_;
+ CallbackQueue<uint32_t> capabilities_cbq_;
+
+ GnssMeasurementCorrectionsCallback() : capabilities_cbq_("capabilities"){};
virtual ~GnssMeasurementCorrectionsCallback() = default;
// Methods from V1_0::IMeasurementCorrectionsCallback follow.
Return<void> setCapabilitiesCb(uint32_t capabilities) override;
};
- /* Producer/consumer queue for storing/retrieving callback events from GNSS HAL */
- template <class T>
- class CallbackQueue {
- public:
- CallbackQueue() : called_count_(0){};
-
- /* Adds callback event to the end of the queue. */
- void store(const T& event) {
- std::unique_lock<std::recursive_mutex> lock(mtx_);
- events_.push_back(event);
- ++called_count_;
- lock.unlock();
- cv_.notify_all();
- }
-
- /*
- * Removes the callack event at the front of the queue, stores it in event parameter
- * and returns true. If the timeout occurs waiting for callback event, returns false.
- */
- bool retrieve(T& event, int timeout_seconds) {
- std::unique_lock<std::recursive_mutex> lock(mtx_);
- cv_.wait_for(lock, std::chrono::seconds(timeout_seconds),
- [&] { return !events_.empty(); });
- if (events_.empty()) {
- return false;
- }
- event = events_.front();
- events_.pop_front();
- return true;
- }
-
- /* Returns the number of events pending to be retrieved from the callback event queue. */
- int size() const {
- std::unique_lock<std::recursive_mutex> lock(mtx_);
- return events_.size();
- }
-
- /* Returns the number of callback events received since last reset(). */
- int calledCount() const {
- std::unique_lock<std::recursive_mutex> lock(mtx_);
- return called_count_;
- }
-
- /* Clears the callback event queue and resets the calledCount() to 0. */
- void reset() {
- std::unique_lock<std::recursive_mutex> lock(mtx_);
- events_.clear();
- called_count_ = 0;
- }
-
- /*
- * Blocks the calling thread until the callback event queue becomes empty or timeout
- * occurs. Returns false on timeout.
- */
- bool waitUntilEmpty(int timeout_seconds) {
- std::unique_lock<std::recursive_mutex> lock(mtx_);
- cv_.wait_for(lock, std::chrono::seconds(timeout_seconds),
- [&] { return events_.empty(); });
- return !events_.empty();
- }
-
- private:
- CallbackQueue(const CallbackQueue&) = delete;
- CallbackQueue& operator=(const CallbackQueue&) = delete;
-
- mutable std::recursive_mutex mtx_;
- std::condition_variable_any cv_;
- std::deque<T> events_;
- int called_count_;
- };
-
/*
* SetUpGnssCallback:
* Set GnssCallback and verify the result.
@@ -274,21 +240,51 @@
void SetPositionMode(const int min_interval_msec, const bool low_power_mode);
sp<IGnss> gnss_hal_; // GNSS HAL to call into
- sp<IGnssCallback_2_0> gnss_cb_; // Primary callback interface
-
- IGnssCallback_1_0::GnssSystemInfo last_info_;
- uint32_t last_capabilities_;
- uint32_t last_measurement_corrections_capabilities_;
- GnssLocation_2_0 last_location_;
- android::hardware::hidl_string last_name_;
-
- CallbackQueue<IGnssCallback_1_0::GnssSystemInfo> info_cbq_;
- CallbackQueue<android::hardware::hidl_string> name_cbq_;
- CallbackQueue<uint32_t> top_hal_capabilities_cbq_;
- CallbackQueue<uint32_t> measurement_corrections_capabilities_cbq_;
- CallbackQueue<IGnssMeasurementCallback_2_0::GnssData> measurement_cbq_;
- CallbackQueue<GnssLocation_2_0> location_cbq_;
- CallbackQueue<hidl_vec<IGnssCallback_2_0::GnssSvInfo>> sv_info_cbq_;
+ sp<GnssCallback> gnss_cb_; // Primary callback interface
};
+template <class T>
+void GnssHalTest::CallbackQueue<T>::store(const T& event) {
+ std::unique_lock<std::recursive_mutex> lock(mtx_);
+ events_.push_back(event);
+ ++called_count_;
+ lock.unlock();
+ cv_.notify_all();
+}
+
+template <class T>
+bool GnssHalTest::CallbackQueue<T>::retrieve(T& event, int timeout_seconds) {
+ std::unique_lock<std::recursive_mutex> lock(mtx_);
+ cv_.wait_for(lock, std::chrono::seconds(timeout_seconds), [&] { return !events_.empty(); });
+ if (events_.empty()) {
+ return false;
+ }
+ event = events_.front();
+ events_.pop_front();
+ return true;
+}
+
+template <class T>
+int GnssHalTest::CallbackQueue<T>::size() const {
+ std::unique_lock<std::recursive_mutex> lock(mtx_);
+ return events_.size();
+}
+
+template <class T>
+int GnssHalTest::CallbackQueue<T>::calledCount() const {
+ std::unique_lock<std::recursive_mutex> lock(mtx_);
+ return called_count_;
+}
+
+template <class T>
+void GnssHalTest::CallbackQueue<T>::reset() {
+ std::unique_lock<std::recursive_mutex> lock(mtx_);
+ if (!events_.empty()) {
+ ALOGW("%u unprocessed events discarded in callback queue %s", (unsigned int)events_.size(),
+ name_.c_str());
+ }
+ events_.clear();
+ called_count_ = 0;
+}
+
#endif // GNSS_HAL_TEST_H_
diff --git a/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp
index 009f43d..155afd6 100644
--- a/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp
+++ b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp
@@ -54,10 +54,10 @@
TEST_F(GnssHalTest, SetupTeardownCreateCleanup) {}
/*
- * TestGnssMeasurementCallback:
+ * TestGnssMeasurementExtension:
* Gets the GnssMeasurementExtension and verifies that it returns an actual extension.
*/
-TEST_F(GnssHalTest, TestGnssMeasurementCallback) {
+TEST_F(GnssHalTest, TestGnssMeasurementExtension) {
auto gnssMeasurement_2_0 = gnss_hal_->getExtensionGnssMeasurement_2_0();
auto gnssMeasurement_1_1 = gnss_hal_->getExtensionGnssMeasurement_1_1();
auto gnssMeasurement_1_0 = gnss_hal_->getExtensionGnssMeasurement();
@@ -193,15 +193,15 @@
return;
}
- sp<IGnssMeasurementCallback_2_0> callback = new GnssMeasurementCallback(*this);
-
+ sp<GnssMeasurementCallback> callback = new GnssMeasurementCallback();
auto result = iGnssMeasurement->setCallback_2_0(callback, /* enableFullTracking= */ true);
ASSERT_TRUE(result.isOk());
EXPECT_EQ(result, IGnssMeasurement_1_0::GnssMeasurementStatus::SUCCESS);
IGnssMeasurementCallback_2_0::GnssData lastMeasurement;
- ASSERT_TRUE(measurement_cbq_.retrieve(lastMeasurement, kFirstGnssMeasurementTimeoutSeconds));
- EXPECT_EQ(measurement_cbq_.calledCount(), 1);
+ ASSERT_TRUE(callback->measurement_cbq_.retrieve(lastMeasurement,
+ kFirstGnssMeasurementTimeoutSeconds));
+ EXPECT_EQ(callback->measurement_cbq_.calledCount(), 1);
ASSERT_TRUE(lastMeasurement.measurements.size() > 0);
for (auto measurement : lastMeasurement.measurements) {
// Verify CodeType is valid.
@@ -291,7 +291,7 @@
* capability flag is set.
*/
TEST_F(GnssHalTest, TestGnssMeasurementCorrectionsCapabilities) {
- if (!(last_capabilities_ & IGnssCallback::Capabilities::MEASUREMENT_CORRECTIONS)) {
+ if (!(gnss_cb_->last_capabilities_ & IGnssCallback::Capabilities::MEASUREMENT_CORRECTIONS)) {
return;
}
@@ -301,17 +301,15 @@
ASSERT_NE(iMeasurementCorrections, nullptr);
// Setup measurement corrections callback.
- sp<IMeasurementCorrectionsCallback> iMeasurementCorrectionsCallback =
- new GnssMeasurementCorrectionsCallback(*this);
- iMeasurementCorrections->setCallback(iMeasurementCorrectionsCallback);
+ sp<GnssMeasurementCorrectionsCallback> callback = new GnssMeasurementCorrectionsCallback();
+ iMeasurementCorrections->setCallback(callback);
const int kMeasurementCorrectionsCapabilitiesTimeoutSeconds = 5;
- measurement_corrections_capabilities_cbq_.retrieve(
- last_measurement_corrections_capabilities_,
- kMeasurementCorrectionsCapabilitiesTimeoutSeconds);
- ASSERT_TRUE(measurement_corrections_capabilities_cbq_.calledCount() > 0);
+ callback->capabilities_cbq_.retrieve(callback->last_capabilities_,
+ kMeasurementCorrectionsCapabilitiesTimeoutSeconds);
+ ASSERT_TRUE(callback->capabilities_cbq_.calledCount() > 0);
using Capabilities = IMeasurementCorrectionsCallback::Capabilities;
- ASSERT_TRUE((last_measurement_corrections_capabilities_ &
+ ASSERT_TRUE((callback->last_capabilities_ &
(Capabilities::LOS_SATS | Capabilities::EXCESS_PATH_LENGTH)) != 0);
}
@@ -321,7 +319,7 @@
* gnss.measurement_corrections@1.0::IMeasurementCorrections interface by invoking a method.
*/
TEST_F(GnssHalTest, TestGnssMeasurementCorrections) {
- if (!(last_capabilities_ & IGnssCallback::Capabilities::MEASUREMENT_CORRECTIONS)) {
+ if (!(gnss_cb_->last_capabilities_ & IGnssCallback::Capabilities::MEASUREMENT_CORRECTIONS)) {
return;
}
@@ -331,15 +329,13 @@
sp<IMeasurementCorrections> iMeasurementCorrections = measurementCorrections;
ASSERT_NE(iMeasurementCorrections, nullptr);
- sp<IMeasurementCorrectionsCallback> iMeasurementCorrectionsCallback =
- new GnssMeasurementCorrectionsCallback(*this);
- iMeasurementCorrections->setCallback(iMeasurementCorrectionsCallback);
+ sp<GnssMeasurementCorrectionsCallback> callback = new GnssMeasurementCorrectionsCallback();
+ iMeasurementCorrections->setCallback(callback);
const int kMeasurementCorrectionsCapabilitiesTimeoutSeconds = 5;
- measurement_corrections_capabilities_cbq_.retrieve(
- last_measurement_corrections_capabilities_,
- kMeasurementCorrectionsCapabilitiesTimeoutSeconds);
- ASSERT_TRUE(measurement_corrections_capabilities_cbq_.calledCount() > 0);
+ callback->capabilities_cbq_.retrieve(callback->last_capabilities_,
+ kMeasurementCorrectionsCapabilitiesTimeoutSeconds);
+ ASSERT_TRUE(callback->capabilities_cbq_.calledCount() > 0);
// Set a mock MeasurementCorrections.
auto result = iMeasurementCorrections->setCorrections(Utils::getMockMeasurementCorrections());
@@ -365,15 +361,15 @@
return;
}
- sp<IGnssMeasurementCallback_2_0> callback = new GnssMeasurementCallback(*this);
-
+ sp<GnssMeasurementCallback> callback = new GnssMeasurementCallback();
auto result = iGnssMeasurement->setCallback_2_0(callback, /* enableFullTracking= */ true);
ASSERT_TRUE(result.isOk());
EXPECT_EQ(result, IGnssMeasurement_1_0::GnssMeasurementStatus::SUCCESS);
IGnssMeasurementCallback_2_0::GnssData lastMeasurement;
- ASSERT_TRUE(measurement_cbq_.retrieve(lastMeasurement, kFirstGnssMeasurementTimeoutSeconds));
- EXPECT_EQ(measurement_cbq_.calledCount(), 1);
+ ASSERT_TRUE(callback->measurement_cbq_.retrieve(lastMeasurement,
+ kFirstGnssMeasurementTimeoutSeconds));
+ EXPECT_EQ(callback->measurement_cbq_.calledCount(), 1);
ASSERT_TRUE((int)lastMeasurement.elapsedRealtime.flags <=
(int)(ElapsedRealtimeFlags::HAS_TIMESTAMP_NS |
@@ -390,13 +386,13 @@
TEST_F(GnssHalTest, TestGnssLocationElapsedRealtime) {
StartAndCheckFirstLocation();
- ASSERT_TRUE((int)last_location_.elapsedRealtime.flags <=
+ ASSERT_TRUE((int)gnss_cb_->last_location_.elapsedRealtime.flags <=
(int)(ElapsedRealtimeFlags::HAS_TIMESTAMP_NS |
ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS));
// We expect a non-zero timestamp when set.
- if (last_location_.elapsedRealtime.flags & ElapsedRealtimeFlags::HAS_TIMESTAMP_NS) {
- ASSERT_TRUE(last_location_.elapsedRealtime.timestampNs != 0);
+ if (gnss_cb_->last_location_.elapsedRealtime.flags & ElapsedRealtimeFlags::HAS_TIMESTAMP_NS) {
+ ASSERT_TRUE(gnss_cb_->last_location_.elapsedRealtime.timestampNs != 0);
}
StopAndClearLocations();
@@ -405,7 +401,7 @@
// This test only verify that injectBestLocation_2_0 does not crash.
TEST_F(GnssHalTest, TestInjectBestLocation_2_0) {
StartAndCheckFirstLocation();
- gnss_hal_->injectBestLocation_2_0(last_location_);
+ gnss_hal_->injectBestLocation_2_0(gnss_cb_->last_location_);
StopAndClearLocations();
}
diff --git a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
index 4018aea..3c408b7 100644
--- a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
+++ b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
@@ -850,10 +850,37 @@
ASSERT_NO_FATAL_FAILURE(layer =
mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount));
+ auto handle = allocate();
+ ASSERT_NE(nullptr, handle);
+ IComposerClient::Rect displayFrame{0, 0, mDisplayWidth, mDisplayHeight};
+
mWriter->selectDisplay(mPrimaryDisplay);
mWriter->selectLayer(layer);
+ mWriter->setLayerBuffer(0, handle, -1);
+ mWriter->setLayerCompositionType(IComposerClient::Composition::CURSOR);
+ mWriter->setLayerDisplayFrame(displayFrame);
+ mWriter->setLayerPlaneAlpha(1);
+ mWriter->setLayerSourceCrop({0, 0, (float)mDisplayWidth, (float)mDisplayHeight});
+ mWriter->setLayerTransform(static_cast<Transform>(0));
+ mWriter->setLayerVisibleRegion(std::vector<IComposerClient::Rect>(1, displayFrame));
+ mWriter->setLayerZOrder(10);
+ mWriter->setLayerBlendMode(IComposerClient::BlendMode::NONE);
+ mWriter->setLayerSurfaceDamage(std::vector<IComposerClient::Rect>(1, displayFrame));
+ mWriter->setLayerDataspace(Dataspace::UNKNOWN);
+ mWriter->validateDisplay();
+
+ execute();
+ if (mReader->mCompositionChanges.size() != 0) {
+ GTEST_SUCCEED() << "Composition change requested, skipping test";
+ return;
+ }
+ mWriter->presentDisplay();
+ ASSERT_EQ(0, mReader->mErrors.size());
+
mWriter->setLayerCursorPosition(1, 1);
mWriter->setLayerCursorPosition(0, 0);
+ mWriter->validateDisplay();
+ mWriter->presentDisplay();
execute();
}
diff --git a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp
index 7834b94..9c80f4d 100644
--- a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp
+++ b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp
@@ -246,7 +246,19 @@
* Test IComposerClient::getPerFrameMetadataKeys.
*/
TEST_F(GraphicsComposerHidlTest, GetPerFrameMetadataKeys) {
- mComposerClient->getPerFrameMetadataKeys(mPrimaryDisplay);
+ std::vector<IComposerClient::PerFrameMetadataKey> keys;
+ Error error = Error::NONE;
+ mComposerClient->getRaw()->getPerFrameMetadataKeys(
+ mPrimaryDisplay, [&](const auto& tmpError, const auto& tmpKeys) {
+ error = tmpError;
+ keys = tmpKeys;
+ });
+ if (error == Error::UNSUPPORTED) {
+ GTEST_SUCCEED() << "getPerFrameMetadataKeys is not supported";
+ return;
+ }
+ ASSERT_EQ(Error::NONE, error);
+ ASSERT_TRUE(keys.size() >= 0);
}
/**
diff --git a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerClient.h b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerClient.h
index 3792c2e..b289b6a 100644
--- a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerClient.h
+++ b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerClient.h
@@ -95,7 +95,7 @@
Return<void> getDisplayCapabilities(
Display display, IComposerClient::getDisplayCapabilities_cb hidl_cb) override {
- hidl_vec<IComposerClient::DisplayCapability> capabilities;
+ std::vector<IComposerClient::DisplayCapability> capabilities;
Error error = mHal->getDisplayCapabilities(display, &capabilities);
hidl_cb(error, capabilities);
return Void();
diff --git a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerHal.h b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerHal.h
index 186b004..c3c4887 100644
--- a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerHal.h
+++ b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerHal.h
@@ -115,7 +115,7 @@
hidl_vec<uint64_t>& sampleComponent2,
hidl_vec<uint64_t>& sampleComponent3) = 0;
virtual Error getDisplayCapabilities(
- Display display, hidl_vec<IComposerClient::DisplayCapability>* outCapabilities) = 0;
+ Display display, std::vector<IComposerClient::DisplayCapability>* outCapabilities) = 0;
virtual Error setLayerPerFrameMetadataBlobs(
Display display, Layer layer,
std::vector<IComposerClient::PerFrameMetadataBlob>& blobs) = 0;
diff --git a/graphics/composer/2.3/utils/passthrough/include/composer-passthrough/2.3/HwcHal.h b/graphics/composer/2.3/utils/passthrough/include/composer-passthrough/2.3/HwcHal.h
index 4829e24..d3b29bb 100644
--- a/graphics/composer/2.3/utils/passthrough/include/composer-passthrough/2.3/HwcHal.h
+++ b/graphics/composer/2.3/utils/passthrough/include/composer-passthrough/2.3/HwcHal.h
@@ -220,7 +220,8 @@
}
Error getDisplayCapabilities(
- Display display, hidl_vec<IComposerClient::DisplayCapability>* outCapabilities) override {
+ Display display,
+ std::vector<IComposerClient::DisplayCapability>* outCapabilities) override {
uint32_t count = 0;
int32_t error = mDispatch.getDisplayCapabilities(mDevice, display, &count, nullptr);
if (error != HWC2_ERROR_NONE) {
@@ -232,7 +233,7 @@
reinterpret_cast<std::underlying_type<IComposerClient::DisplayCapability>::type*>(
outCapabilities->data()));
if (error != HWC2_ERROR_NONE) {
- *outCapabilities = hidl_vec<IComposerClient::DisplayCapability>();
+ *outCapabilities = std::vector<IComposerClient::DisplayCapability>();
return static_cast<Error>(error);
}
return Error::NONE;
@@ -267,6 +268,19 @@
Error getDisplayBrightnessSupport(Display display, bool* outSupport) {
if (!mDispatch.getDisplayBrightnessSupport) {
+ // Preemptively set to false.
+ *outSupport = false;
+ // Try to query from getDisplayCapabilities.
+ std::vector<IComposerClient::DisplayCapability> capabilities;
+ Error error = getDisplayCapabilities(display, &capabilities);
+ if (error != Error::NONE) {
+ // This function is not registered, always return UNSUPPORTED.
+ return Error::UNSUPPORTED;
+ }
+ *outSupport =
+ std::find(capabilities.begin(), capabilities.end(),
+ IComposerClient::DisplayCapability::BRIGHTNESS) != capabilities.end();
+ // This function is not registered, always return UNSUPPORTED.
return Error::UNSUPPORTED;
}
bool support = false;
diff --git a/graphics/composer/2.3/utils/vts/ComposerVts.cpp b/graphics/composer/2.3/utils/vts/ComposerVts.cpp
index b763209..d4f5b3a 100644
--- a/graphics/composer/2.3/utils/vts/ComposerVts.cpp
+++ b/graphics/composer/2.3/utils/vts/ComposerVts.cpp
@@ -192,10 +192,8 @@
bool ComposerClient::getDisplayBrightnessSupport(Display display) {
bool support = false;
- mClient->getDisplayBrightnessSupport(display, [&](const auto& error, const auto& tmpSupport) {
- ASSERT_EQ(Error::NONE, error) << "failed to get brightness support";
- support = tmpSupport;
- });
+ mClient->getDisplayBrightnessSupport(
+ display, [&](const auto& /*error*/, const auto& tmpSupport) { support = tmpSupport; });
return support;
}
diff --git a/neuralnetworks/1.0/types.hal b/neuralnetworks/1.0/types.hal
index b0a1c1a..02db063 100644
--- a/neuralnetworks/1.0/types.hal
+++ b/neuralnetworks/1.0/types.hal
@@ -858,20 +858,21 @@
* elements of the input matrices.
*
* The operation has the following independently optional inputs:
+ * * The cell-to-input weights (\f$W_{ci}\f$), cell-to-forget weights
+ * (\f$W_{cf}\f$) and cell-to-output weights (\f$W_{co}\f$) either all
+ * have values or neither of them have values (i.e., all set to null). If
+ * they have values, the peephole optimization is used.
* * The input-to-input weights (\f$W_{xi}\f$), recurrent-to-input weights
- * (\f$W_{hi}\f$), cell-to-input (\f$W_{ci}\f$) weights, and input gate
- * bias (\f$b_i\f$) either all have values, or none of them have values
- * (i.e., all set to null). If they have no values, coupling of input and
- * forget gates (CIFG) is used, in which case the input gate (\f$i_t\f$)
- * is calculated using the following equation instead.
+ * (\f$W_{hi}\f$) and input gate bias (\f$b_i\f$) either all have values,
+ * or none of them have values. If they have no values, coupling of input
+ * and forget gates (CIFG) is used, in which case the input gate
+ * (\f$i_t\f$) is calculated using the following equation instead.
* \f{eqnarray*}{
* i_t = 1 - f_t
* \f}
- * * The cell-to-forget weights (\f$W_{cf}\f$) and cell-to-output weights
- * (\f$W_{co}\f$) either both have values or neither of them have values.
- * If they have values, the peephole optimization is used. Additionally,
- * if CIFG is not used, cell-to-input weights (\f$W_{ci}\f$) is also
- * required to have values for peephole optimization.
+ * In case peephole optimization is used and CIFG is not used
+ * cell-to-input (\f$W_{ci}\f$) weights must be present. Otherwise, the
+ * cell-to-input weights must have no value.
* * The projection weights (\f$W_{proj}\f$) is required only for the
* recurrent projection layer, and should otherwise have no value.
* * The projection bias (\f$b_{proj}\f$) may (but not required to) have a
@@ -984,8 +985,8 @@
* Outputs:
* * 0: The scratch buffer.
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
- * [batch_size, num_units * 4] with CIFG, or
- * [batch_size, num_units * 3] without CIFG.
+ * [batch_size, num_units * 3] with CIFG, or
+ * [batch_size, num_units * 4] without CIFG.
* * 1: The output state (out) (\f$h_t\f$).
* A 2-D tensor of {@link OperandType::TENSOR_FLOAT32}, of shape
* [batch_size, output_size].
diff --git a/neuralnetworks/1.0/vts/functional/ValidateRequest.cpp b/neuralnetworks/1.0/vts/functional/ValidateRequest.cpp
index 72a5007..f0c93b7 100644
--- a/neuralnetworks/1.0/vts/functional/ValidateRequest.cpp
+++ b/neuralnetworks/1.0/vts/functional/ValidateRequest.cpp
@@ -34,7 +34,6 @@
namespace functional {
using ::android::hardware::neuralnetworks::V1_2::implementation::ExecutionCallback;
-using ::android::hardware::neuralnetworks::V1_2::implementation::PreparedModelCallback;
using ::android::hidl::memory::V1_0::IMemory;
using test_helper::for_all;
using test_helper::MixedTyped;
@@ -42,53 +41,6 @@
///////////////////////// UTILITY FUNCTIONS /////////////////////////
-static void createPreparedModel(const sp<IDevice>& device, const V1_0::Model& model,
- sp<IPreparedModel>* preparedModel) {
- ASSERT_NE(nullptr, preparedModel);
-
- // see if service can handle model
- bool fullySupportsModel = false;
- Return<void> supportedOpsLaunchStatus = device->getSupportedOperations(
- model, [&fullySupportsModel](ErrorStatus status, const hidl_vec<bool>& supported) {
- ASSERT_EQ(ErrorStatus::NONE, status);
- ASSERT_NE(0ul, supported.size());
- fullySupportsModel =
- std::all_of(supported.begin(), supported.end(), [](bool valid) { return valid; });
- });
- ASSERT_TRUE(supportedOpsLaunchStatus.isOk());
-
- // launch prepare model
- sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
- ASSERT_NE(nullptr, preparedModelCallback.get());
- Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback);
- ASSERT_TRUE(prepareLaunchStatus.isOk());
- ASSERT_EQ(ErrorStatus::NONE, static_cast<ErrorStatus>(prepareLaunchStatus));
-
- // retrieve prepared model
- preparedModelCallback->wait();
- ErrorStatus prepareReturnStatus = preparedModelCallback->getStatus();
- *preparedModel = preparedModelCallback->getPreparedModel();
-
- // The getSupportedOperations call returns a list of operations that are
- // guaranteed not to fail if prepareModel is called, and
- // 'fullySupportsModel' is true i.f.f. the entire model is guaranteed.
- // If a driver has any doubt that it can prepare an operation, it must
- // return false. So here, if a driver isn't sure if it can support an
- // operation, but reports that it successfully prepared the model, the test
- // can continue.
- if (!fullySupportsModel && prepareReturnStatus != ErrorStatus::NONE) {
- ASSERT_EQ(nullptr, preparedModel->get());
- LOG(INFO) << "NN VTS: Unable to test Request validation because vendor service cannot "
- "prepare model that it does not support.";
- std::cout << "[ ] Unable to test Request validation because vendor service "
- "cannot prepare model that it does not support."
- << std::endl;
- return;
- }
- ASSERT_EQ(ErrorStatus::NONE, prepareReturnStatus);
- ASSERT_NE(nullptr, preparedModel->get());
-}
-
// Primary validation function. This function will take a valid request, apply a
// mutation to it to invalidate the request, then pass it to interface calls
// that use the request. Note that the request here is passed by value, and any
@@ -237,15 +189,8 @@
return requests;
}
-void ValidationTest::validateRequests(const V1_0::Model& model,
+void ValidationTest::validateRequests(const sp<IPreparedModel>& preparedModel,
const std::vector<Request>& requests) {
- // create IPreparedModel
- sp<IPreparedModel> preparedModel;
- ASSERT_NO_FATAL_FAILURE(createPreparedModel(device, model, &preparedModel));
- if (preparedModel == nullptr) {
- return;
- }
-
// validate each request
for (const Request& request : requests) {
removeInputTest(preparedModel, request);
diff --git a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworks.cpp b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworks.cpp
index 31638c4..aee2f85 100644
--- a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworks.cpp
+++ b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworks.cpp
@@ -18,6 +18,10 @@
#include "VtsHalNeuralnetworks.h"
+#include <android-base/logging.h>
+
+#include "Callbacks.h"
+
namespace android {
namespace hardware {
namespace neuralnetworks {
@@ -25,6 +29,55 @@
namespace vts {
namespace functional {
+using ::android::hardware::neuralnetworks::V1_2::implementation::PreparedModelCallback;
+
+static void createPreparedModel(const sp<IDevice>& device, const V1_0::Model& model,
+ sp<IPreparedModel>* preparedModel) {
+ ASSERT_NE(nullptr, preparedModel);
+
+ // see if service can handle model
+ bool fullySupportsModel = false;
+ Return<void> supportedOpsLaunchStatus = device->getSupportedOperations(
+ model, [&fullySupportsModel](ErrorStatus status, const hidl_vec<bool>& supported) {
+ ASSERT_EQ(ErrorStatus::NONE, status);
+ ASSERT_NE(0ul, supported.size());
+ fullySupportsModel = std::all_of(supported.begin(), supported.end(),
+ [](bool valid) { return valid; });
+ });
+ ASSERT_TRUE(supportedOpsLaunchStatus.isOk());
+
+ // launch prepare model
+ sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
+ ASSERT_NE(nullptr, preparedModelCallback.get());
+ Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback);
+ ASSERT_TRUE(prepareLaunchStatus.isOk());
+ ASSERT_EQ(ErrorStatus::NONE, static_cast<ErrorStatus>(prepareLaunchStatus));
+
+ // retrieve prepared model
+ preparedModelCallback->wait();
+ ErrorStatus prepareReturnStatus = preparedModelCallback->getStatus();
+ *preparedModel = preparedModelCallback->getPreparedModel();
+
+ // The getSupportedOperations call returns a list of operations that are
+ // guaranteed not to fail if prepareModel is called, and
+ // 'fullySupportsModel' is true i.f.f. the entire model is guaranteed.
+ // If a driver has any doubt that it can prepare an operation, it must
+ // return false. So here, if a driver isn't sure if it can support an
+ // operation, but reports that it successfully prepared the model, the test
+ // can continue.
+ if (!fullySupportsModel && prepareReturnStatus != ErrorStatus::NONE) {
+ ASSERT_EQ(nullptr, preparedModel->get());
+ LOG(INFO) << "NN VTS: Unable to test Request validation because vendor service cannot "
+ "prepare model that it does not support.";
+ std::cout << "[ ] Unable to test Request validation because vendor service "
+ "cannot prepare model that it does not support."
+ << std::endl;
+ return;
+ }
+ ASSERT_EQ(ErrorStatus::NONE, prepareReturnStatus);
+ ASSERT_NE(nullptr, preparedModel->get());
+}
+
// A class for test environment setup
NeuralnetworksHidlEnvironment::NeuralnetworksHidlEnvironment() {}
@@ -68,9 +121,17 @@
::testing::VtsHalHidlTargetTestBase::TearDown();
}
-void ValidationTest::validateEverything(const Model& model, const std::vector<Request>& request) {
+void ValidationTest::validateEverything(const Model& model, const std::vector<Request>& requests) {
validateModel(model);
- validateRequests(model, request);
+
+ // create IPreparedModel
+ sp<IPreparedModel> preparedModel;
+ ASSERT_NO_FATAL_FAILURE(createPreparedModel(device, model, &preparedModel));
+ if (preparedModel == nullptr) {
+ return;
+ }
+
+ validateRequests(preparedModel, requests);
}
} // namespace functional
diff --git a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworks.h b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworks.h
index 559d678..22285be 100644
--- a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworks.h
+++ b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworks.h
@@ -67,7 +67,8 @@
private:
void validateModel(const Model& model);
- void validateRequests(const Model& model, const std::vector<Request>& request);
+ void validateRequests(const sp<IPreparedModel>& preparedModel,
+ const std::vector<Request>& requests);
};
// Tag for the generated tests
diff --git a/neuralnetworks/1.1/vts/functional/ValidateRequest.cpp b/neuralnetworks/1.1/vts/functional/ValidateRequest.cpp
index 5225bf7..f4adbab 100644
--- a/neuralnetworks/1.1/vts/functional/ValidateRequest.cpp
+++ b/neuralnetworks/1.1/vts/functional/ValidateRequest.cpp
@@ -34,7 +34,6 @@
namespace functional {
using ::android::hardware::neuralnetworks::V1_2::implementation::ExecutionCallback;
-using ::android::hardware::neuralnetworks::V1_2::implementation::PreparedModelCallback;
using ::android::hidl::memory::V1_0::IMemory;
using test_helper::for_all;
using test_helper::MixedTyped;
@@ -42,54 +41,6 @@
///////////////////////// UTILITY FUNCTIONS /////////////////////////
-static void createPreparedModel(const sp<IDevice>& device, const V1_1::Model& model,
- sp<IPreparedModel>* preparedModel) {
- ASSERT_NE(nullptr, preparedModel);
-
- // see if service can handle model
- bool fullySupportsModel = false;
- Return<void> supportedOpsLaunchStatus = device->getSupportedOperations_1_1(
- model, [&fullySupportsModel](ErrorStatus status, const hidl_vec<bool>& supported) {
- ASSERT_EQ(ErrorStatus::NONE, status);
- ASSERT_NE(0ul, supported.size());
- fullySupportsModel =
- std::all_of(supported.begin(), supported.end(), [](bool valid) { return valid; });
- });
- ASSERT_TRUE(supportedOpsLaunchStatus.isOk());
-
- // launch prepare model
- sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
- ASSERT_NE(nullptr, preparedModelCallback.get());
- Return<ErrorStatus> prepareLaunchStatus = device->prepareModel_1_1(
- model, ExecutionPreference::FAST_SINGLE_ANSWER, preparedModelCallback);
- ASSERT_TRUE(prepareLaunchStatus.isOk());
- ASSERT_EQ(ErrorStatus::NONE, static_cast<ErrorStatus>(prepareLaunchStatus));
-
- // retrieve prepared model
- preparedModelCallback->wait();
- ErrorStatus prepareReturnStatus = preparedModelCallback->getStatus();
- *preparedModel = preparedModelCallback->getPreparedModel();
-
- // The getSupportedOperations_1_1 call returns a list of operations that are
- // guaranteed not to fail if prepareModel_1_1 is called, and
- // 'fullySupportsModel' is true i.f.f. the entire model is guaranteed.
- // If a driver has any doubt that it can prepare an operation, it must
- // return false. So here, if a driver isn't sure if it can support an
- // operation, but reports that it successfully prepared the model, the test
- // can continue.
- if (!fullySupportsModel && prepareReturnStatus != ErrorStatus::NONE) {
- ASSERT_EQ(nullptr, preparedModel->get());
- LOG(INFO) << "NN VTS: Unable to test Request validation because vendor service cannot "
- "prepare model that it does not support.";
- std::cout << "[ ] Unable to test Request validation because vendor service "
- "cannot prepare model that it does not support."
- << std::endl;
- return;
- }
- ASSERT_EQ(ErrorStatus::NONE, prepareReturnStatus);
- ASSERT_NE(nullptr, preparedModel->get());
-}
-
// Primary validation function. This function will take a valid request, apply a
// mutation to it to invalidate the request, then pass it to interface calls
// that use the request. Note that the request here is passed by value, and any
@@ -238,15 +189,8 @@
return requests;
}
-void ValidationTest::validateRequests(const V1_1::Model& model,
+void ValidationTest::validateRequests(const sp<IPreparedModel>& preparedModel,
const std::vector<Request>& requests) {
- // create IPreparedModel
- sp<IPreparedModel> preparedModel;
- ASSERT_NO_FATAL_FAILURE(createPreparedModel(device, model, &preparedModel));
- if (preparedModel == nullptr) {
- return;
- }
-
// validate each request
for (const Request& request : requests) {
removeInputTest(preparedModel, request);
diff --git a/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.cpp b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.cpp
index 11fa693..08069f2 100644
--- a/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.cpp
+++ b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.cpp
@@ -18,6 +18,10 @@
#include "VtsHalNeuralnetworks.h"
+#include <android-base/logging.h>
+
+#include "Callbacks.h"
+
namespace android {
namespace hardware {
namespace neuralnetworks {
@@ -25,6 +29,56 @@
namespace vts {
namespace functional {
+using ::android::hardware::neuralnetworks::V1_2::implementation::PreparedModelCallback;
+
+static void createPreparedModel(const sp<IDevice>& device, const V1_1::Model& model,
+ sp<IPreparedModel>* preparedModel) {
+ ASSERT_NE(nullptr, preparedModel);
+
+ // see if service can handle model
+ bool fullySupportsModel = false;
+ Return<void> supportedOpsLaunchStatus = device->getSupportedOperations_1_1(
+ model, [&fullySupportsModel](ErrorStatus status, const hidl_vec<bool>& supported) {
+ ASSERT_EQ(ErrorStatus::NONE, status);
+ ASSERT_NE(0ul, supported.size());
+ fullySupportsModel = std::all_of(supported.begin(), supported.end(),
+ [](bool valid) { return valid; });
+ });
+ ASSERT_TRUE(supportedOpsLaunchStatus.isOk());
+
+ // launch prepare model
+ sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
+ ASSERT_NE(nullptr, preparedModelCallback.get());
+ Return<ErrorStatus> prepareLaunchStatus = device->prepareModel_1_1(
+ model, ExecutionPreference::FAST_SINGLE_ANSWER, preparedModelCallback);
+ ASSERT_TRUE(prepareLaunchStatus.isOk());
+ ASSERT_EQ(ErrorStatus::NONE, static_cast<ErrorStatus>(prepareLaunchStatus));
+
+ // retrieve prepared model
+ preparedModelCallback->wait();
+ ErrorStatus prepareReturnStatus = preparedModelCallback->getStatus();
+ *preparedModel = preparedModelCallback->getPreparedModel();
+
+ // The getSupportedOperations_1_1 call returns a list of operations that are
+ // guaranteed not to fail if prepareModel_1_1 is called, and
+ // 'fullySupportsModel' is true i.f.f. the entire model is guaranteed.
+ // If a driver has any doubt that it can prepare an operation, it must
+ // return false. So here, if a driver isn't sure if it can support an
+ // operation, but reports that it successfully prepared the model, the test
+ // can continue.
+ if (!fullySupportsModel && prepareReturnStatus != ErrorStatus::NONE) {
+ ASSERT_EQ(nullptr, preparedModel->get());
+ LOG(INFO) << "NN VTS: Unable to test Request validation because vendor service cannot "
+ "prepare model that it does not support.";
+ std::cout << "[ ] Unable to test Request validation because vendor service "
+ "cannot prepare model that it does not support."
+ << std::endl;
+ return;
+ }
+ ASSERT_EQ(ErrorStatus::NONE, prepareReturnStatus);
+ ASSERT_NE(nullptr, preparedModel->get());
+}
+
// A class for test environment setup
NeuralnetworksHidlEnvironment::NeuralnetworksHidlEnvironment() {}
@@ -68,9 +122,17 @@
::testing::VtsHalHidlTargetTestBase::TearDown();
}
-void ValidationTest::validateEverything(const Model& model, const std::vector<Request>& request) {
+void ValidationTest::validateEverything(const Model& model, const std::vector<Request>& requests) {
validateModel(model);
- validateRequests(model, request);
+
+ // create IPreparedModel
+ sp<IPreparedModel> preparedModel;
+ ASSERT_NO_FATAL_FAILURE(createPreparedModel(device, model, &preparedModel));
+ if (preparedModel == nullptr) {
+ return;
+ }
+
+ validateRequests(preparedModel, requests);
}
} // namespace functional
diff --git a/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.h b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.h
index cea2b54..f3f587b 100644
--- a/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.h
+++ b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.h
@@ -76,7 +76,8 @@
private:
void validateModel(const Model& model);
- void validateRequests(const Model& model, const std::vector<Request>& request);
+ void validateRequests(const sp<IPreparedModel>& preparedModel,
+ const std::vector<Request>& requests);
};
// Tag for the generated tests
diff --git a/neuralnetworks/1.2/types.hal b/neuralnetworks/1.2/types.hal
index c2e8f22..f368ce2 100644
--- a/neuralnetworks/1.2/types.hal
+++ b/neuralnetworks/1.2/types.hal
@@ -1177,20 +1177,21 @@
* https://arxiv.org/pdf/1607.06450.pdf
*
* The operation has the following independently optional inputs:
+ * * The cell-to-input weights (\f$W_{ci}\f$), cell-to-forget weights
+ * (\f$W_{cf}\f$) and cell-to-output weights (\f$W_{co}\f$) either all
+ * have values or neither of them have values (i.e., all set to null). If
+ * they have values, the peephole optimization is used.
* * The input-to-input weights (\f$W_{xi}\f$), recurrent-to-input weights
- * (\f$W_{hi}\f$), cell-to-input (\f$W_{ci}\f$) weights, and input gate
- * bias (\f$b_i\f$) either all have values, or none of them have values
- * (i.e., all set to null). If they have no values, coupling of input and
- * forget gates (CIFG) is used, in which case the input gate (\f$i_t\f$)
- * is calculated using the following equation instead.
+ * (\f$W_{hi}\f$) and input gate bias (\f$b_i\f$) either all have values,
+ * or none of them have values. If they have no values, coupling of input
+ * and forget gates (CIFG) is used, in which case the input gate
+ * (\f$i_t\f$) is calculated using the following equation instead.
* \f{eqnarray*}{
* i_t = 1 - f_t
* \f}
- * * The cell-to-forget weights (\f$W_{cf}\f$) and cell-to-output weights
- * (\f$W_{co}\f$) either both have values or neither of them have values.
- * If they have values, the peephole optimization is used. Additionally,
- * if CIFG is not used, cell-to-input weights (\f$W_{ci}\f$) is also
- * required to have values for peephole optimization.
+ * In case peephole optimization is used and CIFG is not used
+ * cell-to-input (\f$W_{ci}\f$) weights must be present. Otherwise, the
+ * cell-to-input weights must have no value.
* * The projection weights (\f$W_{proj}\f$) is required only for the
* recurrent projection layer, and should otherwise have no value.
* * The projection bias (\f$b_{proj}\f$) may (but not required to) have a
diff --git a/neuralnetworks/1.2/vts/functional/ValidateBurst.cpp b/neuralnetworks/1.2/vts/functional/ValidateBurst.cpp
index 386c141..8c6391e 100644
--- a/neuralnetworks/1.2/vts/functional/ValidateBurst.cpp
+++ b/neuralnetworks/1.2/vts/functional/ValidateBurst.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2019 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.
@@ -25,6 +25,7 @@
#include "Utils.h"
#include <android-base/logging.h>
+#include <cstring>
namespace android {
namespace hardware {
@@ -38,7 +39,13 @@
using ::android::nn::ResultChannelReceiver;
using ExecutionBurstCallback = ::android::nn::ExecutionBurstController::ExecutionBurstCallback;
+// This constant value represents the length of an FMQ that is large enough to
+// return a result from a burst execution for all of the generated test cases.
constexpr size_t kExecutionBurstChannelLength = 1024;
+
+// This constant value represents a length of an FMQ that is not large enough
+// to return a result from a burst execution for some of the generated test
+// cases.
constexpr size_t kExecutionBurstChannelSmallLength = 8;
///////////////////////// UTILITY FUNCTIONS /////////////////////////
@@ -50,7 +57,8 @@
static void createBurst(const sp<IPreparedModel>& preparedModel, const sp<IBurstCallback>& callback,
std::unique_ptr<RequestChannelSender>* sender,
std::unique_ptr<ResultChannelReceiver>* receiver,
- sp<IBurstContext>* context) {
+ sp<IBurstContext>* context,
+ size_t resultChannelLength = kExecutionBurstChannelLength) {
ASSERT_NE(nullptr, preparedModel.get());
ASSERT_NE(nullptr, sender);
ASSERT_NE(nullptr, receiver);
@@ -60,7 +68,7 @@
auto [fmqRequestChannel, fmqRequestDescriptor] =
RequestChannelSender::create(kExecutionBurstChannelLength, /*blocking=*/true);
auto [fmqResultChannel, fmqResultDescriptor] =
- ResultChannelReceiver::create(kExecutionBurstChannelLength, /*blocking=*/true);
+ ResultChannelReceiver::create(resultChannelLength, /*blocking=*/true);
ASSERT_NE(nullptr, fmqRequestChannel.get());
ASSERT_NE(nullptr, fmqResultChannel.get());
ASSERT_NE(nullptr, fmqRequestDescriptor);
@@ -86,38 +94,25 @@
}
static void createBurstWithResultChannelLength(
- const sp<IPreparedModel>& preparedModel,
- std::shared_ptr<ExecutionBurstController>* controller, size_t resultChannelLength) {
+ const sp<IPreparedModel>& preparedModel, size_t resultChannelLength,
+ std::shared_ptr<ExecutionBurstController>* controller) {
ASSERT_NE(nullptr, preparedModel.get());
ASSERT_NE(nullptr, controller);
// create FMQ objects
- auto [fmqRequestChannel, fmqRequestDescriptor] =
- RequestChannelSender::create(kExecutionBurstChannelLength, /*blocking=*/true);
- auto [fmqResultChannel, fmqResultDescriptor] =
- ResultChannelReceiver::create(resultChannelLength, /*blocking=*/true);
- ASSERT_NE(nullptr, fmqRequestChannel.get());
- ASSERT_NE(nullptr, fmqResultChannel.get());
- ASSERT_NE(nullptr, fmqRequestDescriptor);
- ASSERT_NE(nullptr, fmqResultDescriptor);
-
- // configure burst
+ std::unique_ptr<RequestChannelSender> sender;
+ std::unique_ptr<ResultChannelReceiver> receiver;
sp<ExecutionBurstCallback> callback = new ExecutionBurstCallback();
- ErrorStatus errorStatus;
- sp<IBurstContext> burstContext;
- const Return<void> ret = preparedModel->configureExecutionBurst(
- callback, *fmqRequestDescriptor, *fmqResultDescriptor,
- [&errorStatus, &burstContext](ErrorStatus status, const sp<IBurstContext>& context) {
- errorStatus = status;
- burstContext = context;
- });
- ASSERT_TRUE(ret.isOk());
- ASSERT_EQ(ErrorStatus::NONE, errorStatus);
- ASSERT_NE(nullptr, burstContext.get());
+ sp<IBurstContext> context;
+ ASSERT_NO_FATAL_FAILURE(createBurst(preparedModel, callback, &sender, &receiver, &context,
+ resultChannelLength));
+ ASSERT_NE(nullptr, sender.get());
+ ASSERT_NE(nullptr, receiver.get());
+ ASSERT_NE(nullptr, context.get());
// return values
- *controller = std::make_shared<ExecutionBurstController>(
- std::move(fmqRequestChannel), std::move(fmqResultChannel), burstContext, callback);
+ *controller = std::make_shared<ExecutionBurstController>(std::move(sender), std::move(receiver),
+ context, callback);
}
// Primary validation function. This function will take a valid serialized
@@ -138,7 +133,7 @@
SCOPED_TRACE(message);
// send invalid packet
- sender->sendPacket(serialized);
+ ASSERT_TRUE(sender->sendPacket(serialized));
// receive error
auto results = receiver->getBlocking();
@@ -149,27 +144,34 @@
EXPECT_TRUE(badTiming(timing));
}
-static std::vector<FmqRequestDatum> createUniqueDatum() {
+// For validation, valid packet entries are mutated to invalid packet entries,
+// or invalid packet entries are inserted into valid packets. This function
+// creates pre-set invalid packet entries for convenience.
+static std::vector<FmqRequestDatum> createBadRequestPacketEntries() {
const FmqRequestDatum::PacketInformation packetInformation = {
/*.packetSize=*/10, /*.numberOfInputOperands=*/10, /*.numberOfOutputOperands=*/10,
/*.numberOfPools=*/10};
const FmqRequestDatum::OperandInformation operandInformation = {
/*.hasNoValue=*/false, /*.location=*/{}, /*.numberOfDimensions=*/10};
const int32_t invalidPoolIdentifier = std::numeric_limits<int32_t>::max();
- std::vector<FmqRequestDatum> unique(7);
- unique[0].packetInformation(packetInformation);
- unique[1].inputOperandInformation(operandInformation);
- unique[2].inputOperandDimensionValue(0);
- unique[3].outputOperandInformation(operandInformation);
- unique[4].outputOperandDimensionValue(0);
- unique[5].poolIdentifier(invalidPoolIdentifier);
- unique[6].measureTiming(MeasureTiming::YES);
- return unique;
+ std::vector<FmqRequestDatum> bad(7);
+ bad[0].packetInformation(packetInformation);
+ bad[1].inputOperandInformation(operandInformation);
+ bad[2].inputOperandDimensionValue(0);
+ bad[3].outputOperandInformation(operandInformation);
+ bad[4].outputOperandDimensionValue(0);
+ bad[5].poolIdentifier(invalidPoolIdentifier);
+ bad[6].measureTiming(MeasureTiming::YES);
+ return bad;
}
-static const std::vector<FmqRequestDatum>& getUniqueDatum() {
- static const std::vector<FmqRequestDatum> unique = createUniqueDatum();
- return unique;
+// For validation, valid packet entries are mutated to invalid packet entries,
+// or invalid packet entries are inserted into valid packets. This function
+// retrieves pre-set invalid packet entries for convenience. This function
+// caches these data so they can be reused on subsequent validation checks.
+static const std::vector<FmqRequestDatum>& getBadRequestPacketEntries() {
+ static const std::vector<FmqRequestDatum> bad = createBadRequestPacketEntries();
+ return bad;
}
///////////////////////// REMOVE DATUM ////////////////////////////////////
@@ -189,7 +191,7 @@
static void addDatumTest(RequestChannelSender* sender, ResultChannelReceiver* receiver,
const std::vector<FmqRequestDatum>& serialized) {
- const std::vector<FmqRequestDatum>& extra = getUniqueDatum();
+ const std::vector<FmqRequestDatum>& extra = getBadRequestPacketEntries();
for (size_t index = 0; index <= serialized.size(); ++index) {
for (size_t type = 0; type < extra.size(); ++type) {
const std::string message = "addDatum: added datum type " + std::to_string(type) +
@@ -208,17 +210,17 @@
using Discriminator = FmqRequestDatum::hidl_discriminator;
const bool differentValues = (lhs != rhs);
- const bool sameSumType = (lhs.getDiscriminator() == rhs.getDiscriminator());
+ const bool sameDiscriminator = (lhs.getDiscriminator() == rhs.getDiscriminator());
const auto discriminator = rhs.getDiscriminator();
const bool isDimensionValue = (discriminator == Discriminator::inputOperandDimensionValue ||
discriminator == Discriminator::outputOperandDimensionValue);
- return differentValues && !(sameSumType && isDimensionValue);
+ return differentValues && !(sameDiscriminator && isDimensionValue);
}
static void mutateDatumTest(RequestChannelSender* sender, ResultChannelReceiver* receiver,
const std::vector<FmqRequestDatum>& serialized) {
- const std::vector<FmqRequestDatum>& change = getUniqueDatum();
+ const std::vector<FmqRequestDatum>& change = getBadRequestPacketEntries();
for (size_t index = 0; index < serialized.size(); ++index) {
for (size_t type = 0; type < change.size(); ++type) {
if (interestingCase(serialized[index], change[type])) {
@@ -251,17 +253,17 @@
// validate each request
for (const Request& request : requests) {
// load memory into callback slots
- std::vector<intptr_t> keys(request.pools.size());
- for (size_t i = 0; i < keys.size(); ++i) {
- keys[i] = reinterpret_cast<intptr_t>(&request.pools[i]);
- }
+ std::vector<intptr_t> keys;
+ keys.reserve(request.pools.size());
+ std::transform(request.pools.begin(), request.pools.end(), std::back_inserter(keys),
+ [](const auto& pool) { return reinterpret_cast<intptr_t>(&pool); });
const std::vector<int32_t> slots = callback->getSlots(request.pools, keys);
// ensure slot std::numeric_limits<int32_t>::max() doesn't exist (for
// subsequent slot validation testing)
- const auto maxElement = std::max_element(slots.begin(), slots.end());
- ASSERT_NE(slots.end(), maxElement);
- ASSERT_NE(std::numeric_limits<int32_t>::max(), *maxElement);
+ ASSERT_TRUE(std::all_of(slots.begin(), slots.end(), [](int32_t slot) {
+ return slot != std::numeric_limits<int32_t>::max();
+ }));
// serialize the request
const auto serialized = ::android::nn::serialize(request, MeasureTiming::YES, slots);
@@ -273,18 +275,20 @@
}
}
+// This test validates that when the Result message size exceeds length of the
+// result FMQ, the service instance gracefully fails and returns an error.
static void validateBurstFmqLength(const sp<IPreparedModel>& preparedModel,
const std::vector<Request>& requests) {
// create regular burst
std::shared_ptr<ExecutionBurstController> controllerRegular;
- ASSERT_NO_FATAL_FAILURE(createBurstWithResultChannelLength(preparedModel, &controllerRegular,
- kExecutionBurstChannelLength));
+ ASSERT_NO_FATAL_FAILURE(createBurstWithResultChannelLength(
+ preparedModel, kExecutionBurstChannelLength, &controllerRegular));
ASSERT_NE(nullptr, controllerRegular.get());
// create burst with small output channel
std::shared_ptr<ExecutionBurstController> controllerSmall;
- ASSERT_NO_FATAL_FAILURE(createBurstWithResultChannelLength(preparedModel, &controllerSmall,
- kExecutionBurstChannelSmallLength));
+ ASSERT_NO_FATAL_FAILURE(createBurstWithResultChannelLength(
+ preparedModel, kExecutionBurstChannelSmallLength, &controllerSmall));
ASSERT_NE(nullptr, controllerSmall.get());
// validate each request
@@ -296,24 +300,103 @@
}
// collect serialized result by running regular burst
- const auto [status1, outputShapes1, timing1] =
+ const auto [statusRegular, outputShapesRegular, timingRegular] =
controllerRegular->compute(request, MeasureTiming::NO, keys);
- // skip test if synchronous output isn't useful
+ // skip test if regular burst output isn't useful for testing a failure
+ // caused by having too small of a length for the result FMQ
const std::vector<FmqResultDatum> serialized =
- ::android::nn::serialize(status1, outputShapes1, timing1);
- if (status1 != ErrorStatus::NONE ||
+ ::android::nn::serialize(statusRegular, outputShapesRegular, timingRegular);
+ if (statusRegular != ErrorStatus::NONE ||
serialized.size() <= kExecutionBurstChannelSmallLength) {
continue;
}
// by this point, execution should fail because the result channel isn't
// large enough to return the serialized result
- const auto [status2, outputShapes2, timing2] =
+ const auto [statusSmall, outputShapesSmall, timingSmall] =
controllerSmall->compute(request, MeasureTiming::NO, keys);
- EXPECT_NE(ErrorStatus::NONE, status2);
- EXPECT_EQ(0u, outputShapes2.size());
- EXPECT_TRUE(badTiming(timing2));
+ EXPECT_NE(ErrorStatus::NONE, statusSmall);
+ EXPECT_EQ(0u, outputShapesSmall.size());
+ EXPECT_TRUE(badTiming(timingSmall));
+ }
+}
+
+static bool isSanitized(const FmqResultDatum& datum) {
+ using Discriminator = FmqResultDatum::hidl_discriminator;
+
+ // check to ensure the padding values in the returned
+ // FmqResultDatum::OperandInformation are initialized to 0
+ if (datum.getDiscriminator() == Discriminator::operandInformation) {
+ static_assert(
+ offsetof(FmqResultDatum::OperandInformation, isSufficient) == 0,
+ "unexpected value for offset of FmqResultDatum::OperandInformation::isSufficient");
+ static_assert(
+ sizeof(FmqResultDatum::OperandInformation::isSufficient) == 1,
+ "unexpected value for size of FmqResultDatum::OperandInformation::isSufficient");
+ static_assert(offsetof(FmqResultDatum::OperandInformation, numberOfDimensions) == 4,
+ "unexpected value for offset of "
+ "FmqResultDatum::OperandInformation::numberOfDimensions");
+ static_assert(sizeof(FmqResultDatum::OperandInformation::numberOfDimensions) == 4,
+ "unexpected value for size of "
+ "FmqResultDatum::OperandInformation::numberOfDimensions");
+ static_assert(sizeof(FmqResultDatum::OperandInformation) == 8,
+ "unexpected value for size of "
+ "FmqResultDatum::OperandInformation");
+
+ constexpr size_t paddingOffset =
+ offsetof(FmqResultDatum::OperandInformation, isSufficient) +
+ sizeof(FmqResultDatum::OperandInformation::isSufficient);
+ constexpr size_t paddingSize =
+ offsetof(FmqResultDatum::OperandInformation, numberOfDimensions) - paddingOffset;
+
+ FmqResultDatum::OperandInformation initialized{};
+ std::memset(&initialized, 0, sizeof(initialized));
+
+ const char* initializedPaddingStart =
+ reinterpret_cast<const char*>(&initialized) + paddingOffset;
+ const char* datumPaddingStart =
+ reinterpret_cast<const char*>(&datum.operandInformation()) + paddingOffset;
+
+ return std::memcmp(datumPaddingStart, initializedPaddingStart, paddingSize) == 0;
+ }
+
+ // there are no other padding initialization checks required, so return true
+ // for any sum-type that isn't FmqResultDatum::OperandInformation
+ return true;
+}
+
+static void validateBurstSanitized(const sp<IPreparedModel>& preparedModel,
+ const std::vector<Request>& requests) {
+ // create burst
+ std::unique_ptr<RequestChannelSender> sender;
+ std::unique_ptr<ResultChannelReceiver> receiver;
+ sp<ExecutionBurstCallback> callback = new ExecutionBurstCallback();
+ sp<IBurstContext> context;
+ ASSERT_NO_FATAL_FAILURE(createBurst(preparedModel, callback, &sender, &receiver, &context));
+ ASSERT_NE(nullptr, sender.get());
+ ASSERT_NE(nullptr, receiver.get());
+ ASSERT_NE(nullptr, context.get());
+
+ // validate each request
+ for (const Request& request : requests) {
+ // load memory into callback slots
+ std::vector<intptr_t> keys;
+ keys.reserve(request.pools.size());
+ std::transform(request.pools.begin(), request.pools.end(), std::back_inserter(keys),
+ [](const auto& pool) { return reinterpret_cast<intptr_t>(&pool); });
+ const std::vector<int32_t> slots = callback->getSlots(request.pools, keys);
+
+ // send valid request
+ ASSERT_TRUE(sender->send(request, MeasureTiming::YES, slots));
+
+ // receive valid result
+ auto serialized = receiver->getPacketBlocking();
+ ASSERT_TRUE(serialized.has_value());
+
+ // sanitize result
+ ASSERT_TRUE(std::all_of(serialized->begin(), serialized->end(), isSanitized))
+ << "The result serialized data is not properly sanitized";
}
}
@@ -323,6 +406,7 @@
const std::vector<Request>& requests) {
ASSERT_NO_FATAL_FAILURE(validateBurstSerialization(preparedModel, requests));
ASSERT_NO_FATAL_FAILURE(validateBurstFmqLength(preparedModel, requests));
+ ASSERT_NO_FATAL_FAILURE(validateBurstSanitized(preparedModel, requests));
}
} // namespace functional
diff --git a/neuralnetworks/1.2/vts/functional/VtsHalNeuralnetworks.cpp b/neuralnetworks/1.2/vts/functional/VtsHalNeuralnetworks.cpp
index 93182f1..4ddefe8 100644
--- a/neuralnetworks/1.2/vts/functional/VtsHalNeuralnetworks.cpp
+++ b/neuralnetworks/1.2/vts/functional/VtsHalNeuralnetworks.cpp
@@ -29,7 +29,6 @@
namespace vts {
namespace functional {
-using ::android::hardware::neuralnetworks::V1_2::implementation::ExecutionCallback;
using ::android::hardware::neuralnetworks::V1_2::implementation::PreparedModelCallback;
using HidlToken = hidl_array<uint8_t, static_cast<uint32_t>(Constant::BYTE_SIZE_OF_CACHE_TOKEN)>;
using V1_1::ExecutionPreference;
@@ -127,7 +126,7 @@
::testing::VtsHalHidlTargetTestBase::TearDown();
}
-void ValidationTest::validateEverything(const Model& model, const std::vector<Request>& request) {
+void ValidationTest::validateEverything(const Model& model, const std::vector<Request>& requests) {
validateModel(model);
// create IPreparedModel
@@ -137,8 +136,8 @@
return;
}
- validateRequests(preparedModel, request);
- validateBurst(preparedModel, request);
+ validateRequests(preparedModel, requests);
+ validateBurst(preparedModel, requests);
}
sp<IPreparedModel> getPreparedModel_1_2(
diff --git a/neuralnetworks/1.2/vts/functional/VtsHalNeuralnetworks.h b/neuralnetworks/1.2/vts/functional/VtsHalNeuralnetworks.h
index 36e73a4..8d1acbe 100644
--- a/neuralnetworks/1.2/vts/functional/VtsHalNeuralnetworks.h
+++ b/neuralnetworks/1.2/vts/functional/VtsHalNeuralnetworks.h
@@ -72,7 +72,7 @@
// Tag for the validation tests
class ValidationTest : public NeuralnetworksHidlTest {
protected:
- void validateEverything(const Model& model, const std::vector<Request>& request);
+ void validateEverything(const Model& model, const std::vector<Request>& requests);
private:
void validateModel(const Model& model);