int sensors_poll_context_t::activate(int handle, int enabled) { ALOGD( "activate handle =%d, enable = %d",handle, enabled ); int err=0; int index = handleToDriver(handle); // if(ID_ORIENTATION == handle) { //ALOGD( "fwq1111" ); ((AccelerationSensor*)(mSensors[accel]))->enableNoHALDataAcc(enabled); ((Hwmsen*)(mSensors[hwmsen]))->enableNoHALDataAcc(enabled); } if(NULL != mSensors[index] && index >0 ) { ALOGD( "use new sensor index=%d, mSensors[index](%x)", index, mSensors[index]); err = mSensors[index]->enable(handle, enabled); } if(err || index<0 ) { ALOGD("use old sensor err(%d),index(%d) go to old hwmsen\n",err,index); // notify to hwmsen sensor to support old architecture err = mSensors[hwmsen]->enable(handle, enabled); } if (enabled && !err) { const char wakeMessage(WAKE_MESSAGE); int result = write(mWritePipeFd, &wakeMessage, 1); ALOGE_IF(result<0, "error sending wake message (%s)", strerror(errno)); } return err; }
int sensors_poll_context_t::setDelay(int handle, int64_t ns) { // LOGE("trm nusensor: sensors_poll_context_t, setDelay "); int index = handleToDriver(handle); if (index < 0) return index; return mSensors[index]->setDelay(handle, ns); }
int sensors_proxy_open_dev(SensorsProxy* proxy,int32_t handle) { int index = handleToDriver(handle); if(index==-EINVAL) return -1; return sensor_open_dev(proxy->mSensors[index]); }
//设定传感器的延迟值 int sensors_poll_context_t::setDelay(int handle, int64_t ns){ //获取当前传感器类型索引 int index = handleToDriver(handle); //判断获取到的的索引是合法,不在则直接返回该索引 if (index < 0) return index; //使用当前传感器对应的setDelay函数来设置当前传感器的延迟 return mSensors[index]->setDelay(handle, ns); }
int sensors_poll_context_t::setDelay(int handle, int64_t ns) { int index = handleToDriver(handle); if (index < 0) { return index; } return mSensors[index]->setDelay(handle, ns); }
int sensors_proxy_enable(SensorsProxy* proxy,int32_t handle, int enable) { int index = handleToDriver(handle); #if SENSORS_DEBUG LOGD("sensors_proxy_enable handle=%d, enable=%d",handle,enable); #endif if(index==-EINVAL) return -1; return sensor_enable(proxy->mSensors[index],handle,enable); }
int sensors_poll_context_t::activate(int handle, int enabled) { int index = handleToDriver(handle); if (index < 0) return index; int err = mSensors[index]->enable(handle, enabled); if (enabled && !err) { const char wakeMessage(WAKE_MESSAGE); int result = write(mWritePipeFd, &wakeMessage, 1); LOGE_IF(result<0, "error sending wake message (%s)", strerror(errno)); } return err; }
int sensors_poll_context_t::activate(int handle, int enabled) { int index = handleToDriver(handle); if (index < 0) return index; int err = mSensors[index]->enable(handle, enabled); if (!err && handle == ID_O) { err = static_cast<AccelerationSensor*>( mSensors[acceleration])->enableOrientation(enabled); } if (enabled && !err) { const char wakeMessage(WAKE_MESSAGE); int result = write(mWritePipeFd, &wakeMessage, 1); ALOGE_IF(result<0, "error sending wake message (%s)", strerror(errno)); } return err; }
//激活传感器 int sensors_poll_context_t::activate(int handle, int enabled){ //获取当前传感器类型索引 int index = handleToDriver(handle); //判断获取到的的索引是合法,不在则直接返回该索引 if (index < 0) return index; //使用当前传感器对应的enable函数来启用当前传感器 int err = mSensors[index]->enable(handle, enabled); //如果是要求不启用或启用不成功则提示发送唤醒消息失败 if (enabled && !err) { const char wakeMessage(WAKE_MESSAGE); int result = write(mWritePipeFd, &wakeMessage, 1); LOGE_IF(result<0, "error sending wake message (%s)", strerror(errno)); } //返回启用的操作结果 return err; }
int sensors_poll_context_t::activate(int handle, int enabled) { int index = handleToDriver(handle); if (index < 0) return index; #if defined(CALIBRATION_SUPPORT) if((index == mma) && enabled) { sensor_get_calibration_from_vendor1(); } #endif int err = mSensors[index]->enable(handle, enabled); if (enabled && !err) { const char wakeMessage(WAKE_MESSAGE); int result = write(mWritePipeFd, &wakeMessage, 1); LOGE_IF(result<0, "error sending wake message (%s)", strerror(errno)); } return err; }
int sensors_poll_context_t::setDelay(int handle, int64_t ns) { int err =0; int index = handleToDriver(handle); if(NULL != mSensors[index] && index >0) { err = mSensors[index]->setDelay(handle, ns); } if(err || index<0) { ALOGE("new acc setDelay handle(%d),ns(%lld) err! go to hwmsen\n",handle,ns); // notify to hwmsen sensor to support old architecture err = mSensors[hwmsen]->setDelay(handle, ns); } return err; }