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

Commit 5e5a6f3e authored by Peng Xu's avatar Peng Xu Committed by android-build-merger
Browse files

Merge "Refactor sensor list in SensorService" into nyc-dev

am: df4f17e1

* commit 'df4f17e1':
  Refactor sensor list in SensorService

Change-Id: Icf06548c50ae7bf38590dc32a212252b95b606a7
parents ce1099ee df4f17e1
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ public:
        uint8_t b[16];
    } uuid_t;

    Sensor();
    Sensor(const char * name = "");
    Sensor(struct sensor_t const* hwSensor, int halVersion = 0);
    ~Sensor();

@@ -80,6 +80,7 @@ public:
    int32_t getMaxDelay() const;
    uint32_t getFlags() const;
    bool isWakeUpSensor() const;
    bool isDynamicSensor() const;
    int32_t getReportingMode() const;
    const uuid_t& getUuid() const;

+6 −2
Original line number Diff line number Diff line
@@ -35,8 +35,8 @@
namespace android {
// ----------------------------------------------------------------------------

Sensor::Sensor()
    : mHandle(0), mType(0),
Sensor::Sensor(const char * name)
    : mName(name), mHandle(0), mType(0),
      mMinValue(0), mMaxValue(0), mResolution(0),
      mPower(0), mMinDelay(0), mVersion(0), mFifoReservedEventCount(0),
      mFifoMaxEventCount(0), mRequiredAppOp(0),
@@ -390,6 +390,10 @@ bool Sensor::isWakeUpSensor() const {
    return mFlags & SENSOR_FLAG_WAKE_UP;
}

bool Sensor::isDynamicSensor() const {
    return mFlags & SENSOR_FLAG_DYNAMIC_SENSOR;
}

int32_t Sensor::getReportingMode() const {
    return ((mFlags & REPORTING_MODE_MASK) >> REPORTING_MODE_SHIFT);
}
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ LOCAL_SRC_FILES:= \
    SensorEventConnection.cpp \
    MostRecentEventLogger.cpp \
    SensorRecord.cpp \
    SensorList.cpp \


LOCAL_CFLAGS:= -DLOG_TAG=\"SensorService\"
+14 −13
Original line number Diff line number Diff line
@@ -39,6 +39,18 @@ CorrectedGyroSensor::CorrectedGyroSensor(sensor_t const* list, size_t count)
            break;
        }
    }

    sensor_t hwSensor;
    hwSensor.name       = "Corrected Gyroscope Sensor";
    hwSensor.vendor     = "AOSP";
    hwSensor.version    = 1;
    hwSensor.handle     = '_cgy';
    hwSensor.type       = SENSOR_TYPE_GYROSCOPE;
    hwSensor.maxRange   = mGyro.getMaxValue();
    hwSensor.resolution = mGyro.getResolution();
    hwSensor.power      = mSensorFusion.getPowerUsage();
    hwSensor.minDelay   = mGyro.getMinDelay();
    mSensor = Sensor(&hwSensor);
}

bool CorrectedGyroSensor::process(sensors_event_t* outEvent,
@@ -66,19 +78,8 @@ status_t CorrectedGyroSensor::setDelay(void* ident, int /*handle*/, int64_t ns)
    return mSensorFusion.setDelay(FUSION_9AXIS, ident, ns);
}

Sensor CorrectedGyroSensor::getSensor() const {
    sensor_t hwSensor;
    hwSensor.name       = "Corrected Gyroscope Sensor";
    hwSensor.vendor     = "AOSP";
    hwSensor.version    = 1;
    hwSensor.handle     = '_cgy';
    hwSensor.type       = SENSOR_TYPE_GYROSCOPE;
    hwSensor.maxRange   = mGyro.getMaxValue();
    hwSensor.resolution = mGyro.getResolution();
    hwSensor.power      = mSensorFusion.getPowerUsage();
    hwSensor.minDelay   = mGyro.getMinDelay();
    Sensor sensor(&hwSensor);
    return sensor;
const Sensor& CorrectedGyroSensor::getSensor() const {
    return mSensor;
}

// ---------------------------------------------------------------------------
+6 −6
Original line number Diff line number Diff line
@@ -35,15 +35,15 @@ class CorrectedGyroSensor : public SensorInterface {
    SensorDevice& mSensorDevice;
    SensorFusion& mSensorFusion;
    Sensor mGyro;
    Sensor mSensor;

public:
    CorrectedGyroSensor(sensor_t const* list, size_t count);
    virtual bool process(sensors_event_t* outEvent,
            const sensors_event_t& event);
    virtual status_t activate(void* ident, bool enabled);
    virtual status_t setDelay(void* ident, int handle, int64_t ns);
    virtual Sensor getSensor() const;
    virtual bool isVirtual() const { return true; }
    virtual bool process(sensors_event_t* outEvent, const sensors_event_t& event) override;
    virtual status_t activate(void* ident, bool enabled) override;
    virtual status_t setDelay(void* ident, int handle, int64_t ns) override;
    virtual const Sensor& getSensor() const override;
    virtual bool isVirtual() const override { return true; }
};

// ---------------------------------------------------------------------------
Loading