bluez/android
Lukasz Rymanowski 9a9f6acc06 android/gatt: Fix handling write cmd
We should not response on write cmd. This patch fixed that.
2014-05-20 23:55:07 +02:00
..
audio_utils android: Add resampler support 2014-05-13 14:17:18 +03:00
client android/client: Support sending GATT Server responses 2014-05-18 13:58:33 +02:00
cutils android: Add possibility to start android daemon on PC in single mode 2014-05-07 16:13:36 +02:00
hardware android: Load bluetooth.default.so as a module 2014-01-10 15:07:23 +02:00
system android/audio: Add kitkat audio headers 2013-12-16 17:41:56 +02:00
a2dp.c android/a2dp: Remove unused local variable 2014-04-23 14:17:48 +02:00
a2dp.h android: Pass mode parameter to registered services 2014-03-04 10:18:27 +01:00
android-tester.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
Android.mk android: Add resampler support 2014-05-13 14:17:18 +03:00
audio-ipc-api.txt android: Update Audio IPC documentation 2014-01-24 22:59:45 +01:00
audio-msg.h android: Create comon header for IPC 2014-02-28 15:22:45 +01:00
avctp.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
avctp.h android/avctp: Add avctp_send_browsing function 2014-04-25 15:05:23 +03:00
avdtp.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
avdtp.h android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
avrcp-lib.c android/avrcp-lib: Add support for SetAbsoluteVolume PDU 2014-05-19 16:12:47 +03:00
avrcp-lib.h android/avrcp-lib: Add support for SetAbsoluteVolume PDU 2014-05-19 16:12:47 +03:00
avrcp.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
avrcp.h android: Pass mode parameter to registered services 2014-03-04 10:18:27 +01:00
bite-rfcomm.txt android: Add BITE results for RFCOMM 2014-05-10 19:18:38 -07:00
bite-spp.txt android: Add BITE results for SPP 2014-05-10 19:19:03 -07:00
bluetooth.c android/bluetooth: Simplify check if device type changed 2014-05-19 10:17:25 +02:00
bluetooth.h android/bluetooth: Add support to read connection RSSI 2014-05-19 10:10:33 +02:00
bluetoothd-snoop.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
bluetoothd-wrapper.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
gatt.c android/gatt: Fix handling write cmd 2014-05-20 23:55:07 +02:00
gatt.h android/gatt: Add initial files 2014-03-03 16:11:07 +01:00
hal-a2dp.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
hal-audio.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
hal-avrcp.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
hal-bluetooth.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
hal-gatt.c android/hal: Fix sending not initialised data 2014-05-18 13:58:33 +02:00
hal-handsfree.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
hal-health.c android/hal: Fix not seting mode in health hal 2014-05-18 13:58:33 +02:00
hal-hidhost.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
hal-ipc-api.txt android/hal-gatt-api: Fix IPC definition for send response 2014-04-30 17:30:02 +02:00
hal-ipc.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
hal-ipc.h android/hal: Add initial code for IPC message handlers 2013-11-19 16:42:01 +02:00
hal-log.h android/tester: Make HAL logging wrapper print to stderr instead of stdout 2013-12-11 13:10:07 +02:00
hal-msg.h android/hal-gatt-api: Fix IPC definition for send response 2014-04-30 17:30:02 +02:00
hal-pan.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
hal-sco.c android/hal-sco: Add write support 2014-05-13 14:17:18 +03:00
hal-socket.c android: Update socket service id name to match service name 2014-02-24 13:45:09 +01:00
hal-utils.c android: Remove support for old Android versions 2014-01-14 12:57:18 +01:00
hal-utils.h android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
hal.h android/hal-health: Add hal-health.c with initial get interface call 2014-03-14 13:34:16 +01:00
handsfree.c android/handsfree: Fix Connect SCO command 2014-05-14 12:51:02 +03:00
handsfree.h android: Pass mode parameter to registered services 2014-03-04 10:18:27 +01:00
health.c android/health: Add initial function for HAL_OP_HEALTH_MDEP command 2014-04-23 21:59:16 +02:00
health.h android/health: Add health.c|h file with basic calls 2014-03-14 13:34:16 +01:00
hidhost.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
hidhost.h android: Pass mode parameter to registered services 2014-03-04 10:18:27 +01:00
init.bluetooth.rc android: Adjust uinput permissions 2014-03-13 21:35:35 +01:00
ipc-common.h android: Create comon header for IPC 2014-02-28 15:22:45 +01:00
ipc-tester.c android/ipc-tester: Fix structure passed to core unregister tests 2014-02-28 19:01:15 +01:00
ipc.c android: Create comon header for IPC 2014-02-28 15:22:45 +01:00
ipc.h android/a2dp: Use common IPC for audio socket 2014-02-28 15:22:45 +01:00
main.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
Makefile.am android/pts: Run PTS tests for SM 2014-05-14 20:53:45 +02:00
mcap-lib.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
mcap-lib.h android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
pan.c android/pan: Print error if failed to create bridge 2014-05-14 16:30:48 +02:00
pan.h android: Pass mode parameter to registered services 2014-03-04 10:18:27 +01:00
pics-a2dp.txt android/pts: Correct PICS for A2DP 2014-04-30 11:09:19 +02:00
pics-avctp.txt android/pts: Update PICS and PIXITs for AVCTP 2014-04-09 18:42:32 +02:00
pics-avrcp.txt android/pts: Bump PICS and PIXIT for AVRCP 2014-04-07 12:47:56 +02:00
pics-did.txt android/pts: Update PTS tests for DID 2014-04-07 11:55:01 +02:00
pics-gap.txt android/pts: Update PICS, PIXIT and tests for GAP 2014-04-14 10:15:38 +02:00
pics-gatt.txt android/pts: Adjust PICS for GATT 2014-05-20 21:02:32 +02:00
pics-hdp.txt android/pts: Add PICS for HDP 2014-03-31 15:27:33 +02:00
pics-hfp.txt android/pts: Bump PTS version for HFP 2014-04-10 11:18:57 +02:00
pics-hid.txt android/pts: Bump PTS version for HID 2014-04-09 18:43:02 +02:00
pics-hsp.txt android/pts: Bump PTS version for HSP 2014-04-10 11:18:57 +02:00
pics-iopt.txt android/pts: PTS tests results for IOPT 2014-05-09 14:48:18 +02:00
pics-l2cap.txt android/pts: Bump PTS version 2014-03-31 15:54:07 +02:00
pics-map.txt android/pts: Re-test MAP against PTS 5.1 2014-04-09 18:43:37 +02:00
pics-mcap.txt android/pts: Add PICS for MCAP 2014-03-31 15:27:33 +02:00
pics-mps.txt android: Make PTS version information machine readable 2014-05-13 09:24:18 -07:00
pics-opp.txt android/pts: Adjust PICS and PIXITs for OPP 2014-04-07 11:47:43 +02:00
pics-pan.txt android/pts: Bump PTS version for PAN 2014-04-10 10:45:08 +02:00
pics-pbap.txt android/pts: Bump PTS version for PBAP 2014-04-10 10:45:08 +02:00
pics-rfcomm.txt android: Add PICS for RFCOMM 2014-05-10 19:12:01 -07:00
pics-sdp.txt android/pts: Change mode for SDP pics file 2014-05-15 17:44:43 +02:00
pics-sm.txt android/pts: Add PICS and PIXITs for SM 2014-05-10 20:24:24 +02:00
pics-spp.txt android: Add PICS for SPP 2014-05-10 19:12:40 -07:00
pixit-a2dp.txt android/pts: Bump PTS version for A2DP 2014-04-09 18:42:09 +02:00
pixit-avctp.txt android/pts: Update PICS and PIXITs for AVCTP 2014-04-09 18:42:32 +02:00
pixit-avrcp.txt android/pts: Bump PICS and PIXIT for AVRCP 2014-04-07 12:47:56 +02:00
pixit-did.txt android/pts: Update PTS tests for DID 2014-04-07 11:55:01 +02:00
pixit-gap.txt android/pts: Update PICS, PIXIT and tests for GAP 2014-04-14 10:15:38 +02:00
pixit-gatt.txt android/pts: Bump PTS version for GATT 2014-04-14 11:45:00 +02:00
pixit-hdp.txt android/pts: Add PIXITs for MCAP and HDP 2014-03-31 15:27:33 +02:00
pixit-hfp.txt android/pts: Bump PTS version for HFP 2014-04-10 11:18:57 +02:00
pixit-hid.txt android/pts: Bump PTS version for HID 2014-04-09 18:43:02 +02:00
pixit-hsp.txt android/pts: Bump PTS version for HSP 2014-04-10 11:18:57 +02:00
pixit-iopt.txt android/pts: PTS tests results for IOPT 2014-05-09 14:48:18 +02:00
pixit-l2cap.txt android/pts: Bump PTS version 2014-03-31 15:54:07 +02:00
pixit-map.txt android/pts: Re-test MAP against PTS 5.1 2014-04-09 18:43:37 +02:00
pixit-mcap.txt android/pts: Add PIXITs for MCAP and HDP 2014-03-31 15:27:33 +02:00
pixit-mps.txt android/pts: Run MPS PTS tests 2014-05-20 20:13:28 +02:00
pixit-opp.txt android/pts: Adjust PICS and PIXITs for OPP 2014-04-07 11:47:43 +02:00
pixit-pan.txt android/pts: Bump PTS version for PAN 2014-04-10 10:45:08 +02:00
pixit-pbap.txt android/pts: Bump PTS version for PBAP 2014-04-10 10:45:08 +02:00
pixit-sm.txt android/pts: Correct file's header 2014-05-14 20:53:45 +02:00
pts-a2dp.txt android/pts: Re-test A2DP against PTS 5.1 2014-04-09 18:42:09 +02:00
pts-avctp.txt android/pts: PTS tests results for AVCTP 2014-04-09 18:42:32 +02:00
pts-avrcp.txt android/pts: Re-test AVRCP against PTS 5.1 2014-04-07 12:47:56 +02:00
pts-did.txt android/pts: Update PTS tests for DID 2014-04-07 11:55:01 +02:00
pts-gap.txt android/pts: Keep PTS GAP results style consistent 2014-05-18 22:10:16 +02:00
pts-gatt.txt android/pts: Re-run all GATT PTS tests 2014-05-20 21:02:32 +02:00
pts-hdp.txt android/pts: Add PTS test listing for HDP 2014-05-13 12:45:32 +02:00
pts-hfp.txt android/pts: Update HFP test results 2014-03-25 23:59:36 +01:00
pts-hid.txt android/pts: Re-test HID against PTS 5.1 2014-04-09 18:43:02 +02:00
pts-hsp.txt android/pts: Re-test HSP against PTS 5.1 2014-04-10 11:18:57 +02:00
pts-iopt.txt android/pts: PTS tests results for IOPT 2014-05-09 14:48:18 +02:00
pts-l2cap.txt android/pts: Add PTS test results for L2CAP 2014-03-31 15:35:45 +02:00
pts-map.txt android/pts: Re-test MAP against PTS 5.1 2014-04-09 18:43:37 +02:00
pts-mcap.txt android/pts: Add test listing for MCAP 2014-05-13 12:45:32 +02:00
pts-mps.txt android/pts: Run MPS PTS tests 2014-05-20 20:13:28 +02:00
pts-opp.txt android/pts: Re-run OPP with ETS-12160 2014-04-30 11:09:19 +02:00
pts-pan.txt android/pts: Re-run PAN tests on PTS 5.1 2014-04-10 10:45:08 +02:00
pts-pbap.txt android/pts: Re-test PBAP against PTS 5.1 2014-04-10 10:45:08 +02:00
pts-sm.txt android/pts: Run PTS tests for SM 2014-05-14 20:53:45 +02:00
README android/README: Update GATT HAL implementation status 2014-04-28 17:59:00 +02:00
sco-ipc-api.txt android: Add SCO IPC API 2014-05-13 14:16:51 +03:00
sco-msg.h android: Add SCO IPC API 2014-05-13 14:16:51 +03:00
socket-api.txt android/doc: Add socket-api.txt document 2013-12-08 17:32:05 +02:00
socket.c android: Make multi-line comments style consistent 2014-04-29 13:31:00 +02:00
socket.h android: Pass mode parameter to registered services 2014-03-04 10:18:27 +01:00
system-emulator.c android/system-emulator: Pass --track-origin=yes to valgrind 2014-04-10 16:14:22 +02:00
test-ipc.c android: Create comon header for IPC 2014-02-28 15:22:45 +01:00
utils.h android: Update copyright and license details 2014-02-11 10:42:56 -08:00

BlueZ for Android
*****************

Since Android 4.2 there exists a well standardized HAL interface that the
Bluetooth stack is expected to provide and which enables the easy replacement
of the stack of choice on Android. Android BlueZ is intended as a drop-in
replacement to Android provided Bluetooth stack.

More details about BlueZ for Android architecture and components can be found
in android/hal-ipc-api.txt file.

Supported Android version: 4.4


Building and running on Android
===============================

Steps needed to build and run Android Open Source Project 4.4.2 with
integrated BlueZ.


Build requirements
------------------

- GLib - Android 4.2 or later don't provide GLib and one must provide it in
'external/bluetooth/glib' folder of Android tree. Sample Android GLib port
is available at https://code.google.com/p/aosp-bluez.glib/

- SBC - A2DP code requires SBC library (version 1.2 or higher) present in
'external/bluetooth/sbc' directory. Library is build from Android.mk provided
by BlueZ. SBC code is available at git://git.kernel.org/pub/scm/bluetooth/sbc

- Bionic support - Currently only 'master' branch available at
https://android.googlesource.com/platform/bionic provides all required
functionality and running BlueZ on release branch requires backporting missing
features (currently epoll_create1 and ppoll calls for Android 4.4.2). Sample
Bionic for Android 4.4.2 with all required features backported is available at
https://code.google.com/p/aosp-bluez.platform-bionic/


