Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 608560d3 authored by Steven Thomas's avatar Steven Thomas
Browse files

Remove stale sensor service code

Sensor service no longer exists, so remove the client code to connect to
it.

Bug: 69567797

Test: Confirmed pdx_tool no longer prints an error about failing to
connect to sensor service.

Change-Id: Id5e97b1e262195d0bce8ceeb3f74676490cc922a
(cherry picked from commit 99183e6bf8307acaf601392e2d0b08d9be760513)
parent 2878422d
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@

sourceFiles = [
    "pose_client.cpp",
    "sensor_client.cpp",
    "latency_model.cpp",
]

+0 −17
Original line number Diff line number Diff line
#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_
+0 −37
Original line number Diff line number Diff line
#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_
+0 −79
Original line number Diff line number Diff line
#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);
}