OSDN Git Service
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.
June R. Tate-Gans [Thu, 19 Feb 2015 22:29:35 +0000 (14:29 -0800)]
Rewrite the SCO socket implementation to be more robust.
This code presents a socket interface for SCO connections. Like the
previous implementation, it does not support sending/receiving data
over the sockets; rather, it only provides a mechanism to establish
and tear down connections. It is assumed that all SCO data routing is
done out-of-band over PCM/I2S.
A SCO socket is represented internally by a file descriptor and SCO
handle. The file descriptor is one end of a socketpair (the other
end is sent to the Java process) and the SCO handle represents a
server (listening) or client (connecting) socket owned by the BTM
layer of the stack.
The most notable implementation detail is that, unlike typical
sockets, listening SCO sockets get "upgraded" when a connection is
established. In other words, a SCO handle for a listening socket
turns into a handle for a connected socket. To present a BSD-style
API to Java processes, we play a trick: when a listening socket gets
upgraded, we create a new listening SCO socket and reassociate the
SCO handle for the two sockets. The reassociation allows the Java
process to continue listening for new incoming SCO connections on
the same file descriptor.
Ian McKellar [Wed, 19 Feb 2014 23:33:32 +0000 (15:33 -0800)]
Move the disconnect_immediately logic so that it's only in effect for data sockets
Ian McKellar [Thu, 13 Feb 2014 22:11:06 +0000 (14:11 -0800)]
Clear connected & disconnect_immediately flags when intializing SCO sockets
Ian McKellar [Tue, 11 Feb 2014 00:52:26 +0000 (16:52 -0800)]
Fix a race condition where closing a SCO connection that was not yet fully open would silently fail.
Ian McKellar [Fri, 10 Jan 2014 02:28:30 +0000 (18:28 -0800)]
Clean up closed SCO listen sockets
Ian McKellar [Thu, 9 Jan 2014 22:51:49 +0000 (14:51 -0800)]
Fix locking in btsock_sco_signaled
Ian McKellar [Mon, 16 Dec 2013 20:26:19 +0000 (12:26 -0800)]
Refactor SCO code to allow closing
Ian McKellar [Fri, 8 Nov 2013 00:30:05 +0000 (16:30 -0800)]
SCO socket support in bluedroid
Chris Manton [Tue, 6 May 2014 17:35:42 +0000 (10:35 -0700)]
Enforce GKI API buffer usage
Also add another API GKI_queue_length(BUFFER_Q *)
Sharvil Nanavati [Fri, 22 Aug 2014 20:44:24 +0000 (13:44 -0700)]
Refactor RFCOMM code; also fixes a random-disconnect / performance bug.
The majority of this change is just style cleanup and eliminating
unnecessary code. There was a bug in the code where, if an entire
data buffer gets successfully written to the app, the rest of the
queue is not drained and the connection may get dropped. This bug
came about due to an early function exit from a switch statement
instead of breaking out of the switch.
Zach Johnson [Mon, 25 Aug 2014 23:44:56 +0000 (16:44 -0700)]
Implement memory allocation tracker
Provides an interface to track memory allocations, and assert
bad things like double frees don't happen.
Zach Johnson [Tue, 26 Aug 2014 01:21:12 +0000 (18:21 -0700)]
Add common hash functions so we don't have to redefine everywhere
Chris Manton [Tue, 26 Aug 2014 00:54:40 +0000 (17:54 -0700)]
Remove unnecessary layer of indirection
Chris Manton [Tue, 26 Aug 2014 16:41:13 +0000 (09:41 -0700)]
Add back hash_map_test to ositests
Somewhere along the way it got lost
Chris Manton [Wed, 13 Aug 2014 23:36:50 +0000 (16:36 -0700)]
Global counter API for bluedroid
Chris Manton [Wed, 13 Aug 2014 23:25:24 +0000 (16:25 -0700)]
Added encapulsated iterator to hashmap
Also added back hash_map_test which seemed
to have been dropped somewhere along the way.
Zach Johnson [Fri, 22 Aug 2014 04:00:43 +0000 (21:00 -0700)]
Modify eager reader to support multi-byte reads
Zach Johnson [Thu, 21 Aug 2014 06:25:36 +0000 (23:25 -0700)]
H4: -1 -> INVALID_FD; make uart_fd invalid on close
Zach Johnson [Thu, 21 Aug 2014 06:12:33 +0000 (23:12 -0700)]
Implement an HCI HAL for MCT
Unit tested. Needs verification on actual device (i.e. HDP profile).
Zach Johnson [Thu, 21 Aug 2014 01:09:06 +0000 (18:09 -0700)]
Scope the lock_count variable in the alarm test harness
Zach Johnson [Thu, 21 Aug 2014 00:51:26 +0000 (17:51 -0700)]
Unspecial-case the zero queue in the data dispatcher
Since hash map supports zero keys now this is no longer necessary.
Zach Johnson [Sat, 16 Aug 2014 00:00:17 +0000 (17:00 -0700)]
Refactor HCI layer
Refactor the HCI layer for better testability.
A future CL will add a HAL implementation for multi channel transport.
Since btsnoop and vendor are modified, it's not easy to incrementally introduce these changes.
Zach Johnson [Tue, 5 Aug 2014 03:51:06 +0000 (20:51 -0700)]
Add eager reader
Zach Johnson [Fri, 15 Aug 2014 23:50:32 +0000 (16:50 -0700)]
Add stub testing macros
Zach Johnson [Fri, 15 Aug 2014 23:49:15 +0000 (16:49 -0700)]
Refactor alarm tests to use a test harness
This improves the test writing experience for tests that rely on alarm code.
Zach Johnson [Fri, 15 Aug 2014 23:46:59 +0000 (16:46 -0700)]
Add some stream skip macros for code clarity
Zach Johnson [Fri, 15 Aug 2014 23:44:46 +0000 (16:44 -0700)]
Add peek + dequeue registratation to fixed queue
Zach Johnson [Fri, 15 Aug 2014 23:43:32 +0000 (16:43 -0700)]
Add a join function to thread
Zach Johnson [Fri, 15 Aug 2014 23:41:58 +0000 (16:41 -0700)]
Make hash map support NULL or 0 keys
Zach Johnson [Fri, 15 Aug 2014 23:39:33 +0000 (16:39 -0700)]
Add an allocator interface + default malloc allocator
Sharvil Nanavati [Wed, 13 Aug 2014 07:40:49 +0000 (00:40 -0700)]
Switch to an epoll-based reactor implementation.
epoll is a much nicer interface that very closely matches the
reactor interface. It's also thread-safe which makes it a more
suitable choice for bluedroid. As a result of this change,
reactor_register and reactor_unregister are both thread-safe without
introducing any synchronization in user-space.
Sharvil Nanavati [Sat, 9 Aug 2014 01:26:27 +0000 (18:26 -0700)]
Fix build after enabling assertions: variable reactor is no longer defined.
Sharvil Nanavati [Sat, 16 Aug 2014 01:39:16 +0000 (18:39 -0700)]
Add a function to check if a string represents a bdaddr
Sharvil Nanavati [Fri, 15 Aug 2014 23:14:26 +0000 (16:14 -0700)]
Const-correctness for str2bd.
Sharvil Nanavati [Fri, 15 Aug 2014 22:04:46 +0000 (15:04 -0700)]
Add a method to create a config object without loading from disk.
Sharvil Nanavati [Thu, 14 Aug 2014 19:36:39 +0000 (12:36 -0700)]
Add thread_is_self function
This is useful to compare the current thread against another one.
Sharvil Nanavati [Wed, 13 Aug 2014 08:14:49 +0000 (01:14 -0700)]
Add a tool to inject HCI commands into bluedroid.
This tool is very primitive in a number of ways. First, each new
HCI command needs to be carefully crafted. Second, it is entirely
stateless and operates in "fire-and-forget" mode. In other words,
there's no "read-modify-write" capability yet. That being said,
this tool will grow along with the infrastructure in bluedroid.
Chris Manton [Tue, 12 Aug 2014 21:11:38 +0000 (14:11 -0700)]
btpan thread signal function workaround
btsock does not provide a reliable teardown
procedure. Stale file descriptors may continue
to actively invoke signal callbacks from the
btsock thread. Extra logic to handle gracefully.
Chris Manton [Wed, 13 Aug 2014 18:00:17 +0000 (11:00 -0700)]
Extend add/subtract operations to atomics
Going to be used for counters
Chris Manton [Wed, 6 Aug 2014 16:36:17 +0000 (09:36 -0700)]
Add 64 bit atomic types
Chris Manton [Tue, 5 Aug 2014 19:16:48 +0000 (12:16 -0700)]
Increase thread queue size above default
The UART enqueues work requests in addition to
the actual work onto the rx_q. Many small byte
packets received by the UART cause many work requests
which may fill the work queue causing deadlock.
Chris Manton [Tue, 5 Aug 2014 18:10:12 +0000 (11:10 -0700)]
Add fixed queue size option to thread creation
Chris Manton [Tue, 5 Aug 2014 18:07:23 +0000 (11:07 -0700)]
Expose fixed queue capacity
Zach Johnson [Tue, 5 Aug 2014 03:49:49 +0000 (20:49 -0700)]
Fix reactor to use prepend, fix reactor tests
Zach Johnson [Tue, 5 Aug 2014 03:47:52 +0000 (20:47 -0700)]
Fix socket to use safe reactor registration
Zach Johnson [Tue, 29 Jul 2014 23:25:02 +0000 (16:25 -0700)]
Implement a data dispatcher.
This will be useful at layer boundaries.