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

Commit a7352c9f authored by Mathias Agopian's avatar Mathias Agopian
Browse files

new SensorService

remove old sensor service and implement SensorManager
on top of the new (native) SensorManger API.

Change-Id: Iddb77d498755da3e11646473a44d651f12f40281
parent ac07cd61
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ public:
    };

            Sensor();
            Sensor(struct sensor_t const* hwSensor);
    virtual ~Sensor();

    const String8& getName() const;
+9 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ namespace android {

class ISensorEventConnection;
class Sensor;
class PollLoop;

// ----------------------------------------------------------------------------

@@ -56,13 +57,21 @@ public:
    ssize_t write(ASensorEvent const* events, size_t numEvents);
    ssize_t read(ASensorEvent* events, size_t numEvents);

    status_t waitForEvent() const;
    status_t wake() const;

    status_t enableSensor(Sensor const* sensor) const;
    status_t disableSensor(Sensor const* sensor) const;
    status_t enableSensor(int32_t handle) const;
    status_t disableSensor(int32_t handle) const;
    status_t setEventRate(Sensor const* sensor, nsecs_t ns) const;

private:
    sp<PollLoop> getPollLoop() const;
    sp<ISensorEventConnection> mSensorEventConnection;
    sp<SensorChannel> mSensorChannel;
    mutable Mutex mLock;
    mutable sp<PollLoop> mPollLoop;
};

// ----------------------------------------------------------------------------
+3 −3
Original line number Diff line number Diff line
@@ -47,13 +47,13 @@ public:
    SensorManager();
    ~SensorManager();

    ssize_t getSensorList(Sensor**) const;
    Sensor* getDefaultSensor(int type);
    ssize_t getSensorList(Sensor const* const** list) const;
    Sensor const* getDefaultSensor(int type);
    sp<SensorEventQueue> createEventQueue();

private:
    sp<ISensorServer> mSensorServer;
    Sensor* mSensorList;
    Sensor const** mSensorList;
    Vector<Sensor> mSensors;
};

+3 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ public:
    virtual sp<SensorChannel> getSensorChannel() const
    {
        Parcel data, reply;
        data.writeInterfaceToken(ISensorEventConnection::getInterfaceDescriptor());
        remote()->transact(GET_SENSOR_CHANNEL, data, &reply);
        return new SensorChannel(reply);
    }
@@ -54,6 +55,7 @@ public:
    virtual status_t enableDisable(int handle, bool enabled)
    {
        Parcel data, reply;
        data.writeInterfaceToken(ISensorEventConnection::getInterfaceDescriptor());
        data.writeInt32(handle);
        data.writeInt32(enabled);
        remote()->transact(ENABLE_DISABLE, data, &reply);
@@ -63,6 +65,7 @@ public:
    virtual status_t setEventRate(int handle, nsecs_t ns)
    {
        Parcel data, reply;
        data.writeInterfaceToken(ISensorEventConnection::getInterfaceDescriptor());
        data.writeInt32(handle);
        data.writeInt64(ns);
        remote()->transact(SET_EVENT_RATE, data, &reply);
+2 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ public:
    virtual Vector<Sensor> getSensorList()
    {
        Parcel data, reply;
        data.writeInterfaceToken(ISensorServer::getInterfaceDescriptor());
        remote()->transact(GET_SENSOR_LIST, data, &reply);
        Sensor s;
        Vector<Sensor> v;
@@ -63,6 +64,7 @@ public:
    virtual sp<ISensorEventConnection> createSensorEventConnection()
    {
        Parcel data, reply;
        data.writeInterfaceToken(ISensorServer::getInterfaceDescriptor());
        remote()->transact(CREATE_SENSOR_EVENT_CONNECTION, data, &reply);
        return interface_cast<ISensorEventConnection>(reply.readStrongBinder());
    }
Loading