Lines Matching refs:Sensor
27 #include <sensor/SensorEventQueue.h>
61 * - what about a gyro-corrected magnetic-field sensor?
62 * - run mag sensor from time to time to force calibration
63 * - gravity sensor length is wrong (=> drift in linear-acc sensor)
96 ALOGW("Can't generate HMAC key; dynamic sensor getId() will be wrong.");
113 ALOGW("Unable to write HMAC key; dynamic sensor getId() will change "
121 // Set main thread to SCHED_FIFO to lower sensor event latency when system is under load
224 // counts for each sensor.
227 [&batchingSupported] (const Sensor& s) -> bool {
281 const Sensor& SensorService::registerSensor(SensorInterface* s, bool isDebug, bool isVirtual) {
292 const Sensor& SensorService::registerDynamicSensorLocked(SensorInterface* s, bool isDebug) {
307 const Sensor& SensorService::registerVirtualSensor(SensorInterface* s, bool isDebug) {
341 // temporarily stop all sensor direct report
351 // connections has called flush() and the underlying sensor has been disabled before a
363 // recover all sensor direct report
399 // Default dump the sensor list and debugging information.
401 result.append("Sensor Device:\n");
404 result.append("Sensor List:\n");
410 result.append("Recent Sensor events:\n");
419 // if there is events and sensor does not need special permission.
495 int handle = buffer[i].sensor;
497 handle = buffer[i].meta_data.sensor;
501 // If this buffer has an event from a one_shot sensor and this connection is registered
502 // for this particular one_shot sensor, try cleaning up the connection.
516 // each virtual sensor could generate an event per "real" event, that's why we need to size
529 ALOGE("sensor poll failed (%s)", strerror(-count));
539 // of this loop (especially when one-shot sensor events are present in the sensor_event
548 // Poll has returned. Hold a wakelock if one of the events is from a wake up sensor. The
588 ALOGE("handle %d is not an valid virtual sensor", handle);
608 // handle backward compatibility for RotationVector sensor
621 // on the hardware sensor. mapFlushEventsToConnections[i] will be the
626 const int sensor_handle = mSensorEventBuffer[i].meta_data.sensor;
634 // handle dynamic sensor meta events, process registration and unregistration of dynamic
635 // sensor based on content of event.
640 *(mSensorEventBuffer[i].dynamic_sensor_meta.sensor);
641 ALOGI("Dynamic sensor handle 0x%x connected, type %d, name %s",
647 // make sure the dynamic sensor flag is set
654 // This will release hold on dynamic sensor meta, so it should be called
655 // after Sensor object is created.
663 ALOGI("Dynamic sensor handle 0x%x disconnected", handle);
667 ALOGE("Dynamic sensor release error.");
771 auto logger = mRecentEvent.find(buffer[i].sensor);
794 sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle);
795 return sensor != nullptr && sensor->isVirtual();
799 int handle = event.sensor;
801 handle = event.meta_data.sensor;
803 sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle);
804 return sensor != nullptr && sensor->getSensor().isWakeUpSensor();
807 int32_t SensorService::getIdFromUuid(const Sensor::uuid_t &uuid) const {
813 // This sensor can be uniquely identified in the system by
818 // We have a dynamic sensor.
822 ALOGW("HMAC key failure; dynamic sensor getId() will be wrong.");
827 // same dynamic sensor cannot be tracked across apps by multiple
848 ALOGW("HMAC failure; dynamic sensor getId() will be wrong.");
858 ALOGW("HMAC insufficient; dynamic sensor getId() will be wrong.");
868 // those as dynamic sensor IDs. If we happened to hash to one of those
869 // values, we change 'id' so we report as a dynamic sensor, and not as
879 void SensorService::makeUuidsIntoIdsForSensorList(Vector<Sensor> &sensorList) const {
880 for (auto &sensor : sensorList) {
881 int32_t id = getIdFromUuid(sensor.getUuid());
882 sensor.setId(id);
886 Vector<Sensor> SensorService::getSensorList(const String16& /* opPackageName */) {
889 const Vector<Sensor>& initialSensorList = (atoi(value)) ?
891 Vector<Sensor> accessibleSensorList;
893 Sensor sensor = initialSensorList[i];
894 accessibleSensorList.add(sensor);
900 Vector<Sensor> SensorService::getDynamicSensorList(const String16& opPackageName) {
901 Vector<Sensor> accessibleSensorList;
903 [&opPackageName, &accessibleSensorList] (const Sensor& sensor) -> bool {
904 if (sensor.isDynamicSensor()) {
905 if (canAccessSensor(sensor, "getDynamicSensorList", opPackageName)) {
906 accessibleSensorList.add(sensor);
908 ALOGI("Skipped sensor %s because it requires permission %s and app op %" PRId32,
909 sensor.getName().string(),
910 sensor.getRequiredPermission().string(),
911 sensor.getRequiredAppOp());
1035 // sensor service should never hold pointer or sp of SensorDirectConnection object.
1093 .sensor = handle,
1156 sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle);
1157 if (sensor != nullptr) {
1158 sensor->activate(c, false);
1160 ALOGE("sensor interface of handle=0x%08x is null!", handle);
1167 "removing connection %p for sensor[%zu].handle=0x%08x",
1209 sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle);
1210 if (sensor == nullptr ||
1211 !canAccessSensor(sensor->getSensor(), "Tried enabling", opPackageName)) {
1225 if (sensor->isVirtual()) {
1230 // this sensor is already activated, but we are adding a connection that uses it.
1231 // Immediately send down the last known value of the requested sensor if it's not a
1232 // "continuous" sensor.
1233 if (sensor->getSensor().getReportingMode() == AREPORTING_MODE_ON_CHANGE) {
1240 // It is unlikely that this buffer is empty as the sensor is already active.
1242 // sensor at the same time.
1244 event.sensor = handle;
1262 // the sensor was added (which means it wasn't already there)
1268 ALOGW("sensor %08x already enabled in connection %p (ignoring)",
1272 // Check maximum delay for the sensor.
1273 nsecs_t maxDelayNs = sensor->getSensor().getMaxDelay() * 1000LL;
1278 nsecs_t minDelayNs = sensor->getSensor().getMinDelayNs();
1287 status_t err = sensor->batch(connection.get(), handle, 0, samplingPeriodNs,
1290 // Call flush() before calling activate() on the sensor. Wait for a first
1294 // one should be trigger by a change in value). Also if this sensor isn't
1297 sensor->getSensor().getReportingMode() == AREPORTING_MODE_CONTINUOUS &&
1300 status_t err_flush = sensor->flush(connection.get(), handle);
1301 // Flush may return error if the underlying h/w sensor uses an older HAL.
1311 err = sensor->activate(connection.get(), true);
1337 sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle);
1338 err = sensor != nullptr ? sensor->activate(connection.get(), false) : status_t(BAD_VALUE);
1367 // see if this sensor becomes inactive
1383 sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle);
1384 if (sensor == nullptr ||
1385 !canAccessSensor(sensor->getSensor(), "Tried configuring", opPackageName)) {
1392 nsecs_t minDelayNs = sensor->getSensor().getMinDelayNs();
1397 return sensor->setDelay(connection.get(), handle, ns);
1410 sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle);
1411 if (sensor == nullptr) {
1414 if (sensor->getSensor().getReportingMode() == AREPORTING_MODE_ONE_SHOT) {
1415 ALOGE("flush called on a one-shot sensor");
1424 if (!canAccessSensor(sensor->getSensor(), "Tried flushing", opPackageName)) {
1428 status_t err_flush = sensor->flush(connection.get(), handle);
1439 bool SensorService::canAccessSensor(const Sensor& sensor, const char* operation,
1441 const String8& requiredPermission = sensor.getRequiredPermission();
1450 if (sensor.isRequiredPermissionRuntime()) {
1458 ALOGE("%s a sensor (%s) without holding its required permission: %s",
1459 operation, sensor.getName().string(), sensor.getRequiredPermission().string());
1463 const int32_t opCode = sensor.getRequiredAppOp();
1468 ALOGE("%s a sensor (%s) without enabled required app op: %d",
1469 operation, sensor.getName().string(), opCode);