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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
12 #include "device/battery/battery_monitor.mojom.h" | 12 #include "device/battery/battery_monitor.mojom.h" |
13 #include "device/battery/battery_monitor_impl.h" | 13 #include "device/battery/battery_monitor_impl.h" |
14 #include "device/battery/battery_status_service.h" | 14 #include "device/battery/battery_status_service.h" |
15 #include "device/sensors/device_sensor_host.h" | 15 #include "device/sensors/device_sensor_host.h" |
16 #include "mojo/public/cpp/system/message_pipe.h" | 16 #include "mojo/public/cpp/system/message_pipe.h" |
17 #include "services/device/fingerprint/fingerprint.h" | 17 #include "services/device/fingerprint/fingerprint.h" |
18 #include "services/device/power_monitor/power_monitor_message_broadcaster.h" | 18 #include "services/device/power_monitor/power_monitor_message_broadcaster.h" |
19 #include "services/device/time_zone_monitor/time_zone_monitor.h" | 19 #include "services/device/time_zone_monitor/time_zone_monitor.h" |
20 #include "services/service_manager/public/cpp/connection.h" | 20 #include "services/service_manager/public/cpp/connection.h" |
21 #include "services/service_manager/public/cpp/interface_registry.h" | 21 #include "services/service_manager/public/cpp/interface_registry.h" |
22 | 22 |
23 #if defined(OS_ANDROID) | 23 #if defined(OS_ANDROID) |
24 #include "base/android/context_utils.h" | 24 #include "base/android/context_utils.h" |
25 #include "base/android/jni_android.h" | 25 #include "base/android/jni_android.h" |
26 #include "jni/InterfaceRegistrar_jni.h" | 26 #include "jni/InterfaceRegistrar_jni.h" |
27 #include "services/device/android/register_jni.h" | 27 #include "services/device/android/register_jni.h" |
28 #include "services/device/screen_orientation/screen_orientation_listener_android
.h" | 28 #include "services/device/screen_orientation/screen_orientation_listener_android
.h" |
| 29 #else |
| 30 #include "device/vibration/vibration_manager_impl.h" |
29 #endif | 31 #endif |
30 | 32 |
31 namespace device { | 33 namespace device { |
32 | 34 |
33 std::unique_ptr<service_manager::Service> CreateDeviceService( | 35 std::unique_ptr<service_manager::Service> CreateDeviceService( |
34 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner, | 36 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner, |
35 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) { | 37 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) { |
36 #if defined(OS_ANDROID) | 38 #if defined(OS_ANDROID) |
37 if (!EnsureJniRegistered()) { | 39 if (!EnsureJniRegistered()) { |
38 DLOG(ERROR) << "Failed to register JNI for Device Service"; | 40 DLOG(ERROR) << "Failed to register JNI for Device Service"; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 registry->AddInterface<mojom::MotionSensor>(this); | 72 registry->AddInterface<mojom::MotionSensor>(this); |
71 registry->AddInterface<mojom::OrientationSensor>(this); | 73 registry->AddInterface<mojom::OrientationSensor>(this); |
72 registry->AddInterface<mojom::OrientationAbsoluteSensor>(this); | 74 registry->AddInterface<mojom::OrientationAbsoluteSensor>(this); |
73 registry->AddInterface<mojom::PowerMonitor>(this); | 75 registry->AddInterface<mojom::PowerMonitor>(this); |
74 registry->AddInterface<mojom::ScreenOrientationListener>(this); | 76 registry->AddInterface<mojom::ScreenOrientationListener>(this); |
75 registry->AddInterface<mojom::TimeZoneMonitor>(this); | 77 registry->AddInterface<mojom::TimeZoneMonitor>(this); |
76 | 78 |
77 #if defined(OS_ANDROID) | 79 #if defined(OS_ANDROID) |
78 registry->AddInterface( | 80 registry->AddInterface( |
79 GetJavaInterfaceProvider()->CreateInterfaceFactory<BatteryMonitor>()); | 81 GetJavaInterfaceProvider()->CreateInterfaceFactory<BatteryMonitor>()); |
| 82 registry->AddInterface( |
| 83 GetJavaInterfaceProvider() |
| 84 ->CreateInterfaceFactory<mojom::VibrationManager>()); |
80 #else | 85 #else |
81 registry->AddInterface<BatteryMonitor>(this); | 86 registry->AddInterface<BatteryMonitor>(this); |
| 87 registry->AddInterface<mojom::VibrationManager>(this); |
82 #endif | 88 #endif |
83 | 89 |
84 return true; | 90 return true; |
85 } | 91 } |
86 | 92 |
87 #if !defined(OS_ANDROID) | 93 #if !defined(OS_ANDROID) |
88 void DeviceService::Create(const service_manager::Identity& remote_identity, | 94 void DeviceService::Create(const service_manager::Identity& remote_identity, |
89 BatteryMonitorRequest request) { | 95 BatteryMonitorRequest request) { |
90 device::BatteryMonitorImpl::Create(std::move(request)); | 96 device::BatteryMonitorImpl::Create(std::move(request)); |
91 } | 97 } |
| 98 |
| 99 void DeviceService::Create(const service_manager::Identity& remote_identity, |
| 100 mojom::VibrationManagerRequest request) { |
| 101 VibrationManagerImpl::Create(std::move(request)); |
| 102 } |
92 #endif | 103 #endif |
93 | 104 |
94 void DeviceService::Create(const service_manager::Identity& remote_identity, | 105 void DeviceService::Create(const service_manager::Identity& remote_identity, |
95 mojom::FingerprintRequest request) { | 106 mojom::FingerprintRequest request) { |
96 Fingerprint::Create(std::move(request)); | 107 Fingerprint::Create(std::move(request)); |
97 } | 108 } |
98 | 109 |
99 void DeviceService::Create(const service_manager::Identity& remote_identity, | 110 void DeviceService::Create(const service_manager::Identity& remote_identity, |
100 mojom::LightSensorRequest request) { | 111 mojom::LightSensorRequest request) { |
101 #if defined(OS_ANDROID) | 112 #if defined(OS_ANDROID) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 java_interface_provider_.Bind(std::move(provider)); | 211 java_interface_provider_.Bind(std::move(provider)); |
201 | 212 |
202 java_interface_provider_initialized_ = true; | 213 java_interface_provider_initialized_ = true; |
203 } | 214 } |
204 | 215 |
205 return &java_interface_provider_; | 216 return &java_interface_provider_; |
206 } | 217 } |
207 #endif | 218 #endif |
208 | 219 |
209 } // namespace device | 220 } // namespace device |
OLD | NEW |