4 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #include "sensor_event_handler.h"
22 #include <sensor_log.h>
23 #include <sensor_utils.h>
26 using namespace sensor;
28 static std::vector<uint32_t> ids;
30 sensor_event_handler::sensor_event_handler(physical_sensor_handler *sensor)
35 bool sensor_event_handler::handle(int fd, ipc::event_condition condition)
42 if (m_sensor->read_fd(ids) < 0)
45 auto result = std::find(std::begin(ids), std::end(ids), m_sensor->get_hal_id());
47 if (result == std::end(ids))
51 remains = m_sensor->get_data(&data, &length);
53 _E("Failed to get sensor data");
57 if (m_sensor->on_event(data, length, remains) < 0) {
62 info = m_sensor->get_sensor_info();
64 //_I("[Data] allocate %p", data);
65 if (m_sensor->notify(info.get_uri().c_str(), data, length) < 0) {