OSDN Git Service

android-x86/system-bt.git
8 years agoservice: Move client registration into base class
Arman Uguray [Mon, 21 Sep 2015 18:17:07 +0000 (11:17 -0700)]
service: Move client registration into base class

This CL introduces InterfaceWithClientsBase, which is an abstract class
that implements common client registration logic, which will be reused
for Binder interfaces such as IBluetoothGattClient and
IBluetoothGattServer. This also introduces BluetoothClientInstance, so
that per-application API client instances (and their factories) conform
to a common interface.

Bug: 24245347
Change-Id: Ia4b464fa85f7a33c631bf63342631fce8d155b4a

8 years agoservice: Add missing include
Arman Uguray [Thu, 24 Sep 2015 06:43:18 +0000 (23:43 -0700)]
service: Add missing include

Added missing "#include <atomic>" line to fix build breakages on
some build flavors.

Change-Id: I611bb63e84787217ff4bf774ceebc09ffd3c0476

8 years agoservice/client: Add start-adv and stop-adv
Arman Uguray [Thu, 17 Sep 2015 01:04:32 +0000 (18:04 -0700)]
service/client: Add start-adv and stop-adv

Added the start-adv and stop-adv commands to FCLI for testing
the IBluetoothLowEnergy advertising APIs.

Bug: 23793954
Change-Id: I023441e4db4a50608b4f9a90bf3365c1dab8d0d1

8 years agoservice: Implement IBluetoothLowEnergy advertising
Arman Uguray [Thu, 17 Sep 2015 01:02:31 +0000 (18:02 -0700)]
service: Implement IBluetoothLowEnergy advertising

This CL implements the IBluetoothLowEnergy Binder APIs for
multi-advertising.

Bug: 23793954
Change-Id: I6519f86b9e528d23d2c1f46618188d1123686856

8 years agoservice: Add advertising support to LowEnergyClient
Arman Uguray [Thu, 17 Sep 2015 01:00:05 +0000 (18:00 -0700)]
service: Add advertising support to LowEnergyClient

This CL adds the StartAdvertising and StopAdvertising APIs to
LowEnergyClient. These internally call into the multi-advertising
APIs in HAL and report success or failure in an async callback.
The sequence of calls to enable advertising and setting advertising
and scan response data are serialized internally.

Bug: 23793954
Change-Id: Id093a98f3baca6328653b986857a064e8a722690

8 years agoservice: Fix bug in RemoteCallbackMap
Arman Uguray [Thu, 17 Sep 2015 00:56:32 +0000 (17:56 -0700)]
service: Fix bug in RemoteCallbackMap

Fixed a bug in RemoteCallbackMap that returned the wrong value
in one of the template functions that wasn't exercised before.

Bug: 23793954
Change-Id: Id6848bd08e6941d3c8c6d6e4d6e494a0b9dc4c69

8 years agoservice: Add various LE advertising constants
Arman Uguray [Thu, 17 Sep 2015 00:55:04 +0000 (17:55 -0700)]
service: Add various LE advertising constants

Added several constants that are used in LE advertising. Added
constants for the exposed EIR fields here as well so that clients
can use it.

Bug: 23793954
Change-Id: Ib6a97d6beb1a31c9c3ea7ed468167dab627d7d32

8 years agoservice: Fix build breakage.
Arman Uguray [Sun, 20 Sep 2015 19:26:16 +0000 (12:26 -0700)]
service: Fix build breakage.

Fixed build breakage due to missing changes.

Change-Id: Iac962fef2e9be979a2af90a43a66a5c66bbe4ad4

8 years agoservice: Add HAL wrappers for multi-advertising
Arman Uguray [Thu, 17 Sep 2015 00:53:05 +0000 (17:53 -0700)]
service: Add HAL wrappers for multi-advertising

This CL adds the fake and real HAL wrappers for the multi-advertising
APIs in hardware/bluetooth/bt_gatt_client.h.

Bug: 23793954
Change-Id: I485e7cf87c4b6f42c3a702c62230a287443a75c1

8 years agoservice: Add binder stubs for advertising API
Arman Uguray [Thu, 10 Sep 2015 21:28:54 +0000 (14:28 -0700)]
service: Add binder stubs for advertising API

Added native binder proxy stubs for IBluetoothLowEnergy interface
startMultiAdvertising and stopMultiAdvertising methods and
IBluetoothLowEnergyCallback.onMultiAdvertiseCallback.

Bug: 23793954
Change-Id: I0577619502042f612bf17f2a0affb2a9a1eaed38

8 years agoservice: Add AdvertiseData and AdvertiseSettings
Arman Uguray [Mon, 31 Aug 2015 21:31:02 +0000 (14:31 -0700)]
service: Add AdvertiseData and AdvertiseSettings

Added native definitions for AdvertiseData and AdvertiseSettings
framework objects. Also introduced parcel_helpers, which currently
provides functions to convert AdvertiseData and AdvertiseSettings
to/from Parcel.

As part of this, the bt_service_binder_unittests executable has been
added. This is built for the target device rather than host, as it
requires libbinder and libbinder currently can't be built for host.

Bug: 23793954
Change-Id: Ic55d7f48579e519006decaada5b6f2ef7aefe595

8 years agoservice/client: Add first BLE interface commands
Arman Uguray [Fri, 4 Sep 2015 20:17:39 +0000 (13:17 -0700)]
service/client: Add first BLE interface commands

Added the register-ble, unregister-ble, and unregister-all-ble
commands to FCLI. Also added a DeathListener for the IBluetooth
interface to handle the case when bluetoothtbd dies.

Bug: 23793954
Change-Id: I3c549ea59665cf174fb47114b879f679c0aafcb4

8 years agoservice: Implement IBluetoothLowEnergy client registration
Arman Uguray [Fri, 4 Sep 2015 20:11:39 +0000 (13:11 -0700)]
service: Implement IBluetoothLowEnergy client registration

This CL adds support for the IBluetoothLowEnergy registerClient and
unregisterClient methods. A lot of the code added here deals with
asynchronous callback registration and can be generalized to other
interfaces that asynchronously associate and return client
interface IDs with callback binders.