Runtime requirements
--------------------

BlueZ HAL library requires 'bluetoothd' and 'bluetoothd-snoop' services to be
available on Android system. Some permissions settings are also required.

This can be done by importing init.bluetooth.rc file in init.rc file of targeted
board:
import init.bluetooth.rc

For convenience examples are provided at:
https://code.google.com/p/aosp-bluez.device-lge-mako/    (Nexus 4)
https://code.google.com/p/aosp-bluez.device-asus-flo/    (Nexus 7 2013)


Downloading and building
------------------------

Building for Android requires full Android AOSP source tree. Sample Android
4.4.2 tree with all required components present is available at
http://code.google.com/p/aosp-bluez/

This tree provides support for Nexus4 (target aosp_mako-userdebug) and
Nexus 7 2013 (target aosp_flo-userdebug). Tree does not provide binary blobs
needed to run Android on supported devices. Those can be obtained from
https://developers.google.com/android/nexus/drivers. Binary blobs needs to be
unpacked (EULA acceptance required) into 'vendor' directory of Android tree.

Downloading:
repo init -u https://code.google.com/p/aosp-bluez.platform-manifest -b kitkat
repo sync

Building:
source build/envsetup.sh
lunch aosp_mako-userdebug    or    lunch aosp_flo-userdebug
make -j8

