aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-01-09 00:09:10 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-01-09 00:09:10 +0000
commit36e3566c79fc2786b62729f4ee2d82242900a526 (patch)
treeb048acdd4863efa9e78b306708c4c3f32171b16c
parent3424c9f946b5977305f97780b7404e922b522252 (diff)
parentf8fd15488570b5f49d9449458a8c2be899af157d (diff)
downloadgeneric-android11-qpr3-release.tar.gz
Change-Id: I5920103aa9f8e3d618b874aa93ccf55cff130dfb
-rw-r--r--libnos/BUILD19
-rw-r--r--libnos/NuggetClient.cpp3
-rw-r--r--libnos/NuggetClientDebuggable.cpp74
-rw-r--r--libnos/include/nos/NuggetClient.h2
-rw-r--r--libnos/include/nos/NuggetClientDebuggable.h58
-rw-r--r--nugget/proto/nugget/app/identity/identity.options2
6 files changed, 154 insertions, 4 deletions
diff --git a/libnos/BUILD b/libnos/BUILD
index c2c53c4..a03ec8f 100644
--- a/libnos/BUILD
+++ b/libnos/BUILD
@@ -20,3 +20,22 @@ cc_library(
"//host/generic/libnos_transport",
],
)
+
+cc_library(
+ name = "libnos_debuggable",
+ srcs = [
+ "NuggetClientDebuggable.cpp",
+ ],
+ hdrs = [
+ "include/nos/NuggetClient.h",
+ "include/nos/NuggetClientDebuggable.h",
+ ],
+ includes = [
+ "include",
+ ],
+ visibility = ["//visibility:public"],
+ deps = [
+ "//host/generic:nos_headers",
+ "//host/generic/libnos",
+ ],
+)
diff --git a/libnos/NuggetClient.cpp b/libnos/NuggetClient.cpp
index 3f4682d..72a9e9f 100644
--- a/libnos/NuggetClient.cpp
+++ b/libnos/NuggetClient.cpp
@@ -15,11 +15,8 @@
*/
#include <nos/NuggetClient.h>
-
#include <limits>
-
#include <nos/transport.h>
-
#include <application.h>
namespace nos {
diff --git a/libnos/NuggetClientDebuggable.cpp b/libnos/NuggetClientDebuggable.cpp
new file mode 100644
index 0000000..5ee86e9
--- /dev/null
+++ b/libnos/NuggetClientDebuggable.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2020 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 <nos/NuggetClientDebuggable.h>
+#include <limits>
+#include <nos/transport.h>
+#include <application.h>
+
+namespace nos {
+
+NuggetClientDebuggable::NuggetClientDebuggable(request_cb_t req_fn, response_cb_t resp_fn)
+ : request_cb_(req_fn), response_cb_(resp_fn) {}
+
+NuggetClientDebuggable::NuggetClientDebuggable(const std::string& device_name,
+ request_cb_t req_fn, response_cb_t resp_fn)
+ : NuggetClient(device_name), request_cb_(req_fn), response_cb_(resp_fn) {}
+
+NuggetClientDebuggable::NuggetClientDebuggable(const char* device_name,
+ request_cb_t req_fn, response_cb_t resp_fn)
+ : NuggetClient(device_name), request_cb_(req_fn), response_cb_(resp_fn) {}
+
+uint32_t NuggetClientDebuggable::CallApp(uint32_t appId, uint16_t arg,
+ const std::vector<uint8_t>& request,
+ std::vector<uint8_t>* response) {
+ if (!open_) {
+ return APP_ERROR_IO;
+ }
+
+ if (request.size() > std::numeric_limits<uint32_t>::max()) {
+ return APP_ERROR_TOO_MUCH;
+ }
+
+ const uint32_t requestSize = request.size();
+ uint32_t replySize = 0;
+ uint8_t* replyData = nullptr;
+
+ if (response != nullptr) {
+ response->resize(response->capacity());
+ replySize = response->size();
+ replyData = response->data();
+ }
+
+ if (request_cb_) {
+ (request_cb_)(request);
+ }
+
+ uint32_t status_code = nos_call_application(&device_, appId, arg,
+ request.data(), requestSize,
+ replyData, &replySize);
+
+ if (response != nullptr) {
+ response->resize(replySize);
+ if (response_cb_) {
+ (response_cb_)(status_code, *response);
+ }
+ }
+
+ return status_code;
+}
+
+} // namespace nos
diff --git a/libnos/include/nos/NuggetClient.h b/libnos/include/nos/NuggetClient.h
index f79b168..563f532 100644
--- a/libnos/include/nos/NuggetClient.h
+++ b/libnos/include/nos/NuggetClient.h
@@ -91,7 +91,7 @@ public:
*/
const std::string& DeviceName() const;
-private:
+protected:
std::string device_name_;
nos_device device_;
bool open_;
diff --git a/libnos/include/nos/NuggetClientDebuggable.h b/libnos/include/nos/NuggetClientDebuggable.h
new file mode 100644
index 0000000..507eb15
--- /dev/null
+++ b/libnos/include/nos/NuggetClientDebuggable.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2020 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.
+ */
+
+#ifndef NOS_NUGGET_CLIENT_DEBUGGABLE_H
+#define NOS_NUGGET_CLIENT_DEBUGGABLE_H
+
+#include <cstdint>
+#include <string>
+#include <vector>
+
+#include <nos/device.h>
+#include <nos/NuggetClient.h>
+
+namespace nos {
+
+/**
+ * This adds some debug functions around NuggetClient::CallApp()
+ */
+class NuggetClientDebuggable : public NuggetClient {
+public:
+
+ using request_cb_t = std::function<void(const std::vector<uint8_t>&)>;
+ using response_cb_t = std::function<void(uint32_t, const std::vector<uint8_t>&)>;
+
+ /* Need to pass the base constructor params up */
+ NuggetClientDebuggable(request_cb_t req_cb_ = 0, response_cb_t resp_cb_ = 0);
+ NuggetClientDebuggable(const std::string& device_name,
+ request_cb_t req_cb_ = 0, response_cb_t resp_cb_ = 0);
+ NuggetClientDebuggable(const char* device_name,
+ request_cb_t req_cb_ = 0, response_cb_t resp_cb_ = 0);
+
+ /* We'll override this */
+ uint32_t CallApp(uint32_t appId, uint16_t arg,
+ const std::vector<uint8_t>& request,
+ std::vector<uint8_t>* response) override;
+
+
+private:
+ request_cb_t request_cb_;
+ response_cb_t response_cb_;
+};
+
+} // namespace nos
+
+#endif // NOS_NUGGET_CLIENT_DEBUGGABLE_H
diff --git a/nugget/proto/nugget/app/identity/identity.options b/nugget/proto/nugget/app/identity/identity.options
new file mode 100644
index 0000000..0939e93
--- /dev/null
+++ b/nugget/proto/nugget/app/identity/identity.options
@@ -0,0 +1,2 @@
+nugget.app.identity.ICsetAuthTokenRequest.mac max_size:32
+nugget.app.identity.ICsetAuthTokenRequest.verificationTokenMac max_size:32