OSDN Git Service
Zach Johnson [Fri, 19 Sep 2014 01:13:13 +0000 (18:13 -0700)]
Make stack manager functions not finish until action complete
It's a bit hacky at the moment, but this incremental update means the
stack manager booleans should be correct now and we can start removing
code that relies on the btif states.
Zach Johnson [Fri, 19 Sep 2014 00:16:41 +0000 (17:16 -0700)]
s/async_result/future/g and also improve the future API
Freeing now happens implicitly upon await, and immediate
futures will allow a uniform usage pattern for calls
that are async and calls that are not.
Zach Johnson [Fri, 19 Sep 2014 00:29:54 +0000 (17:29 -0700)]
Make semaphore_free idempotent
Passing NULL before would lead to a segfault.
Zach Johnson [Tue, 9 Sep 2014 23:31:14 +0000 (16:31 -0700)]
Move all stack init/start_up/shut_down/clean_up on a single known thread
Execution happens on the same thread, but the next step will be to
ensure each of the functions do not complete until start_up/shut_down/clean_up
complete. That will ensure each is mutually exclusive.
Zach Johnson [Wed, 10 Sep 2014 01:18:12 +0000 (18:18 -0700)]
async_result abstraction for signaling async return values
This will be useful when signaling success/fail during individual
asynchronous steps of stack start up and shut down.
Zach Johnson [Wed, 17 Sep 2014 22:20:04 +0000 (15:20 -0700)]
Fix packet fragmenter so it doesn't request acl sizes unless it's actually an ACL packet
During the startup process, commands are sent before the ACL sizes are fetched.
With the change that we now assert the acl sizes are fetched when you request
them from the controller, the assertion was being triggered during that phase.
When I was rebasing the waiting changes and also making the assertion change,
I should have been more careful to test this. mea culpa
Also simplifies that code path just a bit.
Zach Johnson [Tue, 9 Sep 2014 01:53:52 +0000 (18:53 -0700)]
Shuffle HCI layer internal functions into a more logical ordering
No actual code additions/deletions, other than additional forward declarations
Zach Johnson [Tue, 9 Sep 2014 01:31:39 +0000 (18:31 -0700)]
Refactor bte_main into more of a shell.
Moves all HCI initialization into hci_layer. Removes superfluous exposed
functionality on the HCI layer (like turning the chip on/off and logging)
Also reorganizes some of hci_layer to group related functions together.
Zach Johnson [Mon, 8 Sep 2014 22:20:22 +0000 (15:20 -0700)]
Add non-repeating timer wrapper for alarm
Refactor the hci layer to use it.
The timer wrapper allows you to specify the duration, etc at construction time
rather than at start time, making some usage patterns of alarm more convenient.
Zach Johnson [Mon, 8 Sep 2014 16:56:35 +0000 (09:56 -0700)]
HCI layer cleanup
- x_interface_t started to get annoyingly verbose, changed to x_t
- buffer_allocator is standalone now, no longer part of bte_main
- new controller_t to handle controller start up and hold controller state
- new hci_packet_factory to make packets, and hci_packet_parser
to read information out of packets.
Chris Manton [Wed, 3 Sep 2014 23:40:58 +0000 (16:40 -0700)]
Remove must-always-be-true BTU_BTA_INCLUDED
Change-Id: I7ddfb9d611b7f4a2787e0f4bec4a090cd9efc202
Sharvil Nanavati [Tue, 16 Sep 2014 07:11:35 +0000 (00:11 -0700)]
Add a check for a NULL root element from tinyxml2's XMLDocument.
This shouldn't really be necessary since a parsed document
should have at least a root element. In practice, however, tinyxml2
sometimes returns success on LoadFile() and NULL on RootElement().
Bug:
17504829
Zach Johnson [Tue, 16 Sep 2014 03:58:21 +0000 (20:58 -0700)]
Fix silly freeing of buffer.data instead of buffer
Also remove an unnecessary log message.
Zach Johnson [Wed, 3 Sep 2014 21:36:44 +0000 (14:36 -0700)]
Sink all HCI transmission management into the HCI layer
Begins the refactoring of the HCI related code in BTA, corrects some
hacks in the HCI layer (no more concept of internal commands, yay!),
and corrects the handling of multiple commands pending response in the
HCI layer.
This introduce a horrible hack external to the HCI layer to keep BTU HCI
handling of command complete/status events on the BTU task. That hack
will be removed when BTU moves to a reactor model and we have osi
threads to work with.
Chris Manton [Mon, 15 Sep 2014 16:46:58 +0000 (09:46 -0700)]
Demote timer hashmap entry failure log message
The procedures that use timers immediately cancel them upon startup
assuming they existed previously. The first time though the codepath
these traversalls cause the hashmap lookup failure.
Chris Manton [Mon, 8 Sep 2014 22:01:39 +0000 (15:01 -0700)]
btif task removal and reactor insertion
Sharvil Nanavati [Sun, 7 Sep 2014 09:48:19 +0000 (02:48 -0700)]
GKI task entry points should have a consistent signature.
Previously, GKI task entry points had inconsistent signatures. For
example, we had:
int btif_media_task(void *p)
void btif_task(UINT32 params)
void btu_task (UINT32 param)
The single argument was universally ignored and the caller always
set it to 0. This change consolidates all of that and defines the
entry point as having 0 arity and no return value.
Sharvil Nanavati [Sun, 7 Sep 2014 09:15:19 +0000 (02:15 -0700)]
Code cleanup in GKI layer.
* move buffer macros into .c from .h
* delete dead code (e.g. GKI_igetpoolbuf, pool_list variable)
* define task states as an enum and not a bitfield
* start renaming fields in GKI control block for future consolidation
Sharvil Nanavati [Sun, 7 Sep 2014 03:09:11 +0000 (20:09 -0700)]
Eliminate unnecessary macros GKI_API, EXPORT_API, and UDRV_API.
Sharvil Nanavati [Sun, 7 Sep 2014 02:49:20 +0000 (19:49 -0700)]
Delete GKI debug code.
GKI is slowly disappearing so much of that debug code isn't useful.
Sharvil Nanavati [Sun, 7 Sep 2014 02:42:22 +0000 (19:42 -0700)]
Eliminate GKI_os_malloc and GKI_os_free.
Sharvil Nanavati [Sun, 7 Sep 2014 01:55:43 +0000 (18:55 -0700)]
Eliminate unused variables bufpool{0..15} in GKI control block.
Sharvil Nanavati [Sun, 7 Sep 2014 01:42:48 +0000 (18:42 -0700)]
GKI_USE_DEFERED_ALLOC_BUF_POOLS is always defined. Flatten code paths.
Sharvil Nanavati [Sun, 7 Sep 2014 01:31:03 +0000 (18:31 -0700)]
Remove unused fields from GKI internal header.
Sharvil Nanavati [Sun, 7 Sep 2014 01:17:55 +0000 (18:17 -0700)]
Cleanup and remove unused variables in GKI's common OS control block.
Sharvil Nanavati [Sun, 7 Sep 2014 00:58:25 +0000 (17:58 -0700)]
Use arrays instead of variable names like Tmr0, Tmr1, ... in GKI.
Sharvil Nanavati [Sat, 6 Sep 2014 23:53:25 +0000 (16:53 -0700)]
Eliminate all attempts to set scheduling policy (all no-ops).
Sharvil Nanavati [Sat, 6 Sep 2014 23:46:46 +0000 (16:46 -0700)]
Eliminate GKI_run and GKI_stop. Neither had any effect.
GKI_run was called but didn't do anything: it would call
sched_setscheduler to increase the priority of the current process
but Android OS policy doesn't allow for that. And GKI_stop was never
called.
Sharvil Nanavati [Sat, 6 Sep 2014 23:40:18 +0000 (16:40 -0700)]
Eliminate always-on macro GKI_PTHREAD_JOINABLE.
Sharvil Nanavati [Sat, 6 Sep 2014 23:31:37 +0000 (16:31 -0700)]
Eliminate unused 'stack' concept for GKI tasks.
This change also fixes the type for task names: should be a const
string, not a mutable INT8*.
Sharvil Nanavati [Sat, 6 Sep 2014 23:16:19 +0000 (16:16 -0700)]
Move BTU task creation into stack/btu/btu_init.c.
Also fixed function naming where the BTE prefix was used
instead of BTU.
Chris Manton [Fri, 29 Aug 2014 16:12:06 +0000 (09:12 -0700)]
Replace timers and btu_task
Replace GKI timers with alarms.
Chris Manton [Wed, 27 Aug 2014 17:30:47 +0000 (10:30 -0700)]
Replace mailboxes with fixed queues.
Also refactored btu_task a bit.
Chris Manton [Thu, 28 Aug 2014 20:28:39 +0000 (13:28 -0700)]
Remove #define BTA_SYS_TIMER_PERIOD
Chris Manton [Wed, 3 Sep 2014 18:04:36 +0000 (11:04 -0700)]
Remove unused BTU timer/event APIs
btu_register_timer
btu_deregister_timer
btu_register_event_range
btu_deregister_event_range
Sharvil Nanavati [Wed, 3 Sep 2014 05:15:37 +0000 (22:15 -0700)]
Fix memory leak in L2CAP utils
A list was not freed (just its contents was).
Chris Manton [Tue, 5 Aug 2014 05:03:39 +0000 (22:03 -0700)]
Replace BUFFER_Q with list_t
Chris Manton [Tue, 5 Aug 2014 20:24:41 +0000 (13:24 -0700)]
Replace A2DP BUFFER_Q with a list
The functions acting upon this list are all executed from action
or event context; which would be the same thread.
Zach Johnson [Tue, 2 Sep 2014 21:54:49 +0000 (14:54 -0700)]
Remove unused function BTM_SecSetConnectFilterCallback
Zach Johnson [Tue, 16 Sep 2014 23:34:31 +0000 (16:34 -0700)]
Make SCO sockets request eSCO instead of SCO
This fixes some audio routing problems.
Sharvil Nanavati [Sat, 30 Aug 2014 01:26:23 +0000 (18:26 -0700)]
Fix memory leak in RFCOMM sockets where some lists were not being freed.
Chris Manton [Tue, 26 Aug 2014 17:35:35 +0000 (10:35 -0700)]
Remove unused #define BTU_CMD_CMPL_TOUT_DOUBLE_CHECK
Chris Manton [Tue, 26 Aug 2014 17:21:12 +0000 (10:21 -0700)]
Remove unused definitions using GKI events
Chris Manton [Wed, 7 May 2014 23:21:00 +0000 (16:21 -0700)]
Re-layout Android.mk for single shared library
Sharvil Nanavati [Sat, 23 Aug 2014 00:13:22 +0000 (17:13 -0700)]
Remove unncessary socket write to SCO socket.
I've verified that the BluetoothSocket is terminated in a timely manner
even without the write(2).
Sharvil Nanavati [Fri, 22 Aug 2014 01:17:19 +0000 (18:17 -0700)]
Update SCO sockets to use OSI.
This change brings us one step closer to eliminating btsock_thread.
Sharvil Nanavati [Thu, 21 Aug 2014 20:17:43 +0000 (13:17 -0700)]
Rewrite the btif_sock module.
The initialization flow now handles errors. The btif_sock module is
now solely responsible for managing the lifetime of the btsock_thread
it creates.
This change lays the foundation for switching all btif sockets to use
the OSI primitives.
Sharvil Nanavati [Thu, 28 Aug 2014 04:30:59 +0000 (21:30 -0700)]
Implement GKI timers in terms of alarm.c. This also fixes some alarm/wake lock bugs.
The OS callout implementation expects only a single outstanding alarm
and a single wake lock being taken. Since alarm.c uses both and GKI
timers use both, they were occasionally clobbering each other resulting
in unpredictable behaviour. By writing GKI timers in terms of alarm.c,
this change addresses those bugs.
Zach Johnson [Fri, 5 Sep 2014 06:05:55 +0000 (23:05 -0700)]
Remove unused "file system" concept & friends
Not actually ever used in the code, beyond importing some
header files and not calling any of their functions.
Zach Johnson [Fri, 5 Sep 2014 01:33:10 +0000 (18:33 -0700)]
Remove Windows related macros
Zach Johnson [Fri, 5 Sep 2014 00:57:58 +0000 (17:57 -0700)]
Eliminate call out/in indirection in bta_sys
Zach Johnson [Thu, 4 Sep 2014 20:45:06 +0000 (13:45 -0700)]
Remove FM/GPS/NFC related definitions
Zach Johnson [Thu, 4 Sep 2014 07:17:41 +0000 (00:17 -0700)]
Make the DURING test stub macro support checking multiple modes at a time
This allows test modes which have almost identical code paths to share
some test stub code instead of having to duplicate it for each of them.
Zach Johnson [Tue, 2 Sep 2014 22:41:26 +0000 (15:41 -0700)]
Remove _WIDCOMM defines and AMP VSE events from hcidefs.h
Zach Johnson [Tue, 2 Sep 2014 23:31:43 +0000 (16:31 -0700)]
Remove some more unused Broadcom specific macros
Zach Johnson [Tue, 2 Sep 2014 23:18:33 +0000 (16:18 -0700)]
Remove BTM_ReadBrcmFeatures because it shouldn't exist and isn't used
Also eliminates some related macros.
Zach Johnson [Tue, 2 Sep 2014 23:01:00 +0000 (16:01 -0700)]
Remove the company id defines (except broadcom for now)
Sharvil Nanavati [Wed, 3 Sep 2014 04:29:48 +0000 (21:29 -0700)]
Remove printf when attempting SDP requests.
Zach Johnson [Tue, 2 Sep 2014 20:54:18 +0000 (13:54 -0700)]
Implement BTM_InqDbRead in terms of btm_inq_db_find
duplicated_code--;
Zach Johnson [Tue, 2 Sep 2014 21:24:56 +0000 (14:24 -0700)]
Remove never used function BTM_GetNumLeLinks
verified unused, even in the latest android code
Zach Johnson [Sat, 30 Aug 2014 00:08:44 +0000 (17:08 -0700)]
Modify allocation tracking to include and verify the allocation source
This will help detect and prevent allocator alloc/free mismatch.
Zach Johnson [Thu, 28 Aug 2014 20:30:17 +0000 (13:30 -0700)]
Add memory canaries and turn them on for unit tests
This will allow us to verify with resonable certainty
that the code is not writing past the end or beginning
of the memory allocation that it was given.
With canaries on, the canaried pointers returned by the
osi alloc functions are no longer passable directly to
free, since they must be offset to get the real allocation
pointers. This means all legacy code must be converted
over to the osi alloc functions before turning canaries
on in the wider codebase.
Zach Johnson [Tue, 2 Sep 2014 18:49:55 +0000 (11:49 -0700)]
Remove unused function BTM_SetInquiryFilterCallback
Zach Johnson [Tue, 2 Sep 2014 18:42:09 +0000 (11:42 -0700)]
Remove unused function BTM_InquiryRegisterForChanges and associated code
Sharvil Nanavati [Tue, 2 Sep 2014 17:53:46 +0000 (10:53 -0700)]
Add a VALGRIND #define to heap-allocate all GKI buffers.
This change allows us to run Valgrind on bluedroid to find memory
leaks. It has already been used to track down multiple memory leaks
which weren't trackable with the existing GKI buffer implementation.
Sharvil Nanavati [Sat, 30 Aug 2014 01:28:19 +0000 (18:28 -0700)]
Fix memory leak in BTU where enequeued buffers were never freed on shutdown.
This resulted in the stack running out of GKI buffers on repeated
enable/disable cycles.
Zach Johnson [Sat, 30 Aug 2014 01:20:48 +0000 (18:20 -0700)]
Rename init/cleanup to start_up/shut_down in the HCI layer
Sharvil Nanavati [Fri, 29 Aug 2014 23:30:25 +0000 (16:30 -0700)]
Don't pass in uninitialized memory to epoll_ctl. Make valgrind happy.
Zach Johnson [Fri, 29 Aug 2014 23:03:20 +0000 (16:03 -0700)]
Remove incomplete FTP #defines and implementation
Zach Johnson [Fri, 29 Aug 2014 21:57:53 +0000 (14:57 -0700)]
Remove unreferenced BTRC_DISP macro
Zach Johnson [Fri, 29 Aug 2014 21:54:43 +0000 (14:54 -0700)]
Remove unreferenced BTE macros
Sharvil Nanavati [Fri, 29 Aug 2014 22:39:56 +0000 (15:39 -0700)]
Fix heap memory leak by placing the BT device struct in static storage
Zach Johnson [Fri, 29 Aug 2014 21:05:36 +0000 (14:05 -0700)]
Removed always false macro BTM_INQ_GET_REMOTE_NAME
Zach Johnson [Fri, 29 Aug 2014 20:57:21 +0000 (13:57 -0700)]
Remove some never used BTM macros
Zach Johnson [Fri, 29 Aug 2014 20:23:07 +0000 (13:23 -0700)]
Remove always false macro L2CAP_HOST_FLOW_CTRL
Zach Johnson [Fri, 29 Aug 2014 18:11:22 +0000 (11:11 -0700)]
Remove unused #define's BTM_IS_CONNECTABLE and BTM_IS_DISCOVERABLE
Zach Johnson [Fri, 29 Aug 2014 05:09:14 +0000 (22:09 -0700)]
Eliminate unused #define BTM_INTERNAL_BB
Sharvil Nanavati [Fri, 29 Aug 2014 08:35:03 +0000 (01:35 -0700)]
Use osi_free with osi_calloc in HCI layer to avoid corruption
There was a mismatch where the free function was GKI_free for a
pointer allocated with osi_calloc. This resulted in GKI exceptions
being thrown if the adapter goes through enable -> disable -> enable
-> disable without terminating the process.
Zach Johnson [Fri, 29 Aug 2014 04:42:39 +0000 (21:42 -0700)]
Remove unused auto-reset code path, with associated macros.
Zach Johnson [Fri, 29 Aug 2014 04:25:04 +0000 (21:25 -0700)]
Remove unused #define BTM_AFTER_RESET_TIMEOUT
Zach Johnson [Fri, 29 Aug 2014 00:05:08 +0000 (17:05 -0700)]
Remove indirection in the controller reset sequence
Sharvil Nanavati [Thu, 28 Aug 2014 04:56:41 +0000 (21:56 -0700)]
Fix issue where last character of device name is missing
The device name stored on disk is correct but has a missing character
at the end when read off of disk. This happened because the returned
|length| parameter to |btif_config_get_str| is in number of *bytes*,
not in number of characters (i.e. must add one for NULL character).
Sharvil Nanavati [Thu, 28 Aug 2014 02:03:03 +0000 (19:03 -0700)]
Add a UUID module to btcore for operating on UUIDs.
This change only adds a single function, uuid_is_empty, but I expect
other UUID-related functions to find themselves here.
Sharvil Nanavati [Wed, 20 Aug 2014 16:39:25 +0000 (09:39 -0700)]
Introduce btcore, a low-level library to manipulate Bluetooth data types.
This change adds a single module to btcore: bdaddr. The bdaddr module
is reponsible for manipulating and working with Bluetooth addresses.
Zach Johnson [Thu, 21 Aug 2014 00:09:25 +0000 (17:09 -0700)]
Fix digital transposition in saving binary config data
Was causing link keys to be saved/read incorrectly, causing reconnect on reboot to fail.
Sharvil Nanavati [Tue, 19 Aug 2014 16:50:18 +0000 (09:50 -0700)]
Eliminate unused arguments to btif_config and clarify variable names
Sharvil Nanavati [Sat, 16 Aug 2014 01:58:22 +0000 (18:58 -0700)]
Switch over from an XML based file format to .INI-style conf files
This change moves us to using a single file format for all configuration
throughout bluedroid. I've provided a transcoder that converts the
previous config file to the new format so settings will be preserved.
In a future revision of bluedroid, we should remove the transcoder and
drop our dependency on tinyxml2.
Sharvil Nanavati [Thu, 28 Aug 2014 02:05:40 +0000 (19:05 -0700)]
Add a method to check for available bytes on a socket
The available bytes function shouldn't normally be required (and
if it is, the code design is probably bad and should be rethought) but
is introduced as a stop-gap until we can redesign the BTA code that
expects a priori knowledge of the number of bytes that can be read from
the socket.
This change also relaxes the requirement that on socket_register that
at least one of read_cb or write_cb must be specified.
Zach Johnson [Thu, 28 Aug 2014 03:26:00 +0000 (20:26 -0700)]
Make osi_strdup report allocation size correctly
Zach Johnson [Wed, 27 Aug 2014 23:30:29 +0000 (16:30 -0700)]
Move HCI over to the osi allocators, and fix the tests accordingly
Zach Johnson [Wed, 27 Aug 2014 03:16:03 +0000 (20:16 -0700)]
Finish allocation tracking for the rest of osi
And found a memory leak in config, so it's doing its job! :)
Chris Manton [Wed, 27 Aug 2014 04:20:44 +0000 (21:20 -0700)]
Remove unused #define RPC_INCLUDED
Zach Johnson [Wed, 27 Aug 2014 22:45:35 +0000 (15:45 -0700)]
Fix timer allocations in the test harness, so bdtest runs again
Steve Gu [Wed, 27 Aug 2014 17:44:52 +0000 (10:44 -0700)]
Correct comments and some redundant statements.
Chris Manton [Tue, 26 Aug 2014 23:11:45 +0000 (16:11 -0700)]
Remove must-always-be-on #define HCISU_H4_INCLUDED
Zach Johnson [Wed, 27 Aug 2014 03:15:19 +0000 (20:15 -0700)]
Add strdup to tracked allocations
Zach Johnson [Wed, 27 Aug 2014 00:21:44 +0000 (17:21 -0700)]
Add internal constructors to hash map and list
This makes allocation tracker safe and ensures the hash map
and associated lists for the allocation tracker don't show
up in the allocation tracker's stats.
Zach Johnson [Tue, 26 Aug 2014 19:23:09 +0000 (12:23 -0700)]
Clean up scattered naive hash functions
Zach Johnson [Tue, 26 Aug 2014 06:22:24 +0000 (23:22 -0700)]
Move some of osi to use the allocation interfaces
Also changes some tests to ensure all memory freed.
Sharvil Nanavati [Fri, 22 Aug 2014 01:13:46 +0000 (18:13 -0700)]
Add a method to pass file descriptors and one to create a socket from an fd.