Merge "Allow REQUEST_NOT_SUPPORTED when requesting data throttling from modem." am: 55091e2ab4 am: 1b45de52c0 am: b6e101c662 am: 6e3be2fa36
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1621706
Change-Id: Idd64d86f488d7ee45b86c8ab5068c93201de1695
diff --git a/automotive/can/1.0/default/libnl++/Android.bp b/automotive/can/1.0/default/libnl++/Android.bp
index 790adcd..2ebd1b4 100644
--- a/automotive/can/1.0/default/libnl++/Android.bp
+++ b/automotive/can/1.0/default/libnl++/Android.bp
@@ -35,6 +35,7 @@
"protocols/generic/Generic.cpp",
"protocols/generic/GenericMessageBase.cpp",
"protocols/generic/Unknown.cpp",
+ "protocols/generic/families/Mac80211hwsim.cpp",
"protocols/generic/families/Nl80211.cpp",
"protocols/route/Link.cpp",
"protocols/route/Route.cpp",
@@ -42,6 +43,7 @@
"protocols/MessageDefinition.cpp",
"protocols/NetlinkProtocol.cpp",
"protocols/all.cpp",
+ "protocols/structs.cpp",
"Attributes.cpp",
"MessageFactory.cpp",
"MessageMutator.cpp",
diff --git a/automotive/can/1.0/default/libnl++/MessageMutator.cpp b/automotive/can/1.0/default/libnl++/MessageMutator.cpp
index 00b48a6..de2a2b1 100644
--- a/automotive/can/1.0/default/libnl++/MessageMutator.cpp
+++ b/automotive/can/1.0/default/libnl++/MessageMutator.cpp
@@ -19,7 +19,7 @@
namespace android::nl {
MessageMutator::MessageMutator(nlmsghdr* buffer, size_t totalLen)
- : mConstBuffer(buffer, totalLen), mMutableBuffer(buffer) {
+ : mMutableBuffer(buffer), mTotalLen(totalLen) {
CHECK(totalLen >= sizeof(nlmsghdr));
}
@@ -27,8 +27,12 @@
return mMutableBuffer;
}
+Buffer<nlmsghdr> MessageMutator::constBuffer() const {
+ return {mMutableBuffer, mTotalLen};
+}
+
MessageMutator::operator Buffer<nlmsghdr>() const {
- return mConstBuffer;
+ return constBuffer();
}
uint64_t MessageMutator::read(Buffer<nlattr> attr) const {
@@ -37,7 +41,8 @@
void MessageMutator::write(Buffer<nlattr> attr, uint64_t val) const {
const auto attrData = attr.data<uint64_t>();
- const auto offset = mConstBuffer.getOffset(attrData);
+ // TODO(b/177251183): deduplicate this code against fragment()
+ const auto offset = constBuffer().getOffset(attrData);
CHECK(offset.has_value()) << "Trying to write attribute that's not a member of this message";
const auto writeableBuffer = reinterpret_cast<uint8_t*>(mMutableBuffer) + *offset;
@@ -47,4 +52,40 @@
memcpy(writeableBuffer, &val, std::min(sizeof(val), attrSize));
}
+MessageMutator MessageMutator::fragment(Buffer<nlmsghdr> buf) const {
+ const auto offset = constBuffer().getOffset(buf);
+ CHECK(offset.has_value()) << "Trying to modify a fragment outside of buffer range";
+
+ const auto writeableBuffer = reinterpret_cast<nlmsghdr*>(uintptr_t(mMutableBuffer) + *offset);
+ const auto len = buf.getRaw().len();
+ CHECK(len <= mTotalLen - *offset);
+
+ return {writeableBuffer, len};
+}
+
+MessageMutator::iterator MessageMutator::begin() const {
+ return {*this, constBuffer().begin()};
+}
+
+MessageMutator::iterator MessageMutator::end() const {
+ return {*this, constBuffer().end()};
+}
+
+MessageMutator::iterator::iterator(const MessageMutator& container,
+ Buffer<nlmsghdr>::iterator current)
+ : mContainer(container), mCurrent(current) {}
+
+MessageMutator::iterator MessageMutator::iterator::operator++() {
+ ++mCurrent;
+ return *this;
+}
+
+bool MessageMutator::iterator::operator==(const iterator& other) const {
+ return other.mCurrent == mCurrent;
+}
+
+const MessageMutator MessageMutator::iterator::operator*() const {
+ return mContainer.fragment(*mCurrent);
+}
+
} // namespace android::nl
diff --git a/automotive/can/1.0/default/libnl++/include/libnl++/Buffer.h b/automotive/can/1.0/default/libnl++/include/libnl++/Buffer.h
index d759a0a..4cabb9a 100644
--- a/automotive/can/1.0/default/libnl++/include/libnl++/Buffer.h
+++ b/automotive/can/1.0/default/libnl++/include/libnl++/Buffer.h
@@ -138,7 +138,7 @@
class raw_iterator : public iterator {
public:
iterator operator++() {
- this->mCurrent.mData++; // ignore alignment
+ ++this->mCurrent.mData; // ignore alignment
return *this;
}
const T& operator*() const { return *this->mCurrent.mData; }
diff --git a/automotive/can/1.0/default/libnl++/include/libnl++/Message.h b/automotive/can/1.0/default/libnl++/include/libnl++/Message.h
index 50b3c4b..29f397d 100644
--- a/automotive/can/1.0/default/libnl++/include/libnl++/Message.h
+++ b/automotive/can/1.0/default/libnl++/include/libnl++/Message.h
@@ -34,7 +34,7 @@
* a single instance can only be used by a single thread - the one owning the underlying buffer).
*/
template <typename T>
-class Message {
+class Message : public Buffer<nlmsghdr> {
public:
/**
* Validate buffer contents as a message carrying T data and create instance of parsed message.
@@ -51,7 +51,7 @@
const auto attributes = buf.data<nlattr>(sizeof(T));
- return Message<T>(nlHeader, dataHeader, attributes);
+ return Message<T>(buf, nlHeader, dataHeader, attributes);
}
/**
@@ -94,8 +94,9 @@
const T* operator->() const { return &data; }
private:
- Message(const nlmsghdr& nlHeader, const T& dataHeader, Attributes attributes)
- : header(nlHeader), data(dataHeader), attributes(attributes) {}
+ Message(Buffer<nlmsghdr> buffer, const nlmsghdr& nlHeader, const T& dataHeader,
+ Attributes attributes)
+ : Buffer<nlmsghdr>(buffer), header(nlHeader), data(dataHeader), attributes(attributes) {}
};
} // namespace android::nl
diff --git a/automotive/can/1.0/default/libnl++/include/libnl++/MessageMutator.h b/automotive/can/1.0/default/libnl++/include/libnl++/MessageMutator.h
index 7d495e9..baadc44 100644
--- a/automotive/can/1.0/default/libnl++/include/libnl++/MessageMutator.h
+++ b/automotive/can/1.0/default/libnl++/include/libnl++/MessageMutator.h
@@ -53,9 +53,27 @@
*/
void write(Buffer<nlattr> attr, uint64_t val) const;
+ class iterator {
+ public:
+ iterator(const MessageMutator& container, Buffer<nlmsghdr>::iterator current);
+
+ iterator operator++();
+ bool operator==(const iterator& other) const;
+ const MessageMutator operator*() const;
+
+ protected:
+ const MessageMutator& mContainer;
+ Buffer<nlmsghdr>::iterator mCurrent;
+ };
+ iterator begin() const;
+ iterator end() const;
+
private:
- const Buffer<nlmsghdr> mConstBuffer;
nlmsghdr* mMutableBuffer;
+ size_t mTotalLen;
+
+ Buffer<nlmsghdr> constBuffer() const;
+ MessageMutator fragment(Buffer<nlmsghdr> buf) const;
};
} // namespace android::nl
diff --git a/automotive/can/1.0/default/libnl++/include/libnl++/generic/families/mac80211_hwsim.h b/automotive/can/1.0/default/libnl++/include/libnl++/generic/families/mac80211_hwsim.h
new file mode 100644
index 0000000..9b811f8
--- /dev/null
+++ b/automotive/can/1.0/default/libnl++/include/libnl++/generic/families/mac80211_hwsim.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+// API definitions from kernel drivers/net/wireless/mac80211_hwsim.h
+
+#define BIT(n) (1 << (n))
+
+enum hwsim_tx_control_flags {
+ HWSIM_TX_CTL_REQ_TX_STATUS = BIT(0),
+ HWSIM_TX_CTL_NO_ACK = BIT(1),
+ HWSIM_TX_STAT_ACK = BIT(2),
+};
+
+enum {
+ HWSIM_CMD_UNSPEC,
+ HWSIM_CMD_REGISTER,
+ HWSIM_CMD_FRAME,
+ HWSIM_CMD_TX_INFO_FRAME,
+ HWSIM_CMD_NEW_RADIO,
+ HWSIM_CMD_DEL_RADIO,
+ HWSIM_CMD_GET_RADIO,
+ HWSIM_CMD_ADD_MAC_ADDR,
+ HWSIM_CMD_DEL_MAC_ADDR,
+};
+
+enum {
+ HWSIM_ATTR_UNSPEC,
+ HWSIM_ATTR_ADDR_RECEIVER,
+ HWSIM_ATTR_ADDR_TRANSMITTER,
+ HWSIM_ATTR_FRAME,
+ HWSIM_ATTR_FLAGS,
+ HWSIM_ATTR_RX_RATE,
+ HWSIM_ATTR_SIGNAL,
+ HWSIM_ATTR_TX_INFO,
+ HWSIM_ATTR_COOKIE,
+ HWSIM_ATTR_CHANNELS,
+ HWSIM_ATTR_RADIO_ID,
+ HWSIM_ATTR_REG_HINT_ALPHA2,
+ HWSIM_ATTR_REG_CUSTOM_REG,
+ HWSIM_ATTR_REG_STRICT_REG,
+ HWSIM_ATTR_SUPPORT_P2P_DEVICE,
+ HWSIM_ATTR_USE_CHANCTX,
+ HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE,
+ HWSIM_ATTR_RADIO_NAME,
+ HWSIM_ATTR_NO_VIF,
+ HWSIM_ATTR_FREQ,
+ HWSIM_ATTR_PAD,
+ HWSIM_ATTR_TX_INFO_FLAGS,
+ HWSIM_ATTR_PERM_ADDR,
+ HWSIM_ATTR_IFTYPE_SUPPORT,
+ HWSIM_ATTR_CIPHER_SUPPORT,
+};
+
+struct hwsim_tx_rate {
+ int8_t idx;
+ uint8_t count;
+} __packed;
+static_assert(sizeof(hwsim_tx_rate) == 2);
+
+#undef BIT
diff --git a/automotive/can/1.0/default/libnl++/printer.cpp b/automotive/can/1.0/default/libnl++/printer.cpp
index f08897e..d540482 100644
--- a/automotive/can/1.0/default/libnl++/printer.cpp
+++ b/automotive/can/1.0/default/libnl++/printer.cpp
@@ -154,16 +154,19 @@
}
}
-std::string toString(const Buffer<nlmsghdr> hdr, int protocol, bool printPayload) {
- if (!hdr.firstOk()) return "nlmsg{buffer overflow}";
+static void toStream(std::stringstream& ss, const Buffer<nlmsghdr> hdr, int protocol,
+ bool printPayload) {
+ if (!hdr.firstOk()) {
+ ss << "nlmsg{buffer overflow}";
+ return;
+ }
- std::stringstream ss;
ss << std::setfill('0');
auto protocolMaybe = protocols::get(protocol);
if (!protocolMaybe.has_value()) {
ss << "nlmsg{protocol=" << protocol << "}";
- return ss.str();
+ return;
}
protocols::NetlinkProtocol& protocolDescr = *protocolMaybe;
@@ -187,7 +190,7 @@
ss << ", crc=" << std::hex << std::setw(4) << crc16(hdr.data<uint8_t>()) << std::dec;
ss << '}';
- if (!printPayload) return ss.str();
+ if (!printPayload) return;
ss << ' ';
if (!msgDescMaybe.has_value()) {
@@ -210,6 +213,17 @@
}
ss << "}";
+}
+
+std::string toString(const Buffer<nlmsghdr> hdrs, int protocol, bool printPayload) {
+ std::stringstream ss;
+ bool first = true;
+ for (const auto hdr : hdrs) {
+ if (!first) ss << std::endl;
+ first = false;
+
+ toStream(ss, hdr, protocol, printPayload);
+ }
return ss.str();
}
diff --git a/automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.cpp b/automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.cpp
index 1e1ad12..478c383 100644
--- a/automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.cpp
@@ -16,6 +16,7 @@
#include "Ctrl.h"
+#include "families/Mac80211hwsim.h"
#include "families/Nl80211.h"
#include <libnl++/Message.h>
@@ -68,12 +69,15 @@
const auto familyId = msg.attributes.get<uint16_t>(CTRL_ATTR_FAMILY_ID);
const auto familyName = msg.attributes.get<std::string>(CTRL_ATTR_FAMILY_NAME);
- /* For now, we support just a single family. But if you add more, please define proper
+ /* For now, we support just two families. But if you add more, please define proper
* abstraction and not hardcode every name and class here.
*/
if (familyName == "nl80211") {
mFamilyRegister[familyId] = std::make_shared<families::Nl80211>(familyId);
}
+ if (familyName == "MAC80211_HWSIM") {
+ mFamilyRegister[familyId] = std::make_shared<families::Mac80211hwsim>(familyId);
+ }
}
} // namespace android::nl::protocols::generic
diff --git a/automotive/can/1.0/default/libnl++/protocols/generic/GenericMessageBase.cpp b/automotive/can/1.0/default/libnl++/protocols/generic/GenericMessageBase.cpp
index b7b811b..f92d6c0 100644
--- a/automotive/can/1.0/default/libnl++/protocols/generic/GenericMessageBase.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/GenericMessageBase.cpp
@@ -40,9 +40,9 @@
ss << "genlmsghdr{";
if (commandName.has_value()) {
- ss << "cmd=" << unsigned(data.cmd);
- } else {
ss << "cmd=" << *commandName;
+ } else {
+ ss << "cmd=" << unsigned(data.cmd);
}
ss << ", version=" << unsigned(data.version);
if (data.reserved != 0) ss << ", reserved=" << data.reserved;
diff --git a/automotive/can/1.0/default/libnl++/protocols/generic/families/Mac80211hwsim.cpp b/automotive/can/1.0/default/libnl++/protocols/generic/families/Mac80211hwsim.cpp
new file mode 100644
index 0000000..f85309e
--- /dev/null
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/families/Mac80211hwsim.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2021 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 "Mac80211hwsim.h"
+
+#include "../../structs.h"
+#include "common.h"
+
+#include <libnl++/generic/families/mac80211_hwsim.h>
+
+namespace android::nl::protocols::generic::families {
+
+using DataType = AttributeDefinition::DataType;
+using Flags = AttributeDefinition::Flags;
+
+static void hwsim_tx_rateToStream(std::stringstream& ss, const Buffer<nlattr> attr);
+
+static const FlagsMap txControlFlags{
+ {HWSIM_TX_CTL_REQ_TX_STATUS, "REQ_TX"},
+ {HWSIM_TX_CTL_NO_ACK, "NO_ACK"},
+ {HWSIM_TX_STAT_ACK, "ACK"},
+};
+
+// clang-format off
+Mac80211hwsim::Mac80211hwsim(nlmsgtype_t familyId) : GenericMessageBase(familyId, "hwsim", {
+ {HWSIM_CMD_UNSPEC, "UNSPEC"},
+ {HWSIM_CMD_REGISTER, "REGISTER"},
+ {HWSIM_CMD_FRAME, "FRAME"},
+ {HWSIM_CMD_TX_INFO_FRAME, "TX_INFO_FRAME"},
+ {HWSIM_CMD_NEW_RADIO, "NEW_RADIO"},
+ {HWSIM_CMD_DEL_RADIO, "DEL_RADIO"},
+ {HWSIM_CMD_GET_RADIO, "GET_RADIO"},
+ {HWSIM_CMD_ADD_MAC_ADDR, "ADD_MAC_ADDR"},
+ {HWSIM_CMD_DEL_MAC_ADDR, "DEL_MAC_ADDR"},
+}, {
+ {HWSIM_ATTR_UNSPEC, {"UNSPEC"}},
+ {HWSIM_ATTR_ADDR_RECEIVER, {"ADDR_RECEIVER", DataType::Struct, hwaddrToStream}},
+ {HWSIM_ATTR_ADDR_TRANSMITTER, {"ADDR_TRANSMITTER", DataType::Struct, hwaddrToStream}},
+ {HWSIM_ATTR_FRAME, {"FRAME", DataType::Raw, AttributeMap{}, Flags::Verbose}},
+ {HWSIM_ATTR_FLAGS, {"FLAGS", DataType::Struct, flagsToStream(txControlFlags)}},
+ {HWSIM_ATTR_RX_RATE, {"RX_RATE", DataType::Uint}},
+ {HWSIM_ATTR_SIGNAL, {"SIGNAL", DataType::Uint}},
+ {HWSIM_ATTR_TX_INFO, {"TX_INFO", DataType::Struct, hwsim_tx_rateToStream}},
+ {HWSIM_ATTR_COOKIE, {"COOKIE", DataType::Uint}},
+ {HWSIM_ATTR_CHANNELS, {"CHANNELS", DataType::Uint}},
+ {HWSIM_ATTR_RADIO_ID, {"RADIO_ID", DataType::Uint}},
+ {HWSIM_ATTR_REG_HINT_ALPHA2, {"REG_HINT_ALPHA2", DataType::String}},
+ {HWSIM_ATTR_REG_CUSTOM_REG, {"REG_CUSTOM_REG", DataType::Uint}},
+ {HWSIM_ATTR_REG_STRICT_REG, {"REG_STRICT_REG", DataType::Flag}},
+ {HWSIM_ATTR_SUPPORT_P2P_DEVICE, {"SUPPORT_P2P_DEVICE", DataType::Flag}},
+ {HWSIM_ATTR_USE_CHANCTX, {"USE_CHANCTX", DataType::Flag}},
+ {HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE, {"DESTROY_RADIO_ON_CLOSE", DataType::Flag}},
+ {HWSIM_ATTR_RADIO_NAME, {"RADIO_NAME", DataType::String}},
+ {HWSIM_ATTR_NO_VIF, {"NO_VIF", DataType::Flag}},
+ {HWSIM_ATTR_FREQ, {"FREQ", DataType::Uint}},
+ {HWSIM_ATTR_PAD, {"PAD", DataType::Uint}},
+ {HWSIM_ATTR_TX_INFO_FLAGS, {"TX_INFO_FLAGS"}}, // hwsim_tx_rate_flag
+ {HWSIM_ATTR_PERM_ADDR, {"PERM_ADDR"}},
+ {HWSIM_ATTR_IFTYPE_SUPPORT, {"IFTYPE_SUPPORT", DataType::Uint}}, // NL80211_IFTYPE_STATION etc
+ {HWSIM_ATTR_CIPHER_SUPPORT, {"CIPHER_SUPPORT", DataType::Struct, arrayToStream<int32_t>}},
+}) {}
+// clang-format on
+
+static void hwsim_tx_rateToStream(std::stringstream& ss, const Buffer<nlattr> attr) {
+ ss << '{';
+ bool first = true;
+ for (const auto rate : attr.data<hwsim_tx_rate>().getRaw()) {
+ if (rate.idx == -1) continue;
+
+ ss << (int)rate.idx << ": " << (unsigned)rate.count;
+
+ if (!first) ss << ", ";
+ first = false;
+ }
+ ss << '}';
+}
+
+} // namespace android::nl::protocols::generic::families
diff --git a/automotive/can/1.0/default/libnl++/protocols/generic/families/Mac80211hwsim.h b/automotive/can/1.0/default/libnl++/protocols/generic/families/Mac80211hwsim.h
new file mode 100644
index 0000000..c01eb93
--- /dev/null
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/families/Mac80211hwsim.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2021 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 "../GenericMessageBase.h"
+
+namespace android::nl::protocols::generic::families {
+
+class Mac80211hwsim : public GenericMessageBase {
+ public:
+ Mac80211hwsim(nlmsgtype_t familyId);
+};
+
+} // namespace android::nl::protocols::generic::families
diff --git a/automotive/can/1.0/default/libnl++/protocols/structs.cpp b/automotive/can/1.0/default/libnl++/protocols/structs.cpp
new file mode 100644
index 0000000..8ff71f0
--- /dev/null
+++ b/automotive/can/1.0/default/libnl++/protocols/structs.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2021 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 "structs.h"
+
+#include <iomanip>
+
+namespace android::nl::protocols {
+
+AttributeDefinition::ToStream flagsToStream(FlagsMap flags) {
+ return [flags](std::stringstream& ss, const Buffer<nlattr> attr) {
+ auto val = attr.data<uint64_t>().copyFirst();
+
+ bool first = true;
+ for (const auto& [flag, name] : flags) {
+ if ((val & flag) != flag) continue;
+ val &= ~flag;
+
+ if (!first) ss << '|';
+ first = false;
+
+ ss << name;
+ }
+
+ if (val == 0) return;
+
+ if (!first) ss << '|';
+ ss << std::hex << val << std::dec;
+ };
+}
+
+void hwaddrToStream(std::stringstream& ss, const Buffer<nlattr> attr) {
+ ss << std::hex;
+ bool first = true;
+ for (const auto byte : attr.data<uint8_t>().getRaw()) {
+ if (!first) ss << ':';
+ first = false;
+
+ ss << std::setw(2) << unsigned(byte);
+ }
+ ss << std::dec;
+}
+
+} // namespace android::nl::protocols
diff --git a/automotive/can/1.0/default/libnl++/protocols/structs.h b/automotive/can/1.0/default/libnl++/protocols/structs.h
index 44c17b8..f3a8c44 100644
--- a/automotive/can/1.0/default/libnl++/protocols/structs.h
+++ b/automotive/can/1.0/default/libnl++/protocols/structs.h
@@ -16,6 +16,8 @@
#pragma once
+#include "MessageDefinition.h"
+
#include <sstream>
namespace android::nl::protocols {
@@ -30,4 +32,9 @@
ss << '}';
}
+typedef std::map<uint64_t, std::string> FlagsMap;
+AttributeDefinition::ToStream flagsToStream(FlagsMap flags);
+
+void hwaddrToStream(std::stringstream& ss, const Buffer<nlattr> attr);
+
} // namespace android::nl::protocols
diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml
index 9e99c48..6800bbd 100644
--- a/compatibility_matrices/compatibility_matrix.current.xml
+++ b/compatibility_matrices/compatibility_matrix.current.xml
@@ -521,7 +521,7 @@
</hal>
<hal format="hidl" optional="true">
<name>android.hardware.soundtrigger</name>
- <version>2.3</version>
+ <version>2.3-4</version>
<interface>
<name>ISoundTriggerHw</name>
<instance>default</instance>
diff --git a/drm/1.0/default/CryptoPlugin.cpp b/drm/1.0/default/CryptoPlugin.cpp
index e6d4e84..17a2f24 100644
--- a/drm/1.0/default/CryptoPlugin.cpp
+++ b/drm/1.0/default/CryptoPlugin.cpp
@@ -79,7 +79,7 @@
}
}
- android::CryptoPlugin::Mode legacyMode;
+ android::CryptoPlugin::Mode legacyMode = android::CryptoPlugin::kMode_Unencrypted;
switch(mode) {
case Mode::UNENCRYPTED:
legacyMode = android::CryptoPlugin::kMode_Unencrypted;
@@ -146,7 +146,10 @@
return Void();
}
- if (destBuffer.offset + destBuffer.size > destBase->getSize()) {
+ size_t totalSize = 0;
+ if (__builtin_add_overflow(destBuffer.offset, destBuffer.size, &totalSize) ||
+ totalSize > destBase->getSize()) {
+ android_errorWriteLog(0x534e4554, "176496353");
_hidl_cb(Status::ERROR_DRM_CANNOT_HANDLE, 0, "invalid buffer size");
return Void();
}
@@ -157,7 +160,7 @@
}
base = static_cast<uint8_t *>(static_cast<void *>(destBase->getPointer()));
- destPtr = static_cast<void *>(base + destination.nonsecureMemory.offset);
+ destPtr = static_cast<void*>(base + destination.nonsecureMemory.offset);
} else if (destination.type == BufferType::NATIVE_HANDLE) {
if (!secure) {
_hidl_cb(Status::BAD_VALUE, 0, "native handle destination must be secure");
diff --git a/neuralnetworks/1.0/types.t b/neuralnetworks/1.0/types.t
index d7b26aa..be1ee07 100644
--- a/neuralnetworks/1.0/types.t
+++ b/neuralnetworks/1.0/types.t
@@ -63,361 +63,25 @@
RELU6 = 3,
};
-/**
- * How an operand is used.
- */
-enum OperandLifeTime : int32_t {
- /**
- * The operand is internal to the model. It's created by an operation and
- * consumed by other operations. It must be an output operand of
- * exactly one operation.
- */
- TEMPORARY_VARIABLE,
+%insert OperandLifeTime
- /**
- * The operand is an input of the model. It must not be an output
- * operand of any operation.
- *
- * An operand can't be both input and output of a model.
- */
- MODEL_INPUT,
+%insert DeviceStatus
- /**
- * The operand is an output of the model. It must be an output
- * operand of exactly one operation.
- *
- * An operand can't be both input and output of a model.
- */
- MODEL_OUTPUT,
+%insert PerformanceInfo
- /**
- * The operand is a constant found in Model.operandValues. It must
- * not be an output operand of any operation.
- */
- CONSTANT_COPY,
+%insert Capabilities
- /**
- * The operand is a constant that was specified via a Memory
- * object. It must not be an output operand of any operation.
- */
- CONSTANT_REFERENCE,
+%insert DataLocation
- /**
- * The operand does not have a value. This is valid only for optional
- * arguments of operations.
- */
- NO_VALUE,
-};
+%insert Operand
-/**
- * Status of a device.
- */
-enum DeviceStatus : int32_t {
- AVAILABLE,
- BUSY,
- OFFLINE,
- UNKNOWN,
-};
+%insert Operation
-/**
- * Performance information for the reference workload.
- *
- * Used by a driver to report its performance characteristics.
- */
-struct PerformanceInfo {
- /**
- * Ratio of the time taken by the driver to execute the
- * workload compared to the time the CPU would take for the
- * same workload. A lower number is better.
- */
- float execTime;
+%insert Model
- /**
- * Ratio of the energy used by the driver compared to what
- * the CPU would use for doing the same workload. A lower number
- * is better.
- */
- float powerUsage;
-};
+%insert RequestArgument
-/**
- * The capabilities of a driver.
- */
-struct Capabilities {
- /**
- * Driver performance when operating on float32 data.
- */
- PerformanceInfo float32Performance;
-
- /**
- * Driver performance when operating on asymmetric 8-bit quantized data.
- */
- PerformanceInfo quantized8Performance;
-};
-
-/**
- * Describes the location of a data object.
- */
-struct DataLocation {
- /**
- * The index of the memory pool where this location is found.
- */
- uint32_t poolIndex;
-
- /**
- * Offset in bytes from the start of the pool.
- */
- uint32_t offset;
-
- /**
- * The length of the data in bytes.
- */
- uint32_t length;
-};
-
-/**
- * Describes one operand of the model's graph.
- */
-struct Operand {
- /**
- * Data type of the operand.
- */
- OperandType type;
-
- /**
- * Dimensions of the operand.
- *
- * For a scalar operand, dimensions.size() must be 0.
- *
- * For a tensor operand, dimensions.size() must be at least 1;
- * however, any of the dimensions may be unspecified.
- *
- * A tensor operand with all dimensions specified has "fully
- * specified" dimensions. Whenever possible (i.e., whenever the
- * dimensions are known at model construction time), a tensor
- * operand should have (but is not required to have) fully
- * specified dimensions, in order to enable the best possible
- * performance.
- *
- * If a tensor operand's dimensions are not fully specified, the
- * dimensions of the operand are deduced from the operand
- * dimensions and values of the operation for which that operand
- * is an output.
- *
- * In the following situations, a tensor operand's dimensions must
- * be fully specified:
- *
- * . The operand has lifetime CONSTANT_COPY or
- * CONSTANT_REFERENCE.
- *
- * . The operand has lifetime MODEL_INPUT or MODEL_OUTPUT. Fully
- * specified dimensions must either be present in the
- * Operand or they must be provided in the corresponding
- * RequestArgument.
- * EXCEPTION: If the input or output is optional and omitted
- * (by setting the hasNoValue field of the corresponding
- * RequestArgument to true) then it need not have fully
- * specified dimensions.
- *
- * A tensor operand with some number of unspecified dimensions is
- * represented by setting each unspecified dimension to 0.
- */
- vec<uint32_t> dimensions;
-
- /**
- * The number of times this operand appears as an operation input.
- *
- * (For example, if this operand appears once in one operation's
- * input list, and three times in another operation's input list,
- * then numberOfConsumers = 4.)
- */
- uint32_t numberOfConsumers;
-
- /**
- * Quantized scale of the operand.
- *
- * Only applicable if the operand is of type TENSOR_QUANT8_ASYMM or
- * TENSOR_INT32.
- */
- float scale;
-
- /**
- * Quantized zero-point offset of the operand.
- *
- * Only applicable if the operand is of type TENSOR_QUANT8_ASYMM.
- */
- int32_t zeroPoint;
-
- /**
- * How the operand is used.
- */
- OperandLifeTime lifetime;
-
- /**
- * Where to find the data for this operand.
- * If the lifetime is TEMPORARY_VARIABLE, MODEL_INPUT, MODEL_OUTPUT, or
- * NO_VALUE:
- * - All the fields must be 0.
- * If the lifetime is CONSTANT_COPY:
- * - location.poolIndex is 0.
- * - location.offset is the offset in bytes into Model.operandValues.
- * - location.length is set.
- * If the lifetime is CONSTANT_REFERENCE:
- * - location.poolIndex is set.
- * - location.offset is the offset in bytes into the specified pool.
- * - location.length is set.
- */
- DataLocation location;
-};
-
-/**
- * Describes one operation of the model's graph.
- */
-struct Operation {
- /**
- * The operation type.
- */
- OperationType type;
-
- /**
- * Describes the table that contains the indexes of the inputs of the
- * operation. The offset is the index in the operandIndexes table.
- */
- vec<uint32_t> inputs;
-
- /**
- * Describes the table that contains the indexes of the outputs of the
- * operation. The offset is the index in the operandIndexes table.
- */
- vec<uint32_t> outputs;
-};
-
-/**
- * A Neural Network Model.
- *
- * This includes not only the execution graph, but also constant data such as
- * weights or scalars added at construction time. The only information that
- * might not be known is the shape of the input tensors.
- */
-struct Model {
- /**
- * All operands included in the model.
- */
- vec<Operand> operands;
-
- /**
- * All operations included in the model.
- *
- * The operations are sorted into execution order. Every operand
- * with lifetime MODEL_OUTPUT or TEMPORARY_VARIABLE must be
- * written before it is read.
- */
- vec<Operation> operations;
-
- /**
- * Input indexes of the model. There must be at least one.
- *
- * Each value corresponds to the index of the operand in "operands".
- */
- vec<uint32_t> inputIndexes;
-
- /**
- * Output indexes of the model. There must be at least one.
- *
- * Each value corresponds to the index of the operand in "operands".
- */
- vec<uint32_t> outputIndexes;
-
- /**
- * A byte buffer containing operand data that were copied into the model.
- *
- * An operand's value must be located here if and only if Operand::lifetime
- * equals OperandLifeTime::CONSTANT_COPY.
- */
- vec<uint8_t> operandValues;
-
- /**
- * A collection of shared memory pools containing operand values.
- *
- * An operand's value must be located here if and only if Operand::lifetime
- * equals OperandLifeTime::CONSTANT_REFERENCE.
- */
- vec<memory> pools;
-};
-
-/**
- * Metadata information specifying the location of the input or output data and
- * any updates to the input or output operand.
- */
-struct RequestArgument {
- /**
- * If true, the argument does not have a value. This can be used for
- * operations that take optional arguments. If true, the fields of location
- * are set to 0 and the dimensions vector is left empty.
- */
- bool hasNoValue;
-
- /**
- * The location within one of the memory pools passed in the Request.
- */
- DataLocation location;
-
- /**
- * Updated dimension information.
- *
- * If dimensions.size() > 0, dimension information was provided
- * along with the argument. This can be the case for models that
- * accept inputs of varying size. This can't change the rank, just
- * the value of the dimensions that were unspecified in the
- * model. If dimensions.size() > 0, then all dimensions must be
- * specified here; and any dimension that was specified in the
- * model must have the same value here.
- *
- * If the dimensions in the model are not fully specified, then
- * they must be fully specified here, unless hasNoValue is set to
- * true. If the dimensions in the model are fully specified, then
- * either dimensions.size() may be 0, or the dimensions in the
- * model must be identical to the dimensions here.
- */
- vec<uint32_t> dimensions;
-};
-
-/**
- * Inputs to be sent to and outputs to be retrieved from a prepared model.
- *
- * A Request serves two primary tasks:
- * 1) Provides the input and output data to be used when executing the model.
- * 2) Specifies any updates to the input operand metadata that were left
- * unspecified at model preparation time.
- *
- * An output must not overlap with any other output, with an input, or
- * with an operand of lifetime CONSTANT_REFERENCE.
- */
-struct Request {
- /**
- * Input data and information to be used in the execution of a prepared
- * model.
- *
- * The index of the input corresponds to the index in Model.inputIndexes.
- * E.g., input[i] corresponds to Model.inputIndexes[i].
- */
- vec<RequestArgument> inputs;
-
- /**
- * Output data and information to be used in the execution of a prepared
- * model.
- *
- * The index of the output corresponds to the index in Model.outputIndexes.
- * E.g., output[i] corresponds to Model.outputIndexes[i].
- */
- vec<RequestArgument> outputs;
-
- /**
- * A collection of shared memory pools containing operand data for both the
- * inputs and the outputs to a model.
- */
- vec<memory> pools;
-};
+%insert Request
/**
* Return status of a function.
diff --git a/neuralnetworks/1.1/types.t b/neuralnetworks/1.1/types.t
index 75ac2e7..8c22b30 100644
--- a/neuralnetworks/1.1/types.t
+++ b/neuralnetworks/1.1/types.t
@@ -31,128 +31,10 @@
%insert Operation_1.1
};
-/**
- * The capabilities of a driver.
- */
-struct Capabilities {
- /**
- * Driver performance when operating on float32 data.
- */
- PerformanceInfo float32Performance;
+%insert Capabilities
- /**
- * Driver performance when operating on asymmetric 8-bit quantized data.
- */
- PerformanceInfo quantized8Performance;
+%insert Operation
- /**
- * Driver performance when operating on float32 data but performing
- * calculations with range and/or precision as low as that of the IEEE
- * 754 16-bit floating-point format.
- */
- PerformanceInfo relaxedFloat32toFloat16Performance;
-};
+%insert Model
-/**
- * Describes one operation of the model's graph.
- */
-struct Operation {
- /**
- * The operation type.
- */
- OperationType type;
-
- /**
- * Describes the table that contains the indexes of the inputs of the
- * operation. The offset is the index in the operandIndexes table.
- */
- vec<uint32_t> inputs;
-
- /**
- * Describes the table that contains the indexes of the outputs of the
- * operation. The offset is the index in the operandIndexes table.
- */
- vec<uint32_t> outputs;
-};
-
-/**
- * A Neural Network Model.
- *
- * This includes not only the execution graph, but also constant data such as
- * weights or scalars added at construction time. The only information that
- * may not be known is the shape of the input tensors.
- */
-struct Model {
- /**
- * All operands included in the model.
- */
- vec<Operand> operands;
-
- /**
- * All operations included in the model.
- *
- * The operations are sorted into execution order. Every operand
- * with lifetime MODEL_OUTPUT or TEMPORARY_VARIABLE must be
- * written before it is read.
- */
- vec<Operation> operations;
-
- /**
- * Input indexes of the model. There must be at least one.
- *
- * Each value corresponds to the index of the operand in "operands".
- */
- vec<uint32_t> inputIndexes;
-
- /**
- * Output indexes of the model. There must be at least one.
- *
- * Each value corresponds to the index of the operand in "operands".
- */
- vec<uint32_t> outputIndexes;
-
- /**
- * A byte buffer containing operand data that were copied into the model.
- *
- * An operand's value must be located here if and only if Operand::lifetime
- * equals OperandLifeTime::CONSTANT_COPY.
- */
- vec<uint8_t> operandValues;
-
- /**
- * A collection of shared memory pools containing operand values.
- *
- * An operand's value must be located here if and only if Operand::lifetime
- * equals OperandLifeTime::CONSTANT_REFERENCE.
- */
- vec<memory> pools;
-
- /**
- * 'true' indicates TENSOR_FLOAT32 may be calculated with range and/or
- * precision as low as that of the IEEE 754 16-bit floating-point format.
- * 'false' indicates TENSOR_FLOAT32 must be calculated using at least the
- * range and precision of the IEEE 754 32-bit floating-point format.
- */
- bool relaxComputationFloat32toFloat16;
-};
-
-/**
- * Execution preferences.
- */
-enum ExecutionPreference : int32_t {
- /**
- * Prefer executing in a way that minimizes battery drain.
- * This is desirable for compilations that will be executed often.
- */
- LOW_POWER = 0,
- /**
- * Prefer returning a single answer as fast as possible, even if this causes
- * more power consumption.
- */
- FAST_SINGLE_ANSWER = 1,
- /**
- * Prefer maximizing the throughput of successive frames, for example when
- * processing successive frames coming from the camera.
- */
- SUSTAINED_SPEED = 2,
-};
+%insert ExecutionPreference
diff --git a/neuralnetworks/1.2/types.t b/neuralnetworks/1.2/types.t
index 4c9fd02..b490f7f 100644
--- a/neuralnetworks/1.2/types.t
+++ b/neuralnetworks/1.2/types.t
@@ -97,379 +97,23 @@
BASE_MAX = 0xFFFF,
};
-/**
- * Device types.
- *
- * The type of NNAPI device.
- */
-enum DeviceType : int32_t {
- // Leaving 0 unused as it means unknown type in NDK NNAPI. There is no
- // HAL equivalent of unknown type and a 1.2 HAL implementation must belong
- // to one of the categories below.
- /** The device does not fall into any category below. */
- OTHER = 1,
- /** The device runs NNAPI models on single or multi-core CPU. */
- CPU = 2,
- /** The device can run NNAPI models and also accelerate graphics APIs such
- * as OpenGL ES and Vulkan. */
- GPU = 3,
- /** Dedicated accelerator for Machine Learning workloads. */
- ACCELERATOR = 4,
-};
+%insert DeviceType
-/**
- * The capabilities of a driver.
- *
- * Performance of an operation comes from the type of its first operand.
- * This represents performance for non extension operand types.
- */
-struct Capabilities {
- /**
- * Driver performance when operating on float32 data but performing
- * calculations with range and/or precision as low as that of the IEEE
- * 754 16-bit floating-point format.
- */
- PerformanceInfo relaxedFloat32toFloat16PerformanceScalar;
- PerformanceInfo relaxedFloat32toFloat16PerformanceTensor;
+%insert Capabilities
- /**
- * Driver performance when operating on a particular data type.
- * In the case of float32 data, this is used when the calculations
- * are not relaxed.
- */
- struct OperandPerformance {
- OperandType type;
- PerformanceInfo info;
- };
+%insert Operation
- /**
- * Performance by operand type. Must be sorted by OperandType.
- * If a particular OperandType is not present in operandPerformance,
- * its performance is treated as { .execTime = FLT_MAX, .powerUsage = FLT_MAX }.
- */
- vec<OperandPerformance> operandPerformance;
-};
+%insert SymmPerChannelQuantParams
-/**
- * Describes one operation of the model's graph.
- */
-struct Operation {
- /**
- * The operation type.
- *
- * Besides the values listed in {@link OperationType}, any value above
- * {@link OperationTypeRange::BASE_MAX} is possible and should be interpreted
- * as an extension type according to {@link Model::extensionNameToPrefix}.
- */
- OperationType type;
+%insert Operand
- /**
- * Describes the table that contains the indexes of the inputs of the
- * operation. The offset is the index in the operandIndexes table.
- */
- vec<uint32_t> inputs;
+%insert Model
- /**
- * Describes the table that contains the indexes of the outputs of the
- * operation. The offset is the index in the operandIndexes table.
- */
- vec<uint32_t> outputs;
-};
+%insert OutputShape
-/**
- * Parameters for TENSOR_QUANT8_SYMM_PER_CHANNEL operand.
- */
-struct SymmPerChannelQuantParams {
- /** Array of scaling values for each channel. Each value must be greater than zero. */
- vec<float> scales;
- /** Index of the channel dimension */
- uint32_t channelDim;
-};
+%insert MeasureTiming
-/**
- * Describes one operand of the model's graph.
- */
-struct Operand {
- /**
- * The data type.
- *
- * Besides the values listed in {@link OperandType}, any value above
- * {@link OperandTypeRange::BASE_MAX} is possible and should be interpreted
- * as an extension type according to {@link Model::extensionNameToPrefix}.
- */
- OperandType type;
-
- /**
- * Dimensions of the operand.
- *
- * For a scalar operand, dimensions.size() must be 0.
- *
- * A tensor operand with all dimensions specified has "fully
- * specified" dimensions. Whenever possible (i.e., whenever the
- * dimensions are known at model construction time), a tensor
- * operand should have (but is not required to have) fully
- * specified dimensions, in order to enable the best possible
- * performance.
- *
- * If a tensor operand's dimensions are not fully specified, the
- * dimensions of the operand are deduced from the operand
- * dimensions and values of the operation for which that operand
- * is an output.
- *
- * In the following situations, a tensor operand's dimensions must
- * be fully specified:
- *
- * . The operand has lifetime CONSTANT_COPY or
- * CONSTANT_REFERENCE.
- *
- * . The operand has lifetime MODEL_INPUT. Fully
- * specified dimensions must either be present in the
- * Operand or they must be provided in the corresponding
- * RequestArgument.
- * EXCEPTION: If the input is optional and omitted
- * (by setting the hasNoValue field of the corresponding
- * RequestArgument to true) then it need not have fully
- * specified dimensions.
- *
- * A tensor operand with some number of unspecified dimensions is
- * represented by setting each unspecified dimension to 0.
- *
- * A tensor operand with unspecified rank is represented by providing
- * an empty dimensions vector.
- */
- vec<uint32_t> dimensions;
-
- /**
- * The number of times this operand appears as an operation input.
- *
- * (For example, if this operand appears once in one operation's
- * input list, and three times in another operation's input list,
- * then numberOfConsumers = 4.)
- */
- uint32_t numberOfConsumers;
-
- /**
- * Quantized scale of the operand.
- *
- * Must be 0 when not applicable to an operand type.
- *
- * See {@link OperandType}.
- */
- float scale;
-
- /**
- * Quantized zero-point offset of the operand.
- *
- * Must be 0 when not applicable to an operand type.
- *
- * See {@link OperandType}.
- */
- int32_t zeroPoint;
-
- /**
- * How the operand is used.
- */
- OperandLifeTime lifetime;
-
- /**
- * Where to find the data for this operand.
- * If the lifetime is TEMPORARY_VARIABLE, MODEL_INPUT, MODEL_OUTPUT, or
- * NO_VALUE:
- * - All the fields must be 0.
- * If the lifetime is CONSTANT_COPY:
- * - location.poolIndex is 0.
- * - location.offset is the offset in bytes into Model.operandValues.
- * - location.length is set.
- * If the lifetime is CONSTANT_REFERENCE:
- * - location.poolIndex is set.
- * - location.offset is the offset in bytes into the specified pool.
- * - location.length is set.
- */
- DataLocation location;
-
- /**
- * Additional parameters specific to a particular operand type.
- */
- safe_union ExtraParams {
- /**
- * No additional parameters.
- */
- Monostate none;
-
- /**
- * Symmetric per-channel quantization parameters.
- *
- * Only applicable to operands of type TENSOR_QUANT8_SYMM_PER_CHANNEL.
- */
- SymmPerChannelQuantParams channelQuant;
-
- /**
- * Extension operand parameters.
- *
- * The framework treats this as an opaque data blob.
- * The format is up to individual extensions.
- */
- vec<uint8_t> extension;
- } extraParams;
-};
-
-/**
- * A Neural Network Model.
- *
- * This includes not only the execution graph, but also constant data such as
- * weights or scalars added at construction time. The only information that
- * may not be known is the shape of the input tensors.
- */
-struct Model {
- /**
- * All operands included in the model.
- */
- vec<Operand> operands;
-
- /**
- * All operations included in the model.
- *
- * The operations are sorted into execution order. Every operand
- * with lifetime MODEL_OUTPUT or TEMPORARY_VARIABLE must be
- * written before it is read.
- */
- vec<Operation> operations;
-
- /**
- * Input indexes of the model. There must be at least one.
- *
- * Each value corresponds to the index of the operand in "operands".
- */
- vec<uint32_t> inputIndexes;
-
- /**
- * Output indexes of the model. There must be at least one.
- *
- * Each value corresponds to the index of the operand in "operands".
- */
- vec<uint32_t> outputIndexes;
-
- /**
- * A byte buffer containing operand data that were copied into the model.
- *
- * An operand's value must be located here if and only if Operand::lifetime
- * equals OperandLifeTime::CONSTANT_COPY.
- */
- vec<uint8_t> operandValues;
-
- /**
- * A collection of shared memory pools containing operand values.
- *
- * An operand's value must be located here if and only if Operand::lifetime
- * equals OperandLifeTime::CONSTANT_REFERENCE.
- */
- vec<memory> pools;
-
- /**
- * 'true' indicates TENSOR_FLOAT32 may be calculated with range and/or
- * precision as low as that of the IEEE 754 16-bit floating-point format.
- * 'false' indicates TENSOR_FLOAT32 must be calculated using at least the
- * range and precision of the IEEE 754 32-bit floating-point format.
- */
- bool relaxComputationFloat32toFloat16;
-
- /**
- * The mapping between extension names and prefixes of operand and
- * operation type values.
- *
- * An operand or operation whose numeric type value is above
- * {@link OperandTypeRange::BASE_MAX} or
- * {@link OperationTypeRange::BASE_MAX} respectively should be interpreted
- * as an extension operand. The low
- * {@link Model::ExtensionTypeEncoding::LOW_BITS_TYPE} bits of the value
- * correspond to the type ID within the extension and the high
- * {@link Model::ExtensionTypeEncoding::HIGH_BITS_PREFIX} bits encode
- * the "prefix", which maps uniquely to the extension name.
- *
- * For example, if a model contains an operation whose value is
- * 0xAAAABBBB and extensionNameToPrefix contains an entry with
- * prefix=0xAAAA and name="vendor.test.test_extension", then
- * the operation should be interpreted as the operation 0xBBBB
- * of the extension named vendor.test.test_extension.
- *
- * This is a one-to-one correspondence. That is, there must be at most one
- * prefix corresponding to each extension name and at most one extension
- * name corresponding to each prefix.
- */
- vec<ExtensionNameAndPrefix> extensionNameToPrefix;
-
- /**
- * A correspondence between an extension name and a prefix of operand and
- * operation type values.
- */
- struct ExtensionNameAndPrefix {
- /**
- * The extension name.
- *
- * See {@link Extension::name} for the format specification.
- */
- string name;
-
- /**
- * The unique extension identifier within the model.
- *
- * See {@link Model::extensionNameToPrefix}.
- */
- uint16_t prefix;
- };
-
- /**
- * Numeric values of extension operand and operation types have the
- * following structure:
- * - 16 high bits represent the "prefix", which corresponds uniquely to the
- * extension name.
- * - 16 low bits represent the type ID within the extension.
- */
- enum ExtensionTypeEncoding : uint8_t {
- HIGH_BITS_PREFIX = 16,
- LOW_BITS_TYPE = 16,
- };
-};
-
-/**
- * Describes the shape information of an output operand after execution.
- */
-struct OutputShape {
- /**
- * Dimensions of the operand.
- */
- vec<uint32_t> dimensions;
-
- /**
- * Whether the provided buffer size is sufficient for the output.
- */
- bool isSufficient;
-};
-
-/**
- * Specifies whether or not to measure timing information during execution.
- */
-enum MeasureTiming : int32_t {
- NO = 0,
- YES = 1,
-};
-
-/**
-
- * Timing information measured during execution. Each time is a duration from
- * the beginning of some task to the end of that task, including time when that
- * task is not active (for example, preempted by some other task, or
- * waiting for some resource to become available).
- *
- * Times are measured in microseconds.
- * When a time is not available, it must be reported as UINT64_MAX.
- */
-struct Timing {
- /** Execution time on device (not driver, which runs on host processor). */
- uint64_t timeOnDevice;
- /** Execution time in driver (including time on device). */
- uint64_t timeInDriver;
-};
+%insert Timing
/**
* FmqRequestDatum is a single element of a serialized representation of an
@@ -683,46 +327,4 @@
Timing executionTiming;
};
-/**
- * Information about an extension.
- */
-struct Extension {
- /**
- * The extension name.
- *
- * The name must consist of lowercase latin letters, numbers, periods, and
- * underscore signs. The name must contain at least one period.
- *
- * The name must start with the reverse domain name of the vendor.
- *
- * Example: com.google.test_extension
- */
- string name;
-
- /**
- * Information about an extension operand type.
- */
- struct OperandTypeInformation {
- /**
- * The extension operand type.
- */
- uint16_t type;
-
- /**
- * Indicates whether the extension operand type represents a tensor or
- * a scalar.
- */
- bool isTensor;
-
- /**
- * The byte size of the operand (if scalar) or of a single element (if
- * tensor).
- */
- uint32_t byteSize;
- };
-
- /**
- * Information about operand types defined by the extension.
- */
- vec<OperandTypeInformation> operandTypes;
-};
+%insert Extension
diff --git a/neuralnetworks/1.3/types.t b/neuralnetworks/1.3/types.t
index 9f69c9e..96d1a1b 100644
--- a/neuralnetworks/1.3/types.t
+++ b/neuralnetworks/1.3/types.t
@@ -90,459 +90,25 @@
BASE_MAX = 0xFFFF,
};
-/**
- * Priority given to a prepared model for execution.
- */
-enum Priority : int32_t {
- LOW,
- MEDIUM,
- HIGH,
-};
+%insert Priority
-/**
- * The capabilities of a driver.
- *
- * This represents performance of non-extension operations.
- *
- * Performance of an operation other than {@link OperationType::IF} and
- * {@link OperationType::WHILE} comes from the type of its first operand.
- */
-struct Capabilities {
- /**
- * Driver performance when operating on float32 data but performing
- * calculations with range and/or precision as low as that of the IEEE
- * 754 16-bit floating-point format.
- */
- PerformanceInfo relaxedFloat32toFloat16PerformanceScalar;
- PerformanceInfo relaxedFloat32toFloat16PerformanceTensor;
+%insert Capabilities
- /**
- * Driver performance when operating on a particular data type.
- * In the case of float32 data, this is used when the calculations
- * are not relaxed.
- */
- struct OperandPerformance {
- OperandType type;
- PerformanceInfo info;
- };
+%insert Operation
- /**
- * Performance by operand type. Must be sorted by OperandType.
- *
- * If a particular {@link OperandType} is not present in operandPerformance,
- * its performance is treated as
- * { .execTime = FLT_MAX, .powerUsage = FLT_MAX }.
- *
- * Performance does not apply to {@link OperandType::SUBGRAPH}, and a driver
- * must not report operand performance for {@link OperandType::SUBGRAPH}.
- */
- vec<OperandPerformance> operandPerformance;
+%insert OperandLifeTime
- /**
- * Performance of an {@link OperationType::IF} operation is the sum of
- * {@link Capabilities::ifPerformance} and the mean of performance for the
- * two branch subgraphs, where performance for a subgraph is the sum of the
- * performance of all operations within the subgraph.
- */
- PerformanceInfo ifPerformance;
+%insert Operand
- /**
- * Performance of a {@link OperationType::WHILE} operation is the sum of
- * {@link Capabilities::whilePerformance}, performance for the condition
- * subgraph and performance for the body subgraph, where performance for a
- * subgraph is the sum of the performance of all operations within the
- * subgraph.
- */
- PerformanceInfo whilePerformance;
-};
+%insert Model
-/**
- * Describes one operation of the model's graph.
- */
-struct Operation {
- /**
- * The operation type.
- *
- * Besides the values listed in {@link OperationType}, any value above
- * {@link OperationTypeRange::BASE_MAX} is possible and should be interpreted
- * as an extension type according to {@link Model::extensionNameToPrefix}.
- */
- OperationType type;
+%insert Subgraph
- /**
- * Describes the table that contains the indexes of the inputs of the
- * operation. The offset is the index in the operandIndexes table.
- */
- vec<uint32_t> inputs;
+%insert BufferDesc
- /**
- * Describes the table that contains the indexes of the outputs of the
- * operation. The offset is the index in the operandIndexes table.
- */
- vec<uint32_t> outputs;
-};
+%insert BufferRole
-/**
- * How an operand is used.
- */
-enum OperandLifeTime : int32_t {
- /**
- * The operand is internal to the model. It's created by an operation and
- * consumed by other operations. It must be an output operand of
- * exactly one operation.
- */
- TEMPORARY_VARIABLE,
-
- /**
- * The operand is an input of a subgraph. It must not be an output
- * operand of any operation.
- *
- * An operand can't be both input and output of a subgraph.
- */
- SUBGRAPH_INPUT,
-
- /**
- * The operand is an output of a subgraph. It must be an output
- * operand of exactly one operation.
- *
- * An operand can't be both input and output of a subgraph.
- */
- SUBGRAPH_OUTPUT,
-
- /**
- * The operand is a constant found in Model.operandValues. It must
- * not be an output operand of any operation.
- */
- CONSTANT_COPY,
-
- /**
- * The operand is a constant that was specified via a Memory
- * object. It must not be an output operand of any operation.
- */
- CONSTANT_REFERENCE,
-
- /**
- * The operand does not have a value. This is valid only for optional
- * arguments of operations.
- */
- NO_VALUE,
-
- /**
- * The operand is a reference to a subgraph. It must be an input to one
- * or more {@link OperationType::IF} or {@link OperationType::WHILE}
- * operations.
- */
- SUBGRAPH,
-};
-
-/**
- * Describes one operand of the model's graph.
- */
-struct Operand {
- /**
- * The data type.
- *
- * Besides the values listed in {@link OperandType}, any value above
- * {@link OperandTypeRange::BASE_MAX} is possible and should be interpreted
- * as an extension type according to {@link Model::extensionNameToPrefix}.
- */
- OperandType type;
-
- /**
- * Dimensions of the operand.
- *
- * For a scalar operand, dimensions.size() must be 0.
- *
- * A tensor operand with all dimensions specified has "fully
- * specified" dimensions. Whenever possible (i.e., whenever the
- * dimensions are known at model construction time), a tensor
- * operand should have (but is not required to have) fully
- * specified dimensions, in order to enable the best possible
- * performance.
- *
- * If a tensor operand's dimensions are not fully specified, the
- * dimensions of the operand are deduced from the operand
- * dimensions and values of the operation for which that operand
- * is an output or from the corresponding {@link OperationType::IF} or
- * {@link OperationType::WHILE} operation input operand dimensions in the
- * case of referenced subgraph input operands.
- *
- * In the following situations, a tensor operand's dimensions must
- * be fully specified:
- *
- * . The operand has lifetime CONSTANT_COPY or
- * CONSTANT_REFERENCE.
- *
- * . The operand has lifetime SUBGRAPH_INPUT and belongs to the main
- * subgraph. Fully specified dimensions must either be present in the
- * Operand or they must be provided in the corresponding
- * RequestArgument.
- * EXCEPTION: If the input is optional and omitted
- * (by setting the hasNoValue field of the corresponding
- * RequestArgument to true) then it need not have fully
- * specified dimensions.
- *
- * A tensor operand with some number of unspecified dimensions is
- * represented by setting each unspecified dimension to 0.
- *
- * A tensor operand with unspecified rank is represented by providing
- * an empty dimensions vector.
- */
- vec<uint32_t> dimensions;
-
- /**
- * The number of times this operand appears as an operation input.
- *
- * (For example, if this operand appears once in one operation's
- * input list, and three times in another operation's input list,
- * then numberOfConsumers = 4.)
- */
- uint32_t numberOfConsumers;
-
- /**
- * Quantized scale of the operand.
- *
- * Must be 0 when not applicable to an operand type.
- *
- * See {@link OperandType}.
- */
- float scale;
-
- /**
- * Quantized zero-point offset of the operand.
- *
- * Must be 0 when not applicable to an operand type.
- *
- * See {@link OperandType}.
- */
- int32_t zeroPoint;
-
- /**
- * How the operand is used.
- */
- OperandLifeTime lifetime;
-
- /**
- * Where to find the data for this operand.
- * If the lifetime is TEMPORARY_VARIABLE, SUBGRAPH_INPUT, SUBGRAPH_OUTPUT,
- * or NO_VALUE:
- * - All the fields must be 0.
- * If the lifetime is CONSTANT_COPY:
- * - location.poolIndex is 0.
- * - location.offset is the offset in bytes into Model.operandValues.
- * - location.length is set.
- * If the lifetime is CONSTANT_REFERENCE:
- * - location.poolIndex is set.
- * - location.offset is the offset in bytes into the specified pool.
- * - location.length is set.
- * If the lifetime is SUBGRAPH:
- * - location.poolIndex is 0.
- * - location.offset is the index of the referenced subgraph in
- * {@link Model::referenced}.
- * - location.length is 0.
- */
- DataLocation location;
-
- /**
- * Additional parameters specific to a particular operand type.
- */
- @1.2::Operand.ExtraParams extraParams;
-};
-
-/**
- * A Neural Network Model.
- *
- * This includes not only the execution graph, but also constant data such as
- * weights or scalars added at construction time. The only information that
- * may not be known is the shape of the input tensors.
- */
-struct Model {
- /**
- * The top-level subgraph.
- */
- Subgraph main;
-
- /**
- * Referenced subgraphs.
- *
- * Each subgraph is referenced by the main subgraph or at least one other
- * referenced subgraph.
- *
- * There must be no reference cycles.
- */
- vec<Subgraph> referenced;
-
- /**
- * A byte buffer containing operand data that were copied into the model.
- *
- * An operand's value must be located here if and only if Operand::lifetime
- * equals OperandLifeTime::CONSTANT_COPY.
- */
- vec<uint8_t> operandValues;
-
- /**
- * A collection of shared memory pools containing operand values.
- *
- * An operand's value must be located here if and only if Operand::lifetime
- * equals OperandLifeTime::CONSTANT_REFERENCE.
- */
- vec<memory> pools;
-
- /**
- * 'true' indicates TENSOR_FLOAT32 may be calculated with range and/or
- * precision as low as that of the IEEE 754 16-bit floating-point format.
- * 'false' indicates TENSOR_FLOAT32 must be calculated using at least the
- * range and precision of the IEEE 754 32-bit floating-point format.
- */
- bool relaxComputationFloat32toFloat16;
-
- /**
- * The mapping between extension names and prefixes of operand and
- * operation type values.
- *
- * An operand or operation whose numeric type value is above
- * {@link OperandTypeRange::BASE_MAX} or
- * {@link OperationTypeRange::BASE_MAX} respectively should be interpreted
- * as an extension operand. The low
- * {@link @1.2::Model::ExtensionTypeEncoding::LOW_BITS_TYPE} bits of the
- * value correspond to the type ID within the extension and the high
- * {@link @1.2::Model::ExtensionTypeEncoding::HIGH_BITS_PREFIX} bits encode
- * the "prefix", which maps uniquely to the extension name.
- *
- * For example, if a model contains an operation whose value is
- * 0xAAAABBBB and extensionNameToPrefix contains an entry with
- * prefix=0xAAAA and name="vendor.test.test_extension", then
- * the operation should be interpreted as the operation 0xBBBB
- * of the extension named vendor.test.test_extension.
- *
- * This is a one-to-one correspondence. That is, there must be at most one
- * prefix corresponding to each extension name and at most one extension
- * name corresponding to each prefix.
- */
- vec<@1.2::Model.ExtensionNameAndPrefix> extensionNameToPrefix;
-};
-
-/**
- * An excerpt of the execution graph.
- */
-struct Subgraph {
- /**
- * All operands included in the subgraph.
- */
- vec<Operand> operands;
-
- /**
- * All operations included in the subgraph.
- *
- * The operations are sorted into execution order. Every operand
- * with lifetime SUBGRAPH_OUTPUT or TEMPORARY_VARIABLE must be
- * written before it is read.
- */
- vec<Operation> operations;
-
- /**
- * Input indexes of the subgraph. There must be at least one.
- *
- * Each value corresponds to the index of the operand in "operands".
- */
- vec<uint32_t> inputIndexes;
-
- /**
- * Output indexes of the subgraph. There must be at least one.
- *
- * Each value corresponds to the index of the operand in "operands".
- */
- vec<uint32_t> outputIndexes;
-};
-
-/**
- * A buffer descriptor. Describes the properties of a buffer.
- */
-struct BufferDesc {
- /**
- * Dimensions of the buffer. May have unknown dimensions or rank. A buffer with some number
- * of unspecified dimensions is represented by setting each unspecified dimension to 0. A
- * buffer with unspecified rank is represented by providing an empty dimensions vector.
- */
- vec<uint32_t> dimensions;
-};
-
-/**
- * Describes a role of an input or output to a prepared model.
- */
-struct BufferRole {
- /**
- * The index of the IPreparedModel within the "preparedModel" argument passed in
- * IDevice::allocate.
- */
- uint32_t modelIndex;
-
- /**
- * The index of the input or output operand.
- */
- uint32_t ioIndex;
-
- /**
- * A floating-point value within the range (0.0, 1.0]. Describes how likely the
- * buffer is to be used in the specified role. This is provided as a hint to
- * optimize the case when multiple roles prefer different buffer locations or data
- * layouts.
- */
- float frequency;
-};
-
-/**
- * Inputs to be sent to and outputs to be retrieved from a prepared model.
- *
- * A Request serves two primary tasks:
- * 1) Provides the input and output data to be used when executing the model.
- * 2) Specifies any updates to the input operand metadata that were left
- * unspecified at model preparation time.
- *
- * An output must not overlap with any other output, with an input, or
- * with an operand of lifetime CONSTANT_REFERENCE.
- */
-struct Request {
- /**
- * Input data and information to be used in the execution of a prepared
- * model.
- *
- * The index of the input corresponds to the index in Model.main.inputIndexes.
- * E.g., input[i] corresponds to Model.main.inputIndexes[i].
- */
- vec<RequestArgument> inputs;
-
- /**
- * Output data and information to be used in the execution of a prepared
- * model.
- *
- * The index of the output corresponds to the index in Model.main.outputIndexes.
- * E.g., output[i] corresponds to Model.main.outputIndexes[i].
- */
- vec<RequestArgument> outputs;
-
- /**
- * A memory pool.
- */
- safe_union MemoryPool {
- /**
- * Specifies a client-managed shared memory pool.
- */
- memory hidlMemory;
-
- /**
- * Specifies a driver-managed buffer. It is the token returned from IDevice::allocate,
- * and is specific to the IDevice object.
- */
- uint32_t token;
- };
-
- /**
- * A collection of memory pools containing operand data for both the
- * inputs and the outputs to a model.
- */
- vec<MemoryPool> pools;
-};
+%insert Request
/**
* Optional time point of the steady clock (as from std::chrono::steady_clock)
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/BufferDesc.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/BufferDesc.aidl
index 71b7758..05cec76 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/BufferDesc.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/BufferDesc.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/BufferRole.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/BufferRole.aidl
index c2d636c..f18e92a 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/BufferRole.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/BufferRole.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Capabilities.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Capabilities.aidl
index 01cc753..30877c0 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Capabilities.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Capabilities.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/DataLocation.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/DataLocation.aidl
index e836dae..db49a38 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/DataLocation.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/DataLocation.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/DeviceBuffer.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/DeviceBuffer.aidl
index 7bc8aa7..7cdd6db 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/DeviceBuffer.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/DeviceBuffer.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/DeviceType.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/DeviceType.aidl
index 1abacc8..82fe8ae 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/DeviceType.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/DeviceType.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ErrorStatus.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ErrorStatus.aidl
index 873c584..57d5d6e 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ErrorStatus.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ErrorStatus.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ExecutionPreference.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ExecutionPreference.aidl
index c4badc0..4352d8f 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ExecutionPreference.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ExecutionPreference.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ExecutionResult.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ExecutionResult.aidl
index b99bb31..44e9922 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ExecutionResult.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ExecutionResult.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Extension.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Extension.aidl
index a7ae942..c47028d 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Extension.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Extension.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ExtensionNameAndPrefix.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ExtensionNameAndPrefix.aidl
index 4c25538..6c287fd 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ExtensionNameAndPrefix.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ExtensionNameAndPrefix.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ExtensionOperandTypeInformation.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ExtensionOperandTypeInformation.aidl
index b32b217..a3680aa 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ExtensionOperandTypeInformation.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/ExtensionOperandTypeInformation.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/FusedActivationFunc.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/FusedActivationFunc.aidl
index 2fee136..7e61bbb 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/FusedActivationFunc.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/FusedActivationFunc.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IBuffer.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IBuffer.aidl
index 2860692..f10e7e2 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IBuffer.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IBuffer.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IBurst.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IBurst.aidl
new file mode 100644
index 0000000..634f39e
--- /dev/null
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IBurst.aidl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.neuralnetworks;
+@VintfStability
+interface IBurst {
+ android.hardware.neuralnetworks.ExecutionResult executeSynchronously(in android.hardware.neuralnetworks.Request request, in long[] memoryIdentifierTokens, in boolean measureTiming, in long deadline, in long loopTimeoutDuration);
+ void releaseMemoryResource(in long memoryIdentifierToken);
+}
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IDevice.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IDevice.aidl
index 4c5fd2f..b328b29 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IDevice.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IDevice.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IFencedExecutionCallback.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IFencedExecutionCallback.aidl
index abe67b8..0bfb80a 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IFencedExecutionCallback.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IFencedExecutionCallback.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IPreparedModel.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IPreparedModel.aidl
index 1f7cbe0..52882cd 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IPreparedModel.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IPreparedModel.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
@@ -35,6 +36,7 @@
interface IPreparedModel {
android.hardware.neuralnetworks.ExecutionResult executeSynchronously(in android.hardware.neuralnetworks.Request request, in boolean measureTiming, in long deadline, in long loopTimeoutDuration);
android.hardware.neuralnetworks.FencedExecutionResult executeFenced(in android.hardware.neuralnetworks.Request request, in ParcelFileDescriptor[] waitFor, in boolean measureTiming, in long deadline, in long loopTimeoutDuration, in long duration);
+ android.hardware.neuralnetworks.IBurst configureExecutionBurst();
const long DEFAULT_LOOP_TIMEOUT_DURATION_NS = 2000000000;
const long MAXIMUM_LOOP_TIMEOUT_DURATION_NS = 15000000000;
}
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IPreparedModelCallback.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IPreparedModelCallback.aidl
index 8eaaab6..e0c763b 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IPreparedModelCallback.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IPreparedModelCallback.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IPreparedModelParcel.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IPreparedModelParcel.aidl
index 8388fda..dbedf12 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IPreparedModelParcel.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/IPreparedModelParcel.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Memory.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Memory.aidl
index 3b2f240..8207b25 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Memory.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Memory.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Model.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Model.aidl
index 9d12e58..30d8dda 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Model.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Model.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/NumberOfCacheFiles.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/NumberOfCacheFiles.aidl
index c1e87da..9314760 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/NumberOfCacheFiles.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/NumberOfCacheFiles.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Operand.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Operand.aidl
index bb78caa..5a9f4ff 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Operand.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Operand.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperandExtraParams.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperandExtraParams.aidl
index 3f6d93b..14792cf 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperandExtraParams.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperandExtraParams.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperandLifeTime.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperandLifeTime.aidl
index d581ced..40adfb1 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperandLifeTime.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperandLifeTime.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperandPerformance.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperandPerformance.aidl
index 87fd3a6..de93d8b 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperandPerformance.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperandPerformance.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperandType.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperandType.aidl
index 186c13d..9f2c759 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperandType.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperandType.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Operation.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Operation.aidl
index fec83a8..33fcd60 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Operation.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Operation.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperationType.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperationType.aidl
index ad42b02..de3b438 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperationType.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OperationType.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OutputShape.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OutputShape.aidl
index 09a43f7..f733505 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OutputShape.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/OutputShape.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/PerformanceInfo.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/PerformanceInfo.aidl
index 178946c..04910f5 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/PerformanceInfo.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/PerformanceInfo.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Priority.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Priority.aidl
index d9b77fa..8f35709 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Priority.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Priority.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Request.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Request.aidl
index 599b3f4..39ec7a9 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Request.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Request.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/RequestArgument.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/RequestArgument.aidl
index 91b9aa7..e3541c0 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/RequestArgument.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/RequestArgument.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/RequestMemoryPool.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/RequestMemoryPool.aidl
index 3813b51..312f581 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/RequestMemoryPool.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/RequestMemoryPool.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Subgraph.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Subgraph.aidl
index dec976f..b7d4451 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Subgraph.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Subgraph.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/SymmPerChannelQuantParams.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/SymmPerChannelQuantParams.aidl
index 66fdfe7..02d68f9 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/SymmPerChannelQuantParams.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/SymmPerChannelQuantParams.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Timing.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Timing.aidl
index d0de34a..9690e01 100644
--- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Timing.aidl
+++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/Timing.aidl
@@ -12,7 +12,8 @@
* 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.
- *////////////////////////////////////////////////////////////////////////////////
+ */
+///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
diff --git a/neuralnetworks/aidl/android/hardware/neuralnetworks/IBurst.aidl b/neuralnetworks/aidl/android/hardware/neuralnetworks/IBurst.aidl
new file mode 100644
index 0000000..85d2a03
--- /dev/null
+++ b/neuralnetworks/aidl/android/hardware/neuralnetworks/IBurst.aidl
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+package android.hardware.neuralnetworks;
+
+import android.hardware.neuralnetworks.ErrorStatus;
+import android.hardware.neuralnetworks.ExecutionResult;
+import android.hardware.neuralnetworks.Request;
+
+/**
+ * IBurst represents a burst execution object.
+ *
+ * Burst executions are a sequence of executions of the same prepared model that occur in rapid
+ * succession, such as frames of a camera capture or successive audio samples. A burst object is
+ * used to control a set of burst executions, and to preserve resources between executions, enabling
+ * executions to have lower overhead. Burst objects enable some optimizations:
+ * (1) A burst object is created before a sequence of executions, and freed when the sequence has
+ * ended. Because of this, the lifetime of the burst object hints to a driver how long it should
+ * remain in a high performance state.
+ * (2) A burst object can preserve resources between executions. For example, a driver can map a
+ * memory object on the first execution and cache the mapping in the burst object for reuse in
+ * subsequent executions. Any cached resource can be released when the burst object is destroyed
+ * or when the NNAPI runtime notifies the burst object that the resource is no longer required.
+ * (3) A burst object may be used for at most one execution at a time. This enables any transient
+ * execution resources such as intermediate tensors to be allocated once when the burst object
+ * is created and freed when the burst object is destroyed.
+ */
+@VintfStability
+interface IBurst {
+ /**
+ * Performs a synchronous execution on a burst object.
+ *
+ * The execution is performed synchronously with respect to the caller. executeSynchronously
+ * must verify the inputs to the function are correct, and the usages of memory pools allocated
+ * by IDevice::allocate are valid. If there is an error, executeSynchronously must immediately
+ * return a service specific exception with the appropriate ErrorStatus value. If the inputs to
+ * the function are valid and there is no error, executeSynchronously must perform the
+ * execution, and must not return until the execution is complete.
+ *
+ * The caller must not change the content of any data object referenced by 'request' (described
+ * by the {@link DataLocation} of a {@link RequestArgument}) until executeSynchronously returns.
+ * executeSynchronously must not change the content of any of the data objects corresponding to
+ * 'request' inputs.
+ *
+ * If the burst object was configured from a prepared model wherein all tensor operands have
+ * fully specified dimensions, and the inputs to the function are valid, and at execution time
+ * every operation's input operands have legal values, then the execution should complete
+ * successfully: there must be no failure unless the device itself is in a bad state.
+ *
+ * executeSynchronously may be called with an optional deadline. If the execution is not able to
+ * be completed before the provided deadline, the execution may be aborted, and either
+ * {@link ErrorStatus::MISSED_DEADLINE_TRANSIENT} or {@link
+ * ErrorStatus::MISSED_DEADLINE_PERSISTENT} may be returned. The error due to an abort must be
+ * sent the same way as other errors, described above.
+ *
+ * Only a single execution on a given burst object may be active at any time.
+ *
+ * @param request The input and output information on which the prepared model is to be
+ * executed.
+ * @param memoryIdentifierTokens A list of tokens where each token is a non-negative number
+ * that uniquely identifies a memory object. Each memory
+ * identifier token corresponds to an element of request.pools. A
+ * value of -1 indicates no identity.
+ * @param measure Specifies whether or not to measure duration of the execution. The duration
+ * runs from the time the driver sees the call to the executeSynchronously
+ * function to the time the driver returns from the function.
+ * @param deadline The time by which the execution is expected to complete. The time is measured
+ * in nanoseconds since epoch of the steady clock (as from
+ * std::chrono::steady_clock). If the execution cannot be finished by the
+ * deadline, the execution may be aborted. Passing -1 means the deadline is
+ * omitted. Other negative values are invalid.
+ * @param loopTimeoutDuration The maximum amount of time in nanoseconds that should be spent
+ * executing a {@link OperationType::WHILE} operation. If a loop
+ * condition model does not output false within this duration, the
+ * execution must be aborted. If -1 is provided, the maximum amount
+ * of time is {@link DEFAULT_LOOP_TIMEOUT_DURATION_NS}. Other
+ * negative values are invalid. When provided, the duration must not
+ * exceed {@link MAXIMUM_LOOP_TIMEOUT_DURATION_NS}.
+ * @return ExecutionResult parcelable, containing the status of the execution, output shapes and
+ * timing information.
+ * @throws ServiceSpecificException with one of the following ErrorStatus values:
+ * - DEVICE_UNAVAILABLE if driver is offline or busy
+ * - GENERAL_FAILURE if there is an unspecified error
+ * - INVALID_ARGUMENT if one of the input arguments is invalid
+ * - MISSED_DEADLINE_* if the execution is aborted because it cannot be completed by the
+ * deadline
+ * - RESOURCE_EXHAUSTED_* if the task was aborted by the driver
+ */
+ ExecutionResult executeSynchronously(in Request request, in long[] memoryIdentifierTokens,
+ in boolean measureTiming, in long deadline, in long loopTimeoutDuration);
+
+ /**
+ * releaseMemoryResource is used by the client to signal to the service that a memory buffer
+ * corresponding to a slot number is no longer needed by the client, and any cached resources
+ * associated with that memory object may be released.
+ *
+ * The identifier tokens are unique to the burst object.
+ *
+ * @param memoryIdentifierToken Value uniquely identifying a memory object that is no longer
+ * used.
+ * @throws ServiceSpecificException with one of the following ErrorStatus values:
+ * - DEVICE_UNAVAILABLE if driver is offline or busy
+ * - GENERAL_FAILURE if there is an unspecified error
+ * - INVALID_ARGUMENT if one of the input arguments is invalid
+ */
+ void releaseMemoryResource(in long memoryIdentifierToken);
+}
diff --git a/neuralnetworks/aidl/android/hardware/neuralnetworks/IPreparedModel.aidl b/neuralnetworks/aidl/android/hardware/neuralnetworks/IPreparedModel.aidl
index 0240e3c..2a9757b 100644
--- a/neuralnetworks/aidl/android/hardware/neuralnetworks/IPreparedModel.aidl
+++ b/neuralnetworks/aidl/android/hardware/neuralnetworks/IPreparedModel.aidl
@@ -20,6 +20,7 @@
import android.hardware.neuralnetworks.ErrorStatus;
import android.hardware.neuralnetworks.ExecutionResult;
import android.hardware.neuralnetworks.FencedExecutionResult;
+import android.hardware.neuralnetworks.IBurst;
import android.hardware.neuralnetworks.Request;
/**
@@ -166,4 +167,22 @@
FencedExecutionResult executeFenced(in Request request, in ParcelFileDescriptor[] waitFor,
in boolean measureTiming, in long deadline, in long loopTimeoutDuration,
in long duration);
+
+ /**
+ * Configure a Burst object used to execute multiple inferences on a prepared model in rapid
+ * succession.
+ *
+ * If the prepared model was prepared from a model wherein all tensor operands have fully
+ * specified dimensions, and a valid serialized Request is sent to the Burst for execution, and
+ * at execution time every operation's input operands have legal values, then the execution
+ * should complete successfully (ErrorStatus::NONE): There must be no failure unless the device
+ * itself is in a bad state.
+ *
+ * @return burst Execution burst controller object.
+ * @throws ServiceSpecificException with one of the following ErrorStatus values:
+ * - DEVICE_UNAVAILABLE if driver is offline or busy
+ * - GENERAL_FAILURE if there is an unspecified error
+ * - RESOURCE_EXHAUSTED_* if the task was aborted by the driver
+ */
+ IBurst configureExecutionBurst();
}
diff --git a/neuralnetworks/aidl/utils/test/MockPreparedModel.h b/neuralnetworks/aidl/utils/test/MockPreparedModel.h
index 545b491..36e0ec3 100644
--- a/neuralnetworks/aidl/utils/test/MockPreparedModel.h
+++ b/neuralnetworks/aidl/utils/test/MockPreparedModel.h
@@ -39,6 +39,8 @@
bool measureTiming, int64_t deadline, int64_t loopTimeoutDuration,
int64_t duration, FencedExecutionResult* fencedExecutionResult),
(override));
+ MOCK_METHOD(ndk::ScopedAStatus, configureExecutionBurst, (std::shared_ptr<IBurst> * burst),
+ (override));
};
inline std::shared_ptr<MockPreparedModel> MockPreparedModel::create() {
diff --git a/neuralnetworks/aidl/vts/functional/GeneratedTestHarness.cpp b/neuralnetworks/aidl/vts/functional/GeneratedTestHarness.cpp
index 7a042ed..2dd02dd 100644
--- a/neuralnetworks/aidl/vts/functional/GeneratedTestHarness.cpp
+++ b/neuralnetworks/aidl/vts/functional/GeneratedTestHarness.cpp
@@ -17,6 +17,7 @@
#include "GeneratedTestHarness.h"
#include <aidl/android/hardware/neuralnetworks/ErrorStatus.h>
+#include <aidl/android/hardware/neuralnetworks/RequestMemoryPool.h>
#include <android-base/logging.h>
#include <android/binder_auto_utils.h>
#include <android/sync.h>
@@ -582,6 +583,53 @@
}
break;
}
+ case Executor::BURST: {
+ SCOPED_TRACE("burst");
+
+ // create burst
+ std::shared_ptr<IBurst> burst;
+ auto ret = preparedModel->configureExecutionBurst(&burst);
+ ASSERT_TRUE(ret.isOk()) << ret.getDescription();
+ ASSERT_NE(nullptr, burst.get());
+
+ // associate a unique slot with each memory pool
+ int64_t currentSlot = 0;
+ std::vector<int64_t> slots;
+ slots.reserve(request.pools.size());
+ for (const auto& pool : request.pools) {
+ if (pool.getTag() == RequestMemoryPool::Tag::pool) {
+ slots.push_back(currentSlot++);
+ } else {
+ EXPECT_EQ(pool.getTag(), RequestMemoryPool::Tag::token);
+ slots.push_back(-1);
+ }
+ }
+
+ ExecutionResult executionResult;
+ // execute
+ ret = burst->executeSynchronously(request, slots, testConfig.measureTiming, kNoDeadline,
+ loopTimeoutDuration, &executionResult);
+ ASSERT_TRUE(ret.isOk() || ret.getExceptionCode() == EX_SERVICE_SPECIFIC)
+ << ret.getDescription();
+ if (ret.isOk()) {
+ executionStatus = executionResult.outputSufficientSize
+ ? ErrorStatus::NONE
+ : ErrorStatus::OUTPUT_INSUFFICIENT_SIZE;
+ outputShapes = std::move(executionResult.outputShapes);
+ timing = executionResult.timing;
+ } else {
+ executionStatus = static_cast<ErrorStatus>(ret.getServiceSpecificError());
+ }
+
+ // Mark each slot as unused after the execution. This is unnecessary because the burst
+ // is freed after this scope ends, but this is here to test the functionality.
+ for (int64_t slot : slots) {
+ ret = burst->releaseMemoryResource(slot);
+ ASSERT_TRUE(ret.isOk()) << ret.getDescription();
+ }
+
+ break;
+ }
case Executor::FENCED: {
SCOPED_TRACE("fenced");
ErrorStatus result = ErrorStatus::NONE;
@@ -727,19 +775,19 @@
case TestKind::GENERAL: {
outputTypesList = {OutputType::FULLY_SPECIFIED};
measureTimingList = {false, true};
- executorList = {Executor::SYNC};
+ executorList = {Executor::SYNC, Executor::BURST};
memoryTypeList = {MemoryType::ASHMEM};
} break;
case TestKind::DYNAMIC_SHAPE: {
outputTypesList = {OutputType::UNSPECIFIED, OutputType::INSUFFICIENT};
measureTimingList = {false, true};
- executorList = {Executor::SYNC, Executor::FENCED};
+ executorList = {Executor::SYNC, Executor::BURST, Executor::FENCED};
memoryTypeList = {MemoryType::ASHMEM};
} break;
case TestKind::MEMORY_DOMAIN: {
outputTypesList = {OutputType::FULLY_SPECIFIED};
measureTimingList = {false};
- executorList = {Executor::SYNC, Executor::FENCED};
+ executorList = {Executor::SYNC, Executor::BURST, Executor::FENCED};
memoryTypeList = {MemoryType::BLOB_AHWB, MemoryType::DEVICE};
} break;
case TestKind::FENCED_COMPUTE: {
@@ -755,7 +803,7 @@
case TestKind::INTINITE_LOOP_TIMEOUT: {
outputTypesList = {OutputType::MISSED_DEADLINE};
measureTimingList = {false, true};
- executorList = {Executor::SYNC, Executor::FENCED};
+ executorList = {Executor::SYNC, Executor::BURST, Executor::FENCED};
memoryTypeList = {MemoryType::ASHMEM};
} break;
}
@@ -779,7 +827,7 @@
const TestModel& coupledModel) {
const std::vector<OutputType> outputTypesList = {OutputType::FULLY_SPECIFIED};
const std::vector<bool> measureTimingList = {false, true};
- const std::vector<Executor> executorList = {Executor::SYNC, Executor::FENCED};
+ const std::vector<Executor> executorList = {Executor::SYNC, Executor::BURST, Executor::FENCED};
for (const OutputType outputType : outputTypesList) {
for (const bool measureTiming : measureTimingList) {
diff --git a/neuralnetworks/aidl/vts/functional/MemoryDomainTests.cpp b/neuralnetworks/aidl/vts/functional/MemoryDomainTests.cpp
index 57bc1ae..627c26a 100644
--- a/neuralnetworks/aidl/vts/functional/MemoryDomainTests.cpp
+++ b/neuralnetworks/aidl/vts/functional/MemoryDomainTests.cpp
@@ -203,6 +203,10 @@
return ndk::ScopedAStatus::fromServiceSpecificError(
static_cast<int32_t>(ErrorStatus::GENERAL_FAILURE));
}
+ ndk::ScopedAStatus configureExecutionBurst(std::shared_ptr<IBurst>*) override {
+ return ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(ErrorStatus::GENERAL_FAILURE));
+ }
};
template <typename... Args>
@@ -866,6 +870,9 @@
case Executor::SYNC:
EXPECT_EQ(executeSync(preparedModel, request), expectedStatus);
break;
+ case Executor::BURST:
+ EXPECT_EQ(executeBurst(preparedModel, request), expectedStatus);
+ break;
case Executor::FENCED:
EXPECT_EQ(executeFenced(preparedModel, request), expectedStatus);
break;
@@ -916,6 +923,35 @@
return executionStatus;
}
+ ErrorStatus executeBurst(const std::shared_ptr<IPreparedModel>& preparedModel,
+ const Request& request) {
+ // create burst
+ std::shared_ptr<IBurst> burst;
+ auto ret = preparedModel->configureExecutionBurst(&burst);
+ EXPECT_TRUE(ret.isOk()) << ret.getDescription();
+ EXPECT_NE(nullptr, burst.get());
+ if (!ret.isOk() || burst.get() == nullptr) {
+ return ErrorStatus::GENERAL_FAILURE;
+ }
+
+ // use -1 for all memory identifier tokens
+ const std::vector<int64_t> slots(request.pools.size(), -1);
+
+ ExecutionResult executionResult;
+ ret = burst->executeSynchronously(request, slots, false, kNoDeadline,
+ kOmittedTimeoutDuration, &executionResult);
+
+ if (!ret.isOk()) {
+ EXPECT_EQ(ret.getExceptionCode(), EX_SERVICE_SPECIFIC);
+ return static_cast<ErrorStatus>(ret.getServiceSpecificError());
+ }
+ const ErrorStatus executionStatus = executionResult.outputSufficientSize
+ ? ErrorStatus::NONE
+ : ErrorStatus::OUTPUT_INSUFFICIENT_SIZE;
+ EXPECT_EQ(executionResult.timing, kNoTiming);
+ return executionStatus;
+ }
+
const Executor kExecutor = std::get<Executor>(GetParam());
};
@@ -1159,7 +1195,7 @@
ErrorStatus::GENERAL_FAILURE);
}
-const auto kExecutorChoices = testing::Values(Executor::SYNC, Executor::FENCED);
+const auto kExecutorChoices = testing::Values(Executor::SYNC, Executor::BURST, Executor::FENCED);
std::string printMemoryDomainExecutionTest(
const testing::TestParamInfo<MemoryDomainExecutionTestParam>& info) {
diff --git a/neuralnetworks/aidl/vts/functional/QualityOfServiceTests.cpp b/neuralnetworks/aidl/vts/functional/QualityOfServiceTests.cpp
index 58db98f..9ace1a9 100644
--- a/neuralnetworks/aidl/vts/functional/QualityOfServiceTests.cpp
+++ b/neuralnetworks/aidl/vts/functional/QualityOfServiceTests.cpp
@@ -51,6 +51,10 @@
using Results = std::tuple<ErrorStatus, std::vector<OutputShape>, Timing>;
using MaybeResults = std::optional<Results>;
+using ExecutionFunction =
+ std::function<MaybeResults(const std::shared_ptr<IPreparedModel>& preparedModel,
+ const Request& request, int64_t deadline)>;
+
static int64_t makeDeadline(DeadlineBoundType deadlineBoundType) {
const auto getNanosecondsSinceEpoch = [](const auto& time) -> int64_t {
const auto timeSinceEpoch = time.time_since_epoch();
@@ -177,13 +181,53 @@
std::move(executionResult.outputShapes), executionResult.timing});
}
+static MaybeResults executeBurst(const std::shared_ptr<IPreparedModel>& preparedModel,
+ const Request& request, int64_t deadline) {
+ SCOPED_TRACE("burst");
+ const bool measure = false;
+
+ // create burst
+ std::shared_ptr<IBurst> burst;
+ auto ret = preparedModel->configureExecutionBurst(&burst);
+ EXPECT_TRUE(ret.isOk()) << ret.getDescription();
+ EXPECT_NE(nullptr, burst.get());
+ if (!ret.isOk() || burst.get() == nullptr) {
+ return std::nullopt;
+ }
+
+ // use -1 for all memory identifier tokens
+ const std::vector<int64_t> slots(request.pools.size(), -1);
+
+ // run execution
+ ExecutionResult executionResult;
+ ret = burst->executeSynchronously(request, slots, measure, deadline, kOmittedTimeoutDuration,
+ &executionResult);
+ EXPECT_TRUE(ret.isOk() || ret.getExceptionCode() == EX_SERVICE_SPECIFIC)
+ << ret.getDescription();
+ if (!ret.isOk()) {
+ if (ret.getExceptionCode() != EX_SERVICE_SPECIFIC) {
+ return std::nullopt;
+ }
+ return MaybeResults(
+ {static_cast<ErrorStatus>(ret.getServiceSpecificError()), {}, kNoTiming});
+ }
+
+ // return results
+ return MaybeResults({executionResult.outputSufficientSize
+ ? ErrorStatus::NONE
+ : ErrorStatus::OUTPUT_INSUFFICIENT_SIZE,
+ std::move(executionResult.outputShapes), executionResult.timing});
+}
+
void runExecutionTest(const std::shared_ptr<IPreparedModel>& preparedModel,
const TestModel& testModel, const Request& request,
- const ExecutionContext& context, DeadlineBoundType deadlineBound) {
+ const ExecutionContext& context, bool synchronous,
+ DeadlineBoundType deadlineBound) {
+ const ExecutionFunction execute = synchronous ? executeSynchronously : executeBurst;
const auto deadline = makeDeadline(deadlineBound);
// Perform execution and unpack results.
- const auto results = executeSynchronously(preparedModel, request, deadline);
+ const auto results = execute(preparedModel, request, deadline);
if (!results.has_value()) return;
const auto& [status, outputShapes, timing] = results.value();
@@ -235,8 +279,11 @@
void runExecutionTests(const std::shared_ptr<IPreparedModel>& preparedModel,
const TestModel& testModel, const Request& request,
const ExecutionContext& context) {
- for (auto deadlineBound : deadlineBounds) {
- runExecutionTest(preparedModel, testModel, request, context, deadlineBound);
+ for (bool synchronous : {false, true}) {
+ for (auto deadlineBound : deadlineBounds) {
+ runExecutionTest(preparedModel, testModel, request, context, synchronous,
+ deadlineBound);
+ }
}
}
diff --git a/neuralnetworks/aidl/vts/functional/ValidateRequest.cpp b/neuralnetworks/aidl/vts/functional/ValidateRequest.cpp
index 3be4c1b..29e2471 100644
--- a/neuralnetworks/aidl/vts/functional/ValidateRequest.cpp
+++ b/neuralnetworks/aidl/vts/functional/ValidateRequest.cpp
@@ -16,7 +16,9 @@
#define LOG_TAG "neuralnetworks_aidl_hal_test"
+#include <aidl/android/hardware/neuralnetworks/RequestMemoryPool.h>
#include <android/binder_auto_utils.h>
+#include <variant>
#include <chrono>
@@ -77,6 +79,35 @@
ASSERT_EQ(static_cast<ErrorStatus>(executeStatus.getServiceSpecificError()),
ErrorStatus::INVALID_ARGUMENT);
}
+
+ // burst
+ {
+ SCOPED_TRACE(message + " [burst]");
+
+ // create burst
+ std::shared_ptr<IBurst> burst;
+ auto ret = preparedModel->configureExecutionBurst(&burst);
+ ASSERT_TRUE(ret.isOk()) << ret.getDescription();
+ ASSERT_NE(nullptr, burst.get());
+
+ // use -1 for all memory identifier tokens
+ const std::vector<int64_t> slots(request.pools.size(), -1);
+
+ ExecutionResult executionResult;
+ const auto executeStatus = burst->executeSynchronously(
+ request, slots, measure, kNoDeadline, kOmittedTimeoutDuration, &executionResult);
+ ASSERT_FALSE(executeStatus.isOk());
+ ASSERT_EQ(executeStatus.getExceptionCode(), EX_SERVICE_SPECIFIC);
+ ASSERT_EQ(static_cast<ErrorStatus>(executeStatus.getServiceSpecificError()),
+ ErrorStatus::INVALID_ARGUMENT);
+ }
+}
+
+std::shared_ptr<IBurst> createBurst(const std::shared_ptr<IPreparedModel>& preparedModel) {
+ std::shared_ptr<IBurst> burst;
+ const auto ret = preparedModel->configureExecutionBurst(&burst);
+ if (!ret.isOk()) return nullptr;
+ return burst;
}
///////////////////////// REMOVE INPUT ////////////////////////////////////
@@ -110,6 +141,65 @@
removeOutputTest(preparedModel, request);
}
+void validateBurst(const std::shared_ptr<IPreparedModel>& preparedModel, const Request& request) {
+ // create burst
+ std::shared_ptr<IBurst> burst;
+ auto ret = preparedModel->configureExecutionBurst(&burst);
+ ASSERT_TRUE(ret.isOk()) << ret.getDescription();
+ ASSERT_NE(nullptr, burst.get());
+
+ const auto test = [&burst, &request](const std::vector<int64_t>& slots) {
+ ExecutionResult executionResult;
+ const auto executeStatus =
+ burst->executeSynchronously(request, slots, /*measure=*/false, kNoDeadline,
+ kOmittedTimeoutDuration, &executionResult);
+ ASSERT_FALSE(executeStatus.isOk());
+ ASSERT_EQ(executeStatus.getExceptionCode(), EX_SERVICE_SPECIFIC);
+ ASSERT_EQ(static_cast<ErrorStatus>(executeStatus.getServiceSpecificError()),
+ ErrorStatus::INVALID_ARGUMENT);
+ };
+
+ int64_t currentSlot = 0;
+ std::vector<int64_t> slots;
+ slots.reserve(request.pools.size());
+ for (const auto& pool : request.pools) {
+ if (pool.getTag() == RequestMemoryPool::Tag::pool) {
+ slots.push_back(currentSlot++);
+ } else {
+ slots.push_back(-1);
+ }
+ }
+
+ constexpr int64_t invalidSlot = -2;
+
+ // validate failure when invalid memory identifier token value
+ for (size_t i = 0; i < request.pools.size(); ++i) {
+ const int64_t oldSlotValue = slots[i];
+
+ slots[i] = invalidSlot;
+ test(slots);
+
+ slots[i] = oldSlotValue;
+ }
+
+ // validate failure when request.pools.size() != memoryIdentifierTokens.size()
+ if (request.pools.size() > 0) {
+ slots = std::vector<int64_t>(request.pools.size() - 1, -1);
+ test(slots);
+ }
+
+ // validate failure when request.pools.size() != memoryIdentifierTokens.size()
+ slots = std::vector<int64_t>(request.pools.size() + 1, -1);
+ test(slots);
+
+ // validate failure when invalid memory identifier token value
+ const auto freeStatus = burst->releaseMemoryResource(invalidSlot);
+ ASSERT_FALSE(freeStatus.isOk());
+ ASSERT_EQ(freeStatus.getExceptionCode(), EX_SERVICE_SPECIFIC);
+ ASSERT_EQ(static_cast<ErrorStatus>(freeStatus.getServiceSpecificError()),
+ ErrorStatus::INVALID_ARGUMENT);
+}
+
void validateRequestFailure(const std::shared_ptr<IPreparedModel>& preparedModel,
const Request& request) {
SCOPED_TRACE("Expecting request to fail [executeSynchronously]");
diff --git a/neuralnetworks/aidl/vts/functional/VtsHalNeuralnetworks.cpp b/neuralnetworks/aidl/vts/functional/VtsHalNeuralnetworks.cpp
index 2d91b8e..0c3a196 100644
--- a/neuralnetworks/aidl/vts/functional/VtsHalNeuralnetworks.cpp
+++ b/neuralnetworks/aidl/vts/functional/VtsHalNeuralnetworks.cpp
@@ -127,6 +127,8 @@
// Forward declaration from ValidateRequest.cpp
void validateRequest(const std::shared_ptr<IPreparedModel>& preparedModel, const Request& request);
// Forward declaration from ValidateRequest.cpp
+void validateBurst(const std::shared_ptr<IPreparedModel>& preparedModel, const Request& request);
+// Forward declaration from ValidateRequest.cpp
void validateRequestFailure(const std::shared_ptr<IPreparedModel>& preparedModel,
const Request& request);
@@ -140,6 +142,7 @@
if (preparedModel == nullptr) return;
validateRequest(preparedModel, request);
+ validateBurst(preparedModel, request);
// HIDL also had test that expected executeFenced to fail on received null fd (-1). This is not
// allowed in AIDL and will result in EX_TRANSACTION_FAILED.
}
@@ -178,8 +181,6 @@
std::string toString(Executor executor) {
switch (executor) {
- case Executor::ASYNC:
- return "ASYNC";
case Executor::SYNC:
return "SYNC";
case Executor::BURST:
diff --git a/neuralnetworks/aidl/vts/functional/VtsHalNeuralnetworks.h b/neuralnetworks/aidl/vts/functional/VtsHalNeuralnetworks.h
index 9b81ee1..4312d3a 100644
--- a/neuralnetworks/aidl/vts/functional/VtsHalNeuralnetworks.h
+++ b/neuralnetworks/aidl/vts/functional/VtsHalNeuralnetworks.h
@@ -52,7 +52,7 @@
std::shared_ptr<IPreparedModel>* preparedModel,
bool reportSkipping = true);
-enum class Executor { ASYNC, SYNC, BURST, FENCED };
+enum class Executor { SYNC, BURST, FENCED };
std::string toString(Executor executor);
diff --git a/soundtrigger/2.4/Android.bp b/soundtrigger/2.4/Android.bp
new file mode 100644
index 0000000..38c32df
--- /dev/null
+++ b/soundtrigger/2.4/Android.bp
@@ -0,0 +1,21 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+ name: "android.hardware.soundtrigger@2.4",
+ root: "android.hardware",
+ srcs: [
+ "ISoundTriggerHw.hal",
+ "ISoundTriggerHwCallback.hal",
+ "ISoundTriggerHwGlobalCallback.hal",
+ ],
+ interfaces: [
+ "android.hardware.audio.common@2.0",
+ "android.hardware.soundtrigger@2.0",
+ "android.hardware.soundtrigger@2.1",
+ "android.hardware.soundtrigger@2.2",
+ "android.hardware.soundtrigger@2.3",
+ "android.hidl.base@1.0",
+ "android.hidl.safe_union@1.0",
+ ],
+ gen_java: true,
+}
diff --git a/soundtrigger/2.4/ISoundTriggerHw.hal b/soundtrigger/2.4/ISoundTriggerHw.hal
new file mode 100644
index 0000000..fd39303
--- /dev/null
+++ b/soundtrigger/2.4/ISoundTriggerHw.hal
@@ -0,0 +1,190 @@
+/*
+ * Copyright 2021 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.
+ */
+
+package android.hardware.soundtrigger@2.4;
+
+import @2.0::SoundModelHandle;
+import @2.1::ISoundTriggerHw.SoundModel;
+import @2.1::ISoundTriggerHw.PhraseSoundModel;
+import @2.3::ISoundTriggerHw;
+import @2.3::RecognitionConfig;
+import ISoundTriggerHwCallback;
+import ISoundTriggerHwGlobalCallback;
+
+/**
+ * SoundTrigger HAL interface. Used for hardware recognition of hotwords
+ * and other sounds.
+ *
+ * Important notes about the threading model:
+ * ==========================================
+ * Both this interface and the corresponding callback interface use a synchronized calling
+ * convention. This model comes with some advantages, but also with some risks of deadlocks if the
+ * implementation does not handle this correctly. Please consider the following:
+ * - After stopRecognition() returns no more recognition events for that model may be sent. This
+ * implies that any queues holding such events must be flushed before the call returns and that
+ * may imply that callback from the HAL to the client are done while stopRecognition() is blocked.
+ * This is OK, and supported by the framework.
+ * - Similarly, the same relationship applies between unloadModel() and subsequent callbacks to
+ * modelUnloaded().
+ * - Other than these two cases, calls into the HAL *MAY NOT* block on callbacks from the HAL, or
+ * else deadlock conditions may result, which may be handled by rebooting of the HAL process and
+ * cause service outages.
+ *
+ * Similarly, it is expected that a single call to startRecognition() generates at most one event
+ * (the model automatically becomes stopped when the event occurs, until explicitly started again)
+ * and that after a modelUnloaded() event no more events would be sent regarding the model.
+ * Note that a getModelState() call may generate a recognition event, but this event DOES NOT modify
+ * the model state - the model remains started.
+ *
+ * The HAL is expected to correctly handle a stopRecognition() call even after it sent an event
+ * indicating that recognition is stopped and an unloadModel() call even after it sent an event
+ * indicating that it has been unloaded. This is required in order to prevent race conditions
+ * between these calls. This also implies that model handles should generally not be reused until
+ * explicitly unloaded. To avoid the rare possibility of running out of handles, the framework will
+ * call unloadModel() on models that have been preemptively unloaded by the HAL.
+ *
+ * Due to the asynchronous nature of recognition events and preemptive model unloading, the HAL must
+ * correctly handle requests that would have been valid before an event has been delivered, but
+ * became moot as result of the event. Namely:
+ * - stopRecognition() may be called on a model that has already delivered an event and became
+ * inactive as a result. The HAL must return a successful return code in this case.
+ * - Furthermore, if a model is preemptively unloaded after it triggers (typically, this would
+ * happen when it is first aborted and immediately preemptively unloaded), stopRecognition() may
+ * be called on it. The HAL must return a successful return code in this case.
+ * - startRecognition() may be called on a model that has been preemptively unloaded. In this case,
+ * the HAL must return -EBUSY to indicate that the operation is temporarily unsuccessful.
+ * - unloadSoundModel() may be called on a model that has been preemptively unloaded. The HAL must
+ * return a successful return code in this case.
+ *
+ * Important notes about resource constraints and concurrency
+ * =========================================================
+ * Up until this version, the framework would enforce concurrency constraints expressed by the
+ * Properties presented by the soundtrigger instance. These include constraints on the maximum
+ * amount of models that can be loaded at the same time and on running recognition while capturing
+ * from the microphone.
+ * This version changes the approach for how these constraints are modeled, both offering the HAL
+ * implementation more flexibility and simplifying the framework's job in enforcing these
+ * limitations. Note that there is no change for how the framework behaves with earlier versions,
+ * everything described below only applies to this version and onward.
+ * The way this is achieved is as following:
+ * - The framework will no longer enforce constraints on concurrent loading of models, as expressed
+ * in the Properties.maxSoundModels field (this property is merely a hint at this point and may be
+ * deprecated in the future.
+ * - The framework will no longer enforce constraints on concurrency of audio recording and
+ * soundtrigger operation, as expressed in the Properties.concurrentCapture field (this property
+ * is merely a hint at this point and may be deprecated in the future).
+ * - The framework will no longer enforce constraints on concurrent loading of models, as expressed
+ * in the Properties (these properties are merely hints at this point and may be deprecated in the
+ * future.
+ * - The HAL implementation is free to reject starting of any model at any time by having the
+ * respective start*() method return -EBUSY.
+ * - The HAL implementation is free to reject loading of any model at any time by having the
+ * respective load*() method return -EBUSY.
+ * - The HAL implementation is free to preemptively stop a previously started model at its own
+ * discretion (for example, if a higher priority use-case which cannot coexist with detection
+ * has been requested). The HAL must notify the framework of the preemption by sending a
+ * recognition event with an `ABORT` status. The implementation must NOT attempt to restart the
+ * recognition automatically when conditions change.
+ * - The HAL implementation is free to preemptively unload a previously loaded model at its own
+ * discretion (for example, if a higher-priority model is being loaded and the two cannot
+ * coexist). When doing so, it must first abort the detection if active (as per above) and then
+ * notify the framework of the unload using the newly added modelUnloaded callback.
+ * - When conditions change, such that a model that couldn't previously load or start or that had
+ * previously been preemptively stopped or unloaded, the HAL must notify the framework via the
+ * newly added tryAgain() callback. This callback is not a guarantee that any operation would now
+ * succeed, but merely a hint that retrying something that had previously failed, now MAY succeed.
+ * Until this callback arrives, the framework may assume that any operation that had previously
+ * failed or aborted would still fail if retried, so the implementation should not forget to
+ * deliver it. There are no guarantees regarding how the framework may respond to this event and
+ * the order in which it may choose to reload/restart its models. Typically, as result of this
+ * event the framework will make a single attempt per model to bring this model to its desired
+ * state (loaded, started).
+ */
+interface ISoundTriggerHw extends @2.3::ISoundTriggerHw {
+ /**
+ * This will get called at most once per every attachment to the service.
+ *
+ * All events not tied to a specific model should go through this callback.
+ */
+ registerGlobalCallback(ISoundTriggerHwGlobalCallback callback);
+
+ /**
+ * Load a sound model. Once loaded, recognition of this model can be
+ * started and stopped.
+ * The implementation returns a unique handle used by other functions
+ * (unloadSoundModel(), startRecognition*(), etc...
+ *
+ * Must have the exact same semantics as loadSoundModel from ISoundTriggerHw@2.3 except that the
+ * return values have changed and that there is no cookie provided (the implementation may pass
+ * any value to the callback, as it is ignored).
+ *
+ * @param soundModel A SoundModel structure describing the sound model
+ * to load.
+ * @param callback The callback interface on which the soundModelCallback*()
+ * method must be called upon completion and modelUnloaded() upon preempted unload.
+ * @return retval Operation completion status: 0 in case of success,
+ * -EBUSY in case the operation is temporarily unavailable (but possible in general).
+ * @return modelHandle A unique handle assigned by the HAL for use by the
+ * framework when controlling activity for this sound model.
+ */
+ loadSoundModel_2_4(SoundModel soundModel, ISoundTriggerHwCallback callback)
+ generates (int32_t retval, SoundModelHandle modelHandle);
+
+ /**
+ * Load a key phrase sound model. Once loaded, recognition of this model can
+ * be started and stopped. Only one active recognition per model at a time.
+ * The SoundTrigger service must handle concurrent recognition requests by
+ * different users/applications on the same model.
+ * The implementation returns a unique handle used by other functions
+ * (unloadSoundModel(), startRecognition*(), etc...
+ *
+ * Must have the exact same semantics as loadPhraseSoundModel from ISoundTriggerHw@2.3 except
+ * that the return values have changed and that there is no cookie provided (the implementation
+ * may pass any value to the callback, as it is ignored).
+ *
+ * @param soundModel A PhraseSoundModel structure describing the sound model
+ * to load.
+ * @param callback The callback interface on which the soundModelCallback*()
+ * method must be called upon completion and modelUnloaded() upon preempted unload.
+ * @return retval Operation completion status: 0 in case of success,
+ * -EBUSY in case the operation is temporarily unavailable (but possible in general).
+ * @return modelHandle A unique handle assigned by the HAL for use by the
+ * framework when controlling activity for this sound model.
+ */
+ loadPhraseSoundModel_2_4(PhraseSoundModel soundModel, ISoundTriggerHwCallback callback)
+ generates (int32_t retval, SoundModelHandle modelHandle);
+
+ /**
+ * Start recognition on a given model. Only one recognition active
+ * at a time per model. Once recognition succeeds or fails, the callback
+ * associated with the model handle is called.
+ *
+ * Must have the exact same semantics as startRecognition from ISoundTriggerHw@2.3 except that
+ * there are different expectations of the return value and that there is no cookie provided
+ * (the implementation may pass any value to the callback, as it is ignored).
+ *
+ * @param modelHandle the handle of the sound model to use for recognition
+ * @param config A RecognitionConfig structure containing attributes of the
+ * recognition to perform
+ * @param callback The callback interface on which the recognitionCallback()
+ * method must be called upon recognition.
+ * @return retval Operation completion status: 0 in case of success,
+ * -EBUSY in case the operation is temporarily unavailable (but possible in general), or in
+ * case model has been preemtively unloaded.
+ */
+ startRecognition_2_4(SoundModelHandle modelHandle, RecognitionConfig config)
+ generates (int32_t retval);
+};
diff --git a/soundtrigger/2.4/ISoundTriggerHwCallback.hal b/soundtrigger/2.4/ISoundTriggerHwCallback.hal
new file mode 100644
index 0000000..594deb0
--- /dev/null
+++ b/soundtrigger/2.4/ISoundTriggerHwCallback.hal
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2021 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.
+ */
+
+package android.hardware.soundtrigger@2.4;
+
+import @2.0::SoundModelHandle;
+import @2.1::ISoundTriggerHwCallback;
+
+/**
+ * SoundTrigger HAL per-model Callback interface.
+ */
+interface ISoundTriggerHwCallback extends @2.1::ISoundTriggerHwCallback {
+ /**
+ * Callback method called by the HAL when a model has been unloaded at the HAL implementation's
+ * discretion. Only a stopped model may be unloaded.
+ * This event is NOT sent as part of an unload sequence initiated by the client.
+ *
+ * @param model The model handle.
+ */
+ modelUnloaded(SoundModelHandle model);
+};
diff --git a/soundtrigger/2.4/ISoundTriggerHwGlobalCallback.hal b/soundtrigger/2.4/ISoundTriggerHwGlobalCallback.hal
new file mode 100644
index 0000000..2f1a977
--- /dev/null
+++ b/soundtrigger/2.4/ISoundTriggerHwGlobalCallback.hal
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2021 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.
+ */
+
+package android.hardware.soundtrigger@2.4;
+
+/**
+ * SoundTrigger HAL callback interface for events not associated with a particular model.
+ */
+interface ISoundTriggerHwGlobalCallback {
+ /**
+ * Callback method called by the HAL whenever internal conditions have been made available, such
+ * that a call that would previously have failed with an -EBUSY status may now succeed.
+ * There is no guarantee that any call would succeed following this event. It is merely a hint
+ * to the client that it may retry.
+ * Conversely, any call that have failed previously with -EBUSY is guaranteed to fail again if
+ * retried, until this callback is delivered.
+ */
+ onResourcesAvailable();
+};
diff --git a/soundtrigger/2.4/cli/Android.bp b/soundtrigger/2.4/cli/Android.bp
new file mode 100644
index 0000000..7647967
--- /dev/null
+++ b/soundtrigger/2.4/cli/Android.bp
@@ -0,0 +1,8 @@
+java_binary {
+ name: "sthal_cli_2.4",
+ wrapper: "sthal_cli_2.4",
+ srcs: ["java/**/*.java"],
+ static_libs: [
+ "android.hardware.soundtrigger-V2.4-java",
+ ],
+}
diff --git a/soundtrigger/2.4/cli/OWNERS b/soundtrigger/2.4/cli/OWNERS
new file mode 100644
index 0000000..e21b66e
--- /dev/null
+++ b/soundtrigger/2.4/cli/OWNERS
@@ -0,0 +1 @@
+include /media/java/android/media/soundtrigger_middleware/OWNERS
diff --git a/soundtrigger/2.4/cli/java/android/hardware/soundtrigger/V2_4/cli/SthalCli.java b/soundtrigger/2.4/cli/java/android/hardware/soundtrigger/V2_4/cli/SthalCli.java
new file mode 100644
index 0000000..e6870aa
--- /dev/null
+++ b/soundtrigger/2.4/cli/java/android/hardware/soundtrigger/V2_4/cli/SthalCli.java
@@ -0,0 +1,401 @@
+/*
+ * Copyright 2021 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.
+ */
+package android.hardware.soundtrigger.V2_4.cli;
+
+import android.hardware.soundtrigger.V2_0.PhraseRecognitionExtra;
+import android.hardware.soundtrigger.V2_0.RecognitionMode;
+import android.hardware.soundtrigger.V2_0.SoundModelType;
+import android.hardware.soundtrigger.V2_3.OptionalModelParameterRange;
+import android.hardware.soundtrigger.V2_4.ISoundTriggerHw;
+import android.hardware.soundtrigger.V2_4.ISoundTriggerHwCallback;
+import android.hardware.soundtrigger.V2_4.ISoundTriggerHwGlobalCallback;
+import android.os.HidlMemoryUtil;
+import android.os.HwBinder;
+import android.os.RemoteException;
+import android.os.SystemProperties;
+
+import java.util.Scanner;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * This is a quick-and-dirty sound trigger HAL console mock.
+ *
+ * It would only work on userdebug builds.
+ *
+ * When this app is started, it will initially:
+ * - Register a ISoundTriggerHw HAL with an instance name "mock".
+ * - Set a sysprop that tells SoundTriggerMiddlewareService to try to connect to the mock instance
+ * rather than the default one.
+ * - Reboot the real (default) HAL.
+ *
+ * In response to that, SoundTriggerMiddlewareService is going to connect to the mock HAL and resume
+ * normal operation.
+ *
+ * Our mock HAL will print to stdout every call it receives as well as expose a basic set of
+ * operations for sending event callbacks to the client. This allows us to simulate the frameworks
+ * behavior in response to different HAL behaviors.
+ */
+public class SthalCli {
+ private static SoundTriggerImpl mService;
+ private static final Scanner scanner = new Scanner(System.in);
+
+ public static void main(String[] args) {
+ try {
+ System.out.println("Registering mock STHAL");
+ HwBinder.setTrebleTestingOverride(true);
+ mService = new SoundTriggerImpl();
+ mService.registerAsService("mock");
+
+ System.out.println("Rebooting STHAL");
+ SystemProperties.set("debug.soundtrigger_middleware.use_mock_hal", "true");
+ SystemProperties.set("sys.audio.restart.hal", "1");
+
+ while (processCommand()) ;
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ cleanup();
+ }
+ }
+
+ private static void cleanup() {
+ System.out.println("Cleaning up.");
+ SystemProperties.set("debug.soundtrigger_middleware.use_mock_hal", "false");
+ HwBinder.setTrebleTestingOverride(false);
+ }
+
+ private static boolean processCommand() {
+ String line = scanner.nextLine();
+ String[] tokens = line.split("\\s+");
+ if (tokens.length < 1) {
+ return false;
+ }
+ switch (tokens[0]) {
+ case "q":
+ return false;
+
+ case "a":
+ mService.sendOnResourcesAvailable();
+ return true;
+
+ case "u":
+ mService.sendModelUnloaded(Integer.parseInt(tokens[1]));
+ return true;
+
+ case "r":
+ mService.sendRecognitionEvent(Integer.parseInt(tokens[1]),
+ Integer.parseInt(tokens[2]));
+ return true;
+
+ case "p":
+ mService.sendPhraseRecognitionEvent(Integer.parseInt(tokens[1]),
+ Integer.parseInt(tokens[2]));
+ return true;
+
+ case "d":
+ mService.dumpModels();
+ return true;
+
+ case "h":
+ System.out.print("Available commands:\n" + "h - help\n" + "q - quit\n"
+ + "a - send onResourcesAvailable event\n"
+ + "u <model> - send modelUnloaded event\n"
+ + "r <model> <status> - send recognitionEvent\n"
+ + "p <model> <status> - send phraseRecognitionEvent\n"
+ + "d - dump models\n");
+
+ default:
+ return true;
+ }
+ }
+
+ private static class SoundTriggerImpl extends ISoundTriggerHw.Stub {
+ static class Model {
+ final ISoundTriggerHwCallback callback;
+ final SoundModel model;
+ final PhraseSoundModel phraseModel;
+ public android.hardware.soundtrigger.V2_3.RecognitionConfig config = null;
+
+ Model(ISoundTriggerHwCallback callback, SoundModel model) {
+ this.callback = callback;
+ this.model = model;
+ this.phraseModel = null;
+ }
+
+ Model(ISoundTriggerHwCallback callback, PhraseSoundModel model) {
+ this.callback = callback;
+ this.model = null;
+ this.phraseModel = model;
+ }
+ }
+
+ private ISoundTriggerHwGlobalCallback mGlobalCallback;
+ private final ConcurrentMap<Integer, Model> mLoadedModels = new ConcurrentHashMap<>();
+ private int mHandleCounter = 1;
+
+ public void dumpModels() {
+ mLoadedModels.forEach((handle, model) -> {
+ System.out.println("+++ Model " + handle);
+ System.out.println(" config = " + model.config);
+ android.hardware.soundtrigger.V2_3.RecognitionConfig recognitionConfig =
+ model.config;
+ if (recognitionConfig != null) {
+ System.out.println(" ACTIVE recognitionConfig = " + recognitionConfig);
+ } else {
+ System.out.println(" INACTIVE");
+ }
+ });
+ }
+
+ public void sendOnResourcesAvailable() {
+ if (mGlobalCallback != null) {
+ try {
+ mGlobalCallback.onResourcesAvailable();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void sendRecognitionEvent(int modelHandle, int status) {
+ Model model = mLoadedModels.get(modelHandle);
+ if (model != null && model.config != null) {
+ android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback.RecognitionEvent event =
+ new android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback.RecognitionEvent();
+ event.header.model = modelHandle;
+ event.header.type = SoundModelType.GENERIC;
+ event.header.status = status;
+ event.header.captureSession = model.config.base.header.captureHandle;
+ event.header.captureAvailable = true;
+ event.header.audioConfig.channelMask = 16;
+ event.header.audioConfig.format = 1;
+ event.header.audioConfig.sampleRateHz = 16000;
+ event.data = HidlMemoryUtil.byteArrayToHidlMemory(new byte[0]);
+ try {
+ model.callback.recognitionCallback_2_1(event, 0);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ model.config = null;
+ }
+ }
+
+ public void sendPhraseRecognitionEvent(int modelHandle, int status) {
+ Model model = mLoadedModels.get(modelHandle);
+ if (model != null && model.config != null) {
+ android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback.PhraseRecognitionEvent
+ event =
+ new android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback.PhraseRecognitionEvent();
+ event.common.header.model = modelHandle;
+ event.common.header.type = SoundModelType.KEYPHRASE;
+ event.common.header.status = status;
+ event.common.header.captureSession = model.config.base.header.captureHandle;
+ event.common.header.captureAvailable = true;
+ event.common.header.audioConfig.channelMask = 16;
+ event.common.header.audioConfig.format = 1;
+ event.common.header.audioConfig.sampleRateHz = 16000;
+ event.common.data = HidlMemoryUtil.byteArrayToHidlMemory(new byte[0]);
+ if (!model.phraseModel.phrases.isEmpty()) {
+ PhraseRecognitionExtra extra = new PhraseRecognitionExtra();
+ extra.id = model.phraseModel.phrases.get(0).id;
+ extra.confidenceLevel = 100;
+ extra.recognitionModes = model.phraseModel.phrases.get(0).recognitionModes;
+ event.phraseExtras.add(extra);
+ }
+ try {
+ model.callback.phraseRecognitionCallback_2_1(event, 0);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ model.config = null;
+ }
+ }
+
+ public void sendModelUnloaded(int modelHandle) {
+ Model model = mLoadedModels.remove(modelHandle);
+ if (model != null) {
+ try {
+ model.callback.modelUnloaded(modelHandle);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ public void registerGlobalCallback(ISoundTriggerHwGlobalCallback callback) {
+ System.out.println("registerGlobalCallback()");
+ mGlobalCallback = callback;
+ }
+
+ @Override
+ public void loadSoundModel_2_4(SoundModel soundModel, ISoundTriggerHwCallback callback,
+ loadSoundModel_2_4Callback _hidl_cb) {
+ int handle = mHandleCounter++;
+ System.out.printf("loadSoundModel_2_4(soundModel=%s) -> %d%n", soundModel, handle);
+ mLoadedModels.put(handle, new Model(callback, soundModel));
+ _hidl_cb.onValues(0, handle);
+ }
+
+ @Override
+ public void loadPhraseSoundModel_2_4(PhraseSoundModel soundModel,
+ ISoundTriggerHwCallback callback, loadPhraseSoundModel_2_4Callback _hidl_cb) {
+ int handle = mHandleCounter++;
+ System.out.printf("loadPhraseSoundModel_2_4(soundModel=%s) -> %d%n", soundModel,
+ handle);
+ mLoadedModels.put(handle, new Model(callback, soundModel));
+ _hidl_cb.onValues(0, handle);
+ }
+
+ @Override
+ public int startRecognition_2_4(int modelHandle,
+ android.hardware.soundtrigger.V2_3.RecognitionConfig config) {
+ System.out.printf("startRecognition_2_4(modelHandle=%d)%n", modelHandle);
+ Model model = mLoadedModels.get(modelHandle);
+ if (model != null) {
+ model.config = config;
+ }
+ return 0;
+ }
+
+ @Override
+ public void getProperties_2_3(getProperties_2_3Callback _hidl_cb) {
+ System.out.println("getProperties_2_3()");
+ android.hardware.soundtrigger.V2_3.Properties properties =
+ new android.hardware.soundtrigger.V2_3.Properties();
+ properties.base.implementor = "Android";
+ properties.base.description = "Mock STHAL";
+ properties.base.maxSoundModels = 2;
+ properties.base.maxKeyPhrases = 1;
+ properties.base.recognitionModes =
+ RecognitionMode.VOICE_TRIGGER | RecognitionMode.GENERIC_TRIGGER;
+ _hidl_cb.onValues(0, properties);
+ }
+
+ @Override
+ public void queryParameter(int modelHandle, int modelParam,
+ queryParameterCallback _hidl_cb) {
+ _hidl_cb.onValues(0, new OptionalModelParameterRange());
+ }
+
+ @Override
+ public int getModelState(int modelHandle) {
+ System.out.printf("getModelState(modelHandle=%d)%n", modelHandle);
+ return 0;
+ }
+
+ @Override
+ public int unloadSoundModel(int modelHandle) {
+ System.out.printf("unloadSoundModel(modelHandle=%d)%n", modelHandle);
+ return 0;
+ }
+
+ @Override
+ public int stopRecognition(int modelHandle) {
+ System.out.printf("stopRecognition(modelHandle=%d)%n", modelHandle);
+ Model model = mLoadedModels.get(modelHandle);
+ if (model != null) {
+ model.config = null;
+ }
+ return 0;
+ }
+
+ @Override
+ public void debug(android.os.NativeHandle fd, java.util.ArrayList<String> options) {
+ if (!options.isEmpty()) {
+ switch (options.get(0)) {
+ case "reboot":
+ System.out.println("Received a reboot request. Exiting.");
+ cleanup();
+ System.exit(1);
+ }
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ // Everything below is not implemented and not expected to be called.
+
+ @Override
+ public int startRecognition_2_3(int modelHandle,
+ android.hardware.soundtrigger.V2_3.RecognitionConfig config) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int setParameter(int modelHandle, int modelParam, int value) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void getParameter(int modelHandle, int modelParam, getParameterCallback _hidl_cb) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void loadSoundModel_2_1(SoundModel soundModel,
+ android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback callback, int cookie,
+ loadSoundModel_2_1Callback _hidl_cb) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void loadPhraseSoundModel_2_1(PhraseSoundModel soundModel,
+ android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback callback, int cookie,
+ loadPhraseSoundModel_2_1Callback _hidl_cb) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int startRecognition_2_1(int modelHandle, RecognitionConfig config,
+ android.hardware.soundtrigger.V2_1.ISoundTriggerHwCallback callback, int cookie) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void getProperties(getPropertiesCallback _hidl_cb) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void loadSoundModel(
+ android.hardware.soundtrigger.V2_0.ISoundTriggerHw.SoundModel soundModel,
+ android.hardware.soundtrigger.V2_0.ISoundTriggerHwCallback callback, int cookie,
+ loadSoundModelCallback _hidl_cb) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void loadPhraseSoundModel(
+ android.hardware.soundtrigger.V2_0.ISoundTriggerHw.PhraseSoundModel soundModel,
+ android.hardware.soundtrigger.V2_0.ISoundTriggerHwCallback callback, int cookie,
+ loadPhraseSoundModelCallback _hidl_cb) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int startRecognition(int modelHandle,
+ android.hardware.soundtrigger.V2_0.ISoundTriggerHw.RecognitionConfig config,
+ android.hardware.soundtrigger.V2_0.ISoundTriggerHwCallback callback, int cookie) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int stopAllRecognitions() {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/soundtrigger/2.4/cli/sthal_cli_2.4 b/soundtrigger/2.4/cli/sthal_cli_2.4
new file mode 100644
index 0000000..0801464
--- /dev/null
+++ b/soundtrigger/2.4/cli/sthal_cli_2.4
@@ -0,0 +1,7 @@
+#!/system/bin/sh
+# Script to start "sthal_cli_2.4" on the device
+#
+base=/system
+export CLASSPATH=$base/framework/sthal_cli_2.4.jar
+exec app_process $base/bin android.hardware.soundtrigger.V2_4.cli.SthalCli "$@"
+
diff --git a/soundtrigger/2.4/vts/functional/Android.bp b/soundtrigger/2.4/vts/functional/Android.bp
new file mode 100644
index 0000000..0e69bf4
--- /dev/null
+++ b/soundtrigger/2.4/vts/functional/Android.bp
@@ -0,0 +1,32 @@
+//
+// Copyright (C) 2021 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.
+//
+
+cc_test {
+ name: "VtsHalSoundtriggerV2_4TargetTest",
+ defaults: ["VtsHalTargetTestDefaults"],
+ srcs: ["VtsHalSoundtriggerV2_4TargetTest.cpp"],
+ static_libs: [
+ "android.hardware.soundtrigger@2.0",
+ "android.hardware.soundtrigger@2.1",
+ "android.hardware.soundtrigger@2.2",
+ "android.hardware.soundtrigger@2.3",
+ "android.hardware.soundtrigger@2.4",
+ ],
+ test_suites: [
+ "general-tests",
+ "vts",
+ ],
+}
diff --git a/soundtrigger/2.4/vts/functional/VtsHalSoundtriggerV2_4TargetTest.cpp b/soundtrigger/2.4/vts/functional/VtsHalSoundtriggerV2_4TargetTest.cpp
new file mode 100644
index 0000000..13d7005
--- /dev/null
+++ b/soundtrigger/2.4/vts/functional/VtsHalSoundtriggerV2_4TargetTest.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#define LOG_TAG "SoundTriggerHidlHalTest"
+
+#include <android-base/logging.h>
+#include <android/hardware/audio/common/2.0/types.h>
+#include <android/hardware/soundtrigger/2.4/ISoundTriggerHwGlobalCallback.h>
+#include <android/hardware/soundtrigger/2.4/ISoundTriggerHw.h>
+#include <gtest/gtest.h>
+#include <hidl/GtestPrinter.h>
+#include <hidl/ServiceManagement.h>
+
+using ::android::sp;
+using ::android::hardware::Return;
+using ::android::hardware::Status;
+using ::android::hardware::soundtrigger::V2_4::ISoundTriggerHw;
+using ::android::hardware::soundtrigger::V2_4::ISoundTriggerHwGlobalCallback;
+
+/**
+ * Test class holding the instance of the SoundTriggerHW service to test.
+ * The passed parameter is the registered name of the implementing service
+ * supplied by INSTANTIATE_TEST_SUITE_P() call.
+ */
+class SoundTriggerHidlTest : public testing::TestWithParam<std::string> {
+public:
+ void SetUp() override {
+ mSoundtrigger = ISoundTriggerHw::getService(GetParam());
+
+ ASSERT_NE(mSoundtrigger, nullptr);
+ LOG(INFO) << "Test is remote " << mSoundtrigger->isRemote();
+ }
+
+protected:
+ sp<ISoundTriggerHw> mSoundtrigger;
+};
+
+/**
+ * Empty test is in place to ensure service is initialized.
+ * Due to the nature of SoundTrigger HAL providing an interface for
+ * proprietary or vendor specific implementations, limited testing on
+ * individual APIs is possible.
+ */
+TEST_P(SoundTriggerHidlTest, ServiceIsInstantiated) {}
+
+class GlobalCallback : public ISoundTriggerHwGlobalCallback {
+ Return<void> onResourcesAvailable() override {
+ return Status::ok();
+ }
+};
+
+/**
+ * Test ISoundTriggerHw::registerGlobalCallback method
+ *
+ * Verifies that:
+ * - the implementation implements the method
+ * - the method returns no error
+ */
+TEST_P(SoundTriggerHidlTest, RegisterGlobalCallback) {
+ Return<void> hidlReturn;
+ sp<ISoundTriggerHwGlobalCallback> callback = new GlobalCallback();
+ hidlReturn = mSoundtrigger->registerGlobalCallback(callback);
+ EXPECT_TRUE(hidlReturn.isOk());
+}
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(SoundTriggerHidlTest);
+
+INSTANTIATE_TEST_SUITE_P(
+ PerInstance, SoundTriggerHidlTest,
+ testing::ValuesIn(android::hardware::getAllHalInstanceNames(ISoundTriggerHw::descriptor)),
+ android::hardware::PrintInstanceNameToString);