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
diff --git a/sensors/2.0/default/Sensors.cpp b/sensors/2.0/default/Sensors.cpp
index 9fea647..29721fa 100644
--- a/sensors/2.0/default/Sensors.cpp
+++ b/sensors/2.0/default/Sensors.cpp
@@ -16,6 +16,7 @@
 
 #include "Sensors.h"
 
+#include <android/hardware/sensors/2.0/types.h>
 #include <log/log.h>
 
 namespace android {
@@ -37,8 +38,15 @@
 }
 
 // Methods from ::android::hardware::sensors::V2_0::ISensors follow.
-Return<void> Sensors::getSensorsList(getSensorsList_cb /* _hidl_cb */) {
-    // TODO implement
+Return<void> Sensors::getSensorsList(getSensorsList_cb _hidl_cb) {
+    std::vector<SensorInfo> sensors;
+    for (const auto& sensor : mSensors) {
+        sensors.push_back(sensor.second->getSensorInfo());
+    }
+
+    // Call the HIDL callback with the SensorInfo
+    _hidl_cb(sensors);
+
     return Void();
 }
 
@@ -47,9 +55,13 @@
     return Result{};
 }
 
-Return<Result> Sensors::activate(int32_t /* sensorHandle */, bool /* enabled */) {
-    // TODO implement
-    return Result{};
+Return<Result> Sensors::activate(int32_t sensorHandle, bool enabled) {
+    auto sensor = mSensors.find(sensorHandle);
+    if (sensor != mSensors.end()) {
+        sensor->second->activate(enabled);
+        return Result::OK;
+    }
+    return Result::BAD_VALUE;
 }
 
 Return<Result> Sensors::initialize(
@@ -86,10 +98,14 @@
     return result;
 }
 
-Return<Result> Sensors::batch(int32_t /* sensorHandle */, int64_t /* samplingPeriodNs */,
+Return<Result> Sensors::batch(int32_t sensorHandle, int64_t samplingPeriodNs,
                               int64_t /* maxReportLatencyNs */) {
-    // TODO implement
-    return Result{};
+    Result result = Result::BAD_VALUE;
+    auto sensor = mSensors.find(sensorHandle);
+    if (sensor != mSensors.end() && sensor->second->batch(samplingPeriodNs)) {
+        result = Result::OK;
+    }
+    return result;
 }
 
 Return<Result> Sensors::flush(int32_t /* sensorHandle */) {