Flashing:
adb reboot bootloader
fastboot flashall -w

After full build is done it is possible to rebuild only BlueZ:
'cd external/bluetooth/bluez/android/'
'mm' (or 'mm -B' to force rebuilding of all files)
'adb sync' to update target device.


Linux Kernel requirements
-------------------------

BlueZ for Android uses Linux Bluetooth subsystem and it must be enabled in
kernel. Minimal required version of management interface is 1.3. This
corresponds to Linux 3.9 but latest available version is recommended. Other
requirements include UHID and network bridge support.

Following kernel options should be enabled:
CONFIG_BT
CONFIG_BT_RFCOMM
CONFIG_BT_RFCOMM_TTY
CONFIG_BT_BNEP
CONFIG_BT_BNEP_MC_FILTER
CONFIG_BT_BNEP_PROTO_FILTER
CONFIG_BRIDGE
CONFIG_UHID

Also BT chip driver needs to be enabled e.g:
CONFIG_BT_HCIBTUSB

If it is not possible to use new enough Linux kernel one can use updated
bluetooth subsytem from Backports project. More information about Backports can
be found at https://backports.wiki.kernel.org. Sample kernels using backports
for running BlueZ on Android are available at
https://code.google.com/p/aosp-bluez.


Running with Valgrind
---------------------