Bug: 23793954
Change-Id: I82cf26e194c456f04363fe66f094bc803a5aa436

8 years agoservice: Added RemoteCallbackMap
Arman Uguray [Fri, 4 Sep 2015 19:57:37 +0000 (12:57 -0700)]
service: Added RemoteCallbackMap

Added the RemoteCallbackMap template class which allows storing
IInterface subclasses in an associative array while tracking the
death of the remote process that owns the associated binder. This is
similar to RemoteCallbackList but stores entries in key-value pairs.

Also fixed some RemoteCallbackList documentation and change the code to
use std::unordered_map rather than std::map.

Bug: 23793954
Change-Id: I205c0491d21fef3bc5eeb5c4a7356dab4b6eb8dc

8 years agoservice: Add IBluetoothLowEnergy interface
Arman Uguray [Wed, 2 Sep 2015 00:22:29 +0000 (17:22 -0700)]
service: Add IBluetoothLowEnergy interface

Introduce the IBluetoothLowEnergy and IBluetoothLowEnergyCallback
interfaces with stub implementations for three methods only. Added
the definition and implementation for IBluetooth.GetLowEnergyInterface.

Bug: 23395353
Change-Id: Iba4d9aa20779956b486c0b46e752e0e00be3aeea

8 years agoservice: Introduce bluetooth::LowEnergyClient
Arman Uguray [Thu, 3 Sep 2015 22:09:41 +0000 (15:09 -0700)]
service: Introduce bluetooth::LowEnergyClient

Added the LowEnergyClient class which manages a per-application BLE
API client instance. This currently only supports getting registered
with the stack and obtaining a client_if handle but will expose APIs
in the future for various BLE operations.

Bug: 23793954
Change-Id: I423f6d12321877826525e5e52136682fa9d5a441

8 years agoservice: Add UUID::GetRandom
Arman Uguray [Thu, 3 Sep 2015 22:00:52 +0000 (15:00 -0700)]
service: Add UUID::GetRandom

Added a static class method to UUID that returns a random 128-bit UUID.
Also converted the enum constants to pure integer constants to make
their meaning more explicit.

Bug: 23395353
Change-Id: If8b97d40c020fdfc8b460b537b2da7c62b0c24ad

8 years agoservice: Add hal::BluetoothGattInterface
Arman Uguray [Mon, 31 Aug 2015 23:29:07 +0000 (16:29 -0700)]
service: Add hal::BluetoothGattInterface

