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

Side by Side Diff: device/generic_sensor/platform_sensor.cc

Issue 2284613002: [sensors] Android platform adaptation for Generic Sensor API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to master. Created 4 years, 3 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/generic_sensor/platform_sensor.h" 5 #include "device/generic_sensor/platform_sensor.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "device/generic_sensor/platform_sensor_provider.h" 9 #include "device/generic_sensor/platform_sensor_provider.h"
10 #include "device/generic_sensor/public/cpp/platform_sensor_configuration.h" 10 #include "device/generic_sensor/public/cpp/platform_sensor_configuration.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 while ((client = it.GetNext()) != nullptr) { 87 while ((client = it.GetNext()) != nullptr) {
88 if (!client->IsNotificationSuspended()) 88 if (!client->IsNotificationSuspended())
89 client->OnSensorReadingChanged(); 89 client->OnSensorReadingChanged();
90 } 90 }
91 } 91 }
92 92
93 void PlatformSensor::NotifySensorError() { 93 void PlatformSensor::NotifySensorError() {
94 FOR_EACH_OBSERVER(Client, clients_, OnSensorError()); 94 FOR_EACH_OBSERVER(Client, clients_, OnSensorError());
95 } 95 }
96 96
97 bool PlatformSensor::UpdateSensorInternal(const ConfigMap& configurations) {
98 const PlatformSensorConfiguration* optimal_configuration = nullptr;
99 for (const auto& pair : configurations) {
100 if (pair.first->IsNotificationSuspended())
101 continue;
102
103 const auto& conf_list = pair.second;
104 for (const auto& configuration : conf_list) {
105 if (!optimal_configuration || configuration > *optimal_configuration) {
106 optimal_configuration = &configuration;
107 }
108 }
109 }
110
111 if (!optimal_configuration) {
112 StopSensor();
113 return true;
114 }
115
116 return StartSensor(*optimal_configuration);
117 }
118
97 } // namespace device 119 } // namespace device
OLDNEW
« no previous file with comments | « device/generic_sensor/platform_sensor.h ('k') | device/generic_sensor/platform_sensor_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698