Commit Graph

72 Commits

Author SHA1 Message Date
Szymon Janc
aa887bf05a android: Update socket service id name to match service name 2014-02-24 13:45:09 +01:00
Andrzej Kaczmarek
8648ed970e android/socket: Fix calling cleanup with invalid pointer 2014-02-21 15:29:09 +01:00
Szymon Janc
6c1c75b368 android: Match socket IPC messages types with HAL name 2014-02-19 18:37:03 +01:00
Szymon Janc
e323df9475 android/socket: Move statics declarations after types definitions
This also makes connections list static.
2014-02-19 18:37:03 +01:00
Szymon Janc
2ed242f4e9 android/socket: Update PBAP profile version in SDP record
Android supports PBAP 1.1.
2014-02-19 17:05:38 +01:00
Andrei Emeltchenko
a6d0df8950 android/socket: Fix wrong memory access
This fixes accessing proto[2] in the code.
2014-02-12 15:23:22 +01:00
Andrzej Kaczmarek
968be4037c android/socket: Fix sockets security
Socket security shall be based on flags passed from HAL.

Android public API uses both encrypt and auth flags for "secure"
sockets which should be mapped to high security on our side, but since
this would also trigger requirement for 16-digits pin code (which is
not used in Android) we'll ignore auth flag and use either low or
medium security based on encrypt flag value only.
2014-02-12 13:50:49 +01:00
Andrzej Kaczmarek
4e3ad171df android/socket: Update channel numbers
OPP and PBAP channel numbers are set to same values as in Bluedroid.
Both MAP and SPP use channel numbers assigned dynamically.
2014-02-12 13:50:49 +01:00
Andrzej Kaczmarek
5b2756dd9b android/socket: Include HF AG in built-in profiles
This patch adds entry for HF AG profile in built-in profiles list. This
it to reserve channel number so it's not assigned to other service
registered by application. Method for creating SDP record is not
provided so it's not possible for application to register HF AG service
by mistake (this can be only done by handsfree profile implementation).
2014-02-12 13:50:49 +01:00
Andrzej Kaczmarek
6c411b1832 android/socket: Register SDP record for application service
This patch adds SDP record for services registered from application
(other than built-in services).
2014-02-12 13:50:49 +01:00
Andrzej Kaczmarek
a41087b916 android/socket: Add support for dynamic channel numbers
This patch adds support to register server with channel number assigned
dynamically, i.e. first free number is assigned. Channels which are
reserved for built-in services are not assigned for other services.
2014-02-12 13:50:49 +01:00
Andrzej Kaczmarek
7f9ab50d9d android/socket: Make servers list as static array
Since there is only small, fixed number of channels to allocate for
RFCOMM servers we can store them in static array. This will make
lookup for free channel simpler once we add support to assign channel
numbers dynamically.

At startup, channels reserved for built-in services which have static
channel number are marked as reserved so they cannot be assigned for
other service.
2014-02-12 13:50:49 +01:00
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