anbox-platform-sdk 1.28.0
Anbox Platform SDK API documentation
vhal_connector.h
Go to the documentation of this file.
1/*
2 * This file is part of Anbox Platform SDK
3 *
4 * Copyright 2024 Canonical Ltd.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#ifndef ANBOX_SDK_VHAL_CONNECTOR_H_
20#define ANBOX_SDK_VHAL_CONNECTOR_H_
21
22#include <stdbool.h>
23#include <stdint.h>
24
31 AnboxVhalAnswerGetConfigs *result, void *user_data);
32
39 int32_t *props, size_t props_size, AnboxVhalAnswerGetConfigs *result,
40 void *user_data);
41
47typedef bool (*AnboxVhalIsAvailableCallback)(void *user_data);
48
55 void *user_data);
56
63 AnboxVhalCommandSet *request, void *user_data);
64
76
77namespace anbox {
84 public:
85 VhalConnector() = default;
86 virtual ~VhalConnector() = default;
87 VhalConnector(const VhalConnector &) = delete;
89
95 bool is_available() {
96 if (!callbacks_.is_available_callback)
97 return false;
98 return callbacks_.is_available_callback(user_data_);
99 }
100
118
132 AnboxVhalAnswerStatus get_prop_configs(int32_t *props, size_t props_size,
134 if (!callbacks_.get_prop_configs_callback)
136 return callbacks_.get_prop_configs_callback(props, props_size, result,
137 user_data_);
138 }
139
152 AnboxVhalPropertyValue *result) {
153 if (!callbacks_.get_callback)
155 return callbacks_.get_callback(request, result, user_data_);
156 }
157
166 if (!callbacks_.set_callback)
168 return callbacks_.set_callback(request, user_data_);
169 }
170
178 void *user_data) {
179 callbacks_ = callbacks;
180 user_data_ = user_data;
181 }
182
183 private:
185 void *user_data_{nullptr};
186};
187} // namespace anbox
188
189#endif
Connects a platform with the Android VHAL interface. The platform can invoke the callbacks which are ...
bool is_available()
Check if the Android VHAL is supported and available.
void set_callbacks(const AnboxVhalConnectorCallbacks &callbacks, void *user_data)
Set all VHAL-related callbacks.
AnboxVhalAnswerStatus get_all_prop_configs(AnboxVhalAnswerGetConfigs *result)
Get all property configs.
VhalConnector & operator=(const VhalConnector &)=delete
VhalConnector(const VhalConnector &)=delete
AnboxVhalAnswerStatus get(AnboxVhalCommandGet *request, AnboxVhalPropertyValue *result)
Get the requested value.
AnboxVhalAnswerStatus set(AnboxVhalCommandSet *request)
Set the requested value.
virtual ~VhalConnector()=default
AnboxVhalAnswerStatus get_prop_configs(int32_t *props, size_t props_size, AnboxVhalAnswerGetConfigs *result)
Get requested property configs.
AnboxVhalAnswerGet contains the answer for a GetAllPropConfigs or GetPropConfigs request sent to the ...
Definition types.h:1586
AnboxVhalCommandGet describes a get request to send to the Android VHAL.
Definition types.h:1595
AnboxVhalCommandSet describes a set request to send to the Android VHAL.
Definition types.h:1614
AnboxVhalConnectorCallbacks is the structure holding all VHAL-related callbacks.
AnboxVhalIsAvailableCallback is_available_callback
AnboxVhalGetAllPropConfigsCallback get_all_prop_configs_callback
AnboxVhalGetPropConfigsCallback get_prop_configs_callback
AnboxVhalGetCallback get_callback
AnboxVhalSetCallback set_callback
AnboxVhalPropertyValue describes the current value of a VHAL property, as returned by a get call to t...
Definition types.h:1497
AnboxVhalAnswerStatus
AnboxVhalAnswerStatus describes the return status of a request sent to the Android VHAL.
Definition types.h:1574
@ ANBOX_VHAL_ANSWER_STATUS_INVALID
Definition types.h:1577
AnboxVhalAnswerStatus(* AnboxVhalGetAllPropConfigsCallback)(AnboxVhalAnswerGetConfigs *result, void *user_data)
AnboxVhalGetAllPropConfigsCallback is invoked when requesting all prop configs.
AnboxVhalAnswerStatus(* AnboxVhalSetCallback)(AnboxVhalCommandSet *request, void *user_data)
AnboxVhalSetCallback is invoked when requesting to change property values.
AnboxVhalAnswerStatus(* AnboxVhalGetPropConfigsCallback)(int32_t *props, size_t props_size, AnboxVhalAnswerGetConfigs *result, void *user_data)
AnboxVhalGetPropConfigsCallback is invoked when requesting some prop configs.
AnboxVhalAnswerStatus(* AnboxVhalGetCallback)(AnboxVhalCommandGet *request, AnboxVhalPropertyValue *result, void *user_data)
AnboxVhalGetCallback is invoked when requesting property values.
bool(* AnboxVhalIsAvailableCallback)(void *user_data)
AnboxVhalIsAvailableCallback is invoked when checking if the Android VHAL is supported and available.