Commit 7c0e41dc authored by Jan Wilken Doerrie's avatar Jan Wilken Doerrie Committed by Commit Bot

[bluetooth] Retrieve WinRT Adapter Name from DeviceInformation

This change implements retrieving the BluetoothAdapter's name from its
associated DeviceInformation. Prior to this change the adapter's device
id was exposed as its name, which was not appropriate.

Bug: 841261
Change-Id: I7a96cc4d7f70e084d99961c0e2656fc139cb0174
Reviewed-on: https://chromium-review.googlesource.com/1057569
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559014}
parent 6143852a
...@@ -285,6 +285,8 @@ test("device_unittests") { ...@@ -285,6 +285,8 @@ test("device_unittests") {
"bluetooth/bluetooth_low_energy_win_fake.h", "bluetooth/bluetooth_low_energy_win_fake.h",
"bluetooth/test/fake_bluetooth_adapter_winrt.cc", "bluetooth/test/fake_bluetooth_adapter_winrt.cc",
"bluetooth/test/fake_bluetooth_adapter_winrt.h", "bluetooth/test/fake_bluetooth_adapter_winrt.h",
"bluetooth/test/fake_device_information_winrt.cc",
"bluetooth/test/fake_device_information_winrt.h",
] ]
} }
......
...@@ -33,6 +33,9 @@ using ABI::Windows::Devices::Bluetooth::BluetoothAdapter; ...@@ -33,6 +33,9 @@ using ABI::Windows::Devices::Bluetooth::BluetoothAdapter;
} // namespace uwp } // namespace uwp
using ABI::Windows::Devices::Bluetooth::IBluetoothAdapter; using ABI::Windows::Devices::Bluetooth::IBluetoothAdapter;
using ABI::Windows::Devices::Bluetooth::IBluetoothAdapterStatics; using ABI::Windows::Devices::Bluetooth::IBluetoothAdapterStatics;
using ABI::Windows::Devices::Enumeration::DeviceInformation;
using ABI::Windows::Devices::Enumeration::IDeviceInformation;
using ABI::Windows::Devices::Enumeration::IDeviceInformationStatics;
using ABI::Windows::Foundation::IAsyncOperation; using ABI::Windows::Foundation::IAsyncOperation;
using ABI::Windows::Foundation::IAsyncOperationCompletedHandler; using ABI::Windows::Foundation::IAsyncOperationCompletedHandler;
using Microsoft::WRL::Callback; using Microsoft::WRL::Callback;
...@@ -305,6 +308,13 @@ HRESULT BluetoothAdapterWinrt::GetBluetoothAdapterStaticsActivationFactory( ...@@ -305,6 +308,13 @@ HRESULT BluetoothAdapterWinrt::GetBluetoothAdapterStaticsActivationFactory(
RuntimeClass_Windows_Devices_Bluetooth_BluetoothAdapter>(statics); RuntimeClass_Windows_Devices_Bluetooth_BluetoothAdapter>(statics);
} }
HRESULT BluetoothAdapterWinrt::GetDeviceInformationStaticsActivationFactory(
IDeviceInformationStatics** statics) const {
return base::win::GetActivationFactory<
IDeviceInformationStatics,
RuntimeClass_Windows_Devices_Enumeration_DeviceInformation>(statics);
}
void BluetoothAdapterWinrt::OnGetDefaultAdapter( void BluetoothAdapterWinrt::OnGetDefaultAdapter(
base::ScopedClosureRunner on_init, base::ScopedClosureRunner on_init,
ComPtr<IBluetoothAdapter> adapter) { ComPtr<IBluetoothAdapter> adapter) {
...@@ -337,9 +347,51 @@ void BluetoothAdapterWinrt::OnGetDefaultAdapter( ...@@ -337,9 +347,51 @@ void BluetoothAdapterWinrt::OnGetDefaultAdapter(
return; return;
} }
// TODO(https://crbug.com/841261): Retrieve the name from the appropriate ComPtr<IDeviceInformationStatics> device_information_statics;
// DeviceInformation. hr =
name_ = base::win::ScopedHString(device_id).GetAsUTF8(); GetDeviceInformationStaticsActivationFactory(&device_information_statics);
if (FAILED(hr)) {
VLOG(2) << "GetDeviceInformationStaticsActivationFactory failed: "
<< logging::SystemErrorCodeToString(hr);
return;
}
ComPtr<IAsyncOperation<DeviceInformation*>> create_from_id_op;
hr = device_information_statics->CreateFromIdAsync(device_id,
&create_from_id_op);
if (FAILED(hr)) {
VLOG(2) << "CreateFromIdAsync failed: "
<< logging::SystemErrorCodeToString(hr);
return;
}
hr = PostAsyncResults(
std::move(create_from_id_op), ui_task_runner_,
base::BindOnce(&BluetoothAdapterWinrt::OnCreateFromIdAsync,
weak_ptr_factory_.GetWeakPtr(), std::move(on_init)));
if (FAILED(hr)) {
VLOG(2) << "PostAsyncResults failed: "
<< logging::SystemErrorCodeToString(hr);
}
}
void BluetoothAdapterWinrt::OnCreateFromIdAsync(
base::ScopedClosureRunner on_init,
ComPtr<IDeviceInformation> device_information) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (!device_information) {
VLOG(2) << "Getting Device Information failed.";
return;
}
HSTRING name;
HRESULT hr = device_information->get_Name(&name);
if (FAILED(hr)) {
VLOG(2) << "Getting Name failed: " << logging::SystemErrorCodeToString(hr);
return;
}
name_ = base::win::ScopedHString(name).GetAsUTF8();
} }
} // namespace device } // namespace device
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WINRT_H_ #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WINRT_H_
#include <windows.devices.bluetooth.h> #include <windows.devices.bluetooth.h>
#include <windows.devices.enumeration.h>
#include <wrl/client.h> #include <wrl/client.h>
#include <memory> #include <memory>
...@@ -82,10 +83,13 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterWinrt : public BluetoothAdapter { ...@@ -82,10 +83,13 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterWinrt : public BluetoothAdapter {
void RemovePairingDelegateInternal( void RemovePairingDelegateInternal(
BluetoothDevice::PairingDelegate* pairing_delegate) override; BluetoothDevice::PairingDelegate* pairing_delegate) override;
// This is declared virtual so that it can be overridden by tests. // These are declared virtual so that they can be overridden by tests.
virtual HRESULT GetBluetoothAdapterStaticsActivationFactory( virtual HRESULT GetBluetoothAdapterStaticsActivationFactory(
ABI::Windows::Devices::Bluetooth::IBluetoothAdapterStatics** statics) ABI::Windows::Devices::Bluetooth::IBluetoothAdapterStatics** statics)
const; const;
virtual HRESULT GetDeviceInformationStaticsActivationFactory(
ABI::Windows::Devices::Enumeration::IDeviceInformationStatics** statics)
const;
private: private:
void OnGetDefaultAdapter( void OnGetDefaultAdapter(
...@@ -93,6 +97,12 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterWinrt : public BluetoothAdapter { ...@@ -93,6 +97,12 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterWinrt : public BluetoothAdapter {
Microsoft::WRL::ComPtr< Microsoft::WRL::ComPtr<
ABI::Windows::Devices::Bluetooth::IBluetoothAdapter> adapter); ABI::Windows::Devices::Bluetooth::IBluetoothAdapter> adapter);
void OnCreateFromIdAsync(
base::ScopedClosureRunner on_init,
Microsoft::WRL::ComPtr<
ABI::Windows::Devices::Enumeration::IDeviceInformation>
device_information);
bool is_initialized_ = false; bool is_initialized_ = false;
bool is_present_ = false; bool is_present_ = false;
std::string address_; std::string address_;
......
...@@ -27,19 +27,24 @@ ...@@ -27,19 +27,24 @@
#include "device/bluetooth/bluetooth_remote_gatt_descriptor_win.h" #include "device/bluetooth/bluetooth_remote_gatt_descriptor_win.h"
#include "device/bluetooth/bluetooth_remote_gatt_service_win.h" #include "device/bluetooth/bluetooth_remote_gatt_service_win.h"
#include "device/bluetooth/test/fake_bluetooth_adapter_winrt.h" #include "device/bluetooth/test/fake_bluetooth_adapter_winrt.h"
#include "device/bluetooth/test/fake_device_information_winrt.h"
namespace { namespace {
using Microsoft::WRL::Make; using Microsoft::WRL::Make;
using Microsoft::WRL::ComPtr; using Microsoft::WRL::ComPtr;
using ABI::Windows::Devices::Bluetooth::IBluetoothAdapterStatics;
using ABI::Windows::Devices::Bluetooth::IBluetoothAdapter; using ABI::Windows::Devices::Bluetooth::IBluetoothAdapter;
using ABI::Windows::Devices::Bluetooth::IBluetoothAdapterStatics;
using ABI::Windows::Devices::Enumeration::IDeviceInformation;
using ABI::Windows::Devices::Enumeration::IDeviceInformationStatics;
class TestBluetoothAdapterWinrt : public device::BluetoothAdapterWinrt { class TestBluetoothAdapterWinrt : public device::BluetoothAdapterWinrt {
public: public:
TestBluetoothAdapterWinrt(ComPtr<IBluetoothAdapter> adapter, TestBluetoothAdapterWinrt(ComPtr<IBluetoothAdapter> adapter,
ComPtr<IDeviceInformation> device_information,
InitCallback init_cb) InitCallback init_cb)
: adapter_(std::move(adapter)) { : adapter_(std::move(adapter)),
device_information_(std::move(device_information)) {
Init(std::move(init_cb)); Init(std::move(init_cb));
} }
...@@ -53,8 +58,17 @@ class TestBluetoothAdapterWinrt : public device::BluetoothAdapterWinrt { ...@@ -53,8 +58,17 @@ class TestBluetoothAdapterWinrt : public device::BluetoothAdapterWinrt {
return adapter_statics.CopyTo(statics); return adapter_statics.CopyTo(statics);
}; };
HRESULT
GetDeviceInformationStaticsActivationFactory(
IDeviceInformationStatics** statics) const override {
auto device_information_statics =
Make<device::FakeDeviceInformationStaticsWinrt>(device_information_);
return device_information_statics.CopyTo(statics);
};
private: private:
ComPtr<IBluetoothAdapter> adapter_; ComPtr<IBluetoothAdapter> adapter_;
ComPtr<IDeviceInformation> device_information_;
}; };
BLUETOOTH_ADDRESS CanonicalStringToBLUETOOTH_ADDRESS( BLUETOOTH_ADDRESS CanonicalStringToBLUETOOTH_ADDRESS(
...@@ -151,7 +165,7 @@ void BluetoothTestWin::InitWithoutDefaultAdapter() { ...@@ -151,7 +165,7 @@ void BluetoothTestWin::InitWithoutDefaultAdapter() {
if (UseNewBLEWinImplementation()) { if (UseNewBLEWinImplementation()) {
base::RunLoop run_loop; base::RunLoop run_loop;
adapter_ = base::MakeRefCounted<TestBluetoothAdapterWinrt>( adapter_ = base::MakeRefCounted<TestBluetoothAdapterWinrt>(
nullptr, run_loop.QuitClosure()); nullptr, nullptr, run_loop.QuitClosure());
run_loop.Run(); run_loop.Run();
return; return;
} }
...@@ -166,7 +180,8 @@ void BluetoothTestWin::InitWithFakeAdapter() { ...@@ -166,7 +180,8 @@ void BluetoothTestWin::InitWithFakeAdapter() {
if (UseNewBLEWinImplementation()) { if (UseNewBLEWinImplementation()) {
base::RunLoop run_loop; base::RunLoop run_loop;
adapter_ = base::MakeRefCounted<TestBluetoothAdapterWinrt>( adapter_ = base::MakeRefCounted<TestBluetoothAdapterWinrt>(
Make<FakeBluetoothAdapterWinrt>(kTestAdapterAddress, kTestAdapterName), Make<FakeBluetoothAdapterWinrt>(kTestAdapterAddress),
Make<FakeDeviceInformationWinrt>(kTestAdapterName),
run_loop.QuitClosure()); run_loop.QuitClosure());
run_loop.Run(); run_loop.Run();
return; return;
......
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/strings/strcat.h" #include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
#include "base/win/async_operation.h" #include "base/win/async_operation.h"
#include "base/win/scoped_hstring.h"
#include "device/bluetooth/test/bluetooth_test.h" #include "device/bluetooth/test/bluetooth_test.h"
namespace device { namespace device {
...@@ -33,11 +33,10 @@ using Microsoft::WRL::Make; ...@@ -33,11 +33,10 @@ using Microsoft::WRL::Make;
} // namespace } // namespace
FakeBluetoothAdapterWinrt::FakeBluetoothAdapterWinrt(std::string address, FakeBluetoothAdapterWinrt::FakeBluetoothAdapterWinrt(
std::string device_id) base::StringPiece address) {
: address_(std::move(address)), device_id_(std::move(device_id)) {
const bool result = base::HexStringToUInt64( const bool result = base::HexStringToUInt64(
base::StrCat(base::SplitStringPiece(address_, ":", base::TRIM_WHITESPACE, base::StrCat(base::SplitStringPiece(address, ":", base::TRIM_WHITESPACE,
base::SPLIT_WANT_ALL)), base::SPLIT_WANT_ALL)),
&raw_address_); &raw_address_);
DCHECK(result); DCHECK(result);
...@@ -46,7 +45,8 @@ FakeBluetoothAdapterWinrt::FakeBluetoothAdapterWinrt(std::string address, ...@@ -46,7 +45,8 @@ FakeBluetoothAdapterWinrt::FakeBluetoothAdapterWinrt(std::string address,
FakeBluetoothAdapterWinrt::~FakeBluetoothAdapterWinrt() = default; FakeBluetoothAdapterWinrt::~FakeBluetoothAdapterWinrt() = default;
HRESULT FakeBluetoothAdapterWinrt::get_DeviceId(HSTRING* value) { HRESULT FakeBluetoothAdapterWinrt::get_DeviceId(HSTRING* value) {
*value = base::win::ScopedHString::Create(device_id_).release(); // The actual device id does not matter for testing, as long as this method
// returns a success code.
return S_OK; return S_OK;
} }
......
...@@ -12,9 +12,8 @@ ...@@ -12,9 +12,8 @@
#include <stdint.h> #include <stdint.h>
#include <string>
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/string_piece_forward.h"
namespace device { namespace device {
...@@ -24,7 +23,7 @@ class FakeBluetoothAdapterWinrt ...@@ -24,7 +23,7 @@ class FakeBluetoothAdapterWinrt
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>, Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::Devices::Bluetooth::IBluetoothAdapter> { ABI::Windows::Devices::Bluetooth::IBluetoothAdapter> {
public: public:
FakeBluetoothAdapterWinrt(std::string address, std::string device_id); explicit FakeBluetoothAdapterWinrt(base::StringPiece address);
~FakeBluetoothAdapterWinrt() override; ~FakeBluetoothAdapterWinrt() override;
// IBluetoothAdapter: // IBluetoothAdapter:
...@@ -42,9 +41,7 @@ class FakeBluetoothAdapterWinrt ...@@ -42,9 +41,7 @@ class FakeBluetoothAdapterWinrt
ABI::Windows::Devices::Radios::Radio*>** operation) override; ABI::Windows::Devices::Radios::Radio*>** operation) override;
private: private:
std::string address_;
uint64_t raw_address_; uint64_t raw_address_;
std::string device_id_;
DISALLOW_COPY_AND_ASSIGN(FakeBluetoothAdapterWinrt); DISALLOW_COPY_AND_ASSIGN(FakeBluetoothAdapterWinrt);
}; };
...@@ -55,7 +52,7 @@ class FakeBluetoothAdapterStaticsWinrt ...@@ -55,7 +52,7 @@ class FakeBluetoothAdapterStaticsWinrt
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>, Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::Devices::Bluetooth::IBluetoothAdapterStatics> { ABI::Windows::Devices::Bluetooth::IBluetoothAdapterStatics> {
public: public:
FakeBluetoothAdapterStaticsWinrt( explicit FakeBluetoothAdapterStaticsWinrt(
Microsoft::WRL::ComPtr< Microsoft::WRL::ComPtr<
ABI::Windows::Devices::Bluetooth::IBluetoothAdapter> default_adapter); ABI::Windows::Devices::Bluetooth::IBluetoothAdapter> default_adapter);
~FakeBluetoothAdapterStaticsWinrt() override; ~FakeBluetoothAdapterStaticsWinrt() override;
......
// 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_device_information_winrt.h"
#include <utility>
#include "base/bind.h"
#include "base/strings/string_piece.h"
#include "base/task_runner_util.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/win/async_operation.h"
#include "base/win/scoped_hstring.h"
namespace device {
namespace {
using ABI::Windows::Devices::Enumeration::DeviceClass;
using ABI::Windows::Devices::Enumeration::DeviceInformation;
using ABI::Windows::Devices::Enumeration::DeviceInformationCollection;
using ABI::Windows::Devices::Enumeration::DeviceThumbnail;
using ABI::Windows::Devices::Enumeration::IDeviceInformation;
using ABI::Windows::Devices::Enumeration::IDeviceInformationUpdate;
using ABI::Windows::Devices::Enumeration::IDeviceWatcher;
using ABI::Windows::Devices::Enumeration::IEnclosureLocation;
using ABI::Windows::Foundation::Collections::IIterable;
using ABI::Windows::Foundation::Collections::IMapView;
using ABI::Windows::Foundation::IAsyncOperation;
using Microsoft::WRL::ComPtr;
using Microsoft::WRL::Make;
} // namespace
FakeDeviceInformationWinrt::FakeDeviceInformationWinrt(std::string name)
: name_(std::move(name)) {}
FakeDeviceInformationWinrt::~FakeDeviceInformationWinrt() = default;
HRESULT FakeDeviceInformationWinrt::get_Id(HSTRING* value) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationWinrt::get_Name(HSTRING* value) {
*value = base::win::ScopedHString::Create(name_).release();
return S_OK;
}
HRESULT FakeDeviceInformationWinrt::get_IsEnabled(boolean* value) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationWinrt::get_IsDefault(boolean* value) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationWinrt::get_EnclosureLocation(
IEnclosureLocation** value) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationWinrt::get_Properties(
IMapView<HSTRING, IInspectable*>** value) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationWinrt::Update(
IDeviceInformationUpdate* update_info) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationWinrt::GetThumbnailAsync(
IAsyncOperation<DeviceThumbnail*>** async_op) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationWinrt::GetGlyphThumbnailAsync(
IAsyncOperation<DeviceThumbnail*>** async_op) {
return E_NOTIMPL;
}
FakeDeviceInformationStaticsWinrt::FakeDeviceInformationStaticsWinrt(
ComPtr<IDeviceInformation> device_information)
: device_information_(std::move(device_information)) {}
FakeDeviceInformationStaticsWinrt::~FakeDeviceInformationStaticsWinrt() =
default;
HRESULT FakeDeviceInformationStaticsWinrt::CreateFromIdAsync(
HSTRING device_id,
IAsyncOperation<DeviceInformation*>** async_op) {
auto operation = Make<base::win::AsyncOperation<DeviceInformation*>>();
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(operation->callback(), device_information_));
*async_op = operation.Detach();
return S_OK;
}
HRESULT
FakeDeviceInformationStaticsWinrt::CreateFromIdAsyncAdditionalProperties(
HSTRING device_id,
IIterable<HSTRING>* additional_properties,
IAsyncOperation<DeviceInformation*>** async_op) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationStaticsWinrt::FindAllAsync(
IAsyncOperation<DeviceInformationCollection*>** async_op) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationStaticsWinrt::FindAllAsyncDeviceClass(
DeviceClass device_class,
IAsyncOperation<DeviceInformationCollection*>** async_op) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationStaticsWinrt::FindAllAsyncAqsFilter(
HSTRING aqs_filter,
IAsyncOperation<DeviceInformationCollection*>** async_op) {
return E_NOTIMPL;
}
HRESULT
FakeDeviceInformationStaticsWinrt::FindAllAsyncAqsFilterAndAdditionalProperties(
HSTRING aqs_filter,
IIterable<HSTRING>* additional_properties,
IAsyncOperation<DeviceInformationCollection*>** async_op) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationStaticsWinrt::CreateWatcher(
IDeviceWatcher** watcher) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationStaticsWinrt::CreateWatcherDeviceClass(
DeviceClass device_class,
IDeviceWatcher** watcher) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationStaticsWinrt::CreateWatcherAqsFilter(
HSTRING aqs_filter,
IDeviceWatcher** watcher) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationStaticsWinrt::
CreateWatcherAqsFilterAndAdditionalProperties(
HSTRING aqs_filter,
IIterable<HSTRING>* additional_properties,
IDeviceWatcher** watcher) {
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_DEVICE_INFORMATION_WINRT_H_
#define DEVICE_BLUETOOTH_TEST_FAKE_DEVICE_INFORMATION_WINRT_H_
#include <windows.devices.enumeration.h>
#include <wrl/client.h>
#include <wrl/implements.h>
#include <string>
#include "base/macros.h"
namespace device {
class FakeDeviceInformationWinrt
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::Devices::Enumeration::IDeviceInformation> {
public:
explicit FakeDeviceInformationWinrt(std::string name);
~FakeDeviceInformationWinrt() override;
// IDeviceInformation:
IFACEMETHODIMP get_Id(HSTRING* value) override;
IFACEMETHODIMP get_Name(HSTRING* value) override;
IFACEMETHODIMP get_IsEnabled(boolean* value) override;
IFACEMETHODIMP get_IsDefault(boolean* value) override;
IFACEMETHODIMP get_EnclosureLocation(
ABI::Windows::Devices::Enumeration::IEnclosureLocation** value) override;
IFACEMETHODIMP get_Properties(
ABI::Windows::Foundation::Collections::IMapView<HSTRING, IInspectable*>**
value) override;
IFACEMETHODIMP Update(
ABI::Windows::Devices::Enumeration::IDeviceInformationUpdate* update_info)
override;
IFACEMETHODIMP GetThumbnailAsync(
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Enumeration::DeviceThumbnail*>** async_op)
override;
IFACEMETHODIMP GetGlyphThumbnailAsync(
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Enumeration::DeviceThumbnail*>** async_op)
override;
private:
std::string name_;
DISALLOW_COPY_AND_ASSIGN(FakeDeviceInformationWinrt);
};
class FakeDeviceInformationStaticsWinrt
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::Devices::Enumeration::IDeviceInformationStatics> {
public:
explicit FakeDeviceInformationStaticsWinrt(
Microsoft::WRL::ComPtr<
ABI::Windows::Devices::Enumeration::IDeviceInformation>
device_information);
~FakeDeviceInformationStaticsWinrt() override;
// IDeviceInformationStatics:
IFACEMETHODIMP CreateFromIdAsync(
HSTRING device_id,
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Enumeration::DeviceInformation*>** async_op)
override;
IFACEMETHODIMP CreateFromIdAsyncAdditionalProperties(
HSTRING device_id,
ABI::Windows::Foundation::Collections::IIterable<HSTRING>*
additional_properties,
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Enumeration::DeviceInformation*>** async_op)
override;
IFACEMETHODIMP FindAllAsync(
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Enumeration::DeviceInformationCollection*>**
async_op) override;
IFACEMETHODIMP FindAllAsyncDeviceClass(
ABI::Windows::Devices::Enumeration::DeviceClass device_class,
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Enumeration::DeviceInformationCollection*>**
async_op) override;
IFACEMETHODIMP FindAllAsyncAqsFilter(
HSTRING aqs_filter,
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Enumeration::DeviceInformationCollection*>**
async_op) override;
IFACEMETHODIMP
FindAllAsyncAqsFilterAndAdditionalProperties(
HSTRING aqs_filter,
ABI::Windows::Foundation::Collections::IIterable<HSTRING>*
additional_properties,
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Enumeration::DeviceInformationCollection*>**
async_op) override;
IFACEMETHODIMP CreateWatcher(
ABI::Windows::Devices::Enumeration::IDeviceWatcher** watcher) override;
IFACEMETHODIMP CreateWatcherDeviceClass(
ABI::Windows::Devices::Enumeration::DeviceClass device_class,
ABI::Windows::Devices::Enumeration::IDeviceWatcher** watcher) override;
IFACEMETHODIMP CreateWatcherAqsFilter(
HSTRING aqs_filter,
ABI::Windows::Devices::Enumeration::IDeviceWatcher** watcher) override;
IFACEMETHODIMP
CreateWatcherAqsFilterAndAdditionalProperties(
HSTRING aqs_filter,
ABI::Windows::Foundation::Collections::IIterable<HSTRING>*
additional_properties,
ABI::Windows::Devices::Enumeration::IDeviceWatcher** watcher) override;
private:
Microsoft::WRL::ComPtr<ABI::Windows::Devices::Enumeration::IDeviceInformation>
device_information_;
DISALLOW_COPY_AND_ASSIGN(FakeDeviceInformationStaticsWinrt);
};
} // namespace device
#endif // DEVICE_BLUETOOTH_TEST_FAKE_DEVICE_INFORMATION_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