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

Commit 776a2789 authored by Aravind Akella's avatar Aravind Akella Committed by Android Git Automerger
Browse files

am 8f3b7ce8: Merge "Sensor related changes for NDK." into lmp-dev

* commit '8f3b7ce8':
  Sensor related changes for NDK.
parents 4b311c51 8f3b7ce8
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -210,10 +210,17 @@ int ASensorManager_getSensorList(ASensorManager* manager, ASensorList* list);

/*
 * Returns the default sensor for the given type, or NULL if no sensor
 * of that type exist.
 * of that type exists.
 */
ASensor const* ASensorManager_getDefaultSensor(ASensorManager* manager, int type);

/*
 * Returns the default sensor with the given type and wakeUp properties or NULL if no sensor
 * of this type and wakeUp properties exists.
 */
ASensor const* ASensorManager_getDefaultSensorEx(ASensorManager* manager, int type,
        bool wakeUp);

/*
 * Creates a new sensor event queue and associate it with a looper.
 */
@@ -321,6 +328,11 @@ const char* ASensor_getStringType(ASensor const* sensor);
 */
int ASensor_getReportingMode(ASensor const* sensor);

/*
 * Returns true if this is a wake up sensor, false otherwise.
 */
bool ASensor_isWakeUpSensor(ASensor const* sensor);

#ifdef __cplusplus
};
#endif
+12 −1
Original line number Diff line number Diff line
@@ -116,14 +116,25 @@ Sensor const* SensorManager::getDefaultSensor(int type)
{
    Mutex::Autolock _l(mLock);
    if (assertStateLocked() == NO_ERROR) {
        bool wakeUpSensor = false;
        // For the following sensor types, return a wake-up sensor. These types are by default
        // defined as wake-up sensors. For the rest of the sensor types defined in sensors.h return
        // a non_wake-up version.
        if (type == SENSOR_TYPE_PROXIMITY || type == SENSOR_TYPE_SIGNIFICANT_MOTION ||
            type == SENSOR_TYPE_TILT_DETECTOR || type == SENSOR_TYPE_WAKE_GESTURE ||
            type == SENSOR_TYPE_GLANCE_GESTURE || type == SENSOR_TYPE_PICK_UP_GESTURE) {
            wakeUpSensor = true;
        }
        // For now we just return the first sensor of that type we find.
        // in the future it will make sense to let the SensorService make
        // that decision.
        for (size_t i=0 ; i<mSensors.size() ; i++) {
            if (mSensorList[i]->getType() == type)
            if (mSensorList[i]->getType() == type &&
                mSensorList[i]->isWakeUpSensor() == wakeUpSensor) {
                return mSensorList[i];
            }
        }
    }
    return NULL;
}