예제 #1
0
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;
}
예제 #2
0
bool SensorManager::isDataInjectionEnabled() {
    Mutex::Autolock _l(mLock);
    if (assertStateLocked() == NO_ERROR) {
        return mSensorServer->isDataInjectionEnabled();
    }
    return false;
}
예제 #3
0
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());
}
예제 #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;
}
예제 #5
0
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;
}
예제 #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;
}
예제 #7
0
SensorManager::SensorManager(const String16& opPackageName)
    : mSensorList(0), mOpPackageName(opPackageName)
{
    // okay we're not locked here, but it's not needed during construction
    assertStateLocked();
}
예제 #8
0
GuiExtClientProducer::GuiExtClientProducer()
{
    assertStateLocked();
}