Commit 35fbdd40 authored by scheib's avatar scheib Committed by Commit bot

bluetooth: Stub out BluetoothAdapterAndroid

BUG=471536

Review URL: https://codereview.chromium.org/1080593007

Cr-Commit-Position: refs/heads/master@{#327562}
parent cb91176f
......@@ -16,6 +16,7 @@ test("device_unittests") {
sources = [
"battery/battery_status_manager_win_unittest.cc",
"battery/battery_status_service_unittest.cc",
"bluetooth/bluetooth_adapter_android_unittest.cc",
"bluetooth/bluetooth_adapter_mac_unittest.mm",
"bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc",
"bluetooth/bluetooth_adapter_unittest.cc",
......
......@@ -21,6 +21,8 @@ component("bluetooth") {
sources = [
"bluetooth_adapter.cc",
"bluetooth_adapter.h",
"bluetooth_adapter_android.cc",
"bluetooth_adapter_android.h",
"bluetooth_adapter_chromeos.cc",
"bluetooth_adapter_chromeos.h",
"bluetooth_adapter_factory.cc",
......
......@@ -25,6 +25,8 @@
# Note: file list duplicated in GN build.
'bluetooth_adapter.cc',
'bluetooth_adapter.h',
'bluetooth_adapter_android.cc',
'bluetooth_adapter_android.h',
'bluetooth_adapter_chromeos.cc',
'bluetooth_adapter_chromeos.h',
'bluetooth_adapter_factory.cc',
......
......@@ -16,7 +16,8 @@ BluetoothAdapter::ServiceOptions::ServiceOptions() {
BluetoothAdapter::ServiceOptions::~ServiceOptions() {
}
#if !defined(OS_CHROMEOS) && !defined(OS_WIN) && !defined(OS_MACOSX)
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) && !defined(OS_MACOSX) && \
!defined(OS_WIN)
//static
base::WeakPtr<BluetoothAdapter> BluetoothAdapter::CreateAdapter(
const InitCallback& init_callback) {
......
// Copyright 2015 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_adapter_android.h"
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "device/bluetooth/bluetooth_advertisement.h"
namespace device {
// static
base::WeakPtr<BluetoothAdapter> BluetoothAdapter::CreateAdapter(
const InitCallback& init_callback) {
return BluetoothAdapterAndroid::CreateAdapter();
}
// static
base::WeakPtr<BluetoothAdapter> BluetoothAdapterAndroid::CreateAdapter() {
BluetoothAdapterAndroid* adapter = new BluetoothAdapterAndroid();
return adapter->weak_ptr_factory_.GetWeakPtr();
}
std::string BluetoothAdapterAndroid::GetAddress() const {
return address_;
}
std::string BluetoothAdapterAndroid::GetName() const {
return name_;
}
void BluetoothAdapterAndroid::SetName(const std::string& name,
const base::Closure& callback,
const ErrorCallback& error_callback) {
NOTIMPLEMENTED();
}
bool BluetoothAdapterAndroid::IsInitialized() const {
NOTIMPLEMENTED();
return false;
}
bool BluetoothAdapterAndroid::IsPresent() const {
NOTIMPLEMENTED();
return false;
}
bool BluetoothAdapterAndroid::IsPowered() const {
NOTIMPLEMENTED();
return false;
}
void BluetoothAdapterAndroid::SetPowered(bool powered,
const base::Closure& callback,
const ErrorCallback& error_callback) {
NOTIMPLEMENTED();
}
bool BluetoothAdapterAndroid::IsDiscoverable() const {
NOTIMPLEMENTED();
return false;
}
void BluetoothAdapterAndroid::SetDiscoverable(
bool discoverable,
const base::Closure& callback,
const ErrorCallback& error_callback) {
NOTIMPLEMENTED();
}
bool BluetoothAdapterAndroid::IsDiscovering() const {
NOTIMPLEMENTED();
return false;
}
void BluetoothAdapterAndroid::CreateRfcommService(
const BluetoothUUID& uuid,
const ServiceOptions& options,
const CreateServiceCallback& callback,
const CreateServiceErrorCallback& error_callback) {
NOTIMPLEMENTED();
error_callback.Run("Not Implemented");
}
void BluetoothAdapterAndroid::CreateL2capService(
const BluetoothUUID& uuid,
const ServiceOptions& options,
const CreateServiceCallback& callback,
const CreateServiceErrorCallback& error_callback) {
NOTIMPLEMENTED();
error_callback.Run("Not Implemented");
}
void BluetoothAdapterAndroid::RegisterAudioSink(
const BluetoothAudioSink::Options& options,
const AcquiredCallback& callback,
const BluetoothAudioSink::ErrorCallback& error_callback) {
error_callback.Run(BluetoothAudioSink::ERROR_UNSUPPORTED_PLATFORM);
}
void BluetoothAdapterAndroid::RegisterAdvertisement(
scoped_ptr<BluetoothAdvertisement::Data> advertisement_data,
const CreateAdvertisementCallback& callback,
const CreateAdvertisementErrorCallback& error_callback) {
error_callback.Run(BluetoothAdvertisement::ERROR_UNSUPPORTED_PLATFORM);
}
BluetoothAdapterAndroid::BluetoothAdapterAndroid() : weak_ptr_factory_(this) {
}
BluetoothAdapterAndroid::~BluetoothAdapterAndroid() {
}
void BluetoothAdapterAndroid::AddDiscoverySession(
BluetoothDiscoveryFilter* discovery_filter,
const base::Closure& callback,
const ErrorCallback& error_callback) {
}
void BluetoothAdapterAndroid::RemoveDiscoverySession(
BluetoothDiscoveryFilter* discovery_filter,
const base::Closure& callback,
const ErrorCallback& error_callback) {
}
void BluetoothAdapterAndroid::SetDiscoveryFilter(
scoped_ptr<BluetoothDiscoveryFilter> discovery_filter,
const base::Closure& callback,
const ErrorCallback& error_callback) {
}
void BluetoothAdapterAndroid::RemovePairingDelegateInternal(
device::BluetoothDevice::PairingDelegate* pairing_delegate) {
}
} // namespace device
// Copyright 2015 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_ADAPTER_ANDROID_H_
#define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_
#include "base/memory/weak_ptr.h"
#include "device/bluetooth/bluetooth_adapter.h"
namespace base {
class SequencedTaskRunner;
} // namespace base
namespace device {
// The BluetoothAdapterAndroid class implements BluetoothAdapter for the
// Android platform.
class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterAndroid final
: public BluetoothAdapter {
public:
static base::WeakPtr<BluetoothAdapter> CreateAdapter();
// BluetoothAdapter:
std::string GetAddress() const override;
std::string GetName() const override;
void SetName(const std::string& name,
const base::Closure& callback,
const ErrorCallback& error_callback) override;
bool IsInitialized() const override;
bool IsPresent() const override;
bool IsPowered() const override;
void SetPowered(bool powered,
const base::Closure& callback,
const ErrorCallback& error_callback) override;
bool IsDiscoverable() const override;
void SetDiscoverable(bool discoverable,
const base::Closure& callback,
const ErrorCallback& error_callback) override;
bool IsDiscovering() const override;
void CreateRfcommService(
const BluetoothUUID& uuid,
const ServiceOptions& options,
const CreateServiceCallback& callback,
const CreateServiceErrorCallback& error_callback) override;
void CreateL2capService(
const BluetoothUUID& uuid,
const ServiceOptions& options,
const CreateServiceCallback& callback,
const CreateServiceErrorCallback& error_callback) override;
void RegisterAudioSink(
const BluetoothAudioSink::Options& options,
const AcquiredCallback& callback,
const BluetoothAudioSink::ErrorCallback& error_callback) override;
void RegisterAdvertisement(
scoped_ptr<BluetoothAdvertisement::Data> advertisement_data,
const CreateAdvertisementCallback& callback,
const CreateAdvertisementErrorCallback& error_callback) override;
protected:
BluetoothAdapterAndroid();
~BluetoothAdapterAndroid() override;
// BluetoothAdapter:
void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter,
const base::Closure& callback,
const ErrorCallback& error_callback) override;
void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter,
const base::Closure& callback,
const ErrorCallback& error_callback) override;
void SetDiscoveryFilter(scoped_ptr<BluetoothDiscoveryFilter> discovery_filter,
const base::Closure& callback,
const ErrorCallback& error_callback) override;
void RemovePairingDelegateInternal(
BluetoothDevice::PairingDelegate* pairing_delegate) override;
std::string address_;
std::string name_;
// Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed.
base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid);
};
} // namespace device
#endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_
// Copyright 2015 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 "base/memory/ref_counted.h"
#include "device/bluetooth/bluetooth_adapter_android.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace device {
class BluetoothAdapterAndroidTest : public testing::Test {
protected:
BluetoothAdapterAndroidTest() {
adapter_ = BluetoothAdapterAndroid::CreateAdapter().get();
}
scoped_refptr<BluetoothAdapter> adapter_;
};
TEST_F(BluetoothAdapterAndroidTest, Construct) {
EXPECT_TRUE(adapter_.get());
}
} // namespace device
......@@ -32,6 +32,7 @@
'battery/battery_status_manager_linux_unittest.cc',
'battery/battery_status_manager_win_unittest.cc',
'battery/battery_status_service_unittest.cc',
'bluetooth/bluetooth_adapter_android_unittest.cc',
'bluetooth/bluetooth_adapter_mac_unittest.mm',
'bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc',
'bluetooth/bluetooth_adapter_unittest.cc',
......
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