Added hal::BluetoothGattInterface which is a C++ wrapper around the
HAL Bluetooth GATT interfaces. This follows the current pattern of hal/*
wrappers and is meant to be fakeable.

Bug: 23395353
Change-Id: Ib11afba9fe2f4632591d5db384edf32ca788bf2c

8 years agoservice: Implement IBluetooth.isMultiAdvertisementSupported()
Arman Uguray [Fri, 21 Aug 2015 21:59:57 +0000 (14:59 -0700)]
service: Implement IBluetooth.isMultiAdvertisementSupported()

Added the Binder bindings, bluetoothtbd implementation, and new
bluetooth-cli command for testing it.

Bug: 23227962
Change-Id: I2de62e49e5d8b0bcc118ccb654d72fdd9f11f748

8 years agogn-build: Add secondary build tree for gmock
Arman Uguray [Fri, 28 Aug 2015 19:15:09 +0000 (12:15 -0700)]
gn-build: Add secondary build tree for gmock

Added a BUILD.gn file for gmock under third_party/gmock.

Change-Id: Icbe93f118142ab8e0ea3a46672a74dd2d7466868

8 years agobrillo: add and install system startup files
Marie Janssen [Tue, 25 Aug 2015 22:07:09 +0000 (15:07 -0700)]
brillo: add and install system startup files

Add files necessary to start bluetoothtbd at startup.

BUG=23120355

Change-Id: Ibdacee621909b9d7fc9af2935343e581693ed010

8 years agoservice: Check for NULL IBinder in registerCallback
Arman Uguray [Mon, 24 Aug 2015 18:00:25 +0000 (11:00 -0700)]
service: Check for NULL IBinder in registerCallback

Added checks for NULL binder in IBluetooth.registerCallback and
IBluetooth.unregisterCallback.

Change-Id: I6136ad08d83696ad0e94cc2425667df9310f2b96

8 years agoservice: Return SUCCESS from Acquire|ReleaseWakeLock
Arman Uguray [Mon, 24 Aug 2015 17:08:19 +0000 (10:08 -0700)]
service: Return SUCCESS from Acquire|ReleaseWakeLock

Added code back to lie and return BT_STATUS_SUCCESS from the
AcquireWakeLock and ReleaseWakeLock OS callouts, since without these
the adapter cannot be properly disabled.

Bug: 23390297
Change-Id: I9801ccc7f72d83d132363fc888319bfb9b2eff29

8 years agoMerge "Improve adv_data transfer between contexts."
Ian Coolidge [Mon, 24 Aug 2015 17:22:45 +0000 (17:22 +0000)]
Merge "Improve adv_data transfer between contexts."

8 years agotest_vendor_lib: Clean up controller documentation and address style
Dennis Cheng [Fri, 21 Aug 2015 03:32:01 +0000 (20:32 -0700)]
test_vendor_lib: Clean up controller documentation and address style
issues

This upload cleans up the command documentation in the controller's
header file and also fixes a few logical errors related to command
status event packets. Some style fixes are also included, such as
removing braces for single line conditionals to conform to remain
consistent with the rest of the project.

Bug: 21586676
Change-Id: Ife5e608e43c3030e76eff8ea79ce6cad0b2c10a3

8 years agotest_vendor_lib: Add tests
Dennis Cheng [Tue, 18 Aug 2015 23:44:08 +0000 (16:44 -0700)]
test_vendor_lib: Add tests

This upload adds unit tests for the packet_stream and hci_transport
objects.

Bug: 21586676
Change-Id: Ica99be959cdd801ea10631d31fc0f0b8ea1d8456

8 years agoMerge "Enable clang compilation, use stdatomic.h."
Chih-hung Hsieh [Fri, 21 Aug 2015 20:25:29 +0000 (20:25 +0000)]
Merge "Enable clang compilation, use stdatomic.h."

8 years agoservice: Don't lie about supporting wake locks
Arman Uguray [Thu, 20 Aug 2015 22:40:31 +0000 (15:40 -0700)]
service: Don't lie about supporting wake locks

Changed the code to return error rather than success from the native
bt_os_callout_t hooks.

Bug: 23390297
Change-Id: I0a4e2678ace88072294b82e57cf1e1bd3edd08cd

8 years agoEnable clang compilation, use stdatomic.h.
Chih-Hung Hsieh [Thu, 13 Aug 2015 19:27:32 +0000 (12:27 -0700)]
Enable clang compilation, use stdatomic.h.

* Remove old atomic.h and atomic_test.cpp.
  Use stdatomi.h in counter.c.
* Suppress warnings on unused variables/parameters.
* Suppress warnings on redefined typedef.

Change-Id: Ic7ec652608f2c9423984a3631fb58efea5a835e7

8 years agotest_vendor_lib: Add working post delayed task
Dennis Cheng [Fri, 14 Aug 2015 20:15:31 +0000 (13:15 -0700)]
test_vendor_lib: Add working post delayed task

This upload fixes the post delayed task functionality so that it uses
a custom time stamped event object instead of posting callbacks to the
vendor manager's task runner (which does not support delayed tasks for
MessageLoopForIO).

Bug: 21586676
Change-Id: Ib5d9019d8c8dd5c9ad865df82eac16b0ecf50268

8 years agoservice/client: Register IBluetoothCallback
Arman Uguray [Thu, 20 Aug 2015 19:47:55 +0000 (12:47 -0700)]
service/client: Register IBluetoothCallback

bluetooth-cli now registers an IBluetoothCallback to receive adapter
state updates, which gets automatically unregistered when bluetooth-cli
exits.

Bug: 23328384
Change-Id: I4f190e91ecd8401b9f5eb1cffdfb26cd9d5cecb0

8 years agoservice: Introduce IBluetoothCallback.h
Arman Uguray [Thu, 20 Aug 2015 19:36:20 +0000 (12:36 -0700)]
service: Introduce IBluetoothCallback.h

This CL introduces the native bindings for the IBluetoothCallback
Binder interface and implements the IBluetooth registerCallback and
unregisterCallback methods.

Bug: 23328384
Change-Id: I6fbf72cff7e3f037a412be8678ea97f3a7ada0c8

8 years agoservice: Add native RemoteCallbackList
Arman Uguray [Thu, 20 Aug 2015 19:31:50 +0000 (12:31 -0700)]
service: Add native RemoteCallbackList

This CL introduces a native port of the android.os.RemoteCallbackList
Java class. This is in preparation of the upcoming IBluetoothCallback
implementation.

Bug: 23328384
Change-Id: Icebf5c286ced820fa631da35f50cdf5d244fdded

8 years agoservice: Add complete IBluetooth transaction enums
Arman Uguray [Thu, 20 Aug 2015 19:12:56 +0000 (12:12 -0700)]
service: Add complete IBluetooth transaction enums

This CL completes the IBluetooth transaction codes based on the
latest IBluetooth.aidl file from goog/mnc-dev.

Bug: 23227962
Change-Id: I76d58647a0467cd0eb18f9bd0d3eceb36ce2abcf

8 years agoRevert "service: Move UNIX IPC code into ipc/unix/"
Arman Uguray [Thu, 20 Aug 2015 21:06:57 +0000 (21:06 +0000)]
Revert "service: Move UNIX IPC code into ipc/unix/"

It turns out "unix" is defined to be 1 somewhere, which breaks compilation of this CL (since I added "namespace unix").

This reverts commit 93e66a66464aa30ca7184e4a7378c8e8d752cbe1.

Change-Id: I00b0a59a35024ccf78297117916d12031a6346a5

8 years agoservice: Introduce bluetooth::Adapter::Observer
Arman Uguray [Thu, 20 Aug 2015 18:38:49 +0000 (11:38 -0700)]
service: Introduce bluetooth::Adapter::Observer

This CL introduces a new Observer interface for the Adapter class.
This meant to serve as the top-level API for receiving Adapter state
notifications, property updates, etc, in a format that doesn't use
the native HAL types.

Bug: 23328384
Change-Id: Ibf29063a169ad5e986d433d0901b3b973af0aa56

8 years agoservice: Support base switches::kV
Arman Uguray [Thu, 20 Aug 2015 18:49:00 +0000 (11:49 -0700)]
service: Support base switches::kV

This is a libbase built-in command-line flag to set log verbosity,
so that the VLOG macro does the right thing. This CL enables that for
the daemon. To enable VLOGs with a given verbosity level and below, do

bluetoothtbd --v=<level>

Change-Id: I128a42c52425c37640c016c3c6158419cc1c0f66

8 years agoservice: Move UNIX IPC code into ipc/unix/
Arman Uguray [Thu, 20 Aug 2015 20:07:18 +0000 (13:07 -0700)]
service: Move UNIX IPC code into ipc/unix/

Moved the UNIX IPC related code into a new ipc/unix subdirectory.
Added new namespace levels for unix and binder that mimic the
directory structure.

Change-Id: I58954d0c3dd1a6fe9c141c3122d42530385265f6

8 years agotest_vendor_lib: Read controller properties from file.
Dennis Cheng [Mon, 10 Aug 2015 16:29:41 +0000 (09:29 -0700)]
test_vendor_lib: Read controller properties from file.

This upload lets the controller be configured via a JSON file that
specifies the controller attributes. A default configuration is not
currently provided but will be included in a future upload. Also fixes
a few mistakes in test_channel.py.

Bug: 21586676
Change-Id: I9d0e65a9664e179ddb97664a748c766f4f8a554e

8 years agoservice/client: Add support for the latest methods
Arman Uguray [Tue, 18 Aug 2015 00:25:04 +0000 (17:25 -0700)]
service/client: Add support for the latest methods

Added support for calling the IBluetooth getAddress, setName,
and getName methods.

Bug: 23227962
Change-Id: Ib8c3f609b02e953a2989c18d614b5f52a56421c2

8 years agoservice: Implement IBluetooth getAddress, getName, and setName
Arman Uguray [Tue, 18 Aug 2015 00:23:42 +0000 (17:23 -0700)]
service: Implement IBluetooth getAddress, getName, and setName

This CL implements the IBluetooth getAddress, getName, and setName
API methods.

Bug: 23227962
Change-Id: I5ba8395a08bdbcf6a882ea8f413448cf0a1f331a

8 years agoFix typo in main/bte_main.c.
Miao Chou [Tue, 11 Aug 2015 18:41:58 +0000 (11:41 -0700)]
Fix typo in main/bte_main.c.

Change-Id: If16dd316545b485f3a92c9700f9af35bf97fdd42

8 years agoservice: Add four more IBluetooth API definitions
Arman Uguray [Sat, 15 Aug 2015 01:32:48 +0000 (18:32 -0700)]
service: Add four more IBluetooth API definitions

Added bindings for the following IBluetooth API methods:

    String getAddress();
    ParcelUuid[] getUuids();
    boolean setName(in String name);
    String getName();

Bug: 23227962
Change-Id: Ia5f57056486bb832b2c9e7fc82837626716992ed

8 years agoservice: Rename Uuid to UUID
Arman Uguray [Sat, 15 Aug 2015 01:28:42 +0000 (18:28 -0700)]
service: Rename Uuid to UUID

This is more consistent with the ancronym naming convention in the
framework code (e.g. java.util.UUID) and elsewhere in the Bluetooth
daemon.

Change-Id: I3461cf12d563e00ba5e0b0b390bd9ef94e6d7418

8 years agoservice: Implement IBluetooth::GetState
Arman Uguray [Sat, 15 Aug 2015 00:23:47 +0000 (17:23 -0700)]
service: Implement IBluetooth::GetState

This CL implements the GetState method of the IBluetooth interface:

   1. A new file, adapter_state.h has been added, which defines the
      STATE_* values from BluetoothAdapter.java in the framework layer.
      This is done this way so that a client library can be built with
      minimal dependency on core service code (e.g. Adapter).

   2. Implemented the GetState method.

   3. Refactored the fake BluetoothInterface such that multiple unit
      test modules can make use of it by centralizing fake behavior
      to hal/.

   4. Added new commands to client/.

Bug: 23227962
Change-Id: Id403094f6fe34cd5cef0577f319309169f74ddf3

8 years agoservice: Implement IBluetooth IsEnabled, Enable, and Disable
Arman Uguray [Fri, 14 Aug 2015 00:05:03 +0000 (17:05 -0700)]
service: Implement IBluetooth IsEnabled, Enable, and Disable

Implemented the IsEnabled, Enable, and Disable methods of the IBluetooth
interface. Added a simple REPL logic to client/main.cpp so that these commands
can be tested real-time via command-line.

Bug: 23169366
Change-Id: Id27a82e5cdadc5ea0b6f88d3ab3a6b7882f6212a

8 years agoservice: Replace CoreStack with Adapter
Arman Uguray [Fri, 14 Aug 2015 00:01:07 +0000 (17:01 -0700)]
service: Replace CoreStack with Adapter

This CL removes the CoreStack class. Code that depended on a CoreStack instance
now depend on Adapter and hal::BluetoothInterface instead.

Bug: 23169364
Change-Id: Ide008cc7d3f9e74656f6bfa4df2dfee511e55b90

8 years agoservice: Introduce Adapter
Arman Uguray [Thu, 13 Aug 2015 23:09:35 +0000 (16:09 -0700)]
service: Introduce Adapter

This CL introduces the Adapter class, which is meant to replace the CoreStack
class. Adapter interfaces with hal::BluetoothInterface rather than calling into
libhardware directly.

Bug: 23169364
Change-Id: Id0a19277d55e83ec3bee3653d5d8795efbd5781b

8 years agoservice: Introduce hal::BluetoothInterface
Arman Uguray [Thu, 13 Aug 2015 22:49:47 +0000 (15:49 -0700)]
service: Introduce hal::BluetoothInterface

This CL introduces the bluetooth::hal::BluetoothInterface class. This is meant
to be an abstraction over the underlying bt_interface_t and bt_callbacks_t
interfaces from libhardware. BluetoothInterface is defined as an abstract
singleton that allows a fake/mock implementation to be injected for testing.

Bug: 23169364
Change-Id: Ia6f21f505dca08651b9a83e30287f638e8ec9a8e

8 years agotest_vendor_lib: Remove handlers
Dennis Cheng [Sun, 9 Aug 2015 00:07:50 +0000 (17:07 -0700)]
test_vendor_lib: Remove handlers

This upload removes the HciHandler and TestChannelHandler classes.
Removing these classes simplifies logic and also allows the
controller to do preprocessing before executing commands.

Bug: 21586676
Change-Id: I3f2711349dd2c86794538edc632b4f5f49b5169b

8 years agotest_vnd_lib: Discover devices
Dennis Cheng [Fri, 7 Aug 2015 23:58:13 +0000 (16:58 -0700)]
test_vnd_lib: Discover devices

This upload allows the user to send fake inquiry responses to the
controller at run-time via the test channel.

Bug: 21586676
Change-Id: Ieae24d496115f19716fcaaffa627a9c22ffade21

8 years agotest_vendor_lib: Add test channel command transport and handler
Dennis Cheng [Tue, 4 Aug 2015 23:51:59 +0000 (16:51 -0700)]
test_vendor_lib: Add test channel command transport and handler

This upload adds the transport and handler functionality for the test
channel. Test channel commands will be sent by the test channel
program and processed by library objects in a manner analogous to how
packets are received and handled from the HCI. The actual
implementation for the 4 test channel commands included here will be
in the next upload.

Bug: 21586676
Change-Id: I9354baedcbd6e48b8920a3ebf1afa69eb89834d9

8 years agotest_vendor_lib: Add test channel for run-time input
Dennis Cheng [Mon, 3 Aug 2015 01:25:17 +0000 (18:25 -0700)]
test_vendor_lib: Add test channel for run-time input

This change adds a test channel for receiving user-specified commands
and data at run-time. Specifically, the channel is intended to be used
for additional debugging capabilities and for fine-tuned control over
the test controller. Implementation-wise, the test channel is simply
another socket that the vendor manager watches on. The handling of test
channel input goes through the pipeline as normal HCI data after it is
received by the HciTransport.

A script for building and running the test vendor library and
(optionally) the test channel has been added in scripts/.

Bug: 21586676
Change-Id: I55bdeedbcd81effbe009aa62a19031637374a1e6

8 years agoMerge "Restore LOG_NDEBUG condition on verbose logging."
Ian Coolidge [Thu, 13 Aug 2015 19:50:05 +0000 (19:50 +0000)]
Merge "Restore LOG_NDEBUG condition on verbose logging."

8 years agoRestore LOG_NDEBUG condition on verbose logging.
Ian Coolidge [Thu, 13 Aug 2015 05:47:45 +0000 (22:47 -0700)]
Restore LOG_NDEBUG condition on verbose logging.

Change-Id: I86c5e03954c5f0a2dad88db5d6fbda3ec9e11e96

8 years agoservice: Allow manufacturer data to be set.
Ian Coolidge [Wed, 12 Aug 2015 21:53:15 +0000 (14:53 -0700)]
service: Allow manufacturer data to be set.

Plumbs IPC and stack code for manufacturer data
on advertisement or scan response.

Change-Id: I4b70506e35f51479bdf4073c31e4cb4f88fa2c98

8 years agoMerge "service: Fix permissions/properties argument order."
Ian Coolidge [Wed, 12 Aug 2015 22:33:47 +0000 (22:33 +0000)]
Merge "service: Fix permissions/properties argument order."

8 years agoservice: Fix permissions/properties argument order.
Ian Coolidge [Wed, 12 Aug 2015 22:19:51 +0000 (15:19 -0700)]
service: Fix permissions/properties argument order.

These were swapped, resulting in a bad configuration
of the control attribute.

Change-Id: I93dd69da1ace70a249d3a8d1856b173a52462a6c

8 years agoservice: Introduce a command-line client
Arman Uguray [Thu, 6 Aug 2015 04:22:39 +0000 (21:22 -0700)]
service: Introduce a command-line client

This CL introduces a CLI for the Bluetooth daemon. The code currently
doesn't do much, other than demonstrate how a native Binder client code
can be placed to the Bluetooth daemon. This objective here is to
extend this with a REPL and send commands to the daemon based on user
input.

Bug: 22743129
Change-Id: I41015e4b639e7099dd9f7086dbe86b01f3a61786

8 years agoservice: Add IPCHandlerBinder
Arman Uguray [Thu, 6 Aug 2015 04:19:02 +0000 (21:19 -0700)]
service: Add IPCHandlerBinder

This CL integrates Binder IPC into the daemon. This introduces
IPCHandlerBinder and BluetoothBinderServer which is the Binder server
proxy for IBluetooth. A new command-line switch is introduced to
optionally disable Binder on platforms that do not use it.

BluetoothBinderServer currently does not fully implement any of the IPC
calls and consists of stubs.

Bug: 22743677
Change-Id: I3e4ba7a3211898bab0c9c8061f4e4db3854711ed

8 years agoImprove adv_data transfer between contexts.
Ian Coolidge [Sat, 8 Aug 2015 03:36:13 +0000 (20:36 -0700)]
Improve adv_data transfer between contexts.

- Drops some unused members from btgatt_multi_adv_inst_cb.
- Flatten tBTA_BLE_ADV_DATA to only require one allocation.
- Copy all of tBTA_BLE_ADV_DATA contents to bt_workqueue_thread.

Bug: 23042223
Change-Id: I5f4d25d5cdd39731a2dfe64394928b7fb77c7c7c

8 years agoservice: Add IBluetooth interface definition
Arman Uguray [Thu, 6 Aug 2015 04:06:17 +0000 (21:06 -0700)]
service: Add IBluetooth interface definition

This CL adds the initial IBluetooth interface definition. Client and server
proxy classes have been added, which would normally be autogenerated in Android
Framework Land. This currently only includes the first five methods from
IBluetooth.aidl but will be extended in the future.

Bug: 22743677
Change-Id: I32be9801e91877c2961e24232cdfaecd80ee2368

8 years agobuild: fix missing include
Marie Janssen [Fri, 7 Aug 2015 06:29:29 +0000 (23:29 -0700)]
build: fix missing include

fatfingered this needed include out of this file

Change-Id: Id4c8d3223b25d0747a2739891e43652c475d399c

8 years agobuild: fixes for breakages on tilapia
Marie Janssen [Fri, 7 Aug 2015 01:30:45 +0000 (18:30 -0700)]
build: fixes for breakages on tilapia

Only include advertising when we can actually advertise on LE.

Change-Id: I380c67db4391650591b94611c4d522bf49fac750

8 years agobuild: LOG_TAG consistency, include order, build fixes
Marie Janssen [Wed, 8 Jul 2015 18:48:57 +0000 (11:48 -0700)]
build: LOG_TAG consistency, include order, build fixes

Fix the order of includes across a bunch of files, and declare LOG_TAG
at the top of every file in which it is used.

Consistently use bt_ as a LOG_TAG prefix.
Fix issues with LOG macro usage.
Remove unused includes and double-includes (when in related .h)

Add includes as necessary to compile cleanly (problems surfaced by
reordering includes)

Change-Id: Ic55520c8302b06bbc1942c10c448b20844669da6

8 years agotest_vendor_lib: Implement event loop with libbase
Dennis Cheng [Thu, 30 Jul 2015 17:06:40 +0000 (10:06 -0700)]
test_vendor_lib: Implement event loop with libbase

Adds event loop functionality by handling IO in the Watcher class,
HciTransport. Also fixes a bug where the vendor's file descriptor was
closed early and another where an object was mistakingly being passed
by value.

Bug: 21586676
Change-Id: I2ec30b68c0ede47bf1ad78ec13beee93d0f8ab9d

8 years agotest_vendor_lib: Use base::Thread
Dennis Cheng [Wed, 29 Jul 2015 18:47:55 +0000 (11:47 -0700)]
test_vendor_lib: Use base::Thread

This upload starts the replacement of the event loop in HciTransport
with libbase's MessageLoopForIO. A global instance of the new
VendorManager class now manages the trio of previously global objects
(i.e. HciTransport, HciHandler, and BREDRController). Note that the new
libbase event loop structure doesn't actually handle anything right now
and the functionality will come in a future change.

Bug: 21586676
Change-Id: Id74392e2a566e06445eb65269f0142265087d47d

8 years agoMerge "service: Clean up IPC shutdown and add unit tests"
Arman Uguray [Thu, 6 Aug 2015 03:54:44 +0000 (03:54 +0000)]
Merge "service: Clean up IPC shutdown and add unit tests"

8 years agotest_vendor_lib: Use libbase's CHECK/DCHECK
Dennis Cheng [Mon, 27 Jul 2015 22:55:15 +0000 (15:55 -0700)]
test_vendor_lib: Use libbase's CHECK/DCHECK

This upload pulls in libchrome to the test vendor library and uses CHECK
and DCHECK from base/logging.h.

Bug: 21586676
Change-Id: Ia88b4aa3728493d798e8d36076a351a00fad7c6b

8 years agotest_vendor_lib: Dummy inquiry result
Dennis Cheng [Thu, 23 Jul 2015 22:22:50 +0000 (15:22 -0700)]
test_vendor_lib: Dummy inquiry result

This upload mainly consists of stub command implementations to get
Bluetooth into the enabled state. The last command handled is the
inquiry command. Upon inquiry, the controller currently sends back a
dummy inquiry result for a fake device. This fake device appears under
the "Available devices" list in the UI.  Bluetooth is able to be toggled
off and on from the UI as well (i.e. it doesn't crash after switching to
on for a few seconds).

Bug: 21586676
Change-Id: Ifd42a6ab4b9338afd461d2ef4f809bdd62fcf79f

8 years agoservice: Clean up IPC shutdown and add unit tests
Arman Uguray [Wed, 5 Aug 2015 01:59:27 +0000 (18:59 -0700)]
service: Clean up IPC shutdown and add unit tests

This CL reworks the IPCHandlerUnix shutdown routine to be more robust
and adds a test suite for the basic thread creation and shutdown sanity.

Bug: 22532180
Change-Id: I22d119d6514f2ceb1460c0925b4e92b71ec87e06

8 years agoservice: Add Mock support for Daemon and CoreStack
Arman Uguray [Tue, 4 Aug 2015 19:56:56 +0000 (12:56 -0700)]
service: Add Mock support for Daemon and CoreStack

This patch turns the Daemon and CoreStack classes into abstract
interfaces. Mock and real implementations are implemented in special
subclasses and obtained via a factory method. Other test implementations
(e.g. stub) can be provided in the future.

Bug: 22532180
Change-Id: Ic3000518e5cef1c867dd803cd0bba6aab49dc596

8 years agoDrop obsolete libpower dependency.
Ian Coolidge [Fri, 31 Jul 2015 23:18:18 +0000 (16:18 -0700)]
Drop obsolete libpower dependency.

Wakelock activity is delegated to depending module.

Change-Id: I368bb9287f208fed3a674423e82fb2a8cb9e8268

8 years agoCompile libbtcore and libosi for host
Arman Uguray [Sat, 1 Aug 2015 02:14:39 +0000 (19:14 -0700)]
Compile libbtcore and libosi for host

The static libraries now also compile for a Linux host as libbtcore-host and
libosi-host. The unittests are compiled for the target against Bionic libc and
for the host against glibc.

Bug: 22884515
Change-Id: Iac1310a48cfd2ff43c356cb31165fd176d0e1d39

8 years agotest_vendor_lib: Use EPOLLOUT
Dennis Cheng [Tue, 16 Jun 2015 19:44:55 +0000 (12:44 -0700)]
test_vendor_lib: Use EPOLLOUT

HciTransport checks for write-readiness before sending any packets
back to the HCI. Packets are maintained on a queue and only written
when the EPOLLOUT flag is set in the epoll_event.

Bug: 21586676
Change-Id: Iebd9599286b62746e2be7e424c522058ae978bb1

8 years agoMerge "bluedroidtest: drop obsolete libhardware_legacy dependency."
Ian Coolidge [Mon, 3 Aug 2015 20:45:39 +0000 (20:45 +0000)]
Merge "bluedroidtest: drop obsolete libhardware_legacy dependency."

8 years agobluedroidtest: drop obsolete libhardware_legacy dependency.
Ian Coolidge [Fri, 31 Jul 2015 22:36:07 +0000 (15:36 -0700)]
bluedroidtest: drop obsolete libhardware_legacy dependency.

Change-Id: Iecd7839aa52debb14c6fc10da2d7f838f8d05327

8 years agotest_vendor_lib: Initial commit
Dennis Cheng [Tue, 16 Jun 2015 19:44:55 +0000 (12:44 -0700)]
test_vendor_lib: Initial commit

Basic vendor library for a test Bluetooth controller. Currently consists
of mostly stub functions and objects and can only handle the reset
command (by immediately responding with a command complete event).
Implemented through a global EventDispatcher object which waits for data
from the HCI and directly returns the appropriate response.

Eventually, the dispatcher will manage a fake controller object that
will provide callbacks to be executed whenever events are processed by
the dispatcher. Unit tests are still in progress and will be in the next
upload.

Bug: 21586676
Change-Id: I1c6746f8b0f1732b89a1da13facecdd49b5ac1b6

8 years agoProvide --android-ipc-socket-suffix.
Ian Coolidge [Fri, 31 Jul 2015 03:51:47 +0000 (20:51 -0700)]
Provide --android-ipc-socket-suffix.

This allows Android init to create a socket
for the service, and have consolidated access control.

Android init creates the socket and passes the FD through
an environment variable, so we must use OSI to decode it.

Bug: 22807533
Change-Id: I7ec0a14b8f3b44277ce99faad68623d6691f7863

8 years agoservice: Refactor IPC and singletons
Arman Uguray [Sat, 25 Jul 2015 02:14:42 +0000 (19:14 -0700)]
service: Refactor IPC and singletons

This CL makes the following major refactors to the system service code:

  1. A new global Daemon object is introduced, which manages the main event
  loop and all other subsystems of the Bluetooth daemon. This object is the only
  singleton class and initializes and owns everything else.

  2. Everything that was a singleton and/or was initialized directly in main.cpp
  is now a) no longer a singleton; b) now initialized and owned by the global
  Daemon instance.

  3. All of the Chromecast specific IPC code has been moved into the ipc/
  subdirectory. This directory is meant for everything that is IPC related,
  paving the way for enabling multiple IPC systems (domain-socket based, Binder
  based, etc) simultaneously in the future. Main changes to the Chromecast IPC
  code are:

      a. All files and classes have been renamed to reflect the
      UNIX-domain-socket-specific nature of the IPC mechanism.

      b. The code no longer hogs up the main thread while listening for
      connections. All of this logic has been moved to a dedicated thread with
      its own MessageLoopForIO, so that it can use the built-in mechanisms for
      polling on client sockets in the future.

Bug: 22532180
Change-Id: I42db06dba6cff3bc8f8101a1ea2b6787a69409fd

8 years agoservice: Add null initialization for new scan cb.
Ian Coolidge [Thu, 11 Jun 2015 03:34:43 +0000 (20:34 -0700)]
service: Add null initialization for new scan cb.

scan_parameter_setup_completed_cb was added to
btgatt_client_callbacks_t.

Change-Id: If0aa113df7cf3db742fa64244bbb7a849c877525

8 years agoMerge "build: Eliminate cutils/str_parms dependency from system/bt"
Miao-chen Chou [Tue, 28 Jul 2015 23:55:28 +0000 (23:55 +0000)]
Merge "build: Eliminate cutils/str_parms dependency from system/bt"

8 years agoAdd GN files for vendor_libs
Arman Uguray [Tue, 28 Jul 2015 01:32:05 +0000 (18:32 -0700)]
Add GN files for vendor_libs

Added BUILD.gn files for vendor_libs and vendor_libs/linux.

Bug: 21585592
Change-Id: I33f98421a94a4b4f530e48c94711775d776d02d7

8 years agobuild: Eliminate cutils/str_parms dependency from system/bt
Miao Chou [Wed, 8 Jul 2015 21:50:32 +0000 (14:50 -0700)]
build: Eliminate cutils/str_parms dependency from system/bt

Eliminate cutils/str_parmss dependency from system/bt by adding osi_str_parms:
 - Added hash_map_utils which implements partial functions of cutils/str_parms
   and uses osi/hash_map instead of cutils/hashmap.
 - Updated osi/Android.mk, osi/BUILD.gn and the includes in audio_a2dp to use
   osi_str_parms.
 - Added unittest for hash_map_utils.

Bug: 21957864
Change-Id: I8458d9e45df6cab2b71840d24d17b9d75de9842c

8 years agoOnly build bt_service_unittests for linux
Christopher Wiley [Mon, 27 Jul 2015 00:31:00 +0000 (17:31 -0700)]
Only build bt_service_unittests for linux

libchrome-host doesn't build on Mac, and while we get that sorted out,
let us not try and build this for Mac either.

Change-Id: I01d27391539d5c345d29a4ce949d0c3bcc931a7f

8 years agoAdd HCI user channel based bluedroid vendor adaptation
Samuel Ortiz [Fri, 24 Jul 2015 21:05:27 +0000 (14:05 -0700)]
Add HCI user channel based bluedroid vendor adaptation

This libbt vendor library creates and binds an HCI user channel
instead of talking to a serial port file descriptor. HCI frames
generated by the Android Bluetooth HAL are passed down as is to the
Linux kernel Bluetooth drivers through those sockets.
By pushing all the hardware dependencies down to the kernel, this
architecture supports all existing Linux Bluetooth drivers with
one single AOSP Bluetooth HAL implementation, Bluedroid.

Change-Id: I7197016b556e5d985843dd4f626db5d0f596f996

8 years agoservice: Introduce a global Settings object
Arman Uguray [Fri, 17 Jul 2015 01:12:13 +0000 (18:12 -0700)]
service: Introduce a global Settings object

Introduced a global Settings object that will store all runtime properties that
would be associated with a config file, Android system properties, etc. Added a
mechanism to parse command-line options which can be used to pass paths to
configuration files, file path for UNIX domain socket based IPC mechanism, and
any other property that is dynamic in nature. This will help us remove hardcoded
paths, strings, and other such values in the future.

Bug: 22532366
Change-Id: I8e790363ed31d44369f7991a8ea7132d1cace70b

8 years agogn-build: Add bluetooth-service target
Arman Uguray [Wed, 8 Jul 2015 22:47:39 +0000 (15:47 -0700)]
gn-build: Add bluetooth-service target

This patch makes the Bluetooth system service (service/) buildable using GN:

1. Added new BUILD.gn file for service/
2. Added conditional compilation for global config paths, with TODOs for
generalizing them later.
3. Added a shim for loading the Bluetooth library that calls hw_get_module on
Android and explicitly calls dlopen on OS_GENERIC.
4. Fixed compile warnings and errors.
5. Did some minor clean up in gatt_server.cpp for better readability.

Bug: 22124644
Change-Id: I3226537a3a5211a6762651a35707638df29956b0

9 years agoservice: Some fixes from end-to-end/user testing.
Ian Coolidge [Tue, 14 Jul 2015 01:22:46 +0000 (18:22 -0700)]
service: Some fixes from end-to-end/user testing.

* Send responses to ExecWrite requests.
* Provide valid data on write responses.
* Properly destruct Gatt::Server objects.
* Synchronize CoreStack 'enable' calls properly.

Change-Id: I4e9eed1979b10abccc7ae487e2c7d90d491e38d9

9 years agoservice: Remove local copies of base and modp_b64
Arman Uguray [Wed, 8 Jul 2015 22:33:05 +0000 (15:33 -0700)]
service: Remove local copies of base and modp_b64

Since libbase is now available on AOSP (under libchrome) Bluetooth code can
depend on it rather than maintain its own copy a subset of base sources (and
modp_b64 dependencies).

Dependent CL: http://r.android.com/158335

Bug: 22175181
Change-Id: I3a301e49353598633ad857ac4345d0361c273beb

9 years agogn-build: Add BUILD files for libchrome
Arman Uguray [Wed, 8 Jul 2015 00:00:09 +0000 (17:00 -0700)]
gn-build: Add BUILD files for libchrome

This CL adds GN build files for libchrome, which is the ChromeOS/Brillo library
for many C++ tools, include libbase. I added a new GN build target for "base"
under secondary sources with a GN build file for libchrome which currently lives
in platform/external/libchrome in AOSP.

To build, clone libchrome into third_party/libchrome and remove
third_party/libchrome/base/BUILD.gn. Also clone external/modp_b64 into
third_party/modp_b64. Eventually I will have scripts set up to do
this automatically.

This means that we can start developing against libbase while running GN builds
on Goobuntu but this would break the tree until libchrome is buildable within
the Android build system (http://r.android.com/158392). So Brillo/Android builds
will depend on libchrome using the conventional Android.mk means.

Bug: 22175181
Change-Id: I9a737aa785488e5bc0ca1adc087d1d5dfcdf3bea

9 years agobuild: Fix LOG_TAG define breakage, macro usage
Marie Janssen [Tue, 7 Jul 2015 23:47:20 +0000 (16:47 -0700)]
build: Fix LOG_TAG define breakage, macro usage

Fixes build breakages related to r.android.com/156982

Change-Id: Ib1143c41fe05a17c296226998afdb41a8cb6294a

9 years agobuild: Update osi log functions, use consistently
Marie Janssen [Fri, 26 Jun 2015 21:53:46 +0000 (14:53 -0700)]
build: Update osi log functions, use consistently

Update the LOG_* functions to take a tag argument which makes them more
consistent with the Android Log.*(TAG, s) common syntax and removes
some #define-dependency with osi/include/log.h.

Also update to never use Android log functions directly.

Also contains minor cleanup of some header includes.

Bug: 21569831
Change-Id: If07385cafbea062232ecdbc7c673f908d5ef8921

9 years agoAdd missing library dependency.
Evgenii Stepanov [Mon, 29 Jun 2015 20:59:44 +0000 (13:59 -0700)]
Add missing library dependency.

Fixes the following link error in SANITIZE_TARGET=address build for
hammerhead:
system/bt/audio_a2dp_hw/audio_a2dp_hw.c:208: error: undefined reference
to 'osi_socket_local_client_connect'

Bug: 21785137
Change-Id: Ie29a2772e7f1a4f697d895eb29b01d39d6f9c651

9 years agobuild: Eliminate cutils/sockets dependencies from system/bt
Miao Chou [Wed, 10 Jun 2015 00:39:46 +0000 (17:39 -0700)]
build: Eliminate cutils/sockets dependencies from system/bt

Eliminate cutils/sockets dependencies by pulling sources files from
core/libcutils into osi/.
   - Pulled source files from cutils/ into osi/ and modified GN files and
     Android.mk
   - Updated includes to use the headers in osi/ and removed unused/duplicated
     headers.
   - Renamed the functions of osi/sockets and updated wherever they are called
     to avoid usign symbols from cutils/sockets, since other cutils
     dependencies have not been eliminated yet.

Bug: 21667795
Change-Id: I3dd4371d585f120d97ac0433ab1f35edb820dbb9

9 years agoReduce CPU utilization from ~60% to ~10% on busy HCI reads.
Sharvil Nanavati [Sat, 13 Jun 2015 09:12:08 +0000 (02:12 -0700)]
Reduce CPU utilization from ~60% to ~10% on busy HCI reads.

This patch improves RFCOMM throughput and reduces CPU utilization.
Instead of using a counting semaphore to measure bytes and reading
one at a time from the eager reader's buffer, read in bulk based
on the incoming read request size.

Change-Id: I17046bfbc3ca49576a9c82b38911aeb84234881a

9 years agoMerge "Rename alarm->creation to alarm->creation_time for readability."
Sharvil Nanavati [Sun, 14 Jun 2015 23:02:08 +0000 (23:02 +0000)]
Merge "Rename alarm->creation to alarm->creation_time for readability."

9 years agoservice: Fix clang warnings in uuid_test.cpp
Arman Uguray [Sat, 13 Jun 2015 00:33:34 +0000 (17:33 -0700)]
service: Fix clang warnings in uuid_test.cpp

This CL fixes some clang compile warnings and errors and style issues in
service/uuid_test.cpp

Bug: none
Change-Id: I2d1ecf6e21fe4d6b1741f2a113ed5834518a29c6

9 years agoMerge "Add bthost, a simple BLE GATT server."
Ian Coolidge [Fri, 12 Jun 2015 22:50:56 +0000 (22:50 +0000)]
Merge "Add bthost, a simple BLE GATT server."

9 years agoAdd bthost, a simple BLE GATT server.
Ian Coolidge [Thu, 4 Jun 2015 00:20:30 +0000 (17:20 -0700)]
Add bthost, a simple BLE GATT server.

This is accessible via Unix socket.
It only has a couple of interesting features:

 * Built in support for large blob attributes (>512 octets)
 * Attribute caching (avoid frame-level IO for IPC clients)

Some string utilies are taken from modp_b64 and Chromium base.

Bug: 21076037
Change-Id: I6a29959159de76f8dd68d6bbaabe2100daabb6fa