2013-11-06 14:03:31

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 1/3] android/hal-sock: Check socket type in connect

From: Andrei Emeltchenko <[email protected]>

Only RFCOMM sockets are supported in Android.
---
android/hal-sock.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/android/hal-sock.c b/android/hal-sock.c
index 131877a..cd85f1f 100644
--- a/android/hal-sock.c
+++ b/android/hal-sock.c
@@ -83,6 +83,11 @@ static bt_status_t sock_connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,

DBG("uuid %p chan %d sock %p type %d", uuid, chan, sock, type);

+ if (type != BTSOCK_RFCOMM) {
+ error("Socket type %u not supported", type);
+ return BT_STATUS_UNSUPPORTED;
+ }
+
cmd.flags = flags;
cmd.type = type;
cmd.channel = chan;
--
1.7.10.4



2013-11-07 08:10:33

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH 3/3] android/hal: Rename hal_op_sock_listen to hal_cmd_sock_listen

Hi Andrei,

On Wed, Nov 06, 2013, Andrei Emeltchenko wrote:
> This makes structures consistent with the rest of the code.
> ---
> android/hal-msg.h | 4 ++--
> android/hal-sock.c | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)

Patches 1 and 3 have been applied. Thanks.

Johan

2013-11-06 14:03:32

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 2/3] android/daemon: Move include mgmt.h to adapter.h

From: Andrei Emeltchenko <[email protected]>

Without including src/shared/mgmt.h adapter.h cannot be included.
This force some profiles which do not use mgmt interface to include
src/shared/mgmt.h like hid.c and socket.c
---
android/adapter.c | 1 -
android/adapter.h | 1 +
android/hid.c | 1 -
android/main.c | 1 -
4 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index cf5edcd..db70b46 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -32,7 +32,6 @@
#include "lib/bluetooth.h"
#include "lib/sdp.h"
#include "lib/mgmt.h"
-#include "src/shared/mgmt.h"
#include "src/glib-helper.h"
#include "src/eir.h"
#include "lib/sdp.h"
diff --git a/android/adapter.h b/android/adapter.h
index 2afc67a..eca77ae 100644
--- a/android/adapter.h
+++ b/android/adapter.h
@@ -27,6 +27,7 @@
#include <glib.h>

#include "lib/bluetooth.h"
+#include "src/shared/mgmt.h"

typedef void (*bt_adapter_ready)(int err);

diff --git a/android/hid.c b/android/hid.c
index c38c4c1..2ef2733 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -38,7 +38,6 @@
#include "lib/sdp.h"
#include "lib/sdp_lib.h"
#include "lib/uuid.h"
-#include "src/shared/mgmt.h"
#include "src/sdp-client.h"
#include "src/glib-helper.h"
#include "profiles/input/uhid_copy.h"
diff --git a/android/main.c b/android/main.c
index 75004cf..80d7c24 100644
--- a/android/main.c
+++ b/android/main.c
@@ -46,7 +46,6 @@

#include "lib/bluetooth.h"
#include "lib/mgmt.h"
-#include "src/shared/mgmt.h"

#include "adapter.h"
#include "socket.h"
--
1.7.10.4


2013-11-06 14:03:33

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 3/3] android/hal: Rename hal_op_sock_listen to hal_cmd_sock_listen

From: Andrei Emeltchenko <[email protected]>

This makes structures consistent with the rest of the code.
---
android/hal-msg.h | 4 ++--
android/hal-sock.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index f0cc800..a5e5c76 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -215,7 +215,7 @@ struct hal_cmd_le_test_mode {
/* Bluetooth Socket HAL api */

#define HAL_OP_SOCK_LISTEN 0x01
-struct hal_op_sock_listen {
+struct hal_cmd_sock_listen {
uint8_t type;
uint8_t name[256];
uint8_t uuid[16];
@@ -224,7 +224,7 @@ struct hal_op_sock_listen {
} __attribute__((packed));

#define HAL_OP_SOCK_CONNECT 0x02
-struct hal_op_sock_connect {
+struct hal_cmd_sock_connect {
uint8_t bdaddr[6];
uint8_t type;
uint8_t uuid[16];
diff --git a/android/hal-sock.c b/android/hal-sock.c
index cd85f1f..32c7939 100644
--- a/android/hal-sock.c
+++ b/android/hal-sock.c
@@ -29,7 +29,7 @@ static bt_status_t sock_listen_rfcomm(const char *service_name,
const uint8_t *uuid, int chan,
int *sock, int flags)
{
- struct hal_op_sock_listen cmd;
+ struct hal_cmd_sock_listen cmd;

DBG("");

@@ -73,7 +73,7 @@ static bt_status_t sock_connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
const uint8_t *uuid, int chan,
int *sock, int flags)
{
- struct hal_op_sock_connect cmd;
+ struct hal_cmd_sock_connect cmd;

if ((!uuid && chan <= 0) || !bdaddr || !sock) {
error("invalid params: bd_addr %p, uuid %p, chan %d, sock %p",
--
1.7.10.4