Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: device/generic_sensor/linux/sensor_data_linux.cc

Issue 2480773002: Reland of [sensors] Ambient light sensor implementation for ChromeOS and Linux. (Closed)
Patch Set: fix for reland Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/generic_sensor/linux/sensor_data_linux.cc
diff --git a/device/generic_sensor/linux/sensor_data_linux.cc b/device/generic_sensor/linux/sensor_data_linux.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4a32e6961485cf2e2dda9e90f2b5e4ca456c1e53
--- /dev/null
+++ b/device/generic_sensor/linux/sensor_data_linux.cc
@@ -0,0 +1,52 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "device/generic_sensor/linux/sensor_data_linux.h"
+#include "device/sensors/public/cpp/device_sensors_consts.h"
+
+namespace device {
+
+namespace {
+
+using mojom::SensorType;
+
+const base::FilePath::CharType* kSensorsBasePath =
+ FILE_PATH_LITERAL("/sys/bus/iio/devices");
+
+void InitAmbientLightSensorData(SensorDataLinux* data) {
+ std::vector<std::string> file_names(
+ {"in_illuminance0_input", "in_illuminance_input", "in_illuminance0_raw",
+ "in_illuminance_raw"});
Reilly Grant (use Gerrit) 2016/11/04 17:00:12 The parenthesis here are unnecessary.
+
+ data->sensor_file_names.push_back(std::move(file_names));
+ data->reporting_mode = mojom::ReportingMode::ON_CHANGE;
+ data->default_configuration =
+ PlatformSensorConfiguration(kDefaultAmbientLightFrequencyHz);
+}
+
+} // namespace
+
+SensorDataLinux::SensorDataLinux() : base_path_sensor_linux(kSensorsBasePath) {}
+
+SensorDataLinux::~SensorDataLinux() = default;
+
+SensorDataLinux::SensorDataLinux(const SensorDataLinux& other) = default;
+
+bool InitSensorData(SensorType type, SensorDataLinux* data) {
+ DCHECK(data);
+
+ switch (type) {
+ case SensorType::AMBIENT_LIGHT: {
+ InitAmbientLightSensorData(data);
+ break;
+ }
+ default: {
+ NOTIMPLEMENTED();
+ return false;
+ }
+ }
+ return true;
+}
+
+} // namespace device
« no previous file with comments | « device/generic_sensor/linux/sensor_data_linux.h ('k') | device/generic_sensor/linux/sensor_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698