* Re: [PATCH 60/73] drivers/bluetooth: delete non-required instances of include <linux/init.h>
From: Marcel Holtmann @ 2014-01-21 21:55 UTC (permalink / raw)
To: Paul Gortmaker
Cc: linux-kernel, linux-arch, Gustavo F. Padovan, Johan Hedberg,
linux-bluetooth@vger.kernel.org development
In-Reply-To: <1390339396-3479-61-git-send-email-paul.gortmaker@windriver.com>
Hi Paul,
> None of these files are actually using any __init type directives
> and hence don't need to include <linux/init.h>. Most are just a
> left over from __devinit and __cpuinit removal, or simply due to
> code getting copied from one driver to the next.
>
> Cc: Marcel Holtmann <marcel@holtmann.org>
> Cc: Gustavo Padovan <gustavo@padovan.org>
> Cc: Johan Hedberg <johan.hedberg@gmail.com>
> Cc: linux-bluetooth@vger.kernel.org
> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
> ---
> drivers/bluetooth/ath3k.c | 1 -
> drivers/bluetooth/bcm203x.c | 1 -
> drivers/bluetooth/bfusb.c | 1 -
> drivers/bluetooth/bluecard_cs.c | 1 -
> drivers/bluetooth/bpa10x.c | 1 -
> drivers/bluetooth/bt3c_cs.c | 1 -
> drivers/bluetooth/btuart_cs.c | 1 -
> drivers/bluetooth/dtl1_cs.c | 1 -
> 8 files changed, 8 deletions(-)
I can take this single patch via bluetooth-next tree or if Linus for example wants to take the whole series, then that is fine with me as well.
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 60/73] drivers/bluetooth: delete non-required instances of include <linux/init.h>
From: Paul Gortmaker @ 2014-01-21 22:30 UTC (permalink / raw)
To: Marcel Holtmann
Cc: linux-kernel, linux-arch, Gustavo F. Padovan, Johan Hedberg,
linux-bluetooth@vger.kernel.org development
In-Reply-To: <8861C0F9-FF68-47B8-B9EB-E52BF6A72A6F@holtmann.org>
On 14-01-21 04:55 PM, Marcel Holtmann wrote:
> Hi Paul,
>
>> None of these files are actually using any __init type directives
>> and hence don't need to include <linux/init.h>. Most are just a
>> left over from __devinit and __cpuinit removal, or simply due to
>> code getting copied from one driver to the next.
>>
>> Cc: Marcel Holtmann <marcel@holtmann.org>
>> Cc: Gustavo Padovan <gustavo@padovan.org>
>> Cc: Johan Hedberg <johan.hedberg@gmail.com>
>> Cc: linux-bluetooth@vger.kernel.org
>> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
>> ---
>> drivers/bluetooth/ath3k.c | 1 -
>> drivers/bluetooth/bcm203x.c | 1 -
>> drivers/bluetooth/bfusb.c | 1 -
>> drivers/bluetooth/bluecard_cs.c | 1 -
>> drivers/bluetooth/bpa10x.c | 1 -
>> drivers/bluetooth/bt3c_cs.c | 1 -
>> drivers/bluetooth/btuart_cs.c | 1 -
>> drivers/bluetooth/dtl1_cs.c | 1 -
>> 8 files changed, 8 deletions(-)
>
> I can take this single patch via bluetooth-next tree or if Linus for example wants to take the whole series, then that is fine with me as well.
>
> Acked-by: Marcel Holtmann <marcel@holtmann.org>
Given that the merge window is open, and maintainers are likely to
have finalized their content, I might as well just keep it in this
series. I've added your ack though -- thanks.
Paul.
--
>
> Regards
>
> Marcel
>
^ permalink raw reply
* [PATCH] android: Refactor paths in Android.mk
From: Andrzej Kaczmarek @ 2014-01-21 23:45 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
Using source paths relative to android/ directory created mess in
Android's obj directory since object files are created also relative
to bluetoothd_intermediates (thus can be created outside it).
To avoid this we set LOCAL_PATH to absolute path (in terms of Android
build root) of directory in which bluez/ is located and change and
update source paths accordingly.
This also allows us to build in future glib and sbc easily using
Android.mk in BlueZ.
---
android/Android.mk | 224 ++++++++++++++++++++++++++---------------------------
1 file changed, 112 insertions(+), 112 deletions(-)
diff --git a/android/Android.mk b/android/Android.mk
index 3b8d471..43e6036 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -1,7 +1,7 @@
-LOCAL_PATH := $(call my-dir)
+LOCAL_PATH := external/bluetooth
# Retrieve BlueZ version from configure.ac file
-BLUEZ_VERSION := $(shell grep ^AC_INIT $(LOCAL_PATH)/../configure.ac | cpp -P -D'AC_INIT(_,v)=v')
+BLUEZ_VERSION := $(shell grep ^AC_INIT $(LOCAL_PATH)/bluez/configure.ac | cpp -P -D'AC_INIT(_,v)=v')
# Specify pathmap for glib
pathmap_INCL += glib:external/bluetooth/glib
@@ -20,41 +20,41 @@ BLUEZ_COMMON_CFLAGS += -Wno-pointer-arith -Wno-missing-field-initializers
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- main.c \
- bluetooth.c \
- hidhost.c \
- socket.c \
- ipc.c \
- audio-ipc.c \
- avdtp.c \
- a2dp.c \
- pan.c \
- ../src/log.c \
- ../src/shared/mgmt.c \
- ../src/shared/util.c \
- ../src/shared/queue.c \
- ../src/shared/io-glib.c \
- ../src/sdpd-database.c \
- ../src/sdpd-service.c \
- ../src/sdpd-request.c \
- ../src/sdpd-server.c \
- ../src/uuid-helper.c \
- ../src/eir.c \
- ../lib/sdp.c \
- ../lib/bluetooth.c \
- ../lib/hci.c \
- ../btio/btio.c \
- ../src/sdp-client.c \
- ../profiles/network/bnep.c \
+ bluez/android/main.c \
+ bluez/android/bluetooth.c \
+ bluez/android/hidhost.c \
+ bluez/android/socket.c \
+ bluez/android/ipc.c \
+ bluez/android/audio-ipc.c \
+ bluez/android/avdtp.c \
+ bluez/android/a2dp.c \
+ bluez/android/pan.c \
+ bluez/src/log.c \
+ bluez/src/shared/mgmt.c \
+ bluez/src/shared/util.c \
+ bluez/src/shared/queue.c \
+ bluez/src/shared/io-glib.c \
+ bluez/src/sdpd-database.c \
+ bluez/src/sdpd-service.c \
+ bluez/src/sdpd-request.c \
+ bluez/src/sdpd-server.c \
+ bluez/src/uuid-helper.c \
+ bluez/src/eir.c \
+ bluez/lib/sdp.c \
+ bluez/lib/bluetooth.c \
+ bluez/lib/hci.c \
+ bluez/btio/btio.c \
+ bluez/src/sdp-client.c \
+ bluez/profiles/network/bnep.c \
LOCAL_C_INCLUDES := \
$(call include-path-for, glib) \
$(call include-path-for, glib)/glib \
LOCAL_C_INCLUDES += \
- $(LOCAL_PATH)/../ \
- $(LOCAL_PATH)/../src \
- $(LOCAL_PATH)/../lib \
+ $(LOCAL_PATH)/bluez \
+ $(LOCAL_PATH)/bluez/src \
+ $(LOCAL_PATH)/bluez/lib \
LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
@@ -72,9 +72,9 @@ lib_headers := \
sco.h \
bnep.h \
-$(shell mkdir -p $(LOCAL_PATH)/../lib/bluetooth)
+$(shell mkdir -p $(LOCAL_PATH)/bluez/lib/bluetooth)
-$(foreach file,$(lib_headers), $(shell ln -sf ../$(file) $(LOCAL_PATH)/../lib/bluetooth/$(file)))
+$(foreach file,$(lib_headers), $(shell ln -sf ../$(file) $(LOCAL_PATH)/bluez/lib/bluetooth/$(file)))
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := bluetoothd
@@ -88,13 +88,13 @@ include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- hal-ipc.c \
- hal-bluetooth.c \
- hal-sock.c \
- hal-hidhost.c \
- hal-pan.c \
- hal-a2dp.c \
- hal-utils.c \
+ bluez/android/hal-ipc.c \
+ bluez/android/hal-bluetooth.c \
+ bluez/android/hal-sock.c \
+ bluez/android/hal-hidhost.c \
+ bluez/android/hal-pan.c \
+ bluez/android/hal-a2dp.c \
+ bluez/android/hal-utils.c \
LOCAL_C_INCLUDES += \
$(call include-path-for, system-core) \
@@ -120,20 +120,20 @@ include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- client/haltest.c \
- client/pollhandler.c \
- client/terminal.c \
- client/history.c \
- client/tabcompletion.c \
- client/if-audio.c \
- client/if-av.c \
- client/if-bt.c \
- client/if-hf.c \
- client/if-hh.c \
- client/if-pan.c \
- client/if-sock.c \
- client/if-gatt.c \
- hal-utils.c \
+ bluez/android/client/haltest.c \
+ bluez/android/client/pollhandler.c \
+ bluez/android/client/terminal.c \
+ bluez/android/client/history.c \
+ bluez/android/client/tabcompletion.c \
+ bluez/android/client/if-audio.c \
+ bluez/android/client/if-av.c \
+ bluez/android/client/if-bt.c \
+ bluez/android/client/if-hf.c \
+ bluez/android/client/if-hh.c \
+ bluez/android/client/if-pan.c \
+ bluez/android/client/if-sock.c \
+ bluez/android/client/if-gatt.c \
+ bluez/android/hal-utils.c \
LOCAL_C_INCLUDES += \
$(call include-path-for, system-core) \
@@ -156,32 +156,32 @@ include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- ../monitor/main.c \
- ../monitor/mainloop.c \
- ../monitor/display.c \
- ../monitor/hcidump.c \
- ../monitor/btsnoop.c \
- ../monitor/control.c \
- ../monitor/packet.c \
- ../monitor/l2cap.c \
- ../monitor/uuid.c \
- ../monitor/sdp.c \
- ../monitor/vendor.c \
- ../monitor/lmp.c \
- ../monitor/crc.c \
- ../monitor/ll.c \
- ../monitor/hwdb.c \
- ../monitor/ellisys.c \
- ../monitor/analyze.c \
- ../src/shared/util.c \
- ../src/shared/queue.c \
- ../lib/hci.c \
- ../lib/bluetooth.c \
+ bluez/monitor/main.c \
+ bluez/monitor/mainloop.c \
+ bluez/monitor/display.c \
+ bluez/monitor/hcidump.c \
+ bluez/monitor/btsnoop.c \
+ bluez/monitor/control.c \
+ bluez/monitor/packet.c \
+ bluez/monitor/l2cap.c \
+ bluez/monitor/uuid.c \
+ bluez/monitor/sdp.c \
+ bluez/monitor/vendor.c \
+ bluez/monitor/lmp.c \
+ bluez/monitor/crc.c \
+ bluez/monitor/ll.c \
+ bluez/monitor/hwdb.c \
+ bluez/monitor/ellisys.c \
+ bluez/monitor/analyze.c \
+ bluez/src/shared/util.c \
+ bluez/src/shared/queue.c \
+ bluez/lib/hci.c \
+ bluez/lib/bluetooth.c \
LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/.. \
- $(LOCAL_PATH)/../lib \
- $(LOCAL_PATH)/../src/shared \
+ $(LOCAL_PATH)/bluez \
+ $(LOCAL_PATH)/bluez/lib \
+ $(LOCAL_PATH)/bluez/src/shared \
LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
@@ -198,13 +198,13 @@ include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- ../tools/btproxy.c \
- ../monitor/mainloop.c \
- ../src/shared/util.c \
+ bluez/tools/btproxy.c \
+ bluez/monitor/mainloop.c \
+ bluez/src/shared/util.c \
LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/.. \
- $(LOCAL_PATH)/../src/shared \
+ $(LOCAL_PATH)/bluez \
+ $(LOCAL_PATH)/bluez/src/shared \
LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
@@ -220,7 +220,7 @@ include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
-LOCAL_SRC_FILES := hal-audio.c
+LOCAL_SRC_FILES := bluez/android/hal-audio.c
LOCAL_C_INCLUDES = \
$(call include-path-for, system-core) \
@@ -244,14 +244,14 @@ include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- ../tools/l2test.c \
- ../lib/bluetooth.c \
- ../lib/hci.c \
+ bluez/tools/l2test.c \
+ bluez/lib/bluetooth.c \
+ bluez/lib/hci.c \
LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/.. \
- $(LOCAL_PATH)/../lib \
- $(LOCAL_PATH)/../src/shared \
+ $(LOCAL_PATH)/bluez \
+ $(LOCAL_PATH)/bluez/lib \
+ $(LOCAL_PATH)/bluez/src/shared \
LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
@@ -268,13 +268,13 @@ include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- bluetoothd-snoop.c \
- ../monitor/mainloop.c \
- ../src/shared/btsnoop.c \
+ bluez/android/bluetoothd-snoop.c \
+ bluez/monitor/mainloop.c \
+ bluez/src/shared/btsnoop.c \
LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/.. \
- $(LOCAL_PATH)/../lib \
+ $(LOCAL_PATH)/bluez \
+ $(LOCAL_PATH)/bluez/lib \
LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
@@ -291,7 +291,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE := init.bluetooth.rc
LOCAL_MODULE_CLASS := ETC
-LOCAL_SRC_FILES := $(LOCAL_MODULE)
+LOCAL_SRC_FILES := bluez/android/$(LOCAL_MODULE)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
@@ -304,20 +304,20 @@ include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- ../tools/btmgmt.c \
- ../lib/bluetooth.c \
- ../lib/sdp.c \
- ../monitor/mainloop.c \
- ../src/shared/io-mainloop.c \
- ../src/shared/mgmt.c \
- ../src/shared/queue.c \
- ../src/shared/util.c \
- ../src/uuid-helper.c \
+ bluez/tools/btmgmt.c \
+ bluez/lib/bluetooth.c \
+ bluez/lib/sdp.c \
+ bluez/monitor/mainloop.c \
+ bluez/src/shared/io-mainloop.c \
+ bluez/src/shared/mgmt.c \
+ bluez/src/shared/queue.c \
+ bluez/src/shared/util.c \
+ bluez/src/uuid-helper.c \
LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/.. \
- $(LOCAL_PATH)/../src \
- $(LOCAL_PATH)/../lib \
+ $(LOCAL_PATH)/bluez \
+ $(LOCAL_PATH)/bluez/src \
+ $(LOCAL_PATH)/bluez/lib \
LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
@@ -334,12 +334,12 @@ include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- ../tools/l2ping.c \
- ../lib/bluetooth.c \
- ../lib/hci.c \
+ bluez/tools/l2ping.c \
+ bluez/lib/bluetooth.c \
+ bluez/lib/hci.c \
LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/../lib \
+ $(LOCAL_PATH)/bluez/lib \
LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
--
1.8.5.2
^ permalink raw reply related
* Re: [PATCH v2 1/2] android: Add btmgmt to debug builds
From: Szymon Janc @ 2014-01-22 0:03 UTC (permalink / raw)
To: Andrzej Kaczmarek; +Cc: linux-bluetooth
In-Reply-To: <1390333570-13196-1-git-send-email-andrzej.kaczmarek@tieto.com>
Hi Andrzej,
On Tuesday 21 January 2014 20:46:09 Andrzej Kaczmarek wrote:
> ---
> android/Android.mk | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/android/Android.mk b/android/Android.mk
> index e66d70a..e3a31c1 100644
> --- a/android/Android.mk
> +++ b/android/Android.mk
> @@ -296,3 +296,33 @@ LOCAL_MODULE_TAGS := optional
> LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
>
> include $(BUILD_PREBUILT)
> +
> +#
> +# btmgmt
> +#
> +
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + ../tools/btmgmt.c \
> + ../lib/bluetooth.c \
> + ../lib/sdp.c \
> + ../monitor/mainloop.c \
> + ../src/shared/io-mainloop.c \
> + ../src/shared/mgmt.c \
> + ../src/shared/queue.c \
> + ../src/shared/util.c \
> + ../src/uuid-helper.c \
> +
> +LOCAL_C_INCLUDES := \
> + $(LOCAL_PATH)/.. \
> + $(LOCAL_PATH)/../src \
> + $(LOCAL_PATH)/../lib \
> +
> +LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
> +
> +LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
> +LOCAL_MODULE_TAGS := debug
> +LOCAL_MODULE := btmgmt
> +
> +include $(BUILD_EXECUTABLE)
Both patches applied, thanks.
--
Szymon K. Janc
szymon.janc@gmail.com
^ permalink raw reply
* [PATCH v2 0/4] Remote device cache support
From: Szymon Janc @ 2014-01-22 0:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
V2:
- keep cache in separate file
- patch 3/5 and 4/5 from V1 squashed to 3/4
V1:
- set cache limit to 300
- update timestamp of cached device
- rebased to master
- other minor fixes
Szymon Janc (4):
android/bluetooth: Split devices list to devices and bonded_devices
android/bluetooth: Use defines for settings and devices files paths
android/bluetooth: Add support for caching remote device info
android/bluetooth: Add support for loading caches devices from storage
android/bluetooth.c | 223 ++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 166 insertions(+), 57 deletions(-)
--
1.8.5.3
^ permalink raw reply
* [PATCH v2 1/4] android/bluetooth: Split devices list to devices and bonded_devices
From: Szymon Janc @ 2014-01-22 0:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1390350645-9725-1-git-send-email-szymon.janc@gmail.com>
Bonded devices are permament until unbondedn. Non-bonded devices will
be held in (size limited) cache based on timestamp property so split
list to ease separation.
---
android/bluetooth.c | 48 ++++++++++++++++++++++++++++++++++++------------
1 file changed, 36 insertions(+), 12 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 4849dab..5d222e1 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -132,6 +132,8 @@ static const uint16_t uuid_list[] = {
static uint16_t option_index = MGMT_INDEX_NONE;
static struct mgmt *mgmt_if = NULL;
+
+static GSList *bonded_devices = NULL;
static GSList *devices = NULL;
/* This list contains addresses which are asked for records */
@@ -283,6 +285,10 @@ static struct device *find_device(const bdaddr_t *bdaddr)
{
GSList *l;
+ l = g_slist_find_custom(bonded_devices, bdaddr, device_match);
+ if (l)
+ return l->data;
+
l = g_slist_find_custom(devices, bdaddr, device_match);
if (l)
return l->data;
@@ -559,12 +565,30 @@ static void set_device_bond_state(const bdaddr_t *addr, uint8_t status,
if (!dev)
return;
- if (dev->bond_state != state) {
- dev->bond_state = state;
- send_bond_state_change(&dev->bdaddr, status, state);
+ if (dev->bond_state == state)
+ return;
- store_device_info(dev);
+ switch (state) {
+ case HAL_BOND_STATE_NONE:
+ if (dev->bond_state == HAL_BOND_STATE_BONDED) {
+ bonded_devices = g_slist_remove(bonded_devices, dev);
+ devices = g_slist_prepend(devices, dev);
+ }
+ break;
+ case HAL_BOND_STATE_BONDED:
+ devices = g_slist_remove(devices, dev);
+ bonded_devices = g_slist_prepend(bonded_devices, dev);
+ break;
+ case HAL_BOND_STATE_BONDING:
+ default:
+ break;
}
+
+ dev->bond_state = state;
+
+ store_device_info(dev);
+
+ send_bond_state_change(&dev->bdaddr, status, state);
}
static void send_device_property(const bdaddr_t *bdaddr, uint8_t type,
@@ -935,6 +959,7 @@ static void mgmt_discovering_event(uint16_t index, uint16_t length,
if (adapter.discovering) {
cp.state = HAL_DISCOVERY_STATE_STARTED;
} else {
+ g_slist_foreach(bonded_devices, clear_device_found, NULL);
g_slist_foreach(devices, clear_device_found, NULL);
cp.state = HAL_DISCOVERY_STATE_STOPPED;
}
@@ -2128,18 +2153,15 @@ static uint8_t get_adapter_scan_mode(void)
static uint8_t get_adapter_bonded_devices(void)
{
- uint8_t buf[sizeof(bdaddr_t) * g_slist_length(devices)];
+ uint8_t buf[sizeof(bdaddr_t) * g_slist_length(bonded_devices)];
int i = 0;
GSList *l;
DBG("");
- for (l = devices; l; l = g_slist_next(l)) {
+ for (l = bonded_devices; l; l = g_slist_next(l)) {
struct device *dev = l->data;
- if (dev->bond_state != HAL_BOND_STATE_BONDED)
- continue;
-
bdaddr2android(&dev->bdaddr, buf + (i * sizeof(bdaddr_t)));
i++;
}
@@ -2691,11 +2713,10 @@ static void send_bonded_devices_props(void)
{
GSList *l;
- for (l = devices; l; l = g_slist_next(l)) {
+ for (l = bonded_devices; l; l = g_slist_next(l)) {
struct device *dev = l->data;
- if (dev->bond_state == HAL_BOND_STATE_BONDED)
- get_remote_device_props(dev);
+ get_remote_device_props(dev);
}
}
@@ -3093,6 +3114,9 @@ void bt_bluetooth_unregister(void)
{
DBG("");
+ g_slist_free_full(bonded_devices, (GDestroyNotify) free_device);
+ bonded_devices = NULL;
+
g_slist_free_full(devices, (GDestroyNotify) free_device);
devices = NULL;
--
1.8.5.3
^ permalink raw reply related
* [PATCH v2 2/4] android/bluetooth: Use defines for settings and devices files paths
From: Szymon Janc @ 2014-01-22 0:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1390350645-9725-1-git-send-email-szymon.janc@gmail.com>
---
android/bluetooth.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 5d222e1..f5ac0e4 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -54,6 +54,9 @@
#define DUT_MODE_FILE "/sys/kernel/debug/bluetooth/hci%u/dut_mode"
+#define SETTINGS_FILE ANDROID_STORAGEDIR"/settings"
+#define DEVICES_FILE ANDROID_STORAGEDIR"/devices"
+
#define DEVICE_ID_SOURCE 0x0002 /* USB */
#define DEVICE_ID_VENDOR 0x1d6b /* Linux Foundation */
#define DEVICE_ID_PRODUCT 0x0247 /* BlueZ for Android */
@@ -148,8 +151,7 @@ static void store_adapter_config(void)
key_file = g_key_file_new();
- g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/settings", 0,
- NULL);
+ g_key_file_load_from_file(key_file, SETTINGS_FILE, 0, NULL);
ba2str(&adapter.bdaddr, addr);
@@ -160,7 +162,7 @@ static void store_adapter_config(void)
data = g_key_file_to_data(key_file, &length, NULL);
- g_file_set_contents(ANDROID_STORAGEDIR"/settings", data, length, NULL);
+ g_file_set_contents(SETTINGS_FILE, data, length, NULL);
g_free(data);
g_key_file_free(key_file);
@@ -173,8 +175,7 @@ static void load_adapter_config(void)
char *str;
key_file = g_key_file_new();
- g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/settings", 0,
- NULL);
+ g_key_file_load_from_file(key_file, SETTINGS_FILE, 0, NULL);
str = g_key_file_get_string(key_file, "General", "Address", NULL);
if (!str) {
@@ -216,8 +217,7 @@ static void store_device_info(struct device *dev)
ba2str(&dev->bdaddr, addr);
key_file = g_key_file_new();
- g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/devices", 0,
- NULL);
+ g_key_file_load_from_file(key_file, DEVICES_FILE, 0, NULL);
if (dev->bond_state == HAL_BOND_STATE_NONE) {
g_key_file_remove_group(key_file, addr, NULL);
@@ -266,7 +266,7 @@ static void store_device_info(struct device *dev)
done:
str = g_key_file_to_data(key_file, &length, NULL);
- g_file_set_contents(ANDROID_STORAGEDIR"/devices", str, length, NULL);
+ g_file_set_contents(DEVICES_FILE, str, length, NULL);
g_free(str);
g_key_file_free(key_file);
@@ -521,8 +521,7 @@ static void store_link_key(const bdaddr_t *dst, const uint8_t *key,
key_file = g_key_file_new();
- if (!g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/devices",
- 0, NULL))
+ if (!g_key_file_load_from_file(key_file, DEVICES_FILE, 0, NULL))
return;
ba2str(dst, addr);
@@ -537,7 +536,7 @@ static void store_link_key(const bdaddr_t *dst, const uint8_t *key,
g_key_file_set_integer(key_file, addr, "LinkKeyPinLength", pin_length);
data = g_key_file_to_data(key_file, &length, NULL);
- g_file_set_contents(ANDROID_STORAGEDIR"/devices", data, length, NULL);
+ g_file_set_contents(DEVICES_FILE, data, length, NULL);
g_free(data);
g_key_file_free(key_file);
@@ -1727,8 +1726,7 @@ static void load_devices_info(bt_bluetooth_ready cb)
key_file = g_key_file_new();
- g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/devices", 0,
- NULL);
+ g_key_file_load_from_file(key_file, DEVICES_FILE, 0, NULL);
devs = g_key_file_get_groups(key_file, &len);
--
1.8.5.3
^ permalink raw reply related
* [PATCH v2 3/4] android/bluetooth: Add support for caching remote device info
From: Szymon Janc @ 2014-01-22 0:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1390350645-9725-1-git-send-email-szymon.janc@gmail.com>
From: Szymon Janc <szymon.janc@tieto.com>
Cache is limited to DEVICES_CACHE_MAX. Devices are sorted with
timestamp so if cache is full olderst device is removed.
---
android/bluetooth.c | 102 +++++++++++++++++++++++++++++++++++-----------------
1 file changed, 70 insertions(+), 32 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index f5ac0e4..1785fc7 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -56,6 +56,7 @@
#define SETTINGS_FILE ANDROID_STORAGEDIR"/settings"
#define DEVICES_FILE ANDROID_STORAGEDIR"/devices"
+#define CACHE_FILE ANDROID_STORAGEDIR"/cache"
#define DEVICE_ID_SOURCE 0x0002 /* USB */
#define DEVICE_ID_VENDOR 0x1d6b /* Linux Foundation */
@@ -70,6 +71,8 @@
/* Default discoverable timeout 120sec as in Android */
#define DEFAULT_DISCOVERABLE_TIMEOUT 120
+#define DEVICES_CACHE_MAX 300
+
#define BASELEN_PROP_CHANGED (sizeof(struct hal_ev_adapter_props_changed) \
+ (sizeof(struct hal_property)))
@@ -199,7 +202,7 @@ static void load_adapter_config(void)
g_key_file_free(key_file);
}
-static void store_device_info(struct device *dev)
+static void store_device_info(struct device *dev, const char *path)
{
GKeyFile *key_file;
char addr[18];
@@ -207,22 +210,10 @@ static void store_device_info(struct device *dev)
char **uuids = NULL;
char *str;
- /* We only store bonded devices and need to modify the storage
- * if the state is either NONE or BONDED.
- */
- if (dev->bond_state != HAL_BOND_STATE_BONDED &&
- dev->bond_state != HAL_BOND_STATE_NONE)
- return;
-
ba2str(&dev->bdaddr, addr);
key_file = g_key_file_new();
- g_key_file_load_from_file(key_file, DEVICES_FILE, 0, NULL);
-
- if (dev->bond_state == HAL_BOND_STATE_NONE) {
- g_key_file_remove_group(key_file, addr, NULL);
- goto done;
- }
+ g_key_file_load_from_file(key_file, path, 0, NULL);
g_key_file_set_integer(key_file, addr, "Type", dev->bdaddr_type);
@@ -264,15 +255,35 @@ static void store_device_info(struct device *dev)
g_key_file_remove_key(key_file, addr, "Services", NULL);
}
-done:
str = g_key_file_to_data(key_file, &length, NULL);
- g_file_set_contents(DEVICES_FILE, str, length, NULL);
+ g_file_set_contents(path, str, length, NULL);
g_free(str);
g_key_file_free(key_file);
g_strfreev(uuids);
}
+static void remove_device_info(struct device *dev, const char *path)
+{
+ GKeyFile *key_file;
+ gsize length = 0;
+ char addr[18];
+ char *str;
+
+ ba2str(&dev->bdaddr, addr);
+
+ key_file = g_key_file_new();
+ g_key_file_load_from_file(key_file, path, 0, NULL);
+
+ g_key_file_remove_group(key_file, addr, NULL);
+
+ str = g_key_file_to_data(key_file, &length, NULL);
+ g_file_set_contents(path, str, length, NULL);
+ g_free(str);
+
+ g_key_file_free(key_file);
+}
+
static int device_match(gconstpointer a, gconstpointer b)
{
const struct device *dev = a;
@@ -296,6 +307,35 @@ static struct device *find_device(const bdaddr_t *bdaddr)
return NULL;
}
+static void free_device(struct device *dev)
+{
+ g_free(dev->name);
+ g_free(dev->friendly_name);
+ g_slist_free_full(dev->uuids, g_free);
+ g_free(dev);
+}
+
+static void cache_device(struct device *new_dev)
+{
+ struct device *dev;
+ GSList *l;
+
+ if (g_slist_length(devices) < DEVICES_CACHE_MAX)
+ goto done;
+
+ l = g_slist_last(devices);
+ dev = l->data;
+
+ devices = g_slist_remove(devices, dev);
+ remove_device_info(dev, CACHE_FILE);
+ free_device(dev);
+
+done:
+ new_dev->timestamp = time(NULL);
+ devices = g_slist_prepend(devices, new_dev);
+ store_device_info(new_dev, CACHE_FILE);
+}
+
static struct device *create_device(const bdaddr_t *bdaddr, uint8_t type)
{
struct device *dev;
@@ -314,19 +354,10 @@ static struct device *create_device(const bdaddr_t *bdaddr, uint8_t type)
/* use address for name, will be change if one is present
* eg. in EIR or set by set_property. */
dev->name = g_strdup(addr);
- devices = g_slist_prepend(devices, dev);
return dev;
}
-static void free_device(struct device *dev)
-{
- g_free(dev->name);
- g_free(dev->friendly_name);
- g_slist_free_full(dev->uuids, g_free);
- g_free(dev);
-}
-
static struct device *get_device(const bdaddr_t *bdaddr, uint8_t type)
{
struct device *dev;
@@ -571,12 +602,15 @@ static void set_device_bond_state(const bdaddr_t *addr, uint8_t status,
case HAL_BOND_STATE_NONE:
if (dev->bond_state == HAL_BOND_STATE_BONDED) {
bonded_devices = g_slist_remove(bonded_devices, dev);
- devices = g_slist_prepend(devices, dev);
+ remove_device_info(dev, DEVICES_FILE);
+ cache_device(dev);
}
break;
case HAL_BOND_STATE_BONDED:
devices = g_slist_remove(devices, dev);
bonded_devices = g_slist_prepend(bonded_devices, dev);
+ remove_device_info(dev, CACHE_FILE);
+ store_device_info(dev, DEVICES_FILE);
break;
case HAL_BOND_STATE_BONDING:
default:
@@ -585,8 +619,6 @@ static void set_device_bond_state(const bdaddr_t *addr, uint8_t status,
dev->bond_state = state;
- store_device_info(dev);
-
send_bond_state_change(&dev->bdaddr, status, state);
}
@@ -627,7 +659,10 @@ static void set_device_uuids(struct device *dev, GSList *uuids)
g_slist_free_full(dev->uuids, g_free);
dev->uuids = uuids;
- store_device_info(dev);
+ if (dev->bond_state == HAL_BOND_STATE_BONDED)
+ store_device_info(dev, DEVICES_FILE);
+ else
+ store_device_info(dev, CACHE_FILE);
send_device_uuids_notif(dev);
}
@@ -1058,8 +1093,6 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
ev->status = HAL_STATUS_SUCCESS;
bdaddr2android(bdaddr, ev->bdaddr);
-
- dev->timestamp = time(NULL);
}
if (eir.class) {
@@ -1087,6 +1120,8 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
(*num_prop)++;
}
+ cache_device(dev);
+
if (*num_prop)
ipc_send_notif(HAL_SERVICE_ID_BLUETOOTH, opcode, size, buf);
@@ -2860,7 +2895,10 @@ static uint8_t set_device_friendly_name(struct device *dev, const uint8_t *val,
g_free(dev->friendly_name);
dev->friendly_name = g_strndup((const char *) val, len);
- store_device_info(dev);
+ if (dev->bond_state == HAL_BOND_STATE_BONDED)
+ store_device_info(dev, DEVICES_FILE);
+ else
+ store_device_info(dev, CACHE_FILE);
send_device_property(&dev->bdaddr, HAL_PROP_DEVICE_FRIENDLY_NAME,
strlen(dev->friendly_name), dev->friendly_name);
--
1.8.5.3
^ permalink raw reply related
* [PATCH v2 4/4] android/bluetooth: Add support for loading caches devices from storage
From: Szymon Janc @ 2014-01-22 0:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1390350645-9725-1-git-send-email-szymon.janc@gmail.com>
From: Szymon Janc <szymon.janc@tieto.com>
Info is now stored for all devices and bond state depends on file.
Based on that devices loaded from storage are put either to cache
or to bonded_devices list.
---
android/bluetooth.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 54 insertions(+), 5 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 1785fc7..80690ec 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -1668,7 +1668,8 @@ static void clear_uuids(void)
sizeof(cp), &cp, NULL, NULL, NULL);
}
-static void create_device_from_info(GKeyFile *key_file, const char *peer)
+static struct device *create_device_from_info(GKeyFile *key_file,
+ const char *peer)
{
struct device *dev;
uint8_t type;
@@ -1683,7 +1684,11 @@ static void create_device_from_info(GKeyFile *key_file, const char *peer)
str2ba(peer, &bdaddr);
dev = create_device(&bdaddr, type);
- dev->bond_state = HAL_BOND_STATE_BONDED;
+ str = g_key_file_get_string(key_file, peer, "LinkKey", NULL);
+ if (str) {
+ g_free(str);
+ dev->bond_state = HAL_BOND_STATE_BONDED;
+ }
str = g_key_file_get_string(key_file, peer, "Name", NULL);
if (str) {
@@ -1719,6 +1724,8 @@ static void create_device_from_info(GKeyFile *key_file, const char *peer)
g_strfreev(uuids);
}
+
+ return dev;
}
static struct mgmt_link_key_info *get_key_info(GKeyFile *key_file, const char *peer)
@@ -1751,6 +1758,40 @@ failed:
return info;
}
+static int device_timestamp_cmp(gconstpointer a, gconstpointer b)
+{
+ const struct device *deva = a;
+ const struct device *devb = b;
+
+ return deva->timestamp < devb->timestamp;
+}
+
+static void load_devices_cache(void)
+{
+ GKeyFile *key_file;
+ gchar **devs;
+ gsize len = 0;
+ unsigned int i;
+
+ key_file = g_key_file_new();
+
+ g_key_file_load_from_file(key_file, CACHE_FILE, 0, NULL);
+
+ devs = g_key_file_get_groups(key_file, &len);
+
+ for (i = 0; i < len; i++) {
+ struct device *dev;
+
+ dev = create_device_from_info(key_file, devs[i]);
+ devices = g_slist_prepend(devices, dev);
+ }
+
+ devices = g_slist_sort(devices, device_timestamp_cmp);
+
+ g_strfreev(devs);
+ g_key_file_free(key_file);
+}
+
static void load_devices_info(bt_bluetooth_ready cb)
{
GKeyFile *key_file;
@@ -1767,14 +1808,21 @@ static void load_devices_info(bt_bluetooth_ready cb)
for (i = 0; i < len; i++) {
struct mgmt_link_key_info *key_info;
+ struct device *dev;
- create_device_from_info(key_file, devs[i]);
+ dev = create_device_from_info(key_file, devs[i]);
key_info = get_key_info(key_file, devs[i]);
- if (key_info)
- keys = g_slist_prepend(keys, key_info);
+ if (!key_info) {
+ error("Failed to load linkkey for %s, skipping",
+ devs[i]);
+ continue;
+ }
/* TODO ltk */
+
+ keys = g_slist_prepend(keys, key_info);
+ bonded_devices = g_slist_prepend(bonded_devices, dev);
}
load_link_keys(keys, cb);
@@ -1862,6 +1910,7 @@ static void read_info_complete(uint8_t status, uint16_t length,
clear_uuids();
load_devices_info(cb);
+ load_devices_cache();
set_io_capability();
set_device_id();
--
1.8.5.3
^ permalink raw reply related
* [PATCH 1/9] android/ipc-tester: Add cases for SOCK msg size
From: Jakub Tyszkowski @ 2014-01-22 8:25 UTC (permalink / raw)
To: linux-bluetooth
Add cases testing message size verification for SOCK opcodes.
---
android/ipc-tester.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index ed0dd10..088c324 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -864,5 +864,23 @@ int main(int argc, char *argv[])
sizeof(struct hal_cmd_le_test_mode), -1,
HAL_SERVICE_ID_BLUETOOTH);
+ /* check for valid data size for SOCK */
+ test_datasize_valid("SOCK Listen+", HAL_SERVICE_ID_SOCK,
+ HAL_OP_SOCK_LISTEN,
+ sizeof(struct hal_cmd_sock_listen), 1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_SOCK);
+ test_datasize_valid("SOCK Listen-", HAL_SERVICE_ID_SOCK,
+ HAL_OP_SOCK_LISTEN,
+ sizeof(struct hal_cmd_sock_listen), -1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_SOCK);
+ test_datasize_valid("SOCK Connect+", HAL_SERVICE_ID_SOCK,
+ HAL_OP_SOCK_CONNECT,
+ sizeof(struct hal_cmd_sock_connect), 1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_SOCK);
+ test_datasize_valid("SOCK Connect-", HAL_SERVICE_ID_SOCK,
+ HAL_OP_SOCK_CONNECT,
+ sizeof(struct hal_cmd_sock_connect), -1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_SOCK);
+
return tester_run();
}
--
1.8.5.2
^ permalink raw reply related
* [PATCH 2/9] android/ipc-tester: Add cases for HIDHOST msg size
From: Jakub Tyszkowski @ 2014-01-22 8:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1390379124-16426-1-git-send-email-jakub.tyszkowski@tieto.com>
Add cases testing message size verification for HIDHOST opcodes.
---
android/ipc-tester.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index 088c324..2871587 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -882,5 +882,79 @@ int main(int argc, char *argv[])
sizeof(struct hal_cmd_sock_connect), -1,
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_SOCK);
+ /* check for valid data size for HID Host */
+ test_datasize_valid("HIDHOST Connect+", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_CONNECT,
+ sizeof(struct hal_cmd_hidhost_connect), 1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_datasize_valid("HIDHOST Connect-", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_CONNECT,
+ sizeof(struct hal_cmd_hidhost_connect), -1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_datasize_valid("HIDHOST Disconnect+", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_DISCONNECT,
+ sizeof(struct hal_cmd_hidhost_disconnect), 1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_datasize_valid("HIDHOST Disconnect-", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_DISCONNECT,
+ sizeof(struct hal_cmd_hidhost_disconnect), -1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_datasize_valid("HIDHOST Virt. Unplug+", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_VIRTUAL_UNPLUG,
+ sizeof(struct hal_cmd_hidhost_virtual_unplug), 1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_datasize_valid("HIDHOST Virt. Unplug-", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_VIRTUAL_UNPLUG,
+ sizeof(struct hal_cmd_hidhost_virtual_unplug), -1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_datasize_valid("HIDHOST Set Info+", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_SET_INFO,
+ sizeof(struct hal_cmd_hidhost_set_info), 1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_datasize_valid("HIDHOST Set Info-", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_SET_INFO,
+ sizeof(struct hal_cmd_hidhost_set_info), -1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_datasize_valid("HIDHOST Get Protocol+", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_GET_PROTOCOL,
+ sizeof(struct hal_cmd_hidhost_get_protocol), 1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_datasize_valid("HIDHOST Get Protocol-", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_GET_PROTOCOL,
+ sizeof(struct hal_cmd_hidhost_get_protocol), -1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_datasize_valid("HIDHOST Set Protocol+", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_SET_PROTOCOL,
+ sizeof(struct hal_cmd_hidhost_set_protocol), 1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_datasize_valid("HIDHOST Set Protocol-", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_SET_PROTOCOL,
+ sizeof(struct hal_cmd_hidhost_set_protocol), -1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_datasize_valid("HIDHOST Get Report+", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_GET_REPORT,
+ sizeof(struct hal_cmd_hidhost_get_report), 1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_datasize_valid("HIDHOST Get Report-", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_GET_REPORT,
+ sizeof(struct hal_cmd_hidhost_get_report), -1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_datasize_valid("HIDHOST Set Report+", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_SET_REPORT,
+ sizeof(struct hal_cmd_hidhost_set_report), 1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_datasize_valid("HIDHOST Set Report-", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_SET_REPORT,
+ sizeof(struct hal_cmd_hidhost_set_report), -1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_datasize_valid("HIDHOST Send Data+", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_SEND_DATA,
+ sizeof(struct hal_cmd_hidhost_send_data), 1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_datasize_valid("HIDHOST Send Data-", HAL_SERVICE_ID_HIDHOST,
+ HAL_OP_HIDHOST_SEND_DATA,
+ sizeof(struct hal_cmd_hidhost_send_data), -1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+
return tester_run();
}
--
1.8.5.2
^ permalink raw reply related
* [PATCH 3/9] android/ipc-tester: Add case for HIDHOST Set Info
From: Jakub Tyszkowski @ 2014-01-22 8:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1390379124-16426-1-git-send-email-jakub.tyszkowski@tieto.com>
This patch adds test for verifying data length inside
hal_cmd_hidhost_set_info struct.
---
android/ipc-tester.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index 2871587..641bc5b 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -650,6 +650,41 @@ struct hal_hdr enable_bt_service_hdr = {
.len = 0,
};
+struct hidhost_set_info_data {
+ struct hal_hdr hdr;
+ struct hal_cmd_hidhost_set_info info;
+
+ /* data placeholder for hal_cmd_hidhost_set_info.descr[0] field */
+ uint8_t buf[BLUEZ_HAL_MTU - sizeof(struct hal_hdr) -
+ sizeof(struct hal_cmd_hidhost_set_info)];
+} __attribute__((packed));
+
+#define set_info_data "some descriptor"
+
+static struct hidhost_set_info_data hidhost_set_info_data_overs = {
+ .hdr.service_id = HAL_SERVICE_ID_HIDHOST,
+ .hdr.opcode = HAL_OP_HIDHOST_SET_INFO,
+ .hdr.len = sizeof(struct hal_cmd_hidhost_set_info) +
+ sizeof(set_info_data),
+
+ /* declare wrong descriptor length */
+ .info.descr_len = sizeof(set_info_data) + 1,
+ /* init .info.descr[0] */
+ .buf = set_info_data,
+};
+
+static struct hidhost_set_info_data hidhost_set_info_data_unders = {
+ .hdr.service_id = HAL_SERVICE_ID_HIDHOST,
+ .hdr.opcode = HAL_OP_HIDHOST_SET_INFO,
+ .hdr.len = sizeof(struct hal_cmd_hidhost_set_info) +
+ sizeof(set_info_data),
+
+ /* declare wrong descriptor length */
+ .info.descr_len = sizeof(set_info_data) - 1,
+ /* init .info.descr[0] */
+ .buf = set_info_data,
+};
+
int main(int argc, char *argv[])
{
snprintf(exec_dir, sizeof(exec_dir), "%s", dirname(argv[0]));
@@ -915,6 +950,20 @@ int main(int argc, char *argv[])
HAL_OP_HIDHOST_SET_INFO,
sizeof(struct hal_cmd_hidhost_set_info), -1,
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_generic("Data size HIDHOST Set Info Vardata+",
+ ipc_send_tc, setup, teardown,
+ &hidhost_set_info_data_overs,
+ (sizeof(struct hal_hdr) +
+ sizeof(struct hal_cmd_hidhost_set_info) +
+ sizeof(set_info_data)),
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_generic("Data size HIDHOST Set Info Vardata-",
+ ipc_send_tc, setup, teardown,
+ &hidhost_set_info_data_unders,
+ (sizeof(struct hal_hdr) +
+ sizeof(struct hal_cmd_hidhost_set_info) +
+ sizeof(set_info_data)),
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
test_datasize_valid("HIDHOST Get Protocol+", HAL_SERVICE_ID_HIDHOST,
HAL_OP_HIDHOST_GET_PROTOCOL,
sizeof(struct hal_cmd_hidhost_get_protocol), 1,
--
1.8.5.2
^ permalink raw reply related
* [PATCH 4/9] android/ipc-tester: Add case for HIDHOST Set Report
From: Jakub Tyszkowski @ 2014-01-22 8:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1390379124-16426-1-git-send-email-jakub.tyszkowski@tieto.com>
This patch adds test for verifying data length inside
hal_cmd_hidhost_set_report struct.
---
android/ipc-tester.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index 641bc5b..ca4d9b9 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -685,6 +685,41 @@ static struct hidhost_set_info_data hidhost_set_info_data_unders = {
.buf = set_info_data,
};
+struct hidhost_set_report_data {
+ struct hal_hdr hdr;
+ struct hal_cmd_hidhost_set_report report;
+
+ /* data placeholder for hal_cmd_hidhost_set_report.data[0] field */
+ uint8_t buf[BLUEZ_HAL_MTU - sizeof(struct hal_hdr) -
+ sizeof(struct hal_cmd_hidhost_set_report)];
+} __attribute__((packed));
+
+#define set_rep_data "1234567890"
+
+static struct hidhost_set_report_data hidhost_set_report_data_overs = {
+ .hdr.service_id = HAL_SERVICE_ID_HIDHOST,
+ .hdr.opcode = HAL_OP_HIDHOST_SET_REPORT,
+ .hdr.len = sizeof(struct hal_cmd_hidhost_set_report) +
+ sizeof(set_rep_data),
+
+ /* declare wrong descriptor length */
+ .report.len = sizeof(set_rep_data) + 1,
+ /* init report.data[0] */
+ .buf = set_rep_data,
+};
+
+static struct hidhost_set_report_data hidhost_set_report_data_unders = {
+ .hdr.service_id = HAL_SERVICE_ID_HIDHOST,
+ .hdr.opcode = HAL_OP_HIDHOST_SET_REPORT,
+ .hdr.len = sizeof(struct hal_cmd_hidhost_set_report) +
+ sizeof(set_rep_data),
+
+ /* declare wrong descriptor length */
+ .report.len = sizeof(set_rep_data) - 1,
+ /* init report.data[0] */
+ .buf = set_rep_data,
+};
+
int main(int argc, char *argv[])
{
snprintf(exec_dir, sizeof(exec_dir), "%s", dirname(argv[0]));
@@ -996,6 +1031,20 @@ int main(int argc, char *argv[])
HAL_OP_HIDHOST_SET_REPORT,
sizeof(struct hal_cmd_hidhost_set_report), -1,
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_generic("Data size HIDHOST Set Report Vardata+",
+ ipc_send_tc, setup, teardown,
+ &hidhost_set_report_data_overs,
+ (sizeof(struct hal_hdr) +
+ sizeof(struct hal_cmd_hidhost_set_report) +
+ sizeof(set_rep_data)),
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_generic("Data size HIDHOST Set Report Vardata-",
+ ipc_send_tc, setup, teardown,
+ &hidhost_set_report_data_unders,
+ (sizeof(struct hal_hdr) +
+ sizeof(struct hal_cmd_hidhost_set_report) +
+ sizeof(set_rep_data)),
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
test_datasize_valid("HIDHOST Send Data+", HAL_SERVICE_ID_HIDHOST,
HAL_OP_HIDHOST_SEND_DATA,
sizeof(struct hal_cmd_hidhost_send_data), 1,
--
1.8.5.2
^ permalink raw reply related
* [PATCH 5/9] android/ipc-tester: Add case for HIDHOST Send Data
From: Jakub Tyszkowski @ 2014-01-22 8:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1390379124-16426-1-git-send-email-jakub.tyszkowski@tieto.com>
This adds test for verifying data length inside
hal_cmd_hidhost_send_data struct.
---
android/ipc-tester.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index ca4d9b9..b161049 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -720,6 +720,41 @@ static struct hidhost_set_report_data hidhost_set_report_data_unders = {
.buf = set_rep_data,
};
+struct hidhost_send_data_data {
+ struct hal_hdr hdr;
+ struct hal_cmd_hidhost_send_data hiddata;
+
+ /* data placeholder for hal_cmd_hidhost_send_data.data[0] field */
+ uint8_t buf[BLUEZ_HAL_MTU - sizeof(struct hal_hdr) -
+ sizeof(struct hal_cmd_hidhost_send_data)];
+} __attribute__((packed));
+
+#define send_data_data "1234567890"
+
+static struct hidhost_send_data_data hidhost_send_data_overs = {
+ .hdr.service_id = HAL_SERVICE_ID_HIDHOST,
+ .hdr.opcode = HAL_OP_HIDHOST_SEND_DATA,
+ .hdr.len = sizeof(struct hal_cmd_hidhost_send_data) +
+ sizeof(send_data_data),
+
+ /* declare wrong descriptor length */
+ .hiddata.len = sizeof(send_data_data) + 1,
+ /* init .hiddata.data[0] */
+ .buf = send_data_data,
+};
+
+static struct hidhost_send_data_data hidhost_send_data_unders = {
+ .hdr.service_id = HAL_SERVICE_ID_HIDHOST,
+ .hdr.opcode = HAL_OP_HIDHOST_SEND_DATA,
+ .hdr.len = sizeof(struct hal_cmd_hidhost_send_data) +
+ sizeof(send_data_data),
+
+ /* declare wrong descriptor length */
+ .hiddata.len = sizeof(send_data_data) - 1,
+ /* init .hiddata.data[0] */
+ .buf = send_data_data,
+};
+
int main(int argc, char *argv[])
{
snprintf(exec_dir, sizeof(exec_dir), "%s", dirname(argv[0]));
@@ -1053,6 +1088,20 @@ int main(int argc, char *argv[])
HAL_OP_HIDHOST_SEND_DATA,
sizeof(struct hal_cmd_hidhost_send_data), -1,
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_generic("Data size HIDHOST Send Vardata+",
+ ipc_send_tc, setup, teardown,
+ &hidhost_send_data_overs,
+ (sizeof(struct hal_hdr) +
+ sizeof(struct hal_cmd_hidhost_send_data) +
+ sizeof(send_data_data)),
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_generic("Data size HIDHOST Send Vardata-",
+ ipc_send_tc, setup, teardown,
+ &hidhost_send_data_unders,
+ (sizeof(struct hal_hdr) +
+ sizeof(struct hal_cmd_hidhost_send_data) +
+ sizeof(send_data_data)),
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
return tester_run();
}
--
1.8.5.2
^ permalink raw reply related
* [PATCH 6/9] android/ipc-tester: Add cases for PAN msg size
From: Jakub Tyszkowski @ 2014-01-22 8:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1390379124-16426-1-git-send-email-jakub.tyszkowski@tieto.com>
Add cases testing message size verification for PAN opcodes.
---
android/ipc-tester.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index b161049..11239e7 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -1103,5 +1103,35 @@ int main(int argc, char *argv[])
sizeof(send_data_data)),
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ /* check for valid data size for PAN */
+ test_datasize_valid("PAN Enable+", HAL_SERVICE_ID_PAN,
+ HAL_OP_PAN_ENABLE,
+ sizeof(struct hal_cmd_pan_enable), 1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
+ test_datasize_valid("PAN Enable-", HAL_SERVICE_ID_PAN,
+ HAL_OP_PAN_ENABLE,
+ sizeof(struct hal_cmd_pan_enable), -1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
+ test_datasize_valid("PAN Get Role+", HAL_SERVICE_ID_PAN,
+ HAL_OP_PAN_GET_ROLE,
+ 0, 1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
+ test_datasize_valid("PAN Connect+", HAL_SERVICE_ID_PAN,
+ HAL_OP_PAN_CONNECT,
+ sizeof(struct hal_cmd_pan_connect), 1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
+ test_datasize_valid("PAN Connect-", HAL_SERVICE_ID_PAN,
+ HAL_OP_PAN_CONNECT,
+ sizeof(struct hal_cmd_pan_connect), -1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
+ test_datasize_valid("PAN Disconnect+", HAL_SERVICE_ID_PAN,
+ HAL_OP_PAN_DISCONNECT,
+ sizeof(struct hal_cmd_pan_disconnect), 1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
+ test_datasize_valid("PAN Disconnect-", HAL_SERVICE_ID_PAN,
+ HAL_OP_PAN_DISCONNECT,
+ sizeof(struct hal_cmd_pan_disconnect), -1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
+
return tester_run();
}
--
1.8.5.2
^ permalink raw reply related
* [PATCH 7/9] android/ipc-tester: Add cases for A2DP msg size
From: Jakub Tyszkowski @ 2014-01-22 8:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1390379124-16426-1-git-send-email-jakub.tyszkowski@tieto.com>
Add cases testing message size veification for A2DP opcodes.
---
android/ipc-tester.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index 11239e7..c621167 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -1133,5 +1133,23 @@ int main(int argc, char *argv[])
sizeof(struct hal_cmd_pan_disconnect), -1,
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
+ /* check for valid data size for A2DP */
+ test_datasize_valid("A2DP Connect+", HAL_SERVICE_ID_A2DP,
+ HAL_OP_A2DP_CONNECT,
+ sizeof(struct hal_cmd_a2dp_connect), 1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_A2DP);
+ test_datasize_valid("A2DP Connect-", HAL_SERVICE_ID_A2DP,
+ HAL_OP_A2DP_CONNECT,
+ sizeof(struct hal_cmd_a2dp_connect), -1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_A2DP);
+ test_datasize_valid("A2DP Disconnect+", HAL_SERVICE_ID_A2DP,
+ HAL_OP_A2DP_DISCONNECT,
+ sizeof(struct hal_cmd_a2dp_disconnect), 1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_A2DP);
+ test_datasize_valid("A2DP Disconnect-", HAL_SERVICE_ID_A2DP,
+ HAL_OP_A2DP_DISCONNECT,
+ sizeof(struct hal_cmd_a2dp_disconnect), -1,
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_A2DP);
+
return tester_run();
}
--
1.8.5.2
^ permalink raw reply related
* [PATCH 8/9] android/ipc-tester: Add case for BT Set adapter prop
From: Jakub Tyszkowski @ 2014-01-22 8:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1390379124-16426-1-git-send-email-jakub.tyszkowski@tieto.com>
This patch adds test for verifying data length inside
hal_cmd_set_adapter_prop struct.
---
android/ipc-tester.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index c621167..e44afb3 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -650,6 +650,43 @@ struct hal_hdr enable_bt_service_hdr = {
.len = 0,
};
+struct bt_set_adapter_prop_data {
+ struct hal_hdr hdr;
+ struct hal_cmd_set_adapter_prop prop;
+
+ /* data placeholder for hal_cmd_set_adapter_prop.val[0] */
+ uint8_t buf[BLUEZ_HAL_MTU - sizeof(struct hal_hdr) -
+ sizeof(struct hal_cmd_set_adapter_prop)];
+} __attribute__((packed));
+
+#define set_name "new name"
+
+static struct bt_set_adapter_prop_data bt_set_adapter_prop_data_overs = {
+ .hdr.service_id = HAL_SERVICE_ID_BLUETOOTH,
+ .hdr.opcode = HAL_OP_SET_ADAPTER_PROP,
+ .hdr.len = sizeof(struct hal_cmd_set_adapter_prop) +
+ sizeof(set_name),
+
+ .prop.type = HAL_PROP_ADAPTER_NAME,
+ /* declare wrong descriptor length */
+ .prop.len = sizeof(set_name) + 1,
+ /* init prop.val[0] */
+ .buf = set_name,
+};
+
+static struct bt_set_adapter_prop_data bt_set_adapter_prop_data_unders = {
+ .hdr.service_id = HAL_SERVICE_ID_BLUETOOTH,
+ .hdr.opcode = HAL_OP_SET_ADAPTER_PROP,
+ .hdr.len = sizeof(struct hal_cmd_set_adapter_prop) +
+ sizeof(set_name),
+
+ .prop.type = HAL_PROP_ADAPTER_NAME,
+ /* declare wrong descriptor length */
+ .prop.len = sizeof(set_name) - 1,
+ /* init prop.val[0] */
+ .buf = set_name,
+};
+
struct hidhost_set_info_data {
struct hal_hdr hdr;
struct hal_cmd_hidhost_set_info info;
@@ -856,6 +893,20 @@ int main(int argc, char *argv[])
HAL_OP_SET_ADAPTER_PROP,
sizeof(struct hal_cmd_set_adapter_prop), -1,
HAL_SERVICE_ID_BLUETOOTH);
+ test_generic("Data size BT Set Adapter Prop Vardata+",
+ ipc_send_tc, setup, teardown,
+ &bt_set_adapter_prop_data_overs,
+ (sizeof(struct hal_hdr) +
+ sizeof(struct hal_cmd_set_adapter_prop) +
+ sizeof(set_name)),
+ HAL_SERVICE_ID_BLUETOOTH);
+ test_generic("Data size BT Set Adapter Prop Vardata+",
+ ipc_send_tc, setup, teardown,
+ &bt_set_adapter_prop_data_unders,
+ (sizeof(struct hal_hdr) +
+ sizeof(struct hal_cmd_set_adapter_prop) +
+ sizeof(set_name)),
+ HAL_SERVICE_ID_BLUETOOTH);
test_datasize_valid("BT Get Remote Props+", HAL_SERVICE_ID_BLUETOOTH,
HAL_OP_GET_REMOTE_DEVICE_PROPS,
sizeof(struct hal_cmd_get_remote_device_props), 1,
--
1.8.5.2
^ permalink raw reply related
* [PATCH 9/9] android/ipc-tester: Add case for BT Set remote prop
From: Jakub Tyszkowski @ 2014-01-22 8:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1390379124-16426-1-git-send-email-jakub.tyszkowski@tieto.com>
This patch adds test for verifying data length inside
hal_cmd_set_remote_device_prop struct.
---
android/ipc-tester.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index e44afb3..e1aeb2e 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -687,6 +687,41 @@ static struct bt_set_adapter_prop_data bt_set_adapter_prop_data_unders = {
.buf = set_name,
};
+struct bt_set_remote_prop_data {
+ struct hal_hdr hdr;
+ struct hal_cmd_set_remote_device_prop prop;
+
+ /* data placeholder for hal_cmd_set_remote_device_prop.val[0] */
+ uint8_t buf[BLUEZ_HAL_MTU - sizeof(struct hal_hdr) -
+ sizeof(struct hal_cmd_set_remote_device_prop)];
+} __attribute__((packed));
+
+static struct bt_set_remote_prop_data bt_set_remote_prop_data_overs = {
+ .hdr.service_id = HAL_SERVICE_ID_BLUETOOTH,
+ .hdr.opcode = HAL_OP_SET_REMOTE_DEVICE_PROP,
+ .hdr.len = sizeof(struct hal_cmd_set_remote_device_prop) +
+ sizeof(set_name),
+
+ .prop.bdaddr = {},
+ .prop.type = HAL_PROP_DEVICE_NAME,
+ /* declare wrong descriptor length */
+ .prop.len = sizeof(set_name) + 1,
+ .buf = set_name,
+};
+
+static struct bt_set_remote_prop_data bt_set_remote_prop_data_unders = {
+ .hdr.service_id = HAL_SERVICE_ID_BLUETOOTH,
+ .hdr.opcode = HAL_OP_SET_REMOTE_DEVICE_PROP,
+ .hdr.len = sizeof(struct hal_cmd_set_remote_device_prop) +
+ sizeof(set_name),
+
+ .prop.bdaddr = {},
+ .prop.type = HAL_PROP_DEVICE_NAME,
+ /* declare wrong descriptor length */
+ .prop.len = sizeof(set_name) - 1,
+ .buf = set_name,
+};
+
struct hidhost_set_info_data {
struct hal_hdr hdr;
struct hal_cmd_hidhost_set_info info;
@@ -931,6 +966,20 @@ int main(int argc, char *argv[])
HAL_OP_SET_REMOTE_DEVICE_PROP,
sizeof(struct hal_cmd_set_remote_device_prop), -1,
HAL_SERVICE_ID_BLUETOOTH);
+ test_generic("Data size BT Set Remote Prop Vardata+",
+ ipc_send_tc, setup, teardown,
+ &bt_set_remote_prop_data_overs,
+ (sizeof(struct hal_hdr) +
+ sizeof(struct hal_cmd_set_remote_device_prop) +
+ sizeof(set_name)),
+ HAL_SERVICE_ID_BLUETOOTH);
+ test_generic("Data size BT Set Remote Prop Vardata-",
+ ipc_send_tc, setup, teardown,
+ &bt_set_remote_prop_data_unders,
+ (sizeof(struct hal_hdr) +
+ sizeof(struct hal_cmd_set_remote_device_prop) +
+ sizeof(set_name)),
+ HAL_SERVICE_ID_BLUETOOTH);
test_datasize_valid("BT Get Remote SV Rec+", HAL_SERVICE_ID_BLUETOOTH,
HAL_OP_GET_REMOTE_SERVICE_REC,
sizeof(struct hal_cmd_get_remote_service_rec), 1,
--
1.8.5.2
^ permalink raw reply related
* Re: [PATCH] android: Refactor paths in Android.mk
From: Szymon Janc @ 2014-01-22 8:37 UTC (permalink / raw)
To: Andrzej Kaczmarek; +Cc: linux-bluetooth
In-Reply-To: <1390347953-29901-1-git-send-email-andrzej.kaczmarek@tieto.com>
Hi Andrzej,
On Wednesday 22 of January 2014 00:45:53 Andrzej Kaczmarek wrote:
> Using source paths relative to android/ directory created mess in
> Android's obj directory since object files are created also relative
> to bluetoothd_intermediates (thus can be created outside it).
>
> To avoid this we set LOCAL_PATH to absolute path (in terms of Android
> build root) of directory in which bluez/ is located and change and
> update source paths accordingly.
>
> This also allows us to build in future glib and sbc easily using
> Android.mk in BlueZ.
Applied, thanks.
--
Best regards,
Szymon Janc
^ permalink raw reply
* Re: [PATCH SBC v5 1/2] sbc: Add sbc_init_a2dp
From: Luiz Augusto von Dentz @ 2014-01-22 8:51 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
In-Reply-To: <1390295313-5951-1-git-send-email-luiz.dentz@gmail.com>
Hi,
On Tue, Jan 21, 2014 at 11:08 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This adds sbc_init_a2dp that can be used to convert A2DP configuration to
> the internal representation since they are not binary compatible.
> ---
> sbc/sbc.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> sbc/sbc.h | 2 +
> 2 files changed, 146 insertions(+)
>
> diff --git a/sbc/sbc.c b/sbc/sbc.c
> index c589217..ee6a2ab 100644
> --- a/sbc/sbc.c
> +++ b/sbc/sbc.c
> @@ -57,6 +57,55 @@
> #define MSBC_SYNCWORD 0xAD
> #define MSBC_BLOCKS 15
>
> +#define A2DP_SAMPLING_FREQ_16000 (1 << 3)
> +#define A2DP_SAMPLING_FREQ_32000 (1 << 2)
> +#define A2DP_SAMPLING_FREQ_44100 (1 << 1)
> +#define A2DP_SAMPLING_FREQ_48000 (1 << 0)
> +
> +#define A2DP_CHANNEL_MODE_MONO (1 << 3)
> +#define A2DP_CHANNEL_MODE_DUAL_CHANNEL (1 << 2)
> +#define A2DP_CHANNEL_MODE_STEREO (1 << 1)
> +#define A2DP_CHANNEL_MODE_JOINT_STEREO (1 << 0)
> +
> +#define A2DP_BLOCK_LENGTH_4 (1 << 3)
> +#define A2DP_BLOCK_LENGTH_8 (1 << 2)
> +#define A2DP_BLOCK_LENGTH_12 (1 << 1)
> +#define A2DP_BLOCK_LENGTH_16 (1 << 0)
> +
> +#define A2DP_SUBBANDS_4 (1 << 1)
> +#define A2DP_SUBBANDS_8 (1 << 0)
> +
> +#define A2DP_ALLOCATION_SNR (1 << 1)
> +#define A2DP_ALLOCATION_LOUDNESS (1 << 0)
> +
> +#if __BYTE_ORDER == __LITTLE_ENDIAN
> +
> +struct a2dp_sbc {
> + uint8_t channel_mode:4;
> + uint8_t frequency:4;
> + uint8_t allocation_method:2;
> + uint8_t subbands:2;
> + uint8_t block_length:4;
> + uint8_t min_bitpool;
> + uint8_t max_bitpool;
> +} __attribute__ ((packed));
> +
> +#elif __BYTE_ORDER == __BIG_ENDIAN
> +
> +struct a2dp_sbc {
> + uint8_t frequency:4;
> + uint8_t channel_mode:4;
> + uint8_t block_length:4;
> + uint8_t subbands:2;
> + uint8_t allocation_method:2;
> + uint8_t min_bitpool;
> + uint8_t max_bitpool;
> +} __attribute__ ((packed));
> +
> +#else
> +#error "Unknown byte order"
> +#endif
> +
> /* This structure contains an unpacked SBC frame.
> Yes, there is probably quite some unused space herein */
> struct sbc_frame {
> @@ -1046,6 +1095,101 @@ SBC_EXPORT int sbc_init_msbc(sbc_t *sbc, unsigned long flags)
> return 0;
> }
>
> +SBC_EXPORT int sbc_init_a2dp(sbc_t *sbc, unsigned long flags,
> + const void *conf, size_t conf_len)
> +{
> + const struct a2dp_sbc *a2dp;
> + int err;
> +
> + if (conf_len != sizeof(*a2dp))
> + return -EINVAL;
> +
> + err = sbc_init(sbc, flags);
> + if (err < 0)
> + return err;
> +
> + a2dp = conf;
> +
> + switch (a2dp->frequency) {
> + case A2DP_SAMPLING_FREQ_16000:
> + sbc->frequency = SBC_FREQ_16000;
> + break;
> + case A2DP_SAMPLING_FREQ_32000:
> + sbc->frequency = SBC_FREQ_32000;
> + break;
> + case A2DP_SAMPLING_FREQ_44100:
> + sbc->frequency = SBC_FREQ_44100;
> + break;
> + case A2DP_SAMPLING_FREQ_48000:
> + sbc->frequency = SBC_FREQ_48000;
> + break;
> + default:
> + goto failed;
> + }
> +
> + switch (a2dp->channel_mode) {
> + case A2DP_CHANNEL_MODE_MONO:
> + sbc->mode = SBC_MODE_MONO;
> + break;
> + case A2DP_CHANNEL_MODE_DUAL_CHANNEL:
> + sbc->mode = SBC_MODE_DUAL_CHANNEL;
> + break;
> + case A2DP_CHANNEL_MODE_STEREO:
> + sbc->mode = SBC_MODE_STEREO;
> + break;
> + case A2DP_CHANNEL_MODE_JOINT_STEREO:
> + sbc->mode = SBC_MODE_JOINT_STEREO;
> + break;
> + default:
> + goto failed;
> + }
> +
> + switch (a2dp->allocation_method) {
> + case A2DP_ALLOCATION_SNR:
> + sbc->allocation = SBC_AM_SNR;
> + break;
> + case A2DP_ALLOCATION_LOUDNESS:
> + sbc->allocation = SBC_AM_LOUDNESS;
> + break;
> + default:
> + goto failed;
> + }
> +
> + switch (a2dp->subbands) {
> + case A2DP_SUBBANDS_4:
> + sbc->subbands = SBC_SB_4;
> + break;
> + case A2DP_SUBBANDS_8:
> + sbc->subbands = SBC_SB_8;
> + break;
> + default:
> + goto failed;
> + }
> +
> + switch (a2dp->block_length) {
> + case A2DP_BLOCK_LENGTH_4:
> + sbc->blocks = SBC_BLK_4;
> + break;
> + case A2DP_BLOCK_LENGTH_8:
> + sbc->blocks = SBC_BLK_8;
> + break;
> + case A2DP_BLOCK_LENGTH_12:
> + sbc->blocks = SBC_BLK_12;
> + break;
> + case A2DP_BLOCK_LENGTH_16:
> + sbc->blocks = SBC_BLK_16;
> + break;
> + default:
> + goto failed;
> + }
> +
> + return 0;
> +
> +failed:
> + sbc_finish(sbc);
> + return -EINVAL;
> +}
> +
> SBC_EXPORT ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len)
> {
> return sbc_decode(sbc, input, input_len, NULL, 0, NULL);
> diff --git a/sbc/sbc.h b/sbc/sbc.h
> index 5f8a1fc..32eb2e9 100644
> --- a/sbc/sbc.h
> +++ b/sbc/sbc.h
> @@ -84,6 +84,8 @@ typedef struct sbc_struct sbc_t;
> int sbc_init(sbc_t *sbc, unsigned long flags);
> int sbc_reinit(sbc_t *sbc, unsigned long flags);
> int sbc_init_msbc(sbc_t *sbc, unsigned long flags);
> +int sbc_init_a2dp(sbc_t *sbc, unsigned long flags,
> + const void *conf, size_t conf_len);
>
> ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len);
>
> --
> 1.8.4.2
Pushed.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [RFC v5 05/14] Bluetooth: Introduce fail_conn_attempt() helper
From: Johan Hedberg @ 2014-01-22 8:58 UTC (permalink / raw)
To: Andre Guedes; +Cc: linux-bluetooth
In-Reply-To: <1387540675-2466-6-git-send-email-andre.guedes@openbossa.org>
Hi Andre,
On Fri, Dec 20, 2013, Andre Guedes wrote:
> This patch moves connection attempt failure code to its own function
> so it can be reused in the next patch.
>
> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> ---
> net/bluetooth/hci_conn.c | 24 ++++++++++++++++--------
> 1 file changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> index b5c3ebff..870bc31 100644
> --- a/net/bluetooth/hci_conn.c
> +++ b/net/bluetooth/hci_conn.c
> @@ -514,6 +514,21 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
> }
> EXPORT_SYMBOL(hci_get_route);
>
> +/* This function requires the caller holds hdev->lock */
> +static void fail_conn_attempt(struct hci_conn *conn, u8 status)
> +{
> + struct hci_dev *hdev = conn->hdev;
> +
> + conn->state = BT_CLOSED;
> +
> + mgmt_connect_failed(hdev, &conn->dst, conn->type, conn->dst_type,
> + status);
> +
> + hci_proto_connect_cfm(conn, status);
> +
> + hci_conn_del(conn);
> +}
Looks otherwise good, but could we call this le_conn_failed instead of
fail_conn_attempt? It would sound less awkward to me.
Johan
^ permalink raw reply
* Re: [RFC v5 06/14] Bluetooth: Stop scanning on LE connection
From: Johan Hedberg @ 2014-01-22 9:03 UTC (permalink / raw)
To: Andre Guedes; +Cc: linux-bluetooth
In-Reply-To: <1387540675-2466-7-git-send-email-andre.guedes@openbossa.org>
Hi Andre,
On Fri, Dec 20, 2013, Andre Guedes wrote:
> + hci_req_init(&req, hdev);
> +
> + memset(&cp, 0, sizeof(cp));
> + cp.scan_interval = cpu_to_le16(hdev->le_scan_interval);
> + cp.scan_window = cpu_to_le16(hdev->le_scan_window);
> + bacpy(&cp.peer_addr, &conn->dst);
> + cp.peer_addr_type = conn->dst_type;
> + cp.own_address_type = conn->src_type;
> + cp.conn_interval_min = cpu_to_le16(conn->le_conn_min_interval);
> + cp.conn_interval_max = cpu_to_le16(conn->le_conn_max_interval);
> + cp.supervision_timeout = __constant_cpu_to_le16(0x002a);
> + cp.min_ce_len = __constant_cpu_to_le16(0x0000);
> + cp.max_ce_len = __constant_cpu_to_le16(0x0000);
> + hci_req_add(&req, HCI_OP_LE_CREATE_CONN, sizeof(cp), &cp);
You might wanna split out hci_req_add a bit with an empty line before it
to make this block of assignments more readable.
> + memset(&cp, 0, sizeof(cp));
> + cp.scan_interval = cpu_to_le16(hdev->le_scan_interval);
> + cp.scan_window = cpu_to_le16(hdev->le_scan_window);
> + bacpy(&cp.peer_addr, &conn->dst);
> + cp.peer_addr_type = conn->dst_type;
> + cp.own_address_type = conn->src_type;
> + cp.conn_interval_min = cpu_to_le16(conn->le_conn_min_interval);
> + cp.conn_interval_max = cpu_to_le16(conn->le_conn_max_interval);
> + cp.supervision_timeout = __constant_cpu_to_le16(0x002a);
> + cp.min_ce_len = __constant_cpu_to_le16(0x0000);
> + cp.max_ce_len = __constant_cpu_to_le16(0x0000);
> + hci_req_add(&req, HCI_OP_LE_CREATE_CONN, sizeof(cp), &cp);
> +
> + err = hci_req_run(&req, create_le_conn_complete);
> + }
> +
> + if (err) {
> + hci_conn_del(conn);
> return ERR_PTR(err);
> + }
Instead of duplicating the HCI_LE_Create_Connection parameter encoding,
did you consider refactoring this into its own function, maybe something
like:
static void le_create_conn_req(struct hci_request *req,
struct hci_dev *hdev, struct hci_conn *conn)
{
...
}
le_create_conn_req(&req, hdev, conn);
err = hci_req_run(&req, le_create_conn_complete);
if (err)
...
Johan
^ permalink raw reply
* Re: [RFC v5 00/14] LE auto connection and connection parameters
From: Johan Hedberg @ 2014-01-22 9:08 UTC (permalink / raw)
To: Andre Guedes; +Cc: linux-bluetooth
In-Reply-To: <1387540675-2466-1-git-send-email-andre.guedes@openbossa.org>
Hi Andre,
On Fri, Dec 20, 2013, Andre Guedes wrote:
> This patch set is pretty much the same of previous one, except it implements
> a different approach to handle discovery and LE connection (as discussed on
> "[RFC v4 05/12] Bluetooth: Stop scanning on LE connection").
>
> Regards,
>
> Andre
>
>
> Andre Guedes (14):
> Bluetooth: Save connection interval parameters in hci_conn
> Bluetooth: Group list_head fields from strcut hci_dev together
> Bluetooth: Introduce connection parameters list
> Bluetooth: Use connection parameters if any
> Bluetooth: Introduce fail_conn_attempt() helper
> Bluetooth: Stop scanning on LE connection
> Bluetooth: Remove unused function
> Bluetooth: Introduce hdev->pend_le_conn list
> Bluetooth: Introduce LE auto connection infrastructure
> Bluetooth: Re-enable background scan in case of error
> Bluetooth: Temporarily stop background scanning on discovery
> Bluetooth: Auto connection and power on
> Bleutooth: Add support for auto connect options
> Bluetooth: Add le_auto_conn file on debugfs
>
> include/net/bluetooth/hci.h | 1 +
> include/net/bluetooth/hci_core.h | 43 +++++-
> net/bluetooth/hci_conn.c | 111 +++++++++++---
> net/bluetooth/hci_core.c | 318 +++++++++++++++++++++++++++++++++++++++
> net/bluetooth/hci_event.c | 60 ++++++++
> net/bluetooth/mgmt.c | 25 ++-
> 6 files changed, 530 insertions(+), 28 deletions(-)
Besides the couple of minor things I just pointed out I didn't find
anything else obviously wrong with this patch set. It might be worth to
send a rebased non-RFC version of it (with the changes I suggested if
you agree with them) so we get this moving forward.
Johan
.
^ permalink raw reply
* [PATCH v3 00/10] android: Add SBC encoding
From: Andrzej Kaczmarek @ 2014-01-22 10:34 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
Hi,
v1 -> v2
- fixed comments
- added dependency to libsbc shared library on Android
v2 -> v3
- added comment explaining why we need to sleep in out_write
- updated to new SBC API
- libsbc shared library is now built from our Android.mk
- implemented proper get_latency callback
Andrzej Kaczmarek (10):
android: Add MTU data to Open Stream Audio IPC
android: Build Audio HAL with SBC
android/hal-audio: Rename sbc_init to avoid collision with libsbc
android/hal-audio: Initialize SBC encoder
android/hal-audio: Calculate SBC stream parameters
android/hal-audio: Add resume to codec callbacks
android/hal-audio: Return proper buffer size to AudioFlinger
android/hal-audio: Read fd from Output Stream response
android/hal-audio: Add proper SBC encoding
android/hal-audio: Return proper latency for stream
android/Android.mk | 37 ++++++-
android/Makefile.am | 2 +
android/a2dp.c | 8 +-
android/audio-msg.h | 1 +
android/hal-audio.c | 301 +++++++++++++++++++++++++++++++++++++++++++++++++---
configure.ac | 7 ++
6 files changed, 338 insertions(+), 18 deletions(-)
--
1.8.5.2
^ permalink raw reply
* [PATCH v3 01/10] android: Add MTU data to Open Stream Audio IPC
From: Andrzej Kaczmarek @ 2014-01-22 10:34 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1390386893-8212-1-git-send-email-andrzej.kaczmarek@tieto.com>
MTU value for transport channel is sent in Open Stream response, which
is required to calculate number of frames which can be packed into
single media packet.
This is to avoid including GPLv2 licensed headers in Audio HAL
implementation.
---
android/a2dp.c | 8 ++++++--
android/audio-msg.h | 1 +
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/android/a2dp.c b/android/a2dp.c
index a996f79..95ecf9b 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -1304,6 +1304,7 @@ static void bt_stream_open(const void *buf, uint16_t len)
struct audio_rsp_open_stream *rsp;
struct a2dp_setup *setup;
int fd;
+ uint16_t omtu;
DBG("");
@@ -1314,14 +1315,17 @@ static void bt_stream_open(const void *buf, uint16_t len)
return;
}
- if (!avdtp_stream_get_transport(setup->stream, &fd, NULL, NULL, NULL)) {
+ if (!avdtp_stream_get_transport(setup->stream, &fd, NULL, &omtu,
+ NULL)) {
error("avdtp_stream_get_transport: failed");
audio_ipc_send_rsp(AUDIO_OP_OPEN_STREAM, AUDIO_STATUS_FAILED);
return;
}
- len = sizeof(struct audio_preset) + setup->preset->len;
+ len = sizeof(struct audio_rsp_open_stream) +
+ sizeof(struct audio_preset) + setup->preset->len;
rsp = g_malloc0(len);
+ rsp->mtu = omtu;
rsp->preset->len = setup->preset->len;
memcpy(rsp->preset->data, setup->preset->data, setup->preset->len);
diff --git a/android/audio-msg.h b/android/audio-msg.h
index 8f03274..17cde09 100644
--- a/android/audio-msg.h
+++ b/android/audio-msg.h
@@ -63,6 +63,7 @@ struct audio_cmd_open_stream {
} __attribute__((packed));
struct audio_rsp_open_stream {
+ uint16_t mtu;
struct audio_preset preset[0];
} __attribute__((packed));
--
1.8.5.2
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox