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

Unified Diff: chromeos/dbus/fake_bluetooth_device_client.cc

Issue 14048007: Bluetooth: D-Bus client interface for org.bluez.Input1 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: interface deletion order fixed. Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/dbus/fake_bluetooth_device_client.h ('k') | chromeos/dbus/fake_bluetooth_input_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/fake_bluetooth_device_client.cc
diff --git a/chromeos/dbus/fake_bluetooth_device_client.cc b/chromeos/dbus/fake_bluetooth_device_client.cc
index 00c8df4009832f704516736a16d4ff1a7a82996d..46d4ae3fc935722e48eccbc00893679908963967 100644
--- a/chromeos/dbus/fake_bluetooth_device_client.cc
+++ b/chromeos/dbus/fake_bluetooth_device_client.cc
@@ -19,6 +19,7 @@
#include "chromeos/dbus/fake_bluetooth_adapter_client.h"
#include "chromeos/dbus/fake_bluetooth_agent_manager_client.h"
#include "chromeos/dbus/fake_bluetooth_agent_service_provider.h"
+#include "chromeos/dbus/fake_bluetooth_input_client.h"
#include "dbus/object_path.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -224,6 +225,8 @@ void FakeBluetoothDeviceClient::Connect(
// The device can be connected.
properties->connected.ReplaceValue(true);
+ AddInputDeviceIfNeeded(object_path, properties);
+
callback.Run();
properties->NotifyPropertyChanged(properties->connected.name());
}
@@ -413,6 +416,15 @@ void FakeBluetoothDeviceClient::RemoveDevice(
VLOG(1) << "removing device: " << properties->alias.value();
device_list_.erase(listiter);
+ // Remove the Input interface if it exists. This should be called before the
+ // ExperimentalBluetoothDeviceClient::Observer::DeviceRemoved because it
+ // deletes the BluetoothDeviceExperimentalChromeOS object, including the
+ // device_path referenced here.
+ FakeBluetoothInputClient* fake_bluetooth_input_client =
+ static_cast<FakeBluetoothInputClient*>(
+ DBusThreadManager::Get()->GetExperimentalBluetoothInputClient());
+ fake_bluetooth_input_client->RemoveInputDevice(device_path);
+
FOR_EACH_OBSERVER(ExperimentalBluetoothDeviceClient::Observer, observers_,
DeviceRemoved(device_path));
@@ -628,6 +640,8 @@ void FakeBluetoothDeviceClient::CompleteSimulatedPairing(
properties->paired.ReplaceValue(true);
+ AddInputDeviceIfNeeded(object_path, properties);
+
callback.Run();
properties->NotifyPropertyChanged(properties->paired.name());
}
@@ -660,6 +674,26 @@ void FakeBluetoothDeviceClient::RejectSimulatedPairing(
"Rejected");
}
+void FakeBluetoothDeviceClient::AddInputDeviceIfNeeded(
+ const dbus::ObjectPath& object_path,
+ Properties* properties) {
+ // If the paired device is a HID device based on it's bluetooth class,
+ // simulate the Input interface.
+ FakeBluetoothInputClient* fake_bluetooth_input_client =
+ static_cast<FakeBluetoothInputClient*>(
+ DBusThreadManager::Get()->GetExperimentalBluetoothInputClient());
+
+ if ((properties->bluetooth_class.value() & 0x001f03) == 0x000500) {
+ std::vector<std::string> uuids = properties->uuids.value();
+ if (std::find(uuids.begin(), uuids.end(),
+ "00001124-0000-1000-8000-00805f9b34fb") == uuids.end()) {
+ uuids.push_back("00001124-0000-1000-8000-00805f9b34fb");
+ properties->uuids.ReplaceValue(uuids);
+ fake_bluetooth_input_client->AddInputDevice(object_path);
+ }
+ }
+}
+
void FakeBluetoothDeviceClient::PinCodeCallback(
const dbus::ObjectPath& object_path,
const base::Closure& callback,
« no previous file with comments | « chromeos/dbus/fake_bluetooth_device_client.h ('k') | chromeos/dbus/fake_bluetooth_input_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698