Apply clang-format to Bluetooth related HAL code
- cp system/bt/.clang-format hardware/interfaces/bluetooth/
- modify hardware/interfaces/bluetooth/.clang-format to match context
- find . -type f \( -iname \*.cpp -o -iname \*.h -o -iname \*.cc \) | xargs clang-format --style=file -i
Test: make
Change-Id: I82e4f26e1efeb715aff7de8a15c3db06e02967a4
diff --git a/bluetooth/.clang-format b/bluetooth/.clang-format
new file mode 100644
index 0000000..9564994
--- /dev/null
+++ b/bluetooth/.clang-format
@@ -0,0 +1,20 @@
+#
+# Copyright 2018 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+BasedOnStyle: Google
+CommentPragmas: NOLINT:.*
+DerivePointerAlignment: false
+
diff --git a/bluetooth/1.0/default/async_fd_watcher.cc b/bluetooth/1.0/default/async_fd_watcher.cc
index 7c74643..18098ca 100644
--- a/bluetooth/1.0/default/async_fd_watcher.cc
+++ b/bluetooth/1.0/default/async_fd_watcher.cc
@@ -18,13 +18,13 @@
#include "async_fd_watcher.h"
+#include <log/log.h>
#include <algorithm>
#include <atomic>
#include <condition_variable>
#include <map>
#include <mutex>
#include <thread>
-#include <log/log.h>
#include <vector>
#include "fcntl.h"
#include "sys/select.h"
@@ -159,11 +159,9 @@
TimeoutCallback saved_cb;
{
std::unique_lock<std::mutex> guard(timeout_mutex_);
- if (timeout_ms_ > std::chrono::milliseconds(0))
- saved_cb = timeout_cb_;
+ if (timeout_ms_ > std::chrono::milliseconds(0)) saved_cb = timeout_cb_;
}
- if (saved_cb != nullptr)
- saved_cb();
+ if (saved_cb != nullptr) saved_cb();
continue;
}
@@ -180,14 +178,14 @@
std::unique_lock<std::mutex> guard(internal_mutex_);
for (auto& it : watched_fds_) {
if (FD_ISSET(it.first, &read_fds)) {
- it.second(it.first);
+ it.second(it.first);
}
}
}
}
}
-} // namespace async
-} // namespace bluetooth
-} // namespace hardware
-} // namespace android
+} // namespace async
+} // namespace bluetooth
+} // namespace hardware
+} // namespace android
diff --git a/bluetooth/1.0/default/async_fd_watcher.h b/bluetooth/1.0/default/async_fd_watcher.h
index 358cbc3..b51f921 100644
--- a/bluetooth/1.0/default/async_fd_watcher.h
+++ b/bluetooth/1.0/default/async_fd_watcher.h
@@ -60,8 +60,7 @@
std::chrono::milliseconds timeout_ms_;
};
-
-} // namespace async
-} // namespace bluetooth
-} // namespace hardware
-} // namespace android
+} // namespace async
+} // namespace bluetooth
+} // namespace hardware
+} // namespace android
diff --git a/bluetooth/1.0/default/bluetooth_address.h b/bluetooth/1.0/default/bluetooth_address.h
index 94bf616..010a113 100644
--- a/bluetooth/1.0/default/bluetooth_address.h
+++ b/bluetooth/1.0/default/bluetooth_address.h
@@ -54,8 +54,8 @@
static bool get_local_address(uint8_t* addr);
};
-} // namespace implementation
-} // namespace V1_0
-} // namespace bluetooth
-} // namespace hardware
-} // namespace android
+} // namespace implementation
+} // namespace V1_0
+} // namespace bluetooth
+} // namespace hardware
+} // namespace android
diff --git a/bluetooth/1.0/default/bluetooth_hci.h b/bluetooth/1.0/default/bluetooth_hci.h
index e2797b1..c966990 100644
--- a/bluetooth/1.0/default/bluetooth_hci.h
+++ b/bluetooth/1.0/default/bluetooth_hci.h
@@ -29,8 +29,8 @@
namespace V1_0 {
namespace implementation {
-using ::android::hardware::Return;
using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
class BluetoothDeathRecipient;
diff --git a/bluetooth/1.0/default/bt_vendor_lib.h b/bluetooth/1.0/default/bt_vendor_lib.h
index c140e52..c4035b7 100644
--- a/bluetooth/1.0/default/bt_vendor_lib.h
+++ b/bluetooth/1.0/default/bt_vendor_lib.h
@@ -418,13 +418,12 @@
// DIRECTORIES.
// ONLY USED INSIDE transmit_cb.
// DO NOT USE IN NEW HAL IMPLEMENTATIONS GOING FORWARD
-typedef struct
-{
- uint16_t event;
- uint16_t len;
- uint16_t offset;
- uint16_t layer_specific;
- uint8_t data[];
+typedef struct {
+ uint16_t event;
+ uint16_t len;
+ uint16_t offset;
+ uint16_t layer_specific;
+ uint8_t data[];
} HC_BT_HDR;
// /MODIFICATION
diff --git a/bluetooth/1.0/default/h4_protocol.cc b/bluetooth/1.0/default/h4_protocol.cc
index df40507..98e3273 100644
--- a/bluetooth/1.0/default/h4_protocol.cc
+++ b/bluetooth/1.0/default/h4_protocol.cc
@@ -34,7 +34,8 @@
{const_cast<uint8_t*>(data), length}};
ssize_t ret = 0;
do {
- ret = TEMP_FAILURE_RETRY(writev(uart_fd_, iov, sizeof(iov) / sizeof(iov[0])));
+ ret =
+ TEMP_FAILURE_RETRY(writev(uart_fd_, iov, sizeof(iov) / sizeof(iov[0])));
} while (-1 == ret && EAGAIN == errno);
if (ret == -1) {
diff --git a/bluetooth/1.0/default/hci_packetizer.cc b/bluetooth/1.0/default/hci_packetizer.cc
index 71f4328..7cb3a11 100644
--- a/bluetooth/1.0/default/hci_packetizer.cc
+++ b/bluetooth/1.0/default/hci_packetizer.cc
@@ -46,9 +46,7 @@
namespace bluetooth {
namespace hci {
-const hidl_vec<uint8_t>& HciPacketizer::GetPacket() const {
- return packet_;
-}
+const hidl_vec<uint8_t>& HciPacketizer::GetPacket() const { return packet_; }
void HciPacketizer::OnDataReady(int fd, HciPacketType packet_type) {
switch (state_) {
diff --git a/bluetooth/1.0/default/hci_protocol.cc b/bluetooth/1.0/default/hci_protocol.cc
index bf94dfe..7e88dc4 100644
--- a/bluetooth/1.0/default/hci_protocol.cc
+++ b/bluetooth/1.0/default/hci_protocol.cc
@@ -20,8 +20,8 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
-#include <unistd.h>
#include <log/log.h>
+#include <unistd.h>
namespace android {
namespace hardware {
diff --git a/bluetooth/1.0/default/service.cpp b/bluetooth/1.0/default/service.cpp
index 3a7aad0..dd3f6a9 100644
--- a/bluetooth/1.0/default/service.cpp
+++ b/bluetooth/1.0/default/service.cpp
@@ -24,9 +24,9 @@
static const size_t kMaxThreads = 5;
// Generated HIDL files
-using android::hardware::bluetooth::V1_0::IBluetoothHci;
using android::hardware::defaultPassthroughServiceImplementation;
+using android::hardware::bluetooth::V1_0::IBluetoothHci;
int main() {
- return defaultPassthroughServiceImplementation<IBluetoothHci>(kMaxThreads);
+ return defaultPassthroughServiceImplementation<IBluetoothHci>(kMaxThreads);
}
diff --git a/bluetooth/1.0/default/test/async_fd_watcher_unittest.cc b/bluetooth/1.0/default/test/async_fd_watcher_unittest.cc
index ee7d8d1..07d8d54 100644
--- a/bluetooth/1.0/default/test/async_fd_watcher_unittest.cc
+++ b/bluetooth/1.0/default/test/async_fd_watcher_unittest.cc
@@ -252,13 +252,13 @@
});
// Set a timeout flag in each callback.
- conn_watcher.ConfigureTimeout(
- std::chrono::milliseconds(500),
- [&conn_watcher, &timed_out, &timed_out2]() {
- timed_out = true;
- conn_watcher.ConfigureTimeout(std::chrono::seconds(1),
+ conn_watcher.ConfigureTimeout(std::chrono::milliseconds(500),
+ [&conn_watcher, &timed_out, &timed_out2]() {
+ timed_out = true;
+ conn_watcher.ConfigureTimeout(
+ std::chrono::seconds(1),
[&timed_out2]() { timed_out2 = true; });
- });
+ });
EXPECT_FALSE(timed_out);
EXPECT_FALSE(timed_out2);
sleep(1);
@@ -385,8 +385,8 @@
CleanUpServer();
}
-} // namespace implementation
-} // namespace V1_0
-} // namespace bluetooth
-} // namespace hardware
-} // namespace android
+} // namespace implementation
+} // namespace V1_0
+} // namespace bluetooth
+} // namespace hardware
+} // namespace android
diff --git a/bluetooth/1.0/default/test/h4_protocol_unittest.cc b/bluetooth/1.0/default/test/h4_protocol_unittest.cc
index ad08086..ba56c0d 100644
--- a/bluetooth/1.0/default/test/h4_protocol_unittest.cc
+++ b/bluetooth/1.0/default/test/h4_protocol_unittest.cc
@@ -36,8 +36,8 @@
namespace V1_0 {
namespace implementation {
-using ::testing::Eq;
using hci::H4Protocol;
+using ::testing::Eq;
static char sample_data1[100] = "A point is that which has no part.";
static char sample_data2[100] = "A line is breadthless length.";
diff --git a/bluetooth/1.0/default/test/mct_protocol_unittest.cc b/bluetooth/1.0/default/test/mct_protocol_unittest.cc
index d45058e..60dbc88 100644
--- a/bluetooth/1.0/default/test/mct_protocol_unittest.cc
+++ b/bluetooth/1.0/default/test/mct_protocol_unittest.cc
@@ -36,8 +36,8 @@
namespace V1_0 {
namespace implementation {
-using ::testing::Eq;
using hci::MctProtocol;
+using ::testing::Eq;
static char sample_data1[100] = "A point is that which has no part.";
static char sample_data2[100] = "A line is breadthless length.";
diff --git a/bluetooth/1.0/default/test/properties.cc b/bluetooth/1.0/default/test/properties.cc
index 6ac4fb4..70de01e 100644
--- a/bluetooth/1.0/default/test/properties.cc
+++ b/bluetooth/1.0/default/test/properties.cc
@@ -36,7 +36,7 @@
struct property properties[MAX_PROPERTIES];
// Find the correct entry.
-static int property_find(const char *key) {
+static int property_find(const char* key) {
for (int i = 0; i < num_properties; i++) {
if (strncmp(properties[i].key, key, PROP_KEY_MAX) == 0) {
return i;
@@ -45,7 +45,7 @@
return MAX_PROPERTIES;
}
-int property_set(const char *key, const char *value) {
+int property_set(const char* key, const char* value) {
if (strnlen(value, PROP_VALUE_MAX) > PROP_VALUE_MAX) return -1;
// Check to see if the property exists.
@@ -63,7 +63,7 @@
return 0;
}
-int property_get(const char *key, char *value, const char *default_value) {
+int property_get(const char* key, char* value, const char* default_value) {
// This doesn't mock the behavior of default value
if (default_value != NULL) ALOGE("%s: default_value is ignored!", __func__);
diff --git a/bluetooth/1.0/default/vendor_interface.cc b/bluetooth/1.0/default/vendor_interface.cc
index a8f5bb4..e5f02f3 100644
--- a/bluetooth/1.0/default/vendor_interface.cc
+++ b/bluetooth/1.0/default/vendor_interface.cc
@@ -35,8 +35,8 @@
namespace {
-using android::hardware::bluetooth::V1_0::implementation::VendorInterface;
using android::hardware::hidl_vec;
+using android::hardware::bluetooth::V1_0::implementation::VendorInterface;
struct {
tINT_CMD_CBACK cb;
@@ -258,8 +258,7 @@
fd_watcher_.WatchFdForNonBlockingReads(
fd_list[CH_EVT], [mct_hci](int fd) { mct_hci->OnEventDataReady(fd); });
fd_watcher_.WatchFdForNonBlockingReads(
- fd_list[CH_ACL_IN],
- [mct_hci](int fd) { mct_hci->OnAclDataReady(fd); });
+ fd_list[CH_ACL_IN], [mct_hci](int fd) { mct_hci->OnAclDataReady(fd); });
hci_ = mct_hci;
}
diff --git a/bluetooth/1.0/default/vendor_interface.h b/bluetooth/1.0/default/vendor_interface.h
index a401ee6..36f4e1b 100644
--- a/bluetooth/1.0/default/vendor_interface.h
+++ b/bluetooth/1.0/default/vendor_interface.h
@@ -40,9 +40,9 @@
PacketReadCallback event_cb, PacketReadCallback acl_cb,
PacketReadCallback sco_cb);
static void Shutdown();
- static VendorInterface *get();
+ static VendorInterface* get();
- size_t Send(uint8_t type, const uint8_t *data, size_t length);
+ size_t Send(uint8_t type, const uint8_t* data, size_t length);
void OnFirmwareConfigured(uint8_t result);
@@ -58,15 +58,15 @@
void HandleIncomingEvent(const hidl_vec<uint8_t>& hci_packet);
- void *lib_handle_;
- bt_vendor_interface_t *lib_interface_;
+ void* lib_handle_;
+ bt_vendor_interface_t* lib_interface_;
async::AsyncFdWatcher fd_watcher_;
InitializeCompleteCallback initialize_complete_cb_;
hci::HciProtocol* hci_;
PacketReadCallback event_cb_;
- FirmwareStartupTimer *firmware_startup_timer_;
+ FirmwareStartupTimer* firmware_startup_timer_;
};
} // namespace implementation
diff --git a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
index 439c5fb..ae84ec2 100644
--- a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
+++ b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
@@ -28,13 +28,13 @@
#include <VtsHalHidlTargetTestEnvBase.h>
#include <queue>
-using ::android::hardware::bluetooth::V1_0::IBluetoothHci;
-using ::android::hardware::bluetooth::V1_0::IBluetoothHciCallbacks;
-using ::android::hardware::bluetooth::V1_0::Status;
+using ::android::sp;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
-using ::android::sp;
+using ::android::hardware::bluetooth::V1_0::IBluetoothHci;
+using ::android::hardware::bluetooth::V1_0::IBluetoothHciCallbacks;
+using ::android::hardware::bluetooth::V1_0::Status;
#define HCI_MINIMUM_HCI_VERSION 5 // Bluetooth Core Specification 3.0 + HS
#define HCI_MINIMUM_LMP_VERSION 5 // Bluetooth Core Specification 3.0 + HS
@@ -191,12 +191,12 @@
}
virtual void TearDown() override {
- // Should not be checked in production code
- ASSERT_TRUE(bluetooth->close().isOk());
- handle_no_ops();
- EXPECT_EQ(static_cast<size_t>(0), event_queue.size());
- EXPECT_EQ(static_cast<size_t>(0), sco_queue.size());
- EXPECT_EQ(static_cast<size_t>(0), acl_queue.size());
+ // Should not be checked in production code
+ ASSERT_TRUE(bluetooth->close().isOk());
+ handle_no_ops();
+ EXPECT_EQ(static_cast<size_t>(0), event_queue.size());
+ EXPECT_EQ(static_cast<size_t>(0), sco_queue.size());
+ EXPECT_EQ(static_cast<size_t>(0), acl_queue.size());
}
void setBufferSizes();
@@ -659,10 +659,11 @@
EXPECT_LT(0, max_sco_data_packet_length);
sendAndCheckSCO(1, max_sco_data_packet_length, sco_connection_handles[0]);
int sco_packets_sent = 1;
- int completed_packets = wait_for_completed_packets_event(sco_connection_handles[0]);
+ int completed_packets =
+ wait_for_completed_packets_event(sco_connection_handles[0]);
if (sco_packets_sent != completed_packets) {
- ALOGW("%s: packets_sent (%d) != completed_packets (%d)", __func__, sco_packets_sent,
- completed_packets);
+ ALOGW("%s: packets_sent (%d) != completed_packets (%d)", __func__,
+ sco_packets_sent, completed_packets);
}
}
@@ -670,10 +671,11 @@
EXPECT_LT(0, max_acl_data_packet_length);
sendAndCheckACL(1, max_acl_data_packet_length, acl_connection_handles[0]);
int acl_packets_sent = 1;
- int completed_packets = wait_for_completed_packets_event(acl_connection_handles[0]);
+ int completed_packets =
+ wait_for_completed_packets_event(acl_connection_handles[0]);
if (acl_packets_sent != completed_packets) {
- ALOGW("%s: packets_sent (%d) != completed_packets (%d)", __func__, acl_packets_sent,
- completed_packets);
+ ALOGW("%s: packets_sent (%d) != completed_packets (%d)", __func__,
+ acl_packets_sent, completed_packets);
}
}
}
@@ -695,10 +697,11 @@
sendAndCheckSCO(NUM_SCO_PACKETS_BANDWIDTH, max_sco_data_packet_length,
sco_connection_handles[0]);
int sco_packets_sent = NUM_SCO_PACKETS_BANDWIDTH;
- int completed_packets = wait_for_completed_packets_event(sco_connection_handles[0]);
+ int completed_packets =
+ wait_for_completed_packets_event(sco_connection_handles[0]);
if (sco_packets_sent != completed_packets) {
- ALOGW("%s: packets_sent (%d) != completed_packets (%d)", __func__, sco_packets_sent,
- completed_packets);
+ ALOGW("%s: packets_sent (%d) != completed_packets (%d)", __func__,
+ sco_packets_sent, completed_packets);
}
}
@@ -707,10 +710,11 @@
sendAndCheckACL(NUM_ACL_PACKETS_BANDWIDTH, max_acl_data_packet_length,
acl_connection_handles[0]);
int acl_packets_sent = NUM_ACL_PACKETS_BANDWIDTH;
- int completed_packets = wait_for_completed_packets_event(acl_connection_handles[0]);
+ int completed_packets =
+ wait_for_completed_packets_event(acl_connection_handles[0]);
if (acl_packets_sent != completed_packets) {
- ALOGW("%s: packets_sent (%d) != completed_packets (%d)", __func__, acl_packets_sent,
- completed_packets);
+ ALOGW("%s: packets_sent (%d) != completed_packets (%d)", __func__,
+ acl_packets_sent, completed_packets);
}
}
}
diff --git a/bluetooth/a2dp/1.0/default/BluetoothAudioOffload.cpp b/bluetooth/a2dp/1.0/default/BluetoothAudioOffload.cpp
index 2a66abe..9abb88d 100644
--- a/bluetooth/a2dp/1.0/default/BluetoothAudioOffload.cpp
+++ b/bluetooth/a2dp/1.0/default/BluetoothAudioOffload.cpp
@@ -23,47 +23,52 @@
namespace V1_0 {
namespace implementation {
-IBluetoothAudioOffload* HIDL_FETCH_IBluetoothAudioOffload(const char* /* name */) {
- return new BluetoothAudioOffload();
+IBluetoothAudioOffload* HIDL_FETCH_IBluetoothAudioOffload(
+ const char* /* name */) {
+ return new BluetoothAudioOffload();
}
-// Methods from ::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioOffload follow.
-Return<::android::hardware::bluetooth::a2dp::V1_0::Status> BluetoothAudioOffload::startSession(
- const sp<::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioHost>& hostIf __unused,
- const ::android::hardware::bluetooth::a2dp::V1_0::CodecConfiguration& codecConfig __unused) {
- /**
- * Initialize the audio platform if codecConfiguration is supported.
- * Save the the IBluetoothAudioHost interface, so that it can be used
- * later to send stream control commands to the HAL client, based on
- * interaction with Audio framework.
- */
- return ::android::hardware::bluetooth::a2dp::V1_0::Status::FAILURE;
+// Methods from
+// ::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioOffload follow.
+Return<::android::hardware::bluetooth::a2dp::V1_0::Status>
+BluetoothAudioOffload::startSession(
+ const sp<::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioHost>&
+ hostIf __unused,
+ const ::android::hardware::bluetooth::a2dp::V1_0::CodecConfiguration&
+ codecConfig __unused) {
+ /**
+ * Initialize the audio platform if codecConfiguration is supported.
+ * Save the the IBluetoothAudioHost interface, so that it can be used
+ * later to send stream control commands to the HAL client, based on
+ * interaction with Audio framework.
+ */
+ return ::android::hardware::bluetooth::a2dp::V1_0::Status::FAILURE;
}
Return<void> BluetoothAudioOffload::streamStarted(
::android::hardware::bluetooth::a2dp::V1_0::Status status __unused) {
- /**
- * Streaming on control path has started,
- * HAL server should start the streaming on data path.
- */
- return Void();
+ /**
+ * Streaming on control path has started,
+ * HAL server should start the streaming on data path.
+ */
+ return Void();
}
Return<void> BluetoothAudioOffload::streamSuspended(
::android::hardware::bluetooth::a2dp::V1_0::Status status __unused) {
- /**
- * Streaming on control path has suspend,
- * HAL server should suspend the streaming on data path.
- */
- return Void();
+ /**
+ * Streaming on control path has suspend,
+ * HAL server should suspend the streaming on data path.
+ */
+ return Void();
}
Return<void> BluetoothAudioOffload::endSession() {
- /**
- * Cleanup the audio platform as remote A2DP Sink device is no
- * longer active
- */
- return Void();
+ /**
+ * Cleanup the audio platform as remote A2DP Sink device is no
+ * longer active
+ */
+ return Void();
}
} // namespace implementation
diff --git a/bluetooth/a2dp/1.0/default/BluetoothAudioOffload.h b/bluetooth/a2dp/1.0/default/BluetoothAudioOffload.h
index 5d07b5b..16a83c2 100644
--- a/bluetooth/a2dp/1.0/default/BluetoothAudioOffload.h
+++ b/bluetooth/a2dp/1.0/default/BluetoothAudioOffload.h
@@ -28,27 +28,32 @@
namespace V1_0 {
namespace implementation {
+using ::android::sp;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
-using ::android::sp;
struct BluetoothAudioOffload : public IBluetoothAudioOffload {
- BluetoothAudioOffload() {}
- // Methods from ::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioOffload follow.
- Return<::android::hardware::bluetooth::a2dp::V1_0::Status> startSession(
- const sp<::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioHost>& hostIf,
- const ::android::hardware::bluetooth::a2dp::V1_0::CodecConfiguration& codecConfig) override;
- Return<void> streamStarted(::android::hardware::bluetooth::a2dp::V1_0::Status status) override;
- Return<void> streamSuspended(
- ::android::hardware::bluetooth::a2dp::V1_0::Status status) override;
- Return<void> endSession() override;
+ BluetoothAudioOffload() {}
+ // Methods from
+ // ::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioOffload follow.
+ Return<::android::hardware::bluetooth::a2dp::V1_0::Status> startSession(
+ const sp<::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioHost>&
+ hostIf,
+ const ::android::hardware::bluetooth::a2dp::V1_0::CodecConfiguration&
+ codecConfig) override;
+ Return<void> streamStarted(
+ ::android::hardware::bluetooth::a2dp::V1_0::Status status) override;
+ Return<void> streamSuspended(
+ ::android::hardware::bluetooth::a2dp::V1_0::Status status) override;
+ Return<void> endSession() override;
};
-extern "C" IBluetoothAudioOffload* HIDL_FETCH_IBluetoothAudioOffload(const char* name);
+extern "C" IBluetoothAudioOffload* HIDL_FETCH_IBluetoothAudioOffload(
+ const char* name);
} // namespace implementation
} // namespace V1_0
diff --git a/bluetooth/a2dp/1.0/vts/functional/VtsHalBluetoothA2dpV1_0TargetTest.cpp b/bluetooth/a2dp/1.0/vts/functional/VtsHalBluetoothA2dpV1_0TargetTest.cpp
index 1a0342f..d8d0c29 100644
--- a/bluetooth/a2dp/1.0/vts/functional/VtsHalBluetoothA2dpV1_0TargetTest.cpp
+++ b/bluetooth/a2dp/1.0/vts/functional/VtsHalBluetoothA2dpV1_0TargetTest.cpp
@@ -26,85 +26,92 @@
#include <VtsHalHidlTargetTestBase.h>
#include <VtsHalHidlTargetTestEnvBase.h>
-using ::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioHost;
-using ::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioOffload;
-using ::android::hardware::bluetooth::a2dp::V1_0::Status;
-using ::android::hardware::bluetooth::a2dp::V1_0::CodecType;
-using ::android::hardware::bluetooth::a2dp::V1_0::SampleRate;
+using ::android::sp;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
using ::android::hardware::bluetooth::a2dp::V1_0::BitsPerSample;
using ::android::hardware::bluetooth::a2dp::V1_0::ChannelMode;
using ::android::hardware::bluetooth::a2dp::V1_0::CodecConfiguration;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
+using ::android::hardware::bluetooth::a2dp::V1_0::CodecType;
+using ::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioHost;
+using ::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioOffload;
+using ::android::hardware::bluetooth::a2dp::V1_0::SampleRate;
+using ::android::hardware::bluetooth::a2dp::V1_0::Status;
// Test environment for Bluetooth HIDL A2DP HAL.
-class BluetoothA2dpHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
- public:
- // get the test environment singleton
- static BluetoothA2dpHidlEnvironment* Instance() {
- static BluetoothA2dpHidlEnvironment* instance = new BluetoothA2dpHidlEnvironment;
- return instance;
- }
+class BluetoothA2dpHidlEnvironment
+ : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static BluetoothA2dpHidlEnvironment* Instance() {
+ static BluetoothA2dpHidlEnvironment* instance =
+ new BluetoothA2dpHidlEnvironment;
+ return instance;
+ }
- virtual void registerTestServices() override { registerTestService<IBluetoothAudioOffload>(); }
+ virtual void registerTestServices() override {
+ registerTestService<IBluetoothAudioOffload>();
+ }
- private:
- BluetoothA2dpHidlEnvironment() {}
+ private:
+ BluetoothA2dpHidlEnvironment() {}
};
// The main test class for Bluetooth A2DP HIDL HAL.
class BluetoothA2dpHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+ public:
+ virtual void SetUp() override {
+ // currently test passthrough mode only
+ audio_offload =
+ ::testing::VtsHalHidlTargetTestBase::getService<IBluetoothAudioOffload>(
+ BluetoothA2dpHidlEnvironment::Instance()
+ ->getServiceName<IBluetoothAudioOffload>());
+ ASSERT_NE(audio_offload, nullptr);
+
+ audio_host = new BluetoothAudioHost(*this);
+ ASSERT_NE(audio_host, nullptr);
+
+ codec.codecType = CodecType::AAC;
+ codec.sampleRate = SampleRate::RATE_44100;
+ codec.bitsPerSample = BitsPerSample::BITS_16;
+ codec.channelMode = ChannelMode::STEREO;
+ codec.encodedAudioBitrate = 320000;
+ codec.peerMtu = 1000;
+ }
+
+ virtual void TearDown() override {}
+
+ // A simple test implementation of IBluetoothAudioHost.
+ class BluetoothAudioHost
+ : public ::testing::VtsHalHidlTargetCallbackBase<BluetoothA2dpHidlTest>,
+ public IBluetoothAudioHost {
+ BluetoothA2dpHidlTest& parent_;
+
public:
- virtual void SetUp() override {
- // currently test passthrough mode only
- audio_offload = ::testing::VtsHalHidlTargetTestBase::getService<IBluetoothAudioOffload>(
- BluetoothA2dpHidlEnvironment::Instance()->getServiceName<IBluetoothAudioOffload>());
- ASSERT_NE(audio_offload, nullptr);
+ BluetoothAudioHost(BluetoothA2dpHidlTest& parent) : parent_(parent){};
+ virtual ~BluetoothAudioHost() = default;
- audio_host = new BluetoothAudioHost(*this);
- ASSERT_NE(audio_host, nullptr);
-
- codec.codecType = CodecType::AAC;
- codec.sampleRate = SampleRate::RATE_44100;
- codec.bitsPerSample = BitsPerSample::BITS_16;
- codec.channelMode = ChannelMode::STEREO;
- codec.encodedAudioBitrate = 320000;
- codec.peerMtu = 1000;
- }
-
- virtual void TearDown() override {}
-
- // A simple test implementation of IBluetoothAudioHost.
- class BluetoothAudioHost
- : public ::testing::VtsHalHidlTargetCallbackBase<BluetoothA2dpHidlTest>,
- public IBluetoothAudioHost {
- BluetoothA2dpHidlTest& parent_;
-
- public:
- BluetoothAudioHost(BluetoothA2dpHidlTest& parent) : parent_(parent){};
- virtual ~BluetoothAudioHost() = default;
-
- Return<void> startStream() override {
- parent_.audio_offload->streamStarted(Status::SUCCESS);
- return Void();
- };
-
- Return<void> suspendStream() override {
- parent_.audio_offload->streamSuspended(Status::SUCCESS);
- return Void();
- };
-
- Return<void> stopStream() override { return Void(); };
+ Return<void> startStream() override {
+ parent_.audio_offload->streamStarted(Status::SUCCESS);
+ return Void();
};
- // audio_host is for the Audio HAL to send stream start/suspend/stop commands to Bluetooth
- sp<IBluetoothAudioHost> audio_host;
- // audio_offload is for the Bluetooth HAL to report session started/ended and handled audio
- // stream started/suspended
- sp<IBluetoothAudioOffload> audio_offload;
- // codec is the currently used codec
- CodecConfiguration codec;
+ Return<void> suspendStream() override {
+ parent_.audio_offload->streamSuspended(Status::SUCCESS);
+ return Void();
+ };
+
+ Return<void> stopStream() override { return Void(); };
+ };
+
+ // audio_host is for the Audio HAL to send stream start/suspend/stop commands
+ // to Bluetooth
+ sp<IBluetoothAudioHost> audio_host;
+ // audio_offload is for the Bluetooth HAL to report session started/ended and
+ // handled audio stream started/suspended
+ sp<IBluetoothAudioOffload> audio_offload;
+ // codec is the currently used codec
+ CodecConfiguration codec;
};
// Empty test: Initialize()/Close() are called in SetUp()/TearDown().
@@ -112,15 +119,15 @@
// Test start and end session
TEST_F(BluetoothA2dpHidlTest, StartAndEndSession) {
- EXPECT_EQ(Status::SUCCESS, audio_offload->startSession(audio_host, codec));
- audio_offload->endSession();
+ EXPECT_EQ(Status::SUCCESS, audio_offload->startSession(audio_host, codec));
+ audio_offload->endSession();
}
int main(int argc, char** argv) {
- ::testing::AddGlobalTestEnvironment(BluetoothA2dpHidlEnvironment::Instance());
- ::testing::InitGoogleTest(&argc, argv);
- BluetoothA2dpHidlEnvironment::Instance()->init(&argc, argv);
- int status = RUN_ALL_TESTS();
- LOG(INFO) << "Test result = " << status;
- return status;
+ ::testing::AddGlobalTestEnvironment(BluetoothA2dpHidlEnvironment::Instance());
+ ::testing::InitGoogleTest(&argc, argv);
+ BluetoothA2dpHidlEnvironment::Instance()->init(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ LOG(INFO) << "Test result = " << status;
+ return status;
}