2 * Copyright (C) 2008 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <sys/select.h>
26 #include <cutils/log.h>
28 #include <linux/input.h>
30 #include "SensorBase.h"
32 int64_t SensorBase::getTimestamp()
35 t.tv_sec = t.tv_nsec = 0;
36 clock_gettime(CLOCK_MONOTONIC, &t);
37 return int64_t(t.tv_sec)*1000000000LL + t.tv_nsec;
40 int SensorBase::open()
43 ALOGE("mDevPath is not set");
46 mFd = ::open(mDevPath.c_str(), O_RDONLY);
47 ALOGE_IF(mFd < 0, "%s: device %s err:%d", __func__, mDevPath.c_str(), -errno);
48 ALOGV("%s: device path:%s, fd:%d", __func__, mDevPath.c_str(), mFd);
52 void SensorBase::close()
54 int ret = ::close(mFd);
56 ALOGV("%s: device path:%s, fd:%d", __func__, mDevPath.c_str(), mFd);