Merge "Surface reportingMode for Sensors."
This commit is contained in:
commit
adb65d9add
@ -73,6 +73,16 @@ enum {
|
||||
ASENSOR_STATUS_ACCURACY_HIGH = 3
|
||||
};
|
||||
|
||||
/*
|
||||
* Sensor Reporting Modes.
|
||||
*/
|
||||
enum {
|
||||
AREPORTING_MODE_CONTINUOUS = 0,
|
||||
AREPORTING_MODE_ON_CHANGE = 1,
|
||||
AREPORTING_MODE_ONE_SHOT = 2,
|
||||
AREPORTING_MODE_SPECIAL_TRIGGER = 3
|
||||
};
|
||||
|
||||
/*
|
||||
* A few useful constants
|
||||
*/
|
||||
@ -306,6 +316,11 @@ int ASensor_getFifoReservedEventCount(ASensor const* sensor);
|
||||
*/
|
||||
const char* ASensor_getStringType(ASensor const* sensor);
|
||||
|
||||
/*
|
||||
* Returns the reporting mode for this sensor. One of AREPORTING_MODE_* constants.
|
||||
*/
|
||||
int ASensor_getReportingMode(ASensor const* sensor);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
@ -72,7 +72,9 @@ public:
|
||||
const String8& getStringType() const;
|
||||
const String8& getRequiredPermission() const;
|
||||
int32_t getMaxDelay() const;
|
||||
int32_t getFlags() const;
|
||||
bool isWakeUpSensor() const;
|
||||
int32_t getReportingMode() const;
|
||||
|
||||
// LightFlattenable protocol
|
||||
inline bool isFixedSize() const { return false; }
|
||||
@ -96,7 +98,7 @@ private:
|
||||
String8 mStringType;
|
||||
String8 mRequiredPermission;
|
||||
int32_t mMaxDelay;
|
||||
bool mWakeUpSensor;
|
||||
int32_t mFlags;
|
||||
static void flattenString8(void*& buffer, size_t& size, const String8& string8);
|
||||
static bool unflattenString8(void const*& buffer, size_t& size, String8& outputString8);
|
||||
};
|
||||
|
@ -36,7 +36,7 @@ Sensor::Sensor()
|
||||
: mHandle(0), mType(0),
|
||||
mMinValue(0), mMaxValue(0), mResolution(0),
|
||||
mPower(0), mMinDelay(0), mFifoReservedEventCount(0), mFifoMaxEventCount(0),
|
||||
mMaxDelay(0), mWakeUpSensor(false)
|
||||
mMaxDelay(0), mFlags(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ Sensor::Sensor(struct sensor_t const* hwSensor, int halVersion)
|
||||
mResolution = hwSensor->resolution;
|
||||
mPower = hwSensor->power;
|
||||
mMinDelay = hwSensor->minDelay;
|
||||
mWakeUpSensor = false;
|
||||
mFlags = 0;
|
||||
|
||||
// Set fifo event count zero for older devices which do not support batching. Fused
|
||||
// sensors also have their fifo counts set to zero.
|
||||
@ -79,154 +79,177 @@ Sensor::Sensor(struct sensor_t const* hwSensor, int halVersion)
|
||||
mMaxDelay = 0;
|
||||
}
|
||||
|
||||
// Ensure existing sensors have correct string type and required
|
||||
// permissions.
|
||||
// Ensure existing sensors have correct string type, required permissions and reporting mode.
|
||||
switch (mType) {
|
||||
case SENSOR_TYPE_ACCELEROMETER:
|
||||
mStringType = SENSOR_STRING_TYPE_ACCELEROMETER;
|
||||
mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_AMBIENT_TEMPERATURE:
|
||||
mStringType = SENSOR_STRING_TYPE_AMBIENT_TEMPERATURE;
|
||||
mFlags |= SENSOR_FLAG_ON_CHANGE_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_GAME_ROTATION_VECTOR:
|
||||
mStringType = SENSOR_STRING_TYPE_GAME_ROTATION_VECTOR;
|
||||
mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR:
|
||||
mStringType = SENSOR_STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR;
|
||||
mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_GRAVITY:
|
||||
mStringType = SENSOR_STRING_TYPE_GRAVITY;
|
||||
mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_GYROSCOPE:
|
||||
mStringType = SENSOR_STRING_TYPE_GYROSCOPE;
|
||||
mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED:
|
||||
mStringType = SENSOR_STRING_TYPE_GYROSCOPE_UNCALIBRATED;
|
||||
mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_HEART_RATE:
|
||||
mStringType = SENSOR_STRING_TYPE_HEART_RATE;
|
||||
mRequiredPermission = SENSOR_PERMISSION_BODY_SENSORS;
|
||||
mFlags |= SENSOR_FLAG_ON_CHANGE_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_LIGHT:
|
||||
mStringType = SENSOR_STRING_TYPE_LIGHT;
|
||||
mFlags |= SENSOR_FLAG_ON_CHANGE_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_LINEAR_ACCELERATION:
|
||||
mStringType = SENSOR_STRING_TYPE_LINEAR_ACCELERATION;
|
||||
mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_MAGNETIC_FIELD:
|
||||
mStringType = SENSOR_STRING_TYPE_MAGNETIC_FIELD;
|
||||
mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED:
|
||||
mStringType = SENSOR_STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED;
|
||||
mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_ORIENTATION:
|
||||
mStringType = SENSOR_STRING_TYPE_ORIENTATION;
|
||||
mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_PRESSURE:
|
||||
mStringType = SENSOR_STRING_TYPE_PRESSURE;
|
||||
mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_PROXIMITY:
|
||||
mStringType = SENSOR_STRING_TYPE_PROXIMITY;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_ON_CHANGE_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_RELATIVE_HUMIDITY:
|
||||
mStringType = SENSOR_STRING_TYPE_RELATIVE_HUMIDITY;
|
||||
mFlags |= SENSOR_FLAG_ON_CHANGE_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_ROTATION_VECTOR:
|
||||
mStringType = SENSOR_STRING_TYPE_ROTATION_VECTOR;
|
||||
mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_SIGNIFICANT_MOTION:
|
||||
mStringType = SENSOR_STRING_TYPE_SIGNIFICANT_MOTION;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_ONE_SHOT_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_STEP_COUNTER:
|
||||
mStringType = SENSOR_STRING_TYPE_STEP_COUNTER;
|
||||
mFlags |= SENSOR_FLAG_ON_CHANGE_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_STEP_DETECTOR:
|
||||
mStringType = SENSOR_STRING_TYPE_STEP_DETECTOR;
|
||||
mFlags |= SENSOR_FLAG_SPECIAL_REPORTING_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_TEMPERATURE:
|
||||
mStringType = SENSOR_STRING_TYPE_TEMPERATURE;
|
||||
mFlags |= SENSOR_FLAG_ON_CHANGE_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_NON_WAKE_UP_PROXIMITY_SENSOR:
|
||||
mStringType = SENSOR_STRING_TYPE_NON_WAKE_UP_PROXIMITY_SENSOR;
|
||||
mFlags |= SENSOR_FLAG_ON_CHANGE_MODE;
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_ACCELEROMETER:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_ACCELEROMETER;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_CONTINUOUS_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_MAGNETIC_FIELD:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_MAGNETIC_FIELD;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_CONTINUOUS_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_ORIENTATION:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_ORIENTATION;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_CONTINUOUS_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_GYROSCOPE:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_GYROSCOPE;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_CONTINUOUS_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_LIGHT:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_LIGHT;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_ON_CHANGE_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_PRESSURE:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_PRESSURE;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_CONTINUOUS_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_GRAVITY:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_GRAVITY;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_CONTINUOUS_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_LINEAR_ACCELERATION:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_LINEAR_ACCELERATION;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_CONTINUOUS_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_ROTATION_VECTOR:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_ROTATION_VECTOR;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_CONTINUOUS_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_RELATIVE_HUMIDITY:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_RELATIVE_HUMIDITY;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_SPECIAL_REPORTING_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_AMBIENT_TEMPERATURE:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_AMBIENT_TEMPERATURE;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_ON_CHANGE_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_MAGNETIC_FIELD_UNCALIBRATED:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_MAGNETIC_FIELD_UNCALIBRATED;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_CONTINUOUS_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_GAME_ROTATION_VECTOR:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_GAME_ROTATION_VECTOR;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_CONTINUOUS_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_GYROSCOPE_UNCALIBRATED:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_GYROSCOPE_UNCALIBRATED;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_CONTINUOUS_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_STEP_DETECTOR:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_STEP_DETECTOR;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_SPECIAL_REPORTING_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_STEP_COUNTER:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_STEP_COUNTER;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_ON_CHANGE_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_GEOMAGNETIC_ROTATION_VECTOR:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_GEOMAGNETIC_ROTATION_VECTOR;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_CONTINUOUS_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_HEART_RATE:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_HEART_RATE;
|
||||
mRequiredPermission = SENSOR_PERMISSION_BODY_SENSORS;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_ON_CHANGE_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_UP_TILT_DETECTOR:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_UP_TILT_DETECTOR;
|
||||
mFlags |= (SENSOR_FLAG_SPECIAL_REPORTING_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
case SENSOR_TYPE_WAKE_GESTURE:
|
||||
mStringType = SENSOR_STRING_TYPE_WAKE_GESTURE;
|
||||
mWakeUpSensor = true;
|
||||
mFlags |= (SENSOR_FLAG_ONE_SHOT_MODE | SENSOR_FLAG_WAKE_UP);
|
||||
break;
|
||||
default:
|
||||
// Only pipe the stringType, requiredPermission and flags for custom sensors.
|
||||
@ -236,8 +259,19 @@ Sensor::Sensor(struct sensor_t const* hwSensor, int halVersion)
|
||||
if (halVersion >= SENSORS_DEVICE_API_VERSION_1_2 && hwSensor->requiredPermission) {
|
||||
mRequiredPermission = hwSensor->requiredPermission;
|
||||
}
|
||||
|
||||
if (halVersion >= SENSORS_DEVICE_API_VERSION_1_3) {
|
||||
mWakeUpSensor = hwSensor->flags & SENSOR_FLAG_WAKE_UP;
|
||||
mFlags = (int32_t) hwSensor->flags;
|
||||
} else {
|
||||
// This is an OEM defined sensor on an older HAL. Use minDelay to determine the
|
||||
// reporting mode of the sensor.
|
||||
if (mMinDelay > 0) {
|
||||
mFlags |= SENSOR_FLAG_CONTINUOUS_MODE;
|
||||
} else if (mMinDelay == 0) {
|
||||
mFlags |= SENSOR_FLAG_ON_CHANGE_MODE;
|
||||
} else if (mMinDelay < 0) {
|
||||
mFlags |= SENSOR_FLAG_ONE_SHOT_MODE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -311,8 +345,16 @@ int32_t Sensor::getMaxDelay() const {
|
||||
return mMaxDelay;
|
||||
}
|
||||
|
||||
int32_t Sensor::getFlags() const {
|
||||
return mFlags;
|
||||
}
|
||||
|
||||
bool Sensor::isWakeUpSensor() const {
|
||||
return mWakeUpSensor;
|
||||
return mFlags & SENSOR_FLAG_WAKE_UP;
|
||||
}
|
||||
|
||||
int32_t Sensor::getReportingMode() const {
|
||||
return ((mFlags & REPORTING_MODE_MASK) >> REPORTING_MODE_SHIFT);
|
||||
}
|
||||
|
||||
size_t Sensor::getFlattenedSize() const
|
||||
@ -320,8 +362,7 @@ size_t Sensor::getFlattenedSize() const
|
||||
size_t fixedSize =
|
||||
sizeof(int32_t) * 3 +
|
||||
sizeof(float) * 4 +
|
||||
sizeof(int32_t) * 4 +
|
||||
sizeof(bool) * 1;
|
||||
sizeof(int32_t) * 5;
|
||||
|
||||
size_t variableSize =
|
||||
sizeof(uint32_t) + FlattenableUtils::align<4>(mName.length()) +
|
||||
@ -352,7 +393,7 @@ status_t Sensor::flatten(void* buffer, size_t size) const {
|
||||
flattenString8(buffer, size, mStringType);
|
||||
flattenString8(buffer, size, mRequiredPermission);
|
||||
FlattenableUtils::write(buffer, size, mMaxDelay);
|
||||
FlattenableUtils::write(buffer, size, mWakeUpSensor);
|
||||
FlattenableUtils::write(buffer, size, mFlags);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
@ -367,8 +408,7 @@ status_t Sensor::unflatten(void const* buffer, size_t size) {
|
||||
size_t fixedSize =
|
||||
sizeof(int32_t) * 3 +
|
||||
sizeof(float) * 4 +
|
||||
sizeof(int32_t) * 4 +
|
||||
sizeof(bool) * 1;
|
||||
sizeof(int32_t) * 5;
|
||||
if (size < fixedSize) {
|
||||
return NO_MEMORY;
|
||||
}
|
||||
@ -391,7 +431,7 @@ status_t Sensor::unflatten(void const* buffer, size_t size) {
|
||||
return NO_MEMORY;
|
||||
}
|
||||
FlattenableUtils::read(buffer, size, mMaxDelay);
|
||||
FlattenableUtils::read(buffer, size, mWakeUpSensor);
|
||||
FlattenableUtils::read(buffer, size, mFlags);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
|
@ -223,14 +223,23 @@ status_t SensorService::dump(int fd, const Vector<String16>& /*args*/)
|
||||
s.getHandle(),
|
||||
s.getRequiredPermission().string());
|
||||
|
||||
if (s.getMinDelay() > 0) {
|
||||
result.appendFormat(
|
||||
"maxRate=%7.2fHz | ", 1e6f / s.getMinDelay());
|
||||
const int reportingMode = s.getReportingMode();
|
||||
if (reportingMode == AREPORTING_MODE_CONTINUOUS) {
|
||||
result.append("continuous |");
|
||||
} else if (reportingMode == AREPORTING_MODE_ON_CHANGE) {
|
||||
result.append("on-change | ");
|
||||
} else if (reportingMode == AREPORTING_MODE_ONE_SHOT) {
|
||||
result.append("one-shot | ");
|
||||
} else {
|
||||
result.append(s.getMinDelay() == 0
|
||||
? "on-demand | "
|
||||
: "one-shot | ");
|
||||
result.append("special-trigger | ");
|
||||
}
|
||||
|
||||
if (s.getMinDelay() > 0) {
|
||||
result.appendFormat("maxRate=%7.2fHz | ", 1e6f / s.getMinDelay());
|
||||
} else {
|
||||
result.appendFormat("minDelay=%5dus |", s.getMinDelay());
|
||||
}
|
||||
|
||||
if (s.getFifoMaxEventCount() > 0) {
|
||||
result.appendFormat("FifoMax=%d events | ",
|
||||
s.getFifoMaxEventCount());
|
||||
@ -301,17 +310,15 @@ status_t SensorService::dump(int fd, const Vector<String16>& /*args*/)
|
||||
|
||||
void SensorService::cleanupAutoDisabledSensorLocked(const sp<SensorEventConnection>& connection,
|
||||
sensors_event_t const* buffer, const int count) {
|
||||
SensorInterface* sensor;
|
||||
status_t err = NO_ERROR;
|
||||
for (int i=0 ; i<count ; i++) {
|
||||
int handle = buffer[i].sensor;
|
||||
int type = buffer[i].type;
|
||||
if (type == SENSOR_TYPE_SIGNIFICANT_MOTION) {
|
||||
if (connection->hasSensor(handle)) {
|
||||
sensor = mSensorMap.valueFor(handle);
|
||||
if (sensor != NULL) {
|
||||
sensor->autoDisable(connection.get(), handle);
|
||||
}
|
||||
if (connection->hasSensor(handle)) {
|
||||
SensorInterface* sensor = mSensorMap.valueFor(handle);
|
||||
// If this buffer has an event from a one_shot sensor and this connection is registered
|
||||
// for this particular one_shot sensor, try cleaning up the connection.
|
||||
if (sensor != NULL &&
|
||||
sensor->getSensor().getReportingMode() == AREPORTING_MODE_ONE_SHOT) {
|
||||
sensor->autoDisable(connection.get(), handle);
|
||||
cleanupWithoutDisableLocked(connection, handle);
|
||||
}
|
||||
}
|
||||
@ -588,7 +595,7 @@ status_t SensorService::enable(const sp<SensorEventConnection>& connection,
|
||||
// this sensor is already activated, but we are adding a connection that uses it.
|
||||
// Immediately send down the last known value of the requested sensor if it's not a
|
||||
// "continuous" sensor.
|
||||
if (sensor->getSensor().getMinDelay() == 0) {
|
||||
if (sensor->getSensor().getReportingMode() == AREPORTING_MODE_ON_CHANGE) {
|
||||
// NOTE: The wake_up flag of this event may get set to
|
||||
// WAKE_UP_SENSOR_EVENT_NEEDS_ACK if this is a wake_up event.
|
||||
sensors_event_t& event(mLastEventSeen.editValueFor(handle));
|
||||
@ -732,8 +739,8 @@ status_t SensorService::flushSensor(const sp<SensorEventConnection>& connection,
|
||||
return BAD_VALUE;
|
||||
}
|
||||
|
||||
if (sensor->getSensor().getType() == SENSOR_TYPE_SIGNIFICANT_MOTION) {
|
||||
ALOGE("flush called on Significant Motion sensor");
|
||||
if (sensor->getSensor().getReportingMode() == AREPORTING_MODE_ONE_SHOT) {
|
||||
ALOGE("flush called on a one-shot sensor");
|
||||
return INVALID_OPERATION;
|
||||
}
|
||||
return sensor->flush(connection.get(), handle);
|
||||
|
Loading…
Reference in New Issue
Block a user