| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ | 5 #ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ |
| 6 #define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ | 6 #define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <map> | 10 #include <map> |
| 9 #include <vector> | 11 #include <vector> |
| 10 | 12 |
| 11 #include "base/bind.h" | 13 #include "base/bind.h" |
| 12 #include "base/callback.h" | 14 #include "base/callback.h" |
| 13 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 14 #include "dbus/object_path.h" | 16 #include "dbus/object_path.h" |
| 15 #include "dbus/property.h" | 17 #include "dbus/property.h" |
| 16 #include "device/bluetooth/bluetooth_export.h" | 18 #include "device/bluetooth/bluetooth_export.h" |
| 17 #include "device/bluetooth/dbus/bluetooth_agent_service_provider.h" | 19 #include "device/bluetooth/dbus/bluetooth_agent_service_provider.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // |object_path|. Set |incoming_request| to true if simulating an incoming | 135 // |object_path|. Set |incoming_request| to true if simulating an incoming |
| 134 // pairing request, false for an outgoing one. On successful completion | 136 // pairing request, false for an outgoing one. On successful completion |
| 135 // |callback| will be called, on failure, |error_callback| is called. | 137 // |callback| will be called, on failure, |error_callback| is called. |
| 136 void SimulatePairing(const dbus::ObjectPath& object_path, | 138 void SimulatePairing(const dbus::ObjectPath& object_path, |
| 137 bool incoming_request, | 139 bool incoming_request, |
| 138 const base::Closure& callback, | 140 const base::Closure& callback, |
| 139 const ErrorCallback& error_callback); | 141 const ErrorCallback& error_callback); |
| 140 | 142 |
| 141 // Updates the connection properties of the fake device that will be returned | 143 // Updates the connection properties of the fake device that will be returned |
| 142 // by GetConnInfo. | 144 // by GetConnInfo. |
| 143 void UpdateConnectionInfo(uint16 connection_rssi, | 145 void UpdateConnectionInfo(uint16_t connection_rssi, |
| 144 uint16 transmit_power, | 146 uint16_t transmit_power, |
| 145 uint16 max_transmit_power); | 147 uint16_t max_transmit_power); |
| 146 | 148 |
| 147 void set_delay_start_discovery(bool value) { delay_start_discovery_ = value; } | 149 void set_delay_start_discovery(bool value) { delay_start_discovery_ = value; } |
| 148 | 150 |
| 149 static const char kTestPinCode[]; | 151 static const char kTestPinCode[]; |
| 150 static const int kTestPassKey; | 152 static const int kTestPassKey; |
| 151 | 153 |
| 152 static const char kPairingMethodNone[]; | 154 static const char kPairingMethodNone[]; |
| 153 static const char kPairingMethodPinCode[]; | 155 static const char kPairingMethodPinCode[]; |
| 154 static const char kPairingMethodPassKey[]; | 156 static const char kPairingMethodPassKey[]; |
| 155 | 157 |
| 156 static const char kPairingActionConfirmation[]; | 158 static const char kPairingActionConfirmation[]; |
| 157 static const char kPairingActionDisplay[]; | 159 static const char kPairingActionDisplay[]; |
| 158 static const char kPairingActionFail[]; | 160 static const char kPairingActionFail[]; |
| 159 static const char kPairingActionRequest[]; | 161 static const char kPairingActionRequest[]; |
| 160 | 162 |
| 161 // Object paths, names, addresses and bluetooth classes of the devices | 163 // Object paths, names, addresses and bluetooth classes of the devices |
| 162 // we can emulate. | 164 // we can emulate. |
| 163 static const char kPairedDevicePath[]; | 165 static const char kPairedDevicePath[]; |
| 164 static const char kPairedDeviceName[]; | 166 static const char kPairedDeviceName[]; |
| 165 static const char kPairedDeviceAddress[]; | 167 static const char kPairedDeviceAddress[]; |
| 166 static const uint32 kPairedDeviceClass; | 168 static const uint32_t kPairedDeviceClass; |
| 167 | 169 |
| 168 static const char kLegacyAutopairPath[]; | 170 static const char kLegacyAutopairPath[]; |
| 169 static const char kLegacyAutopairName[]; | 171 static const char kLegacyAutopairName[]; |
| 170 static const char kLegacyAutopairAddress[]; | 172 static const char kLegacyAutopairAddress[]; |
| 171 static const uint32 kLegacyAutopairClass; | 173 static const uint32_t kLegacyAutopairClass; |
| 172 | 174 |
| 173 static const char kDisplayPinCodePath[]; | 175 static const char kDisplayPinCodePath[]; |
| 174 static const char kDisplayPinCodeName[]; | 176 static const char kDisplayPinCodeName[]; |
| 175 static const char kDisplayPinCodeAddress[]; | 177 static const char kDisplayPinCodeAddress[]; |
| 176 static const uint32 kDisplayPinCodeClass; | 178 static const uint32_t kDisplayPinCodeClass; |
| 177 | 179 |
| 178 static const char kVanishingDevicePath[]; | 180 static const char kVanishingDevicePath[]; |
| 179 static const char kVanishingDeviceName[]; | 181 static const char kVanishingDeviceName[]; |
| 180 static const char kVanishingDeviceAddress[]; | 182 static const char kVanishingDeviceAddress[]; |
| 181 static const uint32 kVanishingDeviceClass; | 183 static const uint32_t kVanishingDeviceClass; |
| 182 | 184 |
| 183 static const char kConnectUnpairablePath[]; | 185 static const char kConnectUnpairablePath[]; |
| 184 static const char kConnectUnpairableName[]; | 186 static const char kConnectUnpairableName[]; |
| 185 static const char kConnectUnpairableAddress[]; | 187 static const char kConnectUnpairableAddress[]; |
| 186 static const uint32 kConnectUnpairableClass; | 188 static const uint32_t kConnectUnpairableClass; |
| 187 | 189 |
| 188 static const char kDisplayPasskeyPath[]; | 190 static const char kDisplayPasskeyPath[]; |
| 189 static const char kDisplayPasskeyName[]; | 191 static const char kDisplayPasskeyName[]; |
| 190 static const char kDisplayPasskeyAddress[]; | 192 static const char kDisplayPasskeyAddress[]; |
| 191 static const uint32 kDisplayPasskeyClass; | 193 static const uint32_t kDisplayPasskeyClass; |
| 192 | 194 |
| 193 static const char kRequestPinCodePath[]; | 195 static const char kRequestPinCodePath[]; |
| 194 static const char kRequestPinCodeName[]; | 196 static const char kRequestPinCodeName[]; |
| 195 static const char kRequestPinCodeAddress[]; | 197 static const char kRequestPinCodeAddress[]; |
| 196 static const uint32 kRequestPinCodeClass; | 198 static const uint32_t kRequestPinCodeClass; |
| 197 | 199 |
| 198 static const char kConfirmPasskeyPath[]; | 200 static const char kConfirmPasskeyPath[]; |
| 199 static const char kConfirmPasskeyName[]; | 201 static const char kConfirmPasskeyName[]; |
| 200 static const char kConfirmPasskeyAddress[]; | 202 static const char kConfirmPasskeyAddress[]; |
| 201 static const uint32 kConfirmPasskeyClass; | 203 static const uint32_t kConfirmPasskeyClass; |
| 202 | 204 |
| 203 static const char kRequestPasskeyPath[]; | 205 static const char kRequestPasskeyPath[]; |
| 204 static const char kRequestPasskeyName[]; | 206 static const char kRequestPasskeyName[]; |
| 205 static const char kRequestPasskeyAddress[]; | 207 static const char kRequestPasskeyAddress[]; |
| 206 static const uint32 kRequestPasskeyClass; | 208 static const uint32_t kRequestPasskeyClass; |
| 207 | 209 |
| 208 static const char kUnconnectableDevicePath[]; | 210 static const char kUnconnectableDevicePath[]; |
| 209 static const char kUnconnectableDeviceName[]; | 211 static const char kUnconnectableDeviceName[]; |
| 210 static const char kUnconnectableDeviceAddress[]; | 212 static const char kUnconnectableDeviceAddress[]; |
| 211 static const uint32 kUnconnectableDeviceClass; | 213 static const uint32_t kUnconnectableDeviceClass; |
| 212 | 214 |
| 213 static const char kUnpairableDevicePath[]; | 215 static const char kUnpairableDevicePath[]; |
| 214 static const char kUnpairableDeviceName[]; | 216 static const char kUnpairableDeviceName[]; |
| 215 static const char kUnpairableDeviceAddress[]; | 217 static const char kUnpairableDeviceAddress[]; |
| 216 static const uint32 kUnpairableDeviceClass; | 218 static const uint32_t kUnpairableDeviceClass; |
| 217 | 219 |
| 218 static const char kJustWorksPath[]; | 220 static const char kJustWorksPath[]; |
| 219 static const char kJustWorksName[]; | 221 static const char kJustWorksName[]; |
| 220 static const char kJustWorksAddress[]; | 222 static const char kJustWorksAddress[]; |
| 221 static const uint32 kJustWorksClass; | 223 static const uint32_t kJustWorksClass; |
| 222 | 224 |
| 223 static const char kLowEnergyPath[]; | 225 static const char kLowEnergyPath[]; |
| 224 static const char kLowEnergyName[]; | 226 static const char kLowEnergyName[]; |
| 225 static const char kLowEnergyAddress[]; | 227 static const char kLowEnergyAddress[]; |
| 226 static const uint32 kLowEnergyClass; | 228 static const uint32_t kLowEnergyClass; |
| 227 | 229 |
| 228 static const char kPairedUnconnectableDevicePath[]; | 230 static const char kPairedUnconnectableDevicePath[]; |
| 229 static const char kPairedUnconnectableDeviceName[]; | 231 static const char kPairedUnconnectableDeviceName[]; |
| 230 static const char kPairedUnconnectableDeviceAddress[]; | 232 static const char kPairedUnconnectableDeviceAddress[]; |
| 231 static const uint32 kPairedUnconnectableDeviceClass; | 233 static const uint32_t kPairedUnconnectableDeviceClass; |
| 232 | 234 |
| 233 static const char kConnectedTrustedNotPairedDevicePath[]; | 235 static const char kConnectedTrustedNotPairedDevicePath[]; |
| 234 static const char kConnectedTrustedNotPairedDeviceAddress[]; | 236 static const char kConnectedTrustedNotPairedDeviceAddress[]; |
| 235 static const char kConnectedTrustedNotPairedDeviceName[]; | 237 static const char kConnectedTrustedNotPairedDeviceName[]; |
| 236 static const uint32 kConnectedTrustedNotPairedDeviceClass; | 238 static const uint32_t kConnectedTrustedNotPairedDeviceClass; |
| 237 | 239 |
| 238 private: | 240 private: |
| 239 // Property callback passed when we create Properties* structures. | 241 // Property callback passed when we create Properties* structures. |
| 240 void OnPropertyChanged(const dbus::ObjectPath& object_path, | 242 void OnPropertyChanged(const dbus::ObjectPath& object_path, |
| 241 const std::string& property_name); | 243 const std::string& property_name); |
| 242 | 244 |
| 243 void DiscoverySimulationTimer(); | 245 void DiscoverySimulationTimer(); |
| 244 void IncomingPairingSimulationTimer(); | 246 void IncomingPairingSimulationTimer(); |
| 245 | 247 |
| 246 void CompleteSimulatedPairing(const dbus::ObjectPath& object_path, | 248 void CompleteSimulatedPairing(const dbus::ObjectPath& object_path, |
| 247 const base::Closure& callback, | 249 const base::Closure& callback, |
| 248 const ErrorCallback& error_callback); | 250 const ErrorCallback& error_callback); |
| 249 void TimeoutSimulatedPairing(const dbus::ObjectPath& object_path, | 251 void TimeoutSimulatedPairing(const dbus::ObjectPath& object_path, |
| 250 const ErrorCallback& error_callback); | 252 const ErrorCallback& error_callback); |
| 251 void CancelSimulatedPairing(const dbus::ObjectPath& object_path, | 253 void CancelSimulatedPairing(const dbus::ObjectPath& object_path, |
| 252 const ErrorCallback& error_callback); | 254 const ErrorCallback& error_callback); |
| 253 void RejectSimulatedPairing(const dbus::ObjectPath& object_path, | 255 void RejectSimulatedPairing(const dbus::ObjectPath& object_path, |
| 254 const ErrorCallback& error_callback); | 256 const ErrorCallback& error_callback); |
| 255 void FailSimulatedPairing(const dbus::ObjectPath& object_path, | 257 void FailSimulatedPairing(const dbus::ObjectPath& object_path, |
| 256 const ErrorCallback& error_callback); | 258 const ErrorCallback& error_callback); |
| 257 void AddInputDeviceIfNeeded(const dbus::ObjectPath& object_path, | 259 void AddInputDeviceIfNeeded(const dbus::ObjectPath& object_path, |
| 258 Properties* properties); | 260 Properties* properties); |
| 259 | 261 |
| 260 // Updates the inquiry RSSI property of fake device with object path | 262 // Updates the inquiry RSSI property of fake device with object path |
| 261 // |object_path| to |rssi|, if the fake device exists. | 263 // |object_path| to |rssi|, if the fake device exists. |
| 262 void UpdateDeviceRSSI(const dbus::ObjectPath& object_path, int16 rssi); | 264 void UpdateDeviceRSSI(const dbus::ObjectPath& object_path, int16_t rssi); |
| 263 | 265 |
| 264 void PinCodeCallback(const dbus::ObjectPath& object_path, | 266 void PinCodeCallback(const dbus::ObjectPath& object_path, |
| 265 const base::Closure& callback, | 267 const base::Closure& callback, |
| 266 const ErrorCallback& error_callback, | 268 const ErrorCallback& error_callback, |
| 267 BluetoothAgentServiceProvider::Delegate::Status status, | 269 BluetoothAgentServiceProvider::Delegate::Status status, |
| 268 const std::string& pincode); | 270 const std::string& pincode); |
| 269 void PasskeyCallback(const dbus::ObjectPath& object_path, | 271 void PasskeyCallback(const dbus::ObjectPath& object_path, |
| 270 const base::Closure& callback, | 272 const base::Closure& callback, |
| 271 const ErrorCallback& error_callback, | 273 const ErrorCallback& error_callback, |
| 272 BluetoothAgentServiceProvider::Delegate::Status status, | 274 BluetoothAgentServiceProvider::Delegate::Status status, |
| 273 uint32 passkey); | 275 uint32_t passkey); |
| 274 void ConfirmationCallback( | 276 void ConfirmationCallback( |
| 275 const dbus::ObjectPath& object_path, | 277 const dbus::ObjectPath& object_path, |
| 276 const base::Closure& callback, | 278 const base::Closure& callback, |
| 277 const ErrorCallback& error_callback, | 279 const ErrorCallback& error_callback, |
| 278 BluetoothAgentServiceProvider::Delegate::Status status); | 280 BluetoothAgentServiceProvider::Delegate::Status status); |
| 279 void SimulateKeypress(uint16 entered, | 281 void SimulateKeypress(uint16_t entered, |
| 280 const dbus::ObjectPath& object_path, | 282 const dbus::ObjectPath& object_path, |
| 281 const base::Closure& callback, | 283 const base::Closure& callback, |
| 282 const ErrorCallback& error_callback); | 284 const ErrorCallback& error_callback); |
| 283 | 285 |
| 284 void ConnectionCallback( | 286 void ConnectionCallback( |
| 285 const dbus::ObjectPath& object_path, | 287 const dbus::ObjectPath& object_path, |
| 286 const base::Closure& callback, | 288 const base::Closure& callback, |
| 287 const ErrorCallback& error_callback, | 289 const ErrorCallback& error_callback, |
| 288 BluetoothProfileServiceProvider::Delegate::Status status); | 290 BluetoothProfileServiceProvider::Delegate::Status status); |
| 289 void DisconnectionCallback( | 291 void DisconnectionCallback( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 304 // be done on request. | 306 // be done on request. |
| 305 using PairingOptionsMap = | 307 using PairingOptionsMap = |
| 306 std::map<const dbus::ObjectPath, scoped_ptr<SimulatedPairingOptions>>; | 308 std::map<const dbus::ObjectPath, scoped_ptr<SimulatedPairingOptions>>; |
| 307 PairingOptionsMap pairing_options_map_; | 309 PairingOptionsMap pairing_options_map_; |
| 308 | 310 |
| 309 int simulation_interval_ms_; | 311 int simulation_interval_ms_; |
| 310 uint32_t discovery_simulation_step_; | 312 uint32_t discovery_simulation_step_; |
| 311 uint32_t incoming_pairing_simulation_step_; | 313 uint32_t incoming_pairing_simulation_step_; |
| 312 bool pairing_cancelled_; | 314 bool pairing_cancelled_; |
| 313 | 315 |
| 314 int16 connection_rssi_; | 316 int16_t connection_rssi_; |
| 315 int16 transmit_power_; | 317 int16_t transmit_power_; |
| 316 int16 max_transmit_power_; | 318 int16_t max_transmit_power_; |
| 317 | 319 |
| 318 // Controls the fake behavior to allow more extensive UI testing without | 320 // Controls the fake behavior to allow more extensive UI testing without |
| 319 // having to cycle the discovery simulation. | 321 // having to cycle the discovery simulation. |
| 320 bool delay_start_discovery_; | 322 bool delay_start_discovery_; |
| 321 }; | 323 }; |
| 322 | 324 |
| 323 } // namespace bluez | 325 } // namespace bluez |
| 324 | 326 |
| 325 #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ | 327 #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ |
| OLD | NEW |