diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2021-01-14 07:53:29 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2021-01-14 07:53:29 +0000 |
commit | e4f1465ae9dad84658581d26103a1568d87ff9be (patch) | |
tree | b048acdd4863efa9e78b306708c4c3f32171b16c | |
parent | 759c92ef51906907551b5d8eb764615b59d585c3 (diff) | |
parent | aac19097d30bad7ac2bde394b11986c9a5617594 (diff) | |
download | generic-e4f1465ae9dad84658581d26103a1568d87ff9be.tar.gz |
Merge cherrypicks of [13343779, 13343968, 13343886, 13343395, 13341216, 13343957, 13343958, 13343762, 13343763, 13343764, 13344125, 13344126, 13344127, 13344128, 13344129, 13344130, 13344131, 13343396, 13343780, 13343781, 13343782, 13343783, 13343784, 13344185, 13343959, 13343960, 13343961, 13343962, 13343963, 13343964, 13344205, 13344206, 13344207, 13344208, 13344209, 13344186, 13343969, 13343970, 13343971, 13343972, 13343973, 13343974, 13343975, 13343918, 13343919, 13343976, 13343397, 13344187] into rvc-qpr2-releaseandroid-11.0.0_r37android-11.0.0_r36android-11.0.0_r35android-11.0.0_r34android-11.0.0_r33android-11.0.0_r32android11-qpr2-release
Change-Id: I0eb89824dfd1f4c61c224c385014abcd1c690c93
-rw-r--r-- | libnos/BUILD | 19 | ||||
-rw-r--r-- | libnos/NuggetClient.cpp | 3 | ||||
-rw-r--r-- | libnos/NuggetClientDebuggable.cpp | 74 | ||||
-rw-r--r-- | libnos/include/nos/NuggetClient.h | 2 | ||||
-rw-r--r-- | libnos/include/nos/NuggetClientDebuggable.h | 58 | ||||
-rw-r--r-- | nugget/proto/nugget/app/identity/identity.options | 2 |
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 |