summaryrefslogtreecommitdiff
path: root/sensors/2.0/default/Sensor.cpp
diff options
context:
space:
mode:
authorBrian Stack <bstack@google.com>2018-10-23 10:38:03 -0700
committerBrian Stack <bstack@google.com>2018-10-24 16:33:26 -0700
commit897528dd53b19da07e35959102defc7e5e1e546c (patch)
treed3a7326377fa2818c734f8b6ad4c0126546722e2 /sensors/2.0/default/Sensor.cpp
parent9a407f23a6134185c5f720a04dd19b33cf7edab1 (diff)
Implement activate and batch functions
Implements the activate and batch functions for the default Sensors 2.0 implementation. Bug: 111070257 Test: Builds Change-Id: I5987ab722cdd97c7cd7ff466d6d989794171b851
Diffstat (limited to 'sensors/2.0/default/Sensor.cpp')
-rw-r--r--sensors/2.0/default/Sensor.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/sensors/2.0/default/Sensor.cpp b/sensors/2.0/default/Sensor.cpp
new file mode 100644
index 0000000000..f4c9b57520
--- /dev/null
+++ b/sensors/2.0/default/Sensor.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Sensor.h"
+
+namespace android {
+namespace hardware {
+namespace sensors {
+namespace V2_0 {
+namespace implementation {
+
+Sensor::Sensor() : mIsEnabled(false), mSamplingPeriodNs(0) {}
+
+const SensorInfo& Sensor::getSensorInfo() const {
+ return mSensorInfo;
+}
+
+bool Sensor::batch(int32_t samplingPeriodNs) {
+ bool success = true;
+ if (samplingPeriodNs >= mSensorInfo.minDelay * 1000 &&
+ samplingPeriodNs <= mSensorInfo.maxDelay * 1000) {
+ mSamplingPeriodNs = samplingPeriodNs;
+ } else {
+ success = false;
+ }
+ return success;
+}
+
+void Sensor::activate(bool enable) {
+ mIsEnabled = enable;
+}
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace sensors
+} // namespace hardware
+} // namespace android \ No newline at end of file