Home | History | Annotate | Download | only in sensorservice

Lines Matching refs:Sensor

31 #include <sensor/SensorEventQueue.h>
67 * - what about a gyro-corrected magnetic-field sensor?
68 * - run mag sensor from time to time to force calibration
69 * - gravity sensor length is wrong (=> drift in linear-acc sensor)
104 ALOGW("Can't generate HMAC key; dynamic sensor getId() will be wrong.");
121 ALOGW("Unable to write HMAC key; dynamic sensor getId() will change "
129 // Set main thread to SCHED_FIFO to lower sensor event latency when system is under load
232 // counts for each sensor.
235 [&batchingSupported] (const Sensor& s) -> bool {
305 const Sensor& SensorService::registerSensor(SensorInterface* s, bool isDebug, bool isVirtual) {
316 const Sensor& SensorService::registerDynamicSensorLocked(SensorInterface* s, bool isDebug) {
331 const Sensor& SensorService::registerVirtualSensor(SensorInterface* s, bool isDebug) {
366 // temporarily stop all sensor direct report
376 // connections has called flush() and the underlying sensor has been disabled before a
388 // recover all sensor direct report
424 // Default dump the sensor list and debugging information.
426 result.append("Sensor Device:\n");
429 result.append("Sensor List:\n");
435 result.append("Recent Sensor events:\n");
444 // if there is events and sensor does not need special permission.
585 return dprintf(out, "Sensor service commands:\n"
596 int handle = buffer[i].sensor;
598 handle = buffer[i].meta_data.sensor;
602 // If this buffer has an event from a one_shot sensor and this connection is registered
603 // for this particular one_shot sensor, try cleaning up the connection.
617 // each virtual sensor could generate an event per "real" event, that's why we need to size
630 ALOGE("sensor poll failed (%s)", strerror(-count));
640 // of this loop (especially when one-shot sensor events are present in the sensor_event
649 // Poll has returned. Hold a wakelock if one of the events is from a wake up sensor. The
689 ALOGE("handle %d is not an valid virtual sensor", handle);
709 // handle backward compatibility for RotationVector sensor
722 // on the hardware sensor. mapFlushEventsToConnections[i] will be the
727 const int sensor_handle = mSensorEventBuffer[i].meta_data.sensor;
735 // handle dynamic sensor meta events, process registration and unregistration of dynamic
736 // sensor based on content of event.
741 *(mSensorEventBuffer[i].dynamic_sensor_meta.sensor);
742 ALOGI("Dynamic sensor handle 0x%x connected, type %d, name %s",
748 // make sure the dynamic sensor flag is set
755 // This will release hold on dynamic sensor meta, so it should be called
756 // after Sensor object is created.
764 ALOGI("Dynamic sensor handle 0x%x disconnected", handle);
768 ALOGE("Dynamic sensor release error.");
871 auto logger = mRecentEvent.find(buffer[i].sensor);
894 sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle);
895 return sensor != nullptr && sensor->isVirtual();
899 int handle = event.sensor;
901 handle = event.meta_data.sensor;
903 sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle);
904 return sensor != nullptr && sensor->getSensor().isWakeUpSensor();
907 int32_t SensorService::getIdFromUuid(const Sensor::uuid_t &uuid) const {
913 // This sensor can be uniquely identified in the system by
918 // We have a dynamic sensor.
922 ALOGW("HMAC key failure; dynamic sensor getId() will be wrong.");
927 // same dynamic sensor cannot be tracked across apps by multiple
948 ALOGW("HMAC failure; dynamic sensor getId() will be wrong.");
958 ALOGW("HMAC insufficient; dynamic sensor getId() will be wrong.");
968 // those as dynamic sensor IDs. If we happened to hash to one of those
969 // values, we change 'id' so we report as a dynamic sensor, and not as
979 void SensorService::makeUuidsIntoIdsForSensorList(Vector<Sensor> &sensorList) const {
980 for (auto &sensor : sensorList) {
981 int32_t id = getIdFromUuid(sensor.getUuid());
982 sensor.setId(id);
986 Vector<Sensor> SensorService::getSensorList(const String16& /* opPackageName */) {
989 const Vector<Sensor>& initialSensorList = (atoi(value)) ?
991 Vector<Sensor> accessibleSensorList;
993 Sensor sensor = initialSensorList[i];
994 accessibleSensorList.add(sensor);
1000 Vector<Sensor> SensorService::getDynamicSensorList(const String16& opPackageName) {
1001 Vector<Sensor> accessibleSensorList;
1003 [&opPackageName, &accessibleSensorList] (const Sensor& sensor) -> bool {
1004 if (sensor.isDynamicSensor()) {
1005 if (canAccessSensor(sensor, "getDynamicSensorList", opPackageName)) {
1006 accessibleSensorList.add(sensor);
1008 ALOGI("Skipped sensor %s because it requires permission %s and app op %" PRId32,
1009 sensor.getName().string(),
1010 sensor.getRequiredPermission().string(),
1011 sensor.getRequiredAppOp());
1141 // sensor service should never hold pointer or sp of SensorDirectConnection object.
1199 .sensor = handle,
1262 sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle);
1263 if (sensor != nullptr) {
1264 sensor->activate(c, false);
1266 ALOGE("sensor interface of handle=0x%08x is null!", handle);
1273 "removing connection %p for sensor[%zu].handle=0x%08x",
1315 sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle);
1316 if (sensor == nullptr ||
1317 !canAccessSensor(sensor->getSensor(), "Tried enabling", opPackageName)) {
1331 if (sensor->isVirtual()) {
1336 // this sensor is already activated, but we are adding a connection that uses it.
1337 // Immediately send down the last known value of the requested sensor if it's not a
1338 // "continuous" sensor.
1339 if (sensor->getSensor().getReportingMode() == AREPORTING_MODE_ON_CHANGE) {
1346 // It is unlikely that this buffer is empty as the sensor is already active.
1348 // sensor at the same time.
1350 event.sensor = handle;
1368 // the sensor was added (which means it wasn't already there)
1374 ALOGW("sensor %08x already enabled in connection %p (ignoring)",
1378 // Check maximum delay for the sensor.
1379 nsecs_t maxDelayNs = sensor->getSensor().getMaxDelay() * 1000LL;
1384 nsecs_t minDelayNs = sensor->getSensor().getMinDelayNs();
1393 status_t err = sensor->batch(connection.get(), handle, 0, samplingPeriodNs,
1396 // Call flush() before calling activate() on the sensor. Wait for a first
1400 // one should be trigger by a change in value). Also if this sensor isn't
1403 sensor->getSensor().getReportingMode() == AREPORTING_MODE_CONTINUOUS &&
1406 status_t err_flush = sensor->flush(connection.get(), handle);
1407 // Flush may return error if the underlying h/w sensor uses an older HAL.
1417 err = sensor->activate(connection.get(), true);
1443 sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle);
1444 err = sensor != nullptr ? sensor->activate(connection.get(), false) : status_t(BAD_VALUE);
1473 // see if this sensor becomes inactive
1489 sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle);
1490 if (sensor == nullptr ||
1491 !canAccessSensor(sensor->getSensor(), "Tried configuring", opPackageName)) {
1498 nsecs_t minDelayNs = sensor->getSensor().getMinDelayNs();
1503 return sensor->setDelay(connection.get(), handle, ns);
1516 sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle);
1517 if (sensor == nullptr) {
1520 if (sensor->getSensor().getReportingMode() == AREPORTING_MODE_ONE_SHOT) {
1521 ALOGE("flush called on a one-shot sensor");
1530 if (!canAccessSensor(sensor->getSensor(), "Tried flushing", opPackageName)) {
1534 status_t err_flush = sensor->flush(connection.get(), handle);
1545 bool SensorService::canAccessSensor(const Sensor& sensor, const char* operation,
1547 const String8& requiredPermission = sensor.getRequiredPermission();
1556 if (sensor.isRequiredPermissionRuntime()) {
1564 ALOGE("%s a sensor (%s) without holding its required permission: %s",
1565 operation, sensor.getName().string(), sensor.getRequiredPermission().string());
1569 const int32_t opCode = sensor.getRequiredAppOp();
1574 ALOGE("%s a sensor (%s) without enabled required app op: %d",
1575 operation, sensor.getName().string(), opCode);