Commit 4a24821e authored by Martin Kreichgauer's avatar Martin Kreichgauer Committed by Commit Bot

Reland "bluetooth: add BluetoothAdapter::IsPeripheralRoleSupported()"

This reverts commit 1101e55e.

Reason for revert: The test failure appears unrelated to me.

Original change's description:
> Revert "bluetooth: add BluetoothAdapter::IsPeripheralRoleSupported()"
> 
> This reverts commit ba7954e5.
> 
> Reason for revert: This probably caused the failure in 
> DevToolsBeforeUnloadTest.TestUndockedDevToolsClose
> https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8882815412590626512/+/steps/browser_tests_on_Windows-10-15063/0/logs/Deterministic_failure:_DevToolsBeforeUnloadTest.TestUndockedDevToolsClose__status_FAILURE_/0
> 
> 
> Original change's description:
> > bluetooth: add BluetoothAdapter::IsPeripheralRoleSupported()
> > 
> > It appears that on Windows, Bluetooth hardware does not generally
> > support the BLE peripheral role (i.e. BLE advertisements). Add a method
> > to BluetoothAdapter that returns the
> > BluetoothAdapter.IsPeripheralRoleSupported property [0] on WinRT and
> > true everywhere else, so that client code can detect these cases.
> > 
> > [0]
> > https://docs.microsoft.com/en-us/uwp/api/windows.devices.bluetooth.bluetoothadapter.isperipheralrolesupported
> > 
> > Bug: 1069140
> > Change-Id: If8f2f448f30db6aaf720c10e00391dea3f65944e
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2152892
> > Commit-Queue: Martin Kreichgauer <martinkr@chromium.org>
> > Reviewed-by: Reilly Grant <reillyg@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#759836}
> 
> TBR=reillyg@chromium.org,martinkr@chromium.org
> 
> Change-Id: I993fe1e58bf4704977cd07b18cf61aba04f402ce
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 1069140
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2153434
> Reviewed-by: Mohamed Amir Yosef <mamir@chromium.org>
> Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#759999}

TBR=reillyg@chromium.org,mamir@chromium.org,martinkr@chromium.org

Change-Id: I2694e301350b8fe4be3d77480ae2437d46174582
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1069140
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2155066Reviewed-by: default avatarMartin Kreichgauer <martinkr@chromium.org>
Commit-Queue: Martin Kreichgauer <martinkr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760147}
parent 65003099
......@@ -91,6 +91,11 @@ void BluetoothAdapter::SetPowered(bool powered,
set_powered_callbacks_->error_callback = error_callback;
}
bool BluetoothAdapter::IsPeripheralRoleSupported() const {
// TODO(crbug/1071595): Implement this for more platforms.
return true;
}
std::unordered_map<BluetoothDevice*, BluetoothDevice::UUIDSet>
BluetoothAdapter::RetrieveGattConnectedDevicesWithDiscoveryFilter(
const BluetoothDiscoveryFilter& discovery_filter) {
......
......@@ -433,6 +433,9 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapter
const base::Closure& callback,
const ErrorCallback& error_callback);
// Indicates whether the adapter support the LowEnergy peripheral role.
virtual bool IsPeripheralRoleSupported() const;
// Indicates whether the adapter radio is discoverable.
virtual bool IsDiscoverable() const = 0;
......
......@@ -765,6 +765,7 @@ TEST_F(BluetoothTest, MAYBE_ConstructFakeAdapter) {
EXPECT_TRUE(adapter_->CanPower());
EXPECT_TRUE(adapter_->IsPresent());
EXPECT_TRUE(adapter_->IsPowered());
EXPECT_TRUE(adapter_->IsPeripheralRoleSupported());
EXPECT_FALSE(adapter_->IsDiscoverable());
EXPECT_FALSE(adapter_->IsDiscovering());
}
......
......@@ -533,6 +533,16 @@ bool BluetoothAdapterWinrt::IsPowered() const {
return GetState(radio_.Get()) == RadioState_On;
}
bool BluetoothAdapterWinrt::IsPeripheralRoleSupported() const {
boolean supported = false;
HRESULT hr = adapter_->get_IsPeripheralRoleSupported(&supported);
if (FAILED(hr)) {
BLUETOOTH_LOG(ERROR) << "Getting IsPeripheralRoleSupported failed: "
<< logging::SystemErrorCodeToString(hr);
}
return supported;
}
bool BluetoothAdapterWinrt::IsDiscoverable() const {
NOTIMPLEMENTED();
return false;
......
......@@ -43,6 +43,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterWinrt : public BluetoothAdapter {
bool IsPresent() const override;
bool CanPower() const override;
bool IsPowered() const override;
bool IsPeripheralRoleSupported() const override;
bool IsDiscoverable() const override;
void SetDiscoverable(bool discoverable,
const base::Closure& callback,
......
......@@ -73,7 +73,8 @@ HRESULT FakeBluetoothAdapterWinrt::get_IsLowEnergySupported(boolean* value) {
HRESULT FakeBluetoothAdapterWinrt::get_IsPeripheralRoleSupported(
boolean* value) {
return E_NOTIMPL;
*value = true;
return S_OK;
}
HRESULT FakeBluetoothAdapterWinrt::get_IsCentralRoleSupported(boolean* value) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment