Commit Graph

60 Commits

Author SHA1 Message Date
Andrzej Kaczmarek
18f045b574 android/socket: Simplify SDP records handling
Records are now created using helper function which creates SDP record
with common contents like service class, name and protocols. Other
attributes are then added by custom functions.
2014-02-12 13:50:49 +01:00
Andrzej Kaczmarek
a5e248b29d android/socket: Improve logging
This patch makes logging more consistent by including rfsock pointer in
most messages which identifies socket structure unambigously (instead
of using bunch of file descriptors for the same purpose) and puts other
parameters in order in some cases.

Additionally, some new logs are introduced to better track socket
structures and connections lifetime.
2014-02-12 13:50:49 +01:00
Andrzej Kaczmarek
30023350be android/socket: Refactor socket related symbol names
This patch changes names of symbols related to various sockets to be
consistent and easier to follow in code.

Symbols related to actual BT (RFCOMM) socket are prefixed with "bt_".
Symbols related to local socket for Java comm are prefixed with "jv_".
Remote socket for Java comm is called "hal_sock".
2014-02-12 13:50:49 +01:00
Marcel Holtmann
cde69653e0 android: Update copyright and license details 2014-02-11 10:42:56 -08:00
Marcel Holtmann
c1add0ff9f android: Use src/log.h include instead of just log.h 2014-01-26 00:23:15 -08:00
Szymon Janc
cada0c0896 core: Add flags parameter to bt_search_service
This allows to pass custom SDP flags to sdp_connect.
2014-01-20 15:19:25 +02:00
Szymon Janc
26381ed7d8 android/socket: Move logic from HAL to daemon in connect
This reduce logic in HAL to bare minimum e.g. no modifications in
library will be needed to add different socket type support.

Both bdaddr2str and btuuid2str handle NULL pointers so it is safe to
print debug unconditionally.
2014-01-06 21:26:21 +02:00
Szymon Janc
74c65573ce android/socket: Move logic from HAL to daemon in listen
This reduce logic in HAL to bare minimum e.g. no modifications in
library will be needed to add different socket type support.

Both bdaddr2str and btuuid2str handle NULL pointers so it is safe to
print debug unconditionally.
2014-01-06 21:25:59 +02:00
Szymon Janc
e99c1dbd33 android/socket: Make channel int32_t in IPC specification
This match IPC type with type in socket HAL API. This allows to pass
data directly from HAL library and will allow to reduce logic in it.
2014-01-06 21:25:43 +02:00
Lukasz Rymanowski
6bd69ca560 android/map: Add support for MAP/MAS
Theres no HAL API exposed to application to register different MAS
instances. Android 4.4 does support only MAS SMS. All Instance ID,
supported msg type and rfcomm channel are hardcoded in the stack.
Unfortunatelly we need to do the same way and wait for new HAL API
which is expected.
2014-01-02 15:48:45 +02:00
Andrei Emeltchenko
94d49aa07e android/socket: Handle Android events for server socket
Add watch for tracking events from Android framework for server socket.
Android might want to close server connection, in this case we close
our listening socket and cleaning up rfsock structure. Glib watch is
added with high priority to avoid races.
2013-12-19 11:08:22 +02:00
Andrei Emeltchenko
eaf5064375 android/socket: Connect directly to RFCOMM channel if uuid is zero
Check uuid and connect to specified RFCOMM channel directly if uuid is
zeroed.
2013-12-19 11:08:22 +02:00
Andrei Emeltchenko
b81374ec80 android/socket: Refactor connect to allow directly connect to rfcomm
Since Socket HAL allows us to specify RFCOMM channel number and directly
connect refactor send function to allow connect directly is uuid is zero
and channel number is specified.
2013-12-19 11:08:22 +02:00
Andrei Emeltchenko
6a9ed0d6b3 android/socket: Do not close fd on unref
We close file descriptors in cleanup_rfsock() and leaving the default
value gives us glib warnings if we close fd already and got G_IO_NVAL in
server_cb from bt_io.
2013-12-13 16:38:37 +02:00
Andrei Emeltchenko
dff1938dac android/socket: Use getsockopt to set buffer
Use the RFCOMM socket buffer size to allocate the intermediate buffer used
for copying data between sockets to minimize context switches.
2013-12-10 12:33:43 +02:00
Andrei Emeltchenko
99f70b8af8 android/socket: Cleanup sockets on unregister
This cleans up rfsock structures closing all sockets and making general
cleanup for servers and for connections. This will be called form socket
unregister.
2013-12-05 16:45:16 +02:00
Szymon Janc
ffb856322c android: Use G_N_ELEMENTS macro for table elements calculation
It is more common in codebase to use this macro instead of opencoded
(sizeof(foo)/sizeof(foo[0])).
2013-12-03 13:44:04 +02:00
Szymon Janc
a35d7765a9 android/socket: Use generic IPC message handling for commands
Handlers are registered on service register and unregistered on
unregister.
2013-12-02 16:24:02 +02:00
Andrei Emeltchenko
aef22eab9f android/socket: Remove unneeded code
The flag is already set in bt_io_listen.
2013-11-29 10:30:16 +02:00
Andrei Emeltchenko
4675a7412d android/socket: Avoid double close of file descriptor
Since we close all file descriptors in cleanup_rfsock do not close it also
during iochannel cleaning up. The flag was setup in bt_io_listen and
bt_io_connect calls.
2013-11-29 10:30:11 +02:00
Andrei Emeltchenko
4df38bd9ed android/socket: Strip extra log messages
Remove debug messages when sending data, debug still exist for connection
establishment. Do not print error when connection hang up, print debug
instead.
2013-11-29 10:30:02 +02:00
Andrei Emeltchenko
0ba58ed345 android/socket: Fix rfsock lists
This fixes several places where rfsock structure were not removed
from the list due to connection errors.
2013-11-29 10:29:51 +02:00
Szymon Janc
7624ea2d42 android: Don't pass notification socket on services register
It is no longer needed as proper socket is use by IPC helpers.
2013-11-28 18:02:27 +02:00
Szymon Janc
22d3f4499b android/socket: Use ipc_send_rsp_full IPC helper
Use command reply helper for sending reply with file descriptor.
2013-11-28 18:02:27 +02:00
Szymon Janc
6456e15664 android: Remove socket parameter from ipc_send_rsp
Use command socket provided to IPC on init.
2013-11-28 18:02:26 +02:00
Johan Hedberg
c95d6263f5 android/socket: Remove useless dst variable 2013-11-27 12:56:41 +02:00
Andrei Emeltchenko
41631e8b46 android/socket: Check create_rfsock returns valid structure 2013-11-27 12:54:37 +02:00
Andrei Emeltchenko
bb712ac791 android/socket: Use security level for connect / listen
Use MEDIUM security level for connections without profile and default
sec_level for others. rfsock now has pointer to profile info.
2013-11-26 17:44:05 +02:00
Andrei Emeltchenko
b3c8fbbb66 android/socket: Make profile struct const
We are not supposed to change profile structure, make it const.
2013-11-26 17:43:27 +02:00
Andrei Emeltchenko
a7f01b2e1b android/socket: Add error printing possible close() failure 2013-11-25 15:37:17 +02:00
Andrei Emeltchenko
407789abea android/socket: Use default sec_level for listen
Set default security level low for OPP and SPP and medium for PBAP and MAS.
Default security level would be low for listening without profile.
2013-11-25 15:36:25 +02:00
Andrei Emeltchenko
ed7452fbbf android/socket: Refactor socket send_fd function
Make code cleaner and initialize local cmsg buffer to zeroes.
2013-11-25 15:32:31 +02:00
Andrei Emeltchenko
d84ffb05e3 android/socket: Support listen() with supplied chan number
No profile is assigned in this case. There is a possibility to use
Serial Port Profile.
2013-11-25 15:32:07 +02:00
Andrei Emeltchenko
27d036281a android/socket: Add SPP SDP record 2013-11-25 15:30:42 +02:00
Andrei Emeltchenko
980ffed8d7 android/socket: Add PBAP SDP record
This adds SDP service record like shown below:

Service Name: OBEX Phonebook Access Server
Service RecHandle: 0x10002
Service Class ID List:
  "Phonebook Access - PSE" (0x112f)
Protocol Descriptor List:
  "RFCOMM" (0x0003)
    Channel: 15
  "OBEX" (0x0008)
Profile Descriptor List:
  "Phonebook Access" (0x1130)
    Version: 0x0100
2013-11-25 15:30:33 +02:00
Andrei Emeltchenko
58ab9edb8a android/socket: Add SPP uuid to profile table 2013-11-25 15:30:24 +02:00
Andrei Emeltchenko
b1e23ebd37 android/socket: Add MAS uuid to profile table 2013-11-25 15:30:13 +02:00
Andrei Emeltchenko
30d49b2b3a android/socket: Add OPP SDP record
This adds SDP record for OPP shown below:

Service Name: OBEX Object Push
Service RecHandle: 0x10002
Service Class ID List:
  "OBEX Object Push" (0x1105)
Protocol Descriptor List:
  "RFCOMM" (0x0003)
    Channel: 9
  "OBEX" (0x0008)
Profile Descriptor List:
  "OBEX Object Push" (0x1105)
    Version: 0x0100
2013-11-25 15:29:58 +02:00
Andrei Emeltchenko
181158d8e6 android/socket: Add general service create/remove function
create_record function from profile is used to create SDP service record.
The record is removed from rfsock cleanup function.
2013-11-25 15:29:15 +02:00
Andrei Emeltchenko
cb2fdb2f53 android/socket: Close file descriptor after sending 2013-11-25 15:28:29 +02:00
Andrei Emeltchenko
7a9c4622e4 android/socket: Send connect signal to Android framework
Android framework expects connect signal to be sent when
remote device is connected.
2013-11-25 15:28:01 +02:00
Andrei Emeltchenko
c8226366a8 android/socket: Send RFCOMM channel to framework
Framework expects channel to be send.
2013-11-25 15:27:00 +02:00
Andrei Emeltchenko
a1deeaf589 android/socket: Implement HAL connect call
HAL connect uses similar event handlers like listen call.
2013-11-25 15:26:03 +02:00
Andrei Emeltchenko
9b33ebad23 android/socket: Parse SDP response and connect
Parse SDP response, find RFCOMM channel and connect.
2013-11-25 15:25:52 +02:00
Andrei Emeltchenko
7ee3686348 android/socket: Implement socket connect HAL method
First step is to query remote device for RFCOMM channel.
2013-11-20 15:10:53 +02:00
Andrei Emeltchenko
002a64f595 android/socket: Notify channel to Android framework
Android framework expects to receive channel number as int.
2013-11-20 15:10:45 +02:00
Andrei Emeltchenko
34c4ae9ad8 android/socket: Send accept signal to Android framework
Android expects to get accept signal over file descriptor which was
set during listen HAL call.
2013-11-20 15:10:17 +02:00
Andrei Emeltchenko
cfc5e2ae33 android/socket: Implement RFCOMM events
Copy data from RFCOMM socket to Android framework. Consider splice
in the future.
2013-11-20 15:10:03 +02:00
Andrei Emeltchenko
601cfc775e android/socket: Implement Android RFCOMM stack events
Handle events from Android framework. Write everything to real RFCOMM
socket. Consider splice() in the future.
2013-11-20 15:09:02 +02:00
Andrei Emeltchenko
1698ccf997 android/socket: Implement socket accepted event
When we get accepted event we create rfcomm slot and start listening
for events from Android framework and from RFCOMM real socket.
2013-11-20 15:08:03 +02:00