Commit Graph

51 Commits

Author SHA1 Message Date
Szymon Janc
14fc3c5403 android: Pass mode parameter to registered services 2014-03-04 10:18:27 +01:00
Szymon Janc
7d95d027b1 android: Create comon header for IPC
This header contains IPC specific structures and code not related to
BT and audio HAL protocols. This allows to fully decouple IPC from
HAL messages.

This is first step to make HAL part of IPC unit-testable and reusable
between BT HAL and audio HAL.
2014-02-28 15:22:45 +01:00
Szymon Janc
dd1e44fce1 android: Refactor IPC init
This allows to pass socket path and max service ID while initializaing
IPC. This is first step to allow use it both for BT and Audio HALs.
2014-02-28 15:22:45 +01:00
Marcel Holtmann
cde69653e0 android: Update copyright and license details 2014-02-11 10:42:56 -08:00
Szymon Janc
7bb2a16843 android/pan: Bring bridge interface down before removing it
Otherwise bridge will be 'in use' and won't be removed.
2014-02-07 11:21:22 +02:00
Szymon Janc
5ab76c6042 android/pan: Pass error in nap_remove_bridge
Don't return EOPNOTSUPP but just pass error from errno.
2014-02-07 11:21:22 +02:00
Szymon Janc
b4fbbb033e android/pan: Use ioctl instead of sysfs for setting forward delay
Using sysfs is causing problems due to filesystem permissions
(bluetoothd is running as bluetooth user) and bluetoothd already has
required capabilities for setting forward delay through ioctl.
2014-02-07 11:21:22 +02:00
Ravi kumar Veeramally
ce8bf58e5f android/pan: Fix bnep interface name
Android uses bt-pan static interface in PAN profile. In server role
it uses it as bridge name. But current implementaion passes interface
names like bnep0, bnep1... Android Framework is unaware of this name
and unable to allocate IP address after profile connection setup.
2014-02-07 11:21:22 +02:00
Szymon Janc
375bed1c4d android/pan: Fix unregistering NAP bridge
This fix not removing NAP bridge in case of error or last device
disconnect.
2014-02-07 11:21:22 +02:00
Szymon Janc
29bf1a3aab android/pan: Move functions up to avoid forward declarations 2014-02-07 11:21:22 +02:00
Szymon Janc
800c6b6678 profiles/network: Allow to pass interface name to bnep_new 2014-02-07 11:21:22 +02:00
Luiz Augusto von Dentz
7af429c001 android/pan: Use g_slist_free_full to free devices list
Calling g_slist_remove within the callback of g_slist_foreach is very
inefficient as it has to iterate in the list twice to figure which
element to remove.
2014-02-06 15:23:50 +02:00
Ravi kumar Veeramally
696372263d android/pan: Handle error case properly in NAP registration 2014-01-28 16:17:07 +01: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
908733202d android/pan: Remove not needed intialization to NULL 2014-01-22 17:35:52 +01:00
Andrei Emeltchenko
2649f6dc0d android/pan: Fix possible NULL dereference
It is better to return here since dev is not allocated and assigned NULL
value.
2014-01-22 17:33:23 +01:00
Andrei Emeltchenko
a163b8c0af android/pan: Fix wrong freeing dev
It does make sense free() dev after it is used. g_free() is not needed
here since it will be already executed in bt_pan_notify_conn_state().
2014-01-22 15:49:39 +02:00
Johan Hedberg
1a9051e9ee Rename glib-helper to uuid-helper 2014-01-21 14:12:47 +02:00
Jakub Tyszkowski
5d6a183585 android/pan: Initialize GError with NULL
This patch fixes the following issue:

