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

Unified Diff: components/arc/bluetooth/arc_bluetooth_bridge.cc

Issue 2354933003: arc: bluetooth: Clean up arc_bluetooth_bridge (Closed)
Patch Set: Fix rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/arc/bluetooth/arc_bluetooth_bridge.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/bluetooth/arc_bluetooth_bridge.cc
diff --git a/components/arc/bluetooth/arc_bluetooth_bridge.cc b/components/arc/bluetooth/arc_bluetooth_bridge.cc
index e9385438299f23f6110b048e441f2e5b65c4f43d..a2316b501b194010a58aee553c627cabfb3db452 100644
--- a/components/arc/bluetooth/arc_bluetooth_bridge.cc
+++ b/components/arc/bluetooth/arc_bluetooth_bridge.cc
@@ -81,6 +81,11 @@ constexpr uint16_t kAndroidMBluetoothVersionNumber = 95;
constexpr uint16_t kMaxAdvertisement = 5;
// Bluetooth SDP Service Class ID List Attribute identifier
constexpr uint16_t kServiceClassIDListAttributeID = 0x0001;
+// Time out for Bluetooth Discovery (scan)
+constexpr uint32_t kDiscoveryTimeout = 120;
Luis Héctor Chávez 2016/09/20 20:23:11 nit: base::TimeDelta::FromSeconds() is constexpr,
puthik_chromium 2016/09/20 20:55:39 Done.
+// From https://www.bluetooth.com/specifications/assigned-numbers/baseband
+// The Class of device for generic computer.
+constexpr uint32_t kBluetoothComputerClass = 0x100;
using GattStatusCallback =
base::Callback<void(arc::mojom::BluetoothGattStatus)>;
@@ -310,12 +315,6 @@ void ArcBluetoothBridge::OnInstanceClosed() {
bluetooth_adapter_->RemoveObserver(this);
}
-void ArcBluetoothBridge::AdapterPoweredChanged(BluetoothAdapter* adapter,
- bool powered) {
- // TODO(smbarber): Invoke EnableAdapter or DisableAdapter via ARC bridge
- // service.
-}
-
void ArcBluetoothBridge::DeviceAdded(BluetoothAdapter* adapter,
BluetoothDevice* device) {
auto* bluetooth_instance =
@@ -808,9 +807,10 @@ void ArcBluetoothBridge::SetRemoteDeviceProperty(
if (!bluetooth_instance)
return;
- // TODO(smbarber): Implement SetRemoteDeviceProperty
+ // Unsupported. Only used by Android hidden API, BluetoothDevice.SetAlias().
+ // And only Android Settings App / Android TV / NFC used that.
bluetooth_instance->OnRemoteDeviceProperties(
- mojom::BluetoothStatus::FAIL, std::move(remote_addr),
+ mojom::BluetoothStatus::UNSUPPORTED, std::move(remote_addr),
mojo::Array<mojom::BluetoothPropertyPtr>::New(0));
}
@@ -827,9 +827,14 @@ void ArcBluetoothBridge::GetRemoteServices(
void ArcBluetoothBridge::StartDiscovery() {
DCHECK(bluetooth_adapter_);
- // TODO(smbarber): Add timeout
+ DCHECK(CalledOnValidThread());
+
if (discovery_session_) {
- LOG(ERROR) << "Discovery session already running; leaving alone";
+ LOG(ERROR) << "Discovery session already running; Reset timeout.";
+ discovery_off_timer_.Start(FROM_HERE,
+ base::TimeDelta::FromSeconds(kDiscoveryTimeout),
+ base::Bind(&ArcBluetoothBridge::CancelDiscovery,
+ weak_factory_.GetWeakPtr()));
SendCachedDevicesFound();
return;
}
@@ -880,8 +885,15 @@ void ArcBluetoothBridge::OnDiscoveryStarted(
if (!bluetooth_instance)
return;
+ DCHECK(CalledOnValidThread());
Luis Héctor Chávez 2016/09/20 20:23:11 nit: move to beginning of function.
puthik_chromium 2016/09/20 20:55:39 Done.
+
discovery_session_ = std::move(session);
+ discovery_off_timer_.Start(FROM_HERE,
+ base::TimeDelta::FromSeconds(kDiscoveryTimeout),
+ base::Bind(&ArcBluetoothBridge::CancelDiscovery,
+ weak_factory_.GetWeakPtr()));
+
bluetooth_instance->OnDiscoveryStateChanged(
mojom::BluetoothDiscoveryState::STARTED);
@@ -896,6 +908,7 @@ void ArcBluetoothBridge::OnDiscoveryStopped() {
return;
discovery_session_.reset();
+ discovery_off_timer_.Stop();
bluetooth_instance->OnDiscoveryStateChanged(
mojom::BluetoothDiscoveryState::STOPPED);
@@ -1761,18 +1774,20 @@ ArcBluetoothBridge::GetAdapterProperties(
}
if (type == mojom::BluetoothPropertyType::ALL ||
type == mojom::BluetoothPropertyType::UUIDS) {
- // TODO(smbarber): Fill in once GetUUIDs is available for the adapter.
+ mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
+ btp->set_uuids(
+ mojo::Array<BluetoothUUID>::From(bluetooth_adapter_->GetUUIDs()));
+ properties.push_back(std::move(btp));
}
if (type == mojom::BluetoothPropertyType::ALL ||
type == mojom::BluetoothPropertyType::CLASS_OF_DEVICE) {
- // TODO(smbarber): Populate with the actual adapter class
mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
- btp->set_device_class(0);
+ btp->set_device_class(kBluetoothComputerClass);
properties.push_back(std::move(btp));
}
if (type == mojom::BluetoothPropertyType::ALL ||
type == mojom::BluetoothPropertyType::TYPE_OF_DEVICE) {
- // TODO(smbarber): Populate with the actual adapter type
+ // Assume that all ChromeOS devices are dual mode Bluetooth device.
mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
btp->set_device_type(device::BLUETOOTH_TRANSPORT_DUAL);
properties.push_back(std::move(btp));
« no previous file with comments | « components/arc/bluetooth/arc_bluetooth_bridge.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698