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 &&
                mSensorList[i]->isWakeUpSensor() == wakeUpSensor) {
                return mSensorList[i];
            }
        }
    }
    return NULL;
}
bool SensorManager::isDataInjectionEnabled() {
    Mutex::Autolock _l(mLock);
    if (assertStateLocked() == NO_ERROR) {
        return mSensorServer->isDataInjectionEnabled();
    }
    return false;
}
ssize_t SensorManager::getSensorList(Sensor const* const** list) const
{
    Mutex::Autolock _l(mLock);
    status_t err = assertStateLocked();
    if (err < 0) {
        return static_cast<ssize_t>(err);
    }
    *list = mSensorList;
    return static_cast<ssize_t>(mSensors.size());
}
Example #4
0
status_t GuiExtClientProducer::free(uint32_t poolId)
{
    status_t err;
    Mutex::Autolock _l(mLock);
    err = assertStateLocked();
    if (err != NO_ERROR) {
        GUIEXT_LOGE("[%s] assertStateLocked fail", __func__);
        return err;
    }

    GUIEXT_LOGV("free +, poolId=%d", poolId);
    err = mGuiExtService->free(poolId);
    GUIEXT_LOGV("free -, poolId=%d, ret=%d", poolId, err);

    return err;
}
sp<SensorEventQueue> SensorManager::createEventQueue(String8 packageName, int mode) {
    sp<SensorEventQueue> queue;

    Mutex::Autolock _l(mLock);
    while (assertStateLocked() == NO_ERROR) {
        sp<ISensorEventConnection> connection =
                mSensorServer->createSensorEventConnection(packageName, mode, mOpPackageName);
        if (connection == NULL) {
            // SensorService just died or the app doesn't have required permissions.
            ALOGE("createEventQueue: connection is NULL.");
            return NULL;
        }
        queue = new SensorEventQueue(connection);
        break;
    }
    return queue;
}
Example #6
0
status_t GuiExtClientProducer::alloc(uint32_t gralloc_usage, uint32_t w, uint32_t h, uint32_t *poolId)
{
    status_t err;
    Mutex::Autolock _l(mLock);
    err = assertStateLocked();
    if (err != NO_ERROR) {
        GUIEXT_LOGE("[%s] assertStateLocked fail", __func__);
        return err;
    }

    GUIEXT_LOGV("alloc +, gralloc_usage=%x, w=%d, h=%d", gralloc_usage, w, h);
    static sp<BBinder> sLife = new BBinder();
    err = mGuiExtService->alloc(sLife, gralloc_usage, w, h, poolId);
    GUIEXT_LOGV("alloc -, poolId=%d", *poolId);

    return err;
}
SensorManager::SensorManager(const String16& opPackageName)
    : mSensorList(0), mOpPackageName(opPackageName)
{
    // okay we're not locked here, but it's not needed during construction
    assertStateLocked();
}
Example #8
0
GuiExtClientProducer::GuiExtClientProducer()
{
    assertStateLocked();
}