bluetoothd[10552]: android/pan.c:register_nap_server()
bluetoothd[10552]: android/pan.c:nap_create_bridge() bnep
(bluetoothd:10552): GLib-WARNING **: GError set over the top of a previous GError or uninitialized memory.
This indicates a bug in someone's code. You must ensure an error is NULL before it's set.
The overwriting error message was: l2cap_bind: Address already in use (98)
bluetoothd[10552]: android/pan.c:destroy_nap_device()
2014-01-20 12:20:12 +02:00
Szymon Janc
cd8e325779 android/pan: Generate file path in compile time
This reduce need of using snprintf function and removes need of manual
buffer size calculation.
2014-01-13 10:21:18 +01:00
Ravi kumar Veeramally
78d1f1391e android/pan: Remove connected PAN devices on profile unregister call 2014-01-10 16:09:55 +01:00
Ravi kumar Veeramally
7f445ac7d5 android/pan: Implement PAN enable HAL api at daemon side 2014-01-10 16:09:55 +01:00
Ravi kumar Veeramally
423f637179 android/pan: Listen for incoming connections and accept in NAP role
Listen for incoming connections and accept it. Create bnep interface
add it to bridge and notify control and connection state information
through HAL. Remove the device on disconnect request. If android
settings UI does not have bluetooth tethering enabled it immediately
sends disconnect signal.
2014-01-10 16:09:55 +01:00
Ravi kumar Veeramally
a89e3dbdb9 android/pan: Register Network Access Point
Register NAP server and adds bnep bridge. Removes bridge
on destroy call. Bridge mechanism is needed when device acting
as a server and listen for incoming connections.
2014-01-10 16:09:55 +01:00
Ravi kumar Veeramally
885cf9d846 android/pan: Add PAN SDP record for NAP role 2013-12-31 15:43:39 +02:00
Ravi kumar Veeramally
50246bbaf3 bnep: Refactored bnep connect and disconnect calls
Refactored bnep connect and disconnect calls to simplify and
keeping bnep related functionality behind curtains.
bnep_connect calls takes care of bnep_setup until interface up
then connect callback will be called. Set disconnect callback
when connect call succeeds. bnep_disconnect should be
called only when iface is up/connected.
2013-12-20 14:54:47 +02:00
Ravi kumar Veeramally
fe8dabaaa1 android/pan: Change local_role to NONE only when device list is empty 2013-12-19 10:11:14 +02:00
Ravi kumar Veeramally
f8a38f2f68 android/pan: Free device after sending diconnected notification 2013-12-19 10:10:25 +02:00
Ravi kumar Veeramally
9e377d47c6 android/pan: Fix minor white space 2013-12-11 15:27:43 +02:00
Ravi kumar Veeramally
bb700aaa91 android/pan: Fix missing cleanup calls 2013-12-11 15:27:40 +02:00
Ravi kumar Veeramally
9ae5925ca3 bnep: Rename bnep_kill_connection to bnep_conndel
Renaming bnep_kill_connection to bnep_conndel to maintain
consistency with bnep_connadd function name.
2013-12-11 15:13:54 +02:00
Jakub Tyszkowski
dd90544dca android/pan: Move logic from HAL to daemon
HAL should contain as little logic as possible, but we should be doing
these checks on daemon side anyway.
2013-12-08 17:47:42 +02:00
Jakub Tyszkowski
314f4ee304 android/pan: Move logic from HAL layer to daemon
HAL should contain as little logic as possible, but we should be doing
these checks on daemon side anyway.
2013-12-08 17:47:42 +02:00
Andrei Emeltchenko
22d3278a5a android/pan: Fix no return on error path
This fixes possible crash in case connect fails.
2013-12-08 17:32:05 +02:00
Andrei Emeltchenko
64f5cc1738 android/pan: Remove unneeded NULL assignment 2013-12-08 17:32:05 +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
ea9af4bc3f android/pan: Use generic IPC message handling for commands
Handlers are registered on service register and unregistered on
unregister.

This also fix sending two IPC responses for get pan role command.
2013-12-02 16:24:02 +02:00
Luiz Augusto von Dentz
d48132c844 android/pan: Fix sending uninitialised bytes
name field of struct hal_ev_pan_ctrl_state is 17 bytes longs so memcpy of
the interface name does not field all the those bytes leaving the last
uninitialised:
Syscall param sendmsg(msg.msg_iov[1]) points to uninitialised byte(s)
   at 0x3600EF6E20: __sendmsg_nocancel (in /usr/lib64/libc-2.17.so)
   by 0x40DC06: ipc_send (ipc.c:93)
   by 0x4149AC: bnep_conn_cb (pan.c:120)
   by 0x4192B8: bnep_setup_cb (bnep.c:324)
   by 0x31D1647DF5: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x31D1648147: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x31D1648549: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3600.3)
   by 0x40338B: main (main.c:629)
 Address 0x7ff0003d3 is on thread 1's stack
2013-11-29 17:10:19 +02:00
Ravi kumar Veeramally
cd57b8b7e0 android/pan: Implement the get local role method in daemon
Returns local role of the device (NONE, PANU or NAP).
2013-11-29 17:10:19 +02:00
Ravi kumar Veeramally
ba10ece248 android/pan: Implement pan disconnect method in daemon
Disconnect ongoing PANU role connection betweek devices, free
the device and notify the connection state.
2013-11-29 17:10:19 +02:00
Ravi kumar Veeramally
64b76dd6ae android/pan: Implement pan connect method in daemon
Implements the PAN connect method in android daemon with PANU role
only. Setting up the bnep environment, adds connection and makes
bnep interface up are part of bnep_connect call. Notifies bnep
interface on control state call back and connection status on
connection state call back.
2013-11-29 17:10:19 +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
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
Ravi kumar Veeramally
b32461d42d android: Handle multiple init(register) and cleanup(unregister) calls properly
This can be tested with haltest.
2013-11-19 18:15:37 +02:00
Ravi kumar Veeramally
0a5ae04d8e android/pan: Fix wrong struct parameter in disconnect function call 2013-11-19 15:23:20 +02:00
Szymon Janc
fc10c55498 android: Improve IPC helper to not send invalid status response
This fix issue with sending invalid success response from several
places where ipc_send_rsp was used for reporting success. Instead of
using using ipc_send for success response, make helper handle that.
2013-11-18 15:17:22 +02:00
Ravi kumar Veeramally
017aa01531 android/pan: Fix wrong HAL service id 2013-11-15 12:02:36 +02:00
Szymon Janc
052e481adc android: Pass notification socket fd to service handlers
IPC helpers were converted to accept socket, not GIOChannel so there
is no need of passing former to handlers.
2013-11-07 17:05:47 +02:00
Szymon Janc
32f29761bf android: Make IPC helpers accept file descriptor
There is no need to pass GIOChannel as writes are done immediately.
2013-11-07 17:05:07 +02:00
Luiz Augusto von Dentz
1ca4c658d9 android/pan: Add initial code for handling commands 2013-11-04 21:13:05 +02:00