BlueZ for Android is preconfigured to be easily run under Valgrind memcheck.
Appropriate configuration and required modules are automatically included when
building either userdebug or eng variant of Android platform.

Valgrind can be enabled in runtime by setting "persist.sys.bluetooth.valgrind"
property to either literal "true" or any numeric value >0. For example:
adb root
adb shell setprop persist.sys.bluetooth.valgrind true

After changing property value Bluetooth need to be restarted to apply changes
(this can be done using UI, just disable and enable it again). Property is
persistent, i.e. there's no need to enable Valgrind again after reboot.

It's recommended to have unstripped libglib.so installed which will enable
complete backtraces in Valgrind output. Otherwise, in many cases backtrace
will break at e.g. g_free() function without prior callers. It's possible to
have proper library installed automatically by appropriate entry in Android.mk,
see https://code.google.com/p/aosp-bluez.glib/ for an example.


Enabling BlueZ debugs
---------------------

BlueZ debug logs can be enabled in runtime by setting "persist.sys.bluetooth.debug"
property to either literal "true" or any numeric value >0. For example:
adb root
adb shell setprop persist.sys.bluetooth.debug 1

After changing property value Bluetooth needs to be restarted to apply changes.

There is also a possibility to enable mgmt debug logs which also enables debugs
as above. To enable it procced in the same way as described above but use
system properties called: persist.sys.bluetooth.mgmtdbg

Note: Debugs are only available on NON USER build variants


Customization
-------------

It is possible to customize BlueZ for Android through Android system properties.
This may include enabling extra profiles or features inside HALs implementation
These properties are read on Bluetooth stack startup only and require stack
restart if changed. All customization properties names start with
"persist.sys.bluetooth." followed by specific HAL name e.g.
"persist.sys.bluetooth.handsfree". This section list available customization
options.

Property	Value		Description
-------------------------------------------
mode		bredr		Enable BlueZ in BR/EDR mode
		le		Enable BlueZ in LE mode
		<none>		Enable BlueZ in default mode - enable BR/EDR/LE
				if available.
handsfree	hfp		Enable Handsfree Profile (HFP) with narrowband
				speech only
		hfp_wbs		Enable Handsfree Profile (HFP) with narrowband
				and wideband speech support
		<none>		Don't enable Handsfree Profile (HFP)


Building and running on Linux
-----------------------------

It is possible to build and test BlueZ for Android daemon on Linux (eg. PC).
Simply follow instructions available at README file in BlueZ top directory.
Android daemon binary is located at android/bluetoothd. See next section on
how to test Android daemon on Linux.


Testing tool
------------

BT HAL test tools located in android/haltest is provided for HAL level testing
of both Android daemon and HAL library. Start it with '-n' parameter and type
'bluetooth init' in prompt to initialize HAL library. Running without parameter
will make haltest try to initialize all services after start. On Android
required bluetoothd service will be started automatically. On Linux it is
required to start android/bluetoothd manually before init command timeout or
use provided android/system-emulator, which takes care of launching daemon
automatically on HAL library initialization. To deinitialize HAL library and
stop daemon type 'bluetooth cleanup'. Type 'help' for more information. Tab
completion is also supported.


