OLD | NEW |
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 "services/device/device_service.h" | 5 #include "services/device/device_service.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/feature_list.h" |
10 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
12 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
13 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
14 #include "device/battery/battery_monitor.mojom.h" | 15 #include "device/battery/battery_monitor.mojom.h" |
15 #include "device/battery/battery_monitor_impl.h" | 16 #include "device/battery/battery_monitor_impl.h" |
16 #include "device/battery/battery_status_service.h" | 17 #include "device/battery/battery_status_service.h" |
| 18 #include "device/generic_sensor/sensor_provider_impl.h" |
17 #include "device/sensors/device_sensor_host.h" | 19 #include "device/sensors/device_sensor_host.h" |
18 #include "device/wake_lock/wake_lock_context_provider.h" | 20 #include "device/wake_lock/wake_lock_context_provider.h" |
19 #include "mojo/public/cpp/system/message_pipe.h" | 21 #include "mojo/public/cpp/system/message_pipe.h" |
20 #include "services/device/fingerprint/fingerprint.h" | 22 #include "services/device/fingerprint/fingerprint.h" |
21 #include "services/device/power_monitor/power_monitor_message_broadcaster.h" | 23 #include "services/device/power_monitor/power_monitor_message_broadcaster.h" |
| 24 #include "services/device/public/cpp/device_features.h" |
22 #include "services/device/time_zone_monitor/time_zone_monitor.h" | 25 #include "services/device/time_zone_monitor/time_zone_monitor.h" |
23 #include "services/service_manager/public/cpp/connection.h" | 26 #include "services/service_manager/public/cpp/connection.h" |
24 #include "services/service_manager/public/cpp/interface_registry.h" | 27 #include "services/service_manager/public/cpp/interface_registry.h" |
25 #include "services/service_manager/public/cpp/service_info.h" | 28 #include "services/service_manager/public/cpp/service_info.h" |
26 #include "ui/gfx/native_widget_types.h" | 29 #include "ui/gfx/native_widget_types.h" |
27 | 30 |
28 #if defined(OS_ANDROID) | 31 #if defined(OS_ANDROID) |
29 #include "base/android/context_utils.h" | 32 #include "base/android/context_utils.h" |
30 #include "base/android/jni_android.h" | 33 #include "base/android/jni_android.h" |
31 #include "jni/InterfaceRegistrar_jni.h" | 34 #include "jni/InterfaceRegistrar_jni.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 87 } |
85 | 88 |
86 void DeviceService::OnStart() { | 89 void DeviceService::OnStart() { |
87 registry_.AddInterface<mojom::Fingerprint>(this); | 90 registry_.AddInterface<mojom::Fingerprint>(this); |
88 registry_.AddInterface<mojom::LightSensor>(this); | 91 registry_.AddInterface<mojom::LightSensor>(this); |
89 registry_.AddInterface<mojom::MotionSensor>(this); | 92 registry_.AddInterface<mojom::MotionSensor>(this); |
90 registry_.AddInterface<mojom::OrientationSensor>(this); | 93 registry_.AddInterface<mojom::OrientationSensor>(this); |
91 registry_.AddInterface<mojom::OrientationAbsoluteSensor>(this); | 94 registry_.AddInterface<mojom::OrientationAbsoluteSensor>(this); |
92 registry_.AddInterface<mojom::PowerMonitor>(this); | 95 registry_.AddInterface<mojom::PowerMonitor>(this); |
93 registry_.AddInterface<mojom::ScreenOrientationListener>(this); | 96 registry_.AddInterface<mojom::ScreenOrientationListener>(this); |
| 97 if (base::FeatureList::IsEnabled(features::kGenericSensor)) { |
| 98 registry_.AddInterface<mojom::SensorProvider>(this); |
| 99 } |
94 registry_.AddInterface<mojom::TimeZoneMonitor>(this); | 100 registry_.AddInterface<mojom::TimeZoneMonitor>(this); |
95 registry_.AddInterface<mojom::WakeLockContextProvider>(this); | 101 registry_.AddInterface<mojom::WakeLockContextProvider>(this); |
96 | 102 |
97 #if defined(OS_ANDROID) | 103 #if defined(OS_ANDROID) |
98 registry_.AddInterface(GetJavaInterfaceProvider() | 104 registry_.AddInterface(GetJavaInterfaceProvider() |
99 ->CreateInterfaceFactory<mojom::BatteryMonitor>()); | 105 ->CreateInterfaceFactory<mojom::BatteryMonitor>()); |
100 registry_.AddInterface( | 106 registry_.AddInterface( |
101 GetJavaInterfaceProvider() | 107 GetJavaInterfaceProvider() |
102 ->CreateInterfaceFactory<mojom::VibrationManager>()); | 108 ->CreateInterfaceFactory<mojom::VibrationManager>()); |
103 #else | 109 #else |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 #if defined(OS_ANDROID) | 217 #if defined(OS_ANDROID) |
212 if (io_task_runner_) { | 218 if (io_task_runner_) { |
213 io_task_runner_->PostTask( | 219 io_task_runner_->PostTask( |
214 FROM_HERE, base::Bind(&ScreenOrientationListenerAndroid::Create, | 220 FROM_HERE, base::Bind(&ScreenOrientationListenerAndroid::Create, |
215 base::Passed(&request))); | 221 base::Passed(&request))); |
216 } | 222 } |
217 #endif | 223 #endif |
218 } | 224 } |
219 | 225 |
220 void DeviceService::Create(const service_manager::Identity& remote_identity, | 226 void DeviceService::Create(const service_manager::Identity& remote_identity, |
| 227 mojom::SensorProviderRequest request) { |
| 228 if (io_task_runner_) { |
| 229 io_task_runner_->PostTask( |
| 230 FROM_HERE, base::Bind(&device::SensorProviderImpl::Create, |
| 231 file_task_runner_, base::Passed(&request))); |
| 232 } |
| 233 } |
| 234 |
| 235 void DeviceService::Create(const service_manager::Identity& remote_identity, |
221 mojom::TimeZoneMonitorRequest request) { | 236 mojom::TimeZoneMonitorRequest request) { |
222 if (!time_zone_monitor_) | 237 if (!time_zone_monitor_) |
223 time_zone_monitor_ = TimeZoneMonitor::Create(file_task_runner_); | 238 time_zone_monitor_ = TimeZoneMonitor::Create(file_task_runner_); |
224 time_zone_monitor_->Bind(std::move(request)); | 239 time_zone_monitor_->Bind(std::move(request)); |
225 } | 240 } |
226 | 241 |
227 void DeviceService::Create(const service_manager::Identity& remote_identity, | 242 void DeviceService::Create(const service_manager::Identity& remote_identity, |
228 mojom::WakeLockContextProviderRequest request) { | 243 mojom::WakeLockContextProviderRequest request) { |
229 WakeLockContextProvider::Create(std::move(request), file_task_runner_, | 244 WakeLockContextProvider::Create(std::move(request), file_task_runner_, |
230 wake_lock_context_callback_); | 245 wake_lock_context_callback_); |
(...skipping 10 matching lines...) Expand all Loading... |
241 java_interface_provider_.Bind(std::move(provider)); | 256 java_interface_provider_.Bind(std::move(provider)); |
242 | 257 |
243 java_interface_provider_initialized_ = true; | 258 java_interface_provider_initialized_ = true; |
244 } | 259 } |
245 | 260 |
246 return &java_interface_provider_; | 261 return &java_interface_provider_; |
247 } | 262 } |
248 #endif | 263 #endif |
249 | 264 |
250 } // namespace device | 265 } // namespace device |
OLD | NEW |