diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2021-06-21 14:48:57 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2021-06-21 14:48:57 +0000 |
commit | 5d0d61d04be09c2d07494aa4e6a05ce7fd9ef436 (patch) | |
tree | f7819440046e4556adeb2aa7070035cb19c2b962 /libnos/include | |
parent | 0b785820a0a0e12c006d9edd829080f5dff33f6f (diff) | |
parent | 42c9a8b6aaece2868a7f23c36278f7a51f856778 (diff) | |
download | generic-android12-mainline-extservices-release.tar.gz |
Snap for 7478067 from 42c9a8b6aaece2868a7f23c36278f7a51f856778 to mainline-extservices-releaseandroid-mainline-12.0.0_r9android-mainline-12.0.0_r87android-mainline-12.0.0_r72android-mainline-12.0.0_r44android-mainline-12.0.0_r27android-mainline-12.0.0_r117android-mainline-12.0.0_r102android12-mainline-extservices-release
Change-Id: Iafa06927a72554f94ee49fdf6f2def983fe97ae2
Diffstat (limited to 'libnos/include')
-rw-r--r-- | libnos/include/nos/NuggetClient.h | 21 | ||||
-rw-r--r-- | libnos/include/nos/NuggetClientDebuggable.h | 55 | ||||
-rw-r--r-- | libnos/include/nos/NuggetClientInterface.h | 6 |
3 files changed, 71 insertions, 11 deletions
diff --git a/libnos/include/nos/NuggetClient.h b/libnos/include/nos/NuggetClient.h index f79b168..9484bd8 100644 --- a/libnos/include/nos/NuggetClient.h +++ b/libnos/include/nos/NuggetClient.h @@ -32,17 +32,13 @@ namespace nos { class NuggetClient : public NuggetClientInterface { public: /** - * Create a client for the default Nugget device. - */ - NuggetClient(); - - /** - * Create a client for the named Nugget device. + * Create a client for the named Nugget device * - * Passing an empty device name causes the default device to be selected. + * An empty device name causes the default device to be selected. + * An empty config uses default configurations. */ - NuggetClient(const std::string& device_name); - NuggetClient(const char* device_name); + NuggetClient(const std::string& name); + NuggetClient(const char* name = 0, uint32_t config = 0); ~NuggetClient() override; @@ -77,6 +73,11 @@ public: std::vector<uint8_t>* response) override; /** + * Reset the device. Use with caution; context may be lost. + */ + uint32_t Reset() const override; + + /** * Access the underlying device. * * NULL is returned if the connection to the device is not open. @@ -91,7 +92,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..ff1f080 --- /dev/null +++ b/libnos/include/nos/NuggetClientDebuggable.h @@ -0,0 +1,55 @@ +/* + * 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(const char* name = 0, uint32_t config = 0, + 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/libnos/include/nos/NuggetClientInterface.h b/libnos/include/nos/NuggetClientInterface.h index f7db0d1..8d78185 100644 --- a/libnos/include/nos/NuggetClientInterface.h +++ b/libnos/include/nos/NuggetClientInterface.h @@ -47,7 +47,7 @@ public: virtual bool IsOpen() const = 0; /** - * Call into and app running on Nugget. + * Call into an app running on Nugget. * * @param app_id The ID of the app to call. * @param arg Argument to pass to the app. @@ -58,6 +58,10 @@ public: virtual uint32_t CallApp(uint32_t appId, uint16_t arg, const std::vector<uint8_t>& request, std::vector<uint8_t>* response) = 0; + /** + * Reset the device. Use with caution; context may be lost. + */ + virtual uint32_t Reset() const = 0; }; } // namespace nos |