Implementation status
=====================

Summary of HALs implementation status.

complete    - implementation is feature complete and Android Framework is able
              to use it normally
partial     - implementation is in progress and not all required features are
              present, Android Framework is able to use some of features
initial     - only initial implementations is present, Android Framework is
              able to initialize but most likely not able to use it
not started - no implementation, Android Framework is not able to initialize it

Profile ID    HAL header         Status
---------------------------------------
core          bluetooth.h        complete
a2dp          bt_av.h            complete
gatt          bt_gatt.h          partial
              bt_gatt_client.h   partial
              bt_gatt_server.h   initial
handsfree     bt_hf.h            complete
hidhost       bt_hh.h            complete
health        bt_hl.h            initial
pan           bt_pan.h           complete
avrcp         bt_rc.h            complete
socket        bt_sock.h          complete


Implementation shortcomings
===========================

It is possible that some of HAL functionality (although being marked as
complete) is missing implementation due to reasons like feature feasibility or
necessity for latest Android Framework. This sections provides list of such
deficiencies. Note that HAL library is always expected to fully implement HAL
API so missing implementation might happen only in daemon.


HAL Bluetooth
-------------

methods:
dut_mode_send                      never called from Android Framework
le_test_mode                       never called from Android Framework
get_remote_service_record          never called from Android Framework

callbacks:
dut_mode_recv_cb                   empty JNI implementation
le_test_mode_cb                    empty JNI implementation

properties:
BT_PROPERTY_SERVICE_RECORD         not supported for adapter and device, for
                                   device this property is to be returned as
                                   response to get_remote_service_record,
                                   not sure what to return on get_property
                                   calls (records of all services?)

BT_PROPERTY_REMOTE_VERSION_INFO    information required by this property (LMP
                                   information) are not accessible from mgmt
                                   interface, also marking this property as
                                   settable is probably a typo in HAL header

HAL Socket
----------

Support only for BTSOCK_RFCOMM socket type.


HAL AVRCP
---------

methods:
list_player_app_attr_rsp           never called from Android Framework
list_player_app_value_rsp          never called from Android Framework
get_player_app_value_rsp           never called from Android Framework
get_player_app_attr_text_rsp       never called from Android Framework
get_player_app_value_text_rsp      never called from Android Framework
set_player_app_value_rsp           never called from Android Framework

callbacks:
list_player_app_attr_cb            NULL JNI implementation
list_player_app_values_cb          NULL JNI implementation
get_player_app_value_cb            NULL JNI implementation
get_player_app_attrs_text_cb       NULL JNI implementation
get_player_app_values_text_cb      NULL JNI implementation
set_player_app_value_cb            NULL JNI implementation


Known Android issues
====================

It is possible that BlueZ is triggering bugs on Android Framework that could
affect qualification or user experience. This section provides list of
recommended Android fixes that are not part of latest AOSP release supported by
BlueZ.

https://android-review.googlesource.com/82757
https://android-review.googlesource.com/87670
https://android-review.googlesource.com/88384


Unimplemented Bluetooth features
================================

Some Bluetooth functionality require support from outside of BT stack
eg. telephony stack. This sections describes profiles optional features not
implemented due to lack of support in other Android subsystems or missing API
in respective BT HALs.

Profile		Feature				Comments
--------------------------------------------------------
HFP		Attach a phone number to	AT+BINP=1
		a voice tag
HFP		Enhanced Call Control		AT+CHLD={1x,2x}
HFP		Explicit Call Transfer		AT+CHLD=4
HFP		Response and Hold		AT+BTRH, +BTRH
HFP		In-band Ring Tone		+BSIR
AVRCP		Player Settings			HAL API present but not used
AVRCP		Browsing			No HAL API