summaryrefslogtreecommitdiff
path: root/cras
diff options
context:
space:
mode:
authorHsin-Yu Chao <hychao@chromium.org>2016-06-22 15:02:17 +0800
committerchrome-bot <chrome-bot@chromium.org>2016-06-24 04:36:06 -0700
commita0bb5828a2f34a4722285a8b23c9418d66d95859 (patch)
tree58e0190b73a90a060881e50635b8b4a23f22a311 /cras
parentdace0e596c97dfa4b0a2b3baa3004376eb2fd2c0 (diff)
downloadadhd-a0bb5828a2f34a4722285a8b23c9418d66d95859.tar.gz
CRAS: bt_io - Fix empty stable id on bt_io
The active node of bt_io doesn't have its stable_id filled so it's always 0x00000000. This could cause problem in Chrome UI to mess up preferences of two different BT headsets. BUG=None TEST=Connect BT headset, cras_test_client --dump_s to verify that all BT nodes has a valid stable_id. Change-Id: I5979dee87976ae1f6993483c853974675b7c0489 Reviewed-on: https://chromium-review.googlesource.com/354794 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Chinyue Chen <chinyue@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'cras')
-rw-r--r--cras/src/Makefile.am2
-rw-r--r--cras/src/server/cras_bt_io.c5
-rw-r--r--cras/src/tests/bt_io_unittest.cc5
3 files changed, 11 insertions, 1 deletions
diff --git a/cras/src/Makefile.am b/cras/src/Makefile.am
index 7412ad9b..27cb2311 100644
--- a/cras/src/Makefile.am
+++ b/cras/src/Makefile.am
@@ -481,7 +481,7 @@ bt_device_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/server \
-I$(top_srcdir)/src/common $(DBUS_CFLAGS)
bt_device_unittest_LDADD = -lgtest -lpthread $(DBUS_LIBS)
-bt_io_unittest_SOURCES = tests/bt_io_unittest.cc
+bt_io_unittest_SOURCES = tests/bt_io_unittest.cc common/sfh.c
bt_io_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/server \
-I$(top_srcdir)/src/common $(DBUS_CFLAGS)
bt_io_unittest_LDADD = -lgtest -lpthread $(DBUS_LIBS)
diff --git a/cras/src/server/cras_bt_io.c b/cras/src/server/cras_bt_io.c
index a82edc1e..a538d190 100644
--- a/cras/src/server/cras_bt_io.c
+++ b/cras/src/server/cras_bt_io.c
@@ -10,6 +10,7 @@
#include "cras_utf8.h"
#include "cras_iodev.h"
#include "cras_iodev_list.h"
+#include "sfh.h"
#include "utlist.h"
#define DEFAULT_BT_DEVICE_NAME "BLUETOOTH"
@@ -376,6 +377,10 @@ struct cras_iodev *cras_bt_io_create(struct cras_bt_device *device,
active->base.type = CRAS_NODE_TYPE_BLUETOOTH;
active->base.volume = 100;
active->base.plugged = 1;
+ active->base.stable_id = SuperFastHash(
+ cras_bt_device_object_path(device),
+ strlen(cras_bt_device_object_path(device)),
+ strlen(cras_bt_device_object_path(device)));
active->profile = profile;
active->profile_dev = dev;
gettimeofday(&active->base.plugged_time, NULL);
diff --git a/cras/src/tests/bt_io_unittest.cc b/cras/src/tests/bt_io_unittest.cc
index f0ef8708..7f9fc43e 100644
--- a/cras/src/tests/bt_io_unittest.cc
+++ b/cras/src/tests/bt_io_unittest.cc
@@ -437,6 +437,11 @@ int cras_bt_device_switch_profile_enable_dev(struct cras_bt_device *device,
return 0;
}
+const char *cras_bt_device_object_path(const struct cras_bt_device *device)
+{
+ return "/fake/object/path";
+}
+
int is_utf8_string(const char* string)
{
return is_utf8_string_ret_value;