diff options
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/vr/libvrsensor/Android.bp | 1 | ||||
| -rw-r--r-- | libs/vr/libvrsensor/include/private/dvr/sensor-ipc.h | 17 | ||||
| -rw-r--r-- | libs/vr/libvrsensor/include/private/dvr/sensor_client.h | 37 | ||||
| -rw-r--r-- | libs/vr/libvrsensor/sensor_client.cpp | 79 |
4 files changed, 0 insertions, 134 deletions
diff --git a/libs/vr/libvrsensor/Android.bp b/libs/vr/libvrsensor/Android.bp index ec36088c8a..fe54b4bb0c 100644 --- a/libs/vr/libvrsensor/Android.bp +++ b/libs/vr/libvrsensor/Android.bp @@ -14,7 +14,6 @@ sourceFiles = [ "pose_client.cpp", - "sensor_client.cpp", "latency_model.cpp", ] diff --git a/libs/vr/libvrsensor/include/private/dvr/sensor-ipc.h b/libs/vr/libvrsensor/include/private/dvr/sensor-ipc.h deleted file mode 100644 index b2ebd95060..0000000000 --- a/libs/vr/libvrsensor/include/private/dvr/sensor-ipc.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef ANDROID_DVR_SENSOR_IPC_H_ -#define ANDROID_DVR_SENSOR_IPC_H_ - -#define DVR_SENSOR_SERVICE_BASE "system/vr/sensors" - -#define DVR_SENSOR_SERVICE_CLIENT (DVR_SENSOR_SERVICE_BASE "/client") - -/* - * Endpoint ops - */ -enum { - DVR_SENSOR_START = 0, - DVR_SENSOR_STOP, - DVR_SENSOR_POLL, -}; - -#endif // ANDROID_DVR_SENSOR_IPC_H_ diff --git a/libs/vr/libvrsensor/include/private/dvr/sensor_client.h b/libs/vr/libvrsensor/include/private/dvr/sensor_client.h deleted file mode 100644 index 15a9b8f5d1..0000000000 --- a/libs/vr/libvrsensor/include/private/dvr/sensor_client.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef ANDROID_DVR_SENSOR_CLIENT_H_ -#define ANDROID_DVR_SENSOR_CLIENT_H_ - -#include <hardware/sensors.h> -#include <pdx/client.h> -#include <poll.h> - -namespace android { -namespace dvr { - -// SensorClient is a remote interface to the sensor service in sensord. -class SensorClient : public pdx::ClientBase<SensorClient> { - public: - ~SensorClient(); - - int StartSensor(); - int StopSensor(); - int Poll(sensors_event_t* events, int max_count); - - private: - friend BASE; - - // Set up a channel associated with the sensor of the indicated type. - // NOTE(segal): If our hardware ends up with multiple sensors of the same - // type, we'll have to change this. - explicit SensorClient(int sensor_type); - - int sensor_type_; - - SensorClient(const SensorClient&); - SensorClient& operator=(const SensorClient&); -}; - -} // namespace dvr -} // namespace android - -#endif // ANDROID_DVR_SENSOR_CLIENT_H_ diff --git a/libs/vr/libvrsensor/sensor_client.cpp b/libs/vr/libvrsensor/sensor_client.cpp deleted file mode 100644 index 04e88cc9a1..0000000000 --- a/libs/vr/libvrsensor/sensor_client.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#define LOG_TAG "SensorClient" -#include <private/dvr/sensor_client.h> - -#include <log/log.h> -#include <poll.h> - -#include <pdx/default_transport/client_channel_factory.h> -#include <private/dvr/sensor-ipc.h> - -using android::pdx::Transaction; - -namespace android { -namespace dvr { - -SensorClient::SensorClient(int sensor_type) - : BASE(pdx::default_transport::ClientChannelFactory::Create( - DVR_SENSOR_SERVICE_CLIENT)), - sensor_type_(sensor_type) {} - -SensorClient::~SensorClient() {} - -int SensorClient::StartSensor() { - Transaction trans{*this}; - auto status = trans.Send<int>(DVR_SENSOR_START, &sensor_type_, - sizeof(sensor_type_), nullptr, 0); - ALOGE_IF(!status, "startSensor() failed because: %s\n", - status.GetErrorMessage().c_str()); - return ReturnStatusOrError(status); -} - -int SensorClient::StopSensor() { - Transaction trans{*this}; - auto status = trans.Send<int>(DVR_SENSOR_STOP); - ALOGE_IF(!status, "stopSensor() failed because: %s\n", - status.GetErrorMessage().c_str()); - return ReturnStatusOrError(status); -} - -int SensorClient::Poll(sensors_event_t* events, int max_events) { - int num_events = 0; - struct iovec rvec[] = { - {.iov_base = &num_events, .iov_len = sizeof(int)}, - {.iov_base = events, .iov_len = max_events * sizeof(sensors_event_t)}, - }; - Transaction trans{*this}; - auto status = trans.SendVector<int>(DVR_SENSOR_POLL, nullptr, rvec); - ALOGE_IF(!status, "Sensor poll() failed because: %s\n", - status.GetErrorMessage().c_str()); - return !status ? -status.error() : num_events; -} - -} // namespace dvr -} // namespace android - -// Entrypoints to simplify using the library when programmatically dynamicly -// loading it. -// Allows us to call this library without linking it, as, for instance, -// when compiling GVR in Google3. -// NOTE(segal): It's kind of a hack. - -extern "C" uint64_t dvrStartSensor(int type) { - android::dvr::SensorClient* service = - android::dvr::SensorClient::Create(type).release(); - service->StartSensor(); - return (uint64_t)service; -} - -extern "C" void dvrStopSensor(uint64_t service) { - android::dvr::SensorClient* iss = - reinterpret_cast<android::dvr::SensorClient*>(service); - iss->StopSensor(); - delete iss; -} - -extern "C" int dvrPollSensor(uint64_t service, int max_count, - sensors_event_t* events) { - return reinterpret_cast<android::dvr::SensorClient*>(service)->Poll( - events, max_count); -} |