Commit d9b78b9a authored by Jan Wilken Doerrie's avatar Jan Wilken Doerrie Committed by Commit Bot

[bluetooth] Skeletons for WinRT GATT Service Discovery

This change adds class skeletons required for the implementation and
testing of GATT service discovery on WinRT. No functionality is added,
this CL is simply meant to reduce the size and boilerplate of the
following change.

Bug: 821766
Change-Id: Ie20629235f08dff9e5ffcb38273cc8ddb2a8e5e0
Reviewed-on: https://chromium-review.googlesource.com/1102023
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568056}
parent d31c147a
...@@ -290,8 +290,14 @@ test("device_unittests") { ...@@ -290,8 +290,14 @@ test("device_unittests") {
"bluetooth/test/fake_bluetooth_le_advertisement_watcher_winrt.h", "bluetooth/test/fake_bluetooth_le_advertisement_watcher_winrt.h",
"bluetooth/test/fake_bluetooth_le_advertisement_winrt.cc", "bluetooth/test/fake_bluetooth_le_advertisement_winrt.cc",
"bluetooth/test/fake_bluetooth_le_advertisement_winrt.h", "bluetooth/test/fake_bluetooth_le_advertisement_winrt.h",
"bluetooth/test/fake_bluetooth_le_device_winrt.cc",
"bluetooth/test/fake_bluetooth_le_device_winrt.h",
"bluetooth/test/fake_device_information_winrt.cc", "bluetooth/test/fake_device_information_winrt.cc",
"bluetooth/test/fake_device_information_winrt.h", "bluetooth/test/fake_device_information_winrt.h",
"bluetooth/test/fake_gatt_device_service_winrt.cc",
"bluetooth/test/fake_gatt_device_service_winrt.h",
"bluetooth/test/fake_gatt_device_services_result_winrt.cc",
"bluetooth/test/fake_gatt_device_services_result_winrt.h",
"bluetooth/test/fake_radio_winrt.cc", "bluetooth/test/fake_radio_winrt.cc",
"bluetooth/test/fake_radio_winrt.h", "bluetooth/test/fake_radio_winrt.h",
] ]
......
...@@ -242,6 +242,8 @@ component("bluetooth") { ...@@ -242,6 +242,8 @@ component("bluetooth") {
"bluetooth_adapter_winrt.h", "bluetooth_adapter_winrt.h",
"bluetooth_device_winrt.cc", "bluetooth_device_winrt.cc",
"bluetooth_device_winrt.h", "bluetooth_device_winrt.h",
"bluetooth_remote_gatt_service_winrt.cc",
"bluetooth_remote_gatt_service_winrt.h",
"event_utils_winrt.h", "event_utils_winrt.h",
] ]
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "device/bluetooth/bluetooth_remote_gatt_service_winrt.h"
#include "base/logging.h"
#include "device/bluetooth/bluetooth_uuid.h"
namespace device {
BluetoothRemoteGattServiceWinrt::BluetoothRemoteGattServiceWinrt() = default;
BluetoothRemoteGattServiceWinrt::~BluetoothRemoteGattServiceWinrt() = default;
std::string BluetoothRemoteGattServiceWinrt::GetIdentifier() const {
NOTIMPLEMENTED();
return std::string();
}
BluetoothUUID BluetoothRemoteGattServiceWinrt::GetUUID() const {
NOTIMPLEMENTED();
return BluetoothUUID();
}
bool BluetoothRemoteGattServiceWinrt::IsPrimary() const {
NOTIMPLEMENTED();
return false;
}
BluetoothDevice* BluetoothRemoteGattServiceWinrt::GetDevice() const {
NOTIMPLEMENTED();
return nullptr;
}
std::vector<BluetoothRemoteGattCharacteristic*>
BluetoothRemoteGattServiceWinrt::GetCharacteristics() const {
NOTIMPLEMENTED();
return {};
}
std::vector<BluetoothRemoteGattService*>
BluetoothRemoteGattServiceWinrt::GetIncludedServices() const {
NOTIMPLEMENTED();
return {};
}
BluetoothRemoteGattCharacteristic*
BluetoothRemoteGattServiceWinrt::GetCharacteristic(
const std::string& identifier) const {
NOTIMPLEMENTED();
return nullptr;
}
} // namespace device
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_WINRT_H_
#define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_WINRT_H_
#include <string>
#include <vector>
#include "base/macros.h"
#include "device/bluetooth/bluetooth_export.h"
#include "device/bluetooth/bluetooth_remote_gatt_service.h"
namespace device {
class BluetoothUUID;
class BluetoothDevice;
class BluetoothRemoteGattCharacteristic;
class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattServiceWinrt
: public BluetoothRemoteGattService {
public:
BluetoothRemoteGattServiceWinrt();
~BluetoothRemoteGattServiceWinrt() override;
// BluetoothRemoteGattService:
std::string GetIdentifier() const override;
BluetoothUUID GetUUID() const override;
bool IsPrimary() const override;
BluetoothDevice* GetDevice() const override;
std::vector<BluetoothRemoteGattCharacteristic*> GetCharacteristics()
const override;
std::vector<BluetoothRemoteGattService*> GetIncludedServices() const override;
BluetoothRemoteGattCharacteristic* GetCharacteristic(
const std::string& identifier) const override;
private:
DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceWinrt);
};
} // namespace device
#endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_WINRT_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "device/bluetooth/test/fake_bluetooth_le_device_winrt.h"
namespace device {
namespace {
using ABI::Windows::Devices::Bluetooth::BluetoothCacheMode;
using ABI::Windows::Devices::Bluetooth::BluetoothConnectionStatus;
using ABI::Windows::Devices::Bluetooth::BluetoothLEDevice;
using ABI::Windows::Devices::Enumeration::DeviceAccessStatus;
using ABI::Windows::Devices::Enumeration::IDeviceAccessInformation;
using ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
GattDeviceService;
using ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
GattDeviceServicesResult;
using ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
IGattDeviceService;
using ABI::Windows::Foundation::Collections::IVectorView;
using ABI::Windows::Foundation::IAsyncOperation;
using ABI::Windows::Foundation::ITypedEventHandler;
} // namespace
FakeBluetoothLEDeviceWinrt::FakeBluetoothLEDeviceWinrt() = default;
FakeBluetoothLEDeviceWinrt::~FakeBluetoothLEDeviceWinrt() = default;
HRESULT FakeBluetoothLEDeviceWinrt::get_DeviceId(HSTRING* value) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceWinrt::get_Name(HSTRING* value) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceWinrt::get_GattServices(
IVectorView<GattDeviceService*>** value) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceWinrt::get_ConnectionStatus(
BluetoothConnectionStatus* value) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceWinrt::get_BluetoothAddress(uint64_t* value) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceWinrt::GetGattService(
GUID service_uuid,
IGattDeviceService** service) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceWinrt::add_NameChanged(
ITypedEventHandler<BluetoothLEDevice*, IInspectable*>* handler,
EventRegistrationToken* token) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceWinrt::remove_NameChanged(
EventRegistrationToken token) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceWinrt::add_GattServicesChanged(
ITypedEventHandler<BluetoothLEDevice*, IInspectable*>* handler,
EventRegistrationToken* token) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceWinrt::remove_GattServicesChanged(
EventRegistrationToken token) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceWinrt::add_ConnectionStatusChanged(
ITypedEventHandler<BluetoothLEDevice*, IInspectable*>* handler,
EventRegistrationToken* token) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceWinrt::remove_ConnectionStatusChanged(
EventRegistrationToken token) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceWinrt::get_DeviceAccessInformation(
IDeviceAccessInformation** value) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceWinrt::RequestAccessAsync(
IAsyncOperation<DeviceAccessStatus>** operation) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceWinrt::GetGattServicesAsync(
IAsyncOperation<GattDeviceServicesResult*>** operation) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceWinrt::GetGattServicesWithCacheModeAsync(
BluetoothCacheMode cache_mode,
IAsyncOperation<GattDeviceServicesResult*>** operation) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceWinrt::GetGattServicesForUuidAsync(
GUID service_uuid,
IAsyncOperation<GattDeviceServicesResult*>** operation) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceWinrt::GetGattServicesForUuidWithCacheModeAsync(
GUID service_uuid,
BluetoothCacheMode cache_mode,
IAsyncOperation<GattDeviceServicesResult*>** operation) {
return E_NOTIMPL;
}
FakeBluetoothLEDeviceStaticsWinrt::FakeBluetoothLEDeviceStaticsWinrt() =
default;
FakeBluetoothLEDeviceStaticsWinrt::~FakeBluetoothLEDeviceStaticsWinrt() =
default;
HRESULT FakeBluetoothLEDeviceStaticsWinrt::FromIdAsync(
HSTRING device_id,
IAsyncOperation<BluetoothLEDevice*>** operation) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceStaticsWinrt::FromBluetoothAddressAsync(
uint64_t bluetooth_address,
IAsyncOperation<BluetoothLEDevice*>** operation) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEDeviceStaticsWinrt::GetDeviceSelector(
HSTRING* device_selector) {
return E_NOTIMPL;
}
} // namespace device
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_BLUETOOTH_TEST_FAKE_BLUETOOTH_LE_DEVICE_WINRT_H_
#define DEVICE_BLUETOOTH_TEST_FAKE_BLUETOOTH_LE_DEVICE_WINRT_H_
#include <windows.devices.bluetooth.h>
#include <windows.foundation.h>
#include <wrl/implements.h>
#include <stdint.h>
#include "base/macros.h"
namespace device {
class FakeBluetoothLEDeviceWinrt
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::Devices::Bluetooth::IBluetoothLEDevice,
ABI::Windows::Devices::Bluetooth::IBluetoothLEDevice3> {
public:
FakeBluetoothLEDeviceWinrt();
~FakeBluetoothLEDeviceWinrt() override;
// IBluetoothLEDevice:
IFACEMETHODIMP get_DeviceId(HSTRING* value) override;
IFACEMETHODIMP get_Name(HSTRING* value) override;
IFACEMETHODIMP get_GattServices(
ABI::Windows::Foundation::Collections::IVectorView<
ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
GattDeviceService*>** value) override;
IFACEMETHODIMP get_ConnectionStatus(
ABI::Windows::Devices::Bluetooth::BluetoothConnectionStatus* value)
override;
IFACEMETHODIMP get_BluetoothAddress(uint64_t* value) override;
IFACEMETHODIMP GetGattService(
GUID service_uuid,
ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
IGattDeviceService** service) override;
IFACEMETHODIMP add_NameChanged(
ABI::Windows::Foundation::ITypedEventHandler<
ABI::Windows::Devices::Bluetooth::BluetoothLEDevice*,
IInspectable*>* handler,
EventRegistrationToken* token) override;
IFACEMETHODIMP remove_NameChanged(EventRegistrationToken token) override;
IFACEMETHODIMP add_GattServicesChanged(
ABI::Windows::Foundation::ITypedEventHandler<
ABI::Windows::Devices::Bluetooth::BluetoothLEDevice*,
IInspectable*>* handler,
EventRegistrationToken* token) override;
IFACEMETHODIMP remove_GattServicesChanged(
EventRegistrationToken token) override;
IFACEMETHODIMP add_ConnectionStatusChanged(
ABI::Windows::Foundation::ITypedEventHandler<
ABI::Windows::Devices::Bluetooth::BluetoothLEDevice*,
IInspectable*>* handler,
EventRegistrationToken* token) override;
IFACEMETHODIMP remove_ConnectionStatusChanged(
EventRegistrationToken token) override;
// IBluetoothLEDevice3:
IFACEMETHODIMP get_DeviceAccessInformation(
ABI::Windows::Devices::Enumeration::IDeviceAccessInformation** value)
override;
IFACEMETHODIMP RequestAccessAsync(
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Enumeration::DeviceAccessStatus>** operation)
override;
IFACEMETHODIMP GetGattServicesAsync(
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
GattDeviceServicesResult*>** operation) override;
IFACEMETHODIMP GetGattServicesWithCacheModeAsync(
ABI::Windows::Devices::Bluetooth::BluetoothCacheMode cache_mode,
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
GattDeviceServicesResult*>** operation) override;
IFACEMETHODIMP GetGattServicesForUuidAsync(
GUID service_uuid,
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
GattDeviceServicesResult*>** operation) override;
IFACEMETHODIMP GetGattServicesForUuidWithCacheModeAsync(
GUID service_uuid,
ABI::Windows::Devices::Bluetooth::BluetoothCacheMode cache_mode,
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
GattDeviceServicesResult*>** operation) override;
private:
DISALLOW_COPY_AND_ASSIGN(FakeBluetoothLEDeviceWinrt);
};
class FakeBluetoothLEDeviceStaticsWinrt
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::Devices::Bluetooth::IBluetoothLEDeviceStatics> {
public:
FakeBluetoothLEDeviceStaticsWinrt();
~FakeBluetoothLEDeviceStaticsWinrt() override;
// IBluetoothLEDeviceStatics:
IFACEMETHODIMP FromIdAsync(
HSTRING device_id,
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Bluetooth::BluetoothLEDevice*>** operation)
override;
IFACEMETHODIMP FromBluetoothAddressAsync(
uint64_t bluetooth_address,
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Bluetooth::BluetoothLEDevice*>** operation)
override;
IFACEMETHODIMP GetDeviceSelector(HSTRING* device_selector) override;
private:
DISALLOW_COPY_AND_ASSIGN(FakeBluetoothLEDeviceStaticsWinrt);
};
} // namespace device
#endif // DEVICE_BLUETOOTH_TEST_FAKE_BLUETOOTH_LE_DEVICE_WINRT_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "device/bluetooth/test/fake_gatt_device_service_winrt.h"
namespace device {
namespace {
using ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
GattCharacteristic;
using ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
GattDeviceService;
using ABI::Windows::Foundation::Collections::IVectorView;
} // namespace
FakeGattDeviceServiceWinrt::FakeGattDeviceServiceWinrt() = default;
FakeGattDeviceServiceWinrt::~FakeGattDeviceServiceWinrt() = default;
HRESULT FakeGattDeviceServiceWinrt::GetCharacteristics(
GUID characteristic_uuid,
IVectorView<GattCharacteristic*>** value) {
return E_NOTIMPL;
}
HRESULT FakeGattDeviceServiceWinrt::GetIncludedServices(
GUID service_uuid,
IVectorView<GattDeviceService*>** value) {
return E_NOTIMPL;
}
HRESULT FakeGattDeviceServiceWinrt::get_DeviceId(HSTRING* value) {
return E_NOTIMPL;
}
HRESULT FakeGattDeviceServiceWinrt::get_Uuid(GUID* value) {
return E_NOTIMPL;
}
HRESULT FakeGattDeviceServiceWinrt::get_AttributeHandle(uint16_t* value) {
return E_NOTIMPL;
}
} // namespace device
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_BLUETOOTH_TEST_FAKE_GATT_DEVICE_SERVICE_WINRT_H_
#define DEVICE_BLUETOOTH_TEST_FAKE_GATT_DEVICE_SERVICE_WINRT_H_
#include <windows.devices.bluetooth.genericattributeprofile.h>
#include <windows.foundation.collections.h>
#include <wrl/implements.h>
#include <stdint.h>
#include "base/macros.h"
namespace device {
class FakeGattDeviceServiceWinrt
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
IGattDeviceService> {
public:
FakeGattDeviceServiceWinrt();
~FakeGattDeviceServiceWinrt() override;
// IGattDeviceService:
IFACEMETHODIMP GetCharacteristics(
GUID characteristic_uuid,
ABI::Windows::Foundation::Collections::IVectorView<
ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
GattCharacteristic*>** value) override;
IFACEMETHODIMP GetIncludedServices(
GUID service_uuid,
ABI::Windows::Foundation::Collections::IVectorView<
ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
GattDeviceService*>** value) override;
IFACEMETHODIMP get_DeviceId(HSTRING* value) override;
IFACEMETHODIMP get_Uuid(GUID* value) override;
IFACEMETHODIMP get_AttributeHandle(uint16_t* value) override;
private:
DISALLOW_COPY_AND_ASSIGN(FakeGattDeviceServiceWinrt);
};
} // namespace device
#endif // DEVICE_BLUETOOTH_TEST_FAKE_GATT_DEVICE_SERVICE_WINRT_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "device/bluetooth/test/fake_gatt_device_services_result_winrt.h"
namespace device {
namespace {
using ABI::Windows::Foundation::Collections::IVectorView;
using ABI::Windows::Foundation::IReference;
using ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
GattDeviceService;
using ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
GattCommunicationStatus;
} // namespace
FakeGattDeviceServicesResultWinrt::FakeGattDeviceServicesResultWinrt() =
default;
FakeGattDeviceServicesResultWinrt::~FakeGattDeviceServicesResultWinrt() =
default;
HRESULT FakeGattDeviceServicesResultWinrt::get_Status(
GattCommunicationStatus* value) {
return E_NOTIMPL;
}
HRESULT FakeGattDeviceServicesResultWinrt::get_ProtocolError(
IReference<uint8_t>** value) {
return E_NOTIMPL;
}
HRESULT FakeGattDeviceServicesResultWinrt::get_Services(
IVectorView<GattDeviceService*>** value) {
return E_NOTIMPL;
}
} // namespace device
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_BLUETOOTH_TEST_FAKE_GATT_DEVICE_SERVICES_RESULT_WINRT_H_
#define DEVICE_BLUETOOTH_TEST_FAKE_GATT_DEVICE_SERVICES_RESULT_WINRT_H_
#include <windows.devices.bluetooth.genericattributeprofile.h>
#include <windows.foundation.collections.h>
#include <windows.foundation.h>
#include <wrl/implements.h>
#include <stdint.h>
#include "base/macros.h"
namespace device {
class FakeGattDeviceServicesResultWinrt
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
IGattDeviceServicesResult> {
public:
FakeGattDeviceServicesResultWinrt();
~FakeGattDeviceServicesResultWinrt() override;
// IGattDeviceServicesResult:
IFACEMETHODIMP get_Status(
ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
GattCommunicationStatus* value) override;
IFACEMETHODIMP get_ProtocolError(
ABI::Windows::Foundation::IReference<uint8_t>** value) override;
IFACEMETHODIMP get_Services(
ABI::Windows::Foundation::Collections::IVectorView<
ABI::Windows::Devices::Bluetooth::GenericAttributeProfile::
GattDeviceService*>** value) override;
private:
DISALLOW_COPY_AND_ASSIGN(FakeGattDeviceServicesResultWinrt);
};
} // namespace device
#endif // DEVICE_BLUETOOTH_TEST_FAKE_GATT_DEVICE_SERVICES_RESULT_WINRT_H_
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