NFC VTS test use VtsHalHidlCallbackBase for callback wait and notify
am: 859f18bec0
Change-Id: I46175ab4cd7ab9106313c8d97ea773f89d638e23
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..787d47a
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,28 @@
+#
+# Copyright (C) 2017 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.
+#
+
+#
+# Below are some minor deviations from the default Google style to
+# accommodate for handling of the large legacy code base.
+#
+
+BasedOnStyle: Google
+CommentPragmas: NOLINT:.*
+DerivePointerAlignment: false
+AllowShortFunctionsOnASingleLine: Inline
+TabWidth: 4
+UseTab: Never
+IndentWidth: 4
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
new file mode 100644
index 0000000..213c93a
--- /dev/null
+++ b/PREUPLOAD.cfg
@@ -0,0 +1,5 @@
+[Options]
+ignore_merged_commits = true
+
+[Builtin Hooks]
+clang_format = true
diff --git a/bluetooth/1.0/default/vendor_interface.cc b/bluetooth/1.0/default/vendor_interface.cc
index 68cac5f..bb66460 100644
--- a/bluetooth/1.0/default/vendor_interface.cc
+++ b/bluetooth/1.0/default/vendor_interface.cc
@@ -16,8 +16,6 @@
#include "vendor_interface.h"
-#include <assert.h>
-
#define LOG_TAG "android.hardware.bluetooth@1.0-impl"
#include <android-base/logging.h>
#include <cutils/properties.h>
@@ -165,7 +163,7 @@
InitializeCompleteCallback initialize_complete_cb,
PacketReadCallback event_cb, PacketReadCallback acl_cb,
PacketReadCallback sco_cb) {
- assert(!g_vendor_interface);
+ CHECK(!g_vendor_interface);
g_vendor_interface = new VendorInterface();
return g_vendor_interface->Open(initialize_complete_cb, event_cb, acl_cb,
sco_cb);
diff --git a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
index 6156553..d699f21 100644
--- a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
+++ b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
@@ -158,7 +158,7 @@
EXPECT_TRUE(
bluetooth_cb->WaitForCallback(kCallbackNameInitializationComplete)
- .first);
+ .no_timeout);
ASSERT_EQ(initialized, true);
}
@@ -260,12 +260,12 @@
int status_event_count = 0;
hidl_vec<uint8_t> event;
do {
- EXPECT_TRUE(
- bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
- EXPECT_LT(static_cast<size_t>(0), event_queue.size());
- if (event_queue.size() == 0) {
- event.resize(0);
- break;
+ EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived)
+ .no_timeout);
+ EXPECT_LT(static_cast<size_t>(0), event_queue.size());
+ if (event_queue.size() == 0) {
+ event.resize(0);
+ break;
}
event = event_queue.front();
event_queue.pop();
@@ -294,7 +294,7 @@
bluetooth->sendHciCommand(cmd);
EXPECT_TRUE(
- bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
+ bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).no_timeout);
EXPECT_LT(static_cast<size_t>(0), event_queue.size());
if (event_queue.size() == 0) return;
@@ -348,8 +348,8 @@
bluetooth->sendHciCommand(cmd);
// Check the loopback of the HCI packet
- EXPECT_TRUE(
- bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
+ EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived)
+ .no_timeout);
hidl_vec<uint8_t> event = event_queue.front();
event_queue.pop();
size_t compare_length =
@@ -385,8 +385,8 @@
bluetooth->sendScoData(sco_vector);
// Check the loopback of the SCO packet
- EXPECT_TRUE(
- bluetooth_cb->WaitForCallback(kCallbackNameScoEventReceived).first);
+ EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameScoEventReceived)
+ .no_timeout);
hidl_vec<uint8_t> sco_loopback = sco_queue.front();
sco_queue.pop();
@@ -431,8 +431,8 @@
bluetooth->sendAclData(acl_vector);
// Check the loopback of the ACL packet
- EXPECT_TRUE(
- bluetooth_cb->WaitForCallback(kCallbackNameAclEventReceived).first);
+ EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameAclEventReceived)
+ .no_timeout);
hidl_vec<uint8_t> acl_loopback = acl_queue.front();
acl_queue.pop();
@@ -458,20 +458,20 @@
// Return the number of completed packets reported by the controller.
int BluetoothHidlTest::wait_for_completed_packets_event(uint16_t handle) {
- EXPECT_TRUE(
- bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
- int packets_processed = 0;
- while (event_queue.size() > 0) {
- hidl_vec<uint8_t> event = event_queue.front();
- event_queue.pop();
+ EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived)
+ .no_timeout);
+ int packets_processed = 0;
+ while (event_queue.size() > 0) {
+ hidl_vec<uint8_t> event = event_queue.front();
+ event_queue.pop();
- EXPECT_EQ(EVENT_NUMBER_OF_COMPLETED_PACKETS, event[EVENT_CODE_BYTE]);
- EXPECT_EQ(1, event[EVENT_NUMBER_OF_COMPLETED_PACKETS_NUM_HANDLES]);
+ EXPECT_EQ(EVENT_NUMBER_OF_COMPLETED_PACKETS, event[EVENT_CODE_BYTE]);
+ EXPECT_EQ(1, event[EVENT_NUMBER_OF_COMPLETED_PACKETS_NUM_HANDLES]);
- uint16_t event_handle = event[3] + (event[4] << 8);
- EXPECT_EQ(handle, event_handle);
+ uint16_t event_handle = event[3] + (event[4] << 8);
+ EXPECT_EQ(handle, event_handle);
- packets_processed += event[5] + (event[6] << 8);
+ packets_processed += event[5] + (event[6] << 8);
}
return packets_processed;
}
@@ -486,33 +486,34 @@
int connection_event_count = 0;
hidl_vec<uint8_t> event;
do {
- EXPECT_TRUE(
- bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
- event = event_queue.front();
- event_queue.pop();
- EXPECT_GT(event.size(),
- static_cast<size_t>(EVENT_COMMAND_COMPLETE_STATUS_BYTE));
- if (event[EVENT_CODE_BYTE] == EVENT_CONNECTION_COMPLETE) {
+ EXPECT_TRUE(bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived)
+ .no_timeout);
+ event = event_queue.front();
+ event_queue.pop();
EXPECT_GT(event.size(),
- static_cast<size_t>(EVENT_CONNECTION_COMPLETE_TYPE));
- EXPECT_EQ(event[EVENT_LENGTH_BYTE],
- EVENT_CONNECTION_COMPLETE_PARAM_LENGTH);
- uint8_t connection_type = event[EVENT_CONNECTION_COMPLETE_TYPE];
+ static_cast<size_t>(EVENT_COMMAND_COMPLETE_STATUS_BYTE));
+ if (event[EVENT_CODE_BYTE] == EVENT_CONNECTION_COMPLETE) {
+ EXPECT_GT(event.size(),
+ static_cast<size_t>(EVENT_CONNECTION_COMPLETE_TYPE));
+ EXPECT_EQ(event[EVENT_LENGTH_BYTE],
+ EVENT_CONNECTION_COMPLETE_PARAM_LENGTH);
+ uint8_t connection_type = event[EVENT_CONNECTION_COMPLETE_TYPE];
- EXPECT_TRUE(connection_type == EVENT_CONNECTION_COMPLETE_TYPE_SCO ||
- connection_type == EVENT_CONNECTION_COMPLETE_TYPE_ACL);
+ EXPECT_TRUE(connection_type == EVENT_CONNECTION_COMPLETE_TYPE_SCO ||
+ connection_type == EVENT_CONNECTION_COMPLETE_TYPE_ACL);
- // Save handles
- uint16_t handle = event[EVENT_CONNECTION_COMPLETE_HANDLE_LSBYTE] |
- event[EVENT_CONNECTION_COMPLETE_HANDLE_LSBYTE + 1] << 8;
- if (connection_type == EVENT_CONNECTION_COMPLETE_TYPE_SCO)
- sco_handles.push_back(handle);
- else
- acl_handles.push_back(handle);
+ // Save handles
+ uint16_t handle = event[EVENT_CONNECTION_COMPLETE_HANDLE_LSBYTE] |
+ event[EVENT_CONNECTION_COMPLETE_HANDLE_LSBYTE + 1]
+ << 8;
+ if (connection_type == EVENT_CONNECTION_COMPLETE_TYPE_SCO)
+ sco_handles.push_back(handle);
+ else
+ acl_handles.push_back(handle);
- ALOGD("Connect complete type = %d handle = %d",
- event[EVENT_CONNECTION_COMPLETE_TYPE], handle);
- connection_event_count++;
+ ALOGD("Connect complete type = %d handle = %d",
+ event[EVENT_CONNECTION_COMPLETE_TYPE], handle);
+ connection_event_count++;
}
} while (event[EVENT_CODE_BYTE] == EVENT_CONNECTION_COMPLETE);
@@ -541,7 +542,7 @@
bluetooth->sendHciCommand(cmd);
EXPECT_TRUE(
- bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
+ bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).no_timeout);
hidl_vec<uint8_t> event = event_queue.front();
event_queue.pop();
@@ -562,7 +563,7 @@
bluetooth->sendHciCommand(cmd);
EXPECT_TRUE(
- bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).first);
+ bluetooth_cb->WaitForCallback(kCallbackNameHciEventReceived).no_timeout);
hidl_vec<uint8_t> event = event_queue.front();
event_queue.pop();