History log of /system/bt/bta/ag/bta_ag_main.cc
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
90174f35148c69502beec0325c93bce931d6f8f6 20-May-2018 Jack He <siyuanh@google.com> HFP: Return SDP status to HFP layer

* Fix an error introduced in change Ic0b4498dd623d0ea31b4513d6b7861cae390bc72
so that SDP status is sent up to the HFP BTA layer
* With SDP status correctly passed up, HFP BTA layer can correctly
determine when to continue SDP search for HSP
* When open connection to HFP or HSP devices, use a control block's
registered services instead of passing in opening services every time
from BTIF layer
* Do not use a control block that are in CONNECTING or DISCONNECTING
state
* Add a crash in btif_hf.cc:connect_int() to gurantee that no control
block is in connecting or disconnecting state when connect_int is
called as it should be guranteed by the btif queue configuration

Bug: 74234576
Test: connect to headset, make calls and hangup
Change-Id: I5e2bce8c2f0f51bd3fd3e85e82827c5fb5e92887
(cherry picked from commit 4bf260f2b71c15f091290b16f6c7948b21fa7c49)
/system/bt/bta/ag/bta_ag_main.cc
2dd0bdf068e329bf2aaf8d131730270de083cbe3 01-May-2018 Jack He <siyuanh@google.com> HFP: Workaround for car kits that do not send AT+BAC command

* Some misbehaving HF devices (e.g. some Hyundai car kits) indicate
their support on Wide Band Speech and Codec Negotiation, but do not
send the required AT+BAC command during Service Level Connection
setup. However, such car kits still expect Fluoride to do codec
negotiation during SCO setup.
* This CL adds a workaround so that when HF indicates support for WBS
and codec negotiation, Fluoride will attempt codec negotiation even
though AT+BAC is never received.
* Store the SDP feature locally. If WBS is supported and no AT+BAC is
received, use the SDP features to set the suported codec.

Bug: 77883405
Test: make, connect SCO to and from Hyundai car kits
Change-Id: I2be6007022183cac5b9006f37089a587b4a67372
(cherry picked from commit e42cf153f8cc9f2b80153aa3eb7c0be04f3c326f)
/system/bt/bta/ag/bta_ag_main.cc
b690c22637e522acdd8aebcd18699abc5dd0425c 23-Apr-2018 Jack He <siyuanh@google.com> HFP: Fix connection colision handling

* When there is a connection collison, and remote device is trying to
connect to HFP server channel while we try to connect to remote's
server channel as a client. If the remote device succssfully connect
to us, we should drop our connection request to remote device and
accept remote device's connection request. As result, we will observe
1. Our connection request fails, this propagate up to Java layer and
also clean up any states in these layers
2. Remote connection request succeeds, this propagate up to Java layer
as well as a new incoming connection
* Added BTA_AG_COLLISION_EVT to formally handle AG collision in state
machine
* Modified bta_ag_resume_open to re-send BTA_AG_API_OPEN_EVT instead of
modifying the state machine state directly. State machine states
should only be modified by state machine handler
* Ignore RFCOMM open event if PORT_CheckConnection fails
* Added StackRfcommTest.TestConnectionCollision to reproduce this
scenario with 100% certainty
* Add static checks to HFP BTA state machine to make sure action and
event indices match enum sizes

Bug: 77224743
Test: connect to multiple remote devices with HFP, MAP and PBAP
StackRfcommTest.TestConnectionCollision
btestplans/details/158641/3975
Change-Id: Ib3652784b123abe195e7bd30421ef5f4345b1d4d
Merged-In: Ib3652784b123abe195e7bd30421ef5f4345b1d4d
(cherry picked from commit 88cc85a086bf90e1e669fd689276c6e658286af2)
/system/bt/bta/ag/bta_ag_main.cc
3ebc3c5ac0f288be3a8e1ee8b0e56a9ece740200 28-Mar-2018 Jack He <siyuanh@google.com> RFCOMM: Add more logging on failure cases

* Log every instance of RFCOMM unexpected disconnection
* Log every time when RFCOMM channel (DLCI) is changed
* Refactor some RFCOMM code to be more readable and easier for logging
* Remove excessive logging in power manager
* Assign HSP default version more appropriate location
* Replace some usage of NULL with nullptr

Bug: 77224743
Test: make, no functional changes
Change-Id: I5e62dd6d338f7e92a8b8d39c1fe155b71396034c
(cherry picked from commit 4e01c6d5f2d03fb5c98567b573a9dd32d28a4106)
/system/bt/bta/ag/bta_ag_main.cc
29cddf92a53abcf5c5e1946ffeccda1c4396e8a5 21-Oct-2017 Jack He <siyuanh@google.com> HFP: Save discovered HFP version to config file

* Store discovered HFP version to btif config file so that a
reconnection session knows the HFP version before SDP
* Check stored HFP version when RFCOMM channel is open before any AT
command is processed
* Set peer HFP version to 0 on control block allocation

Bug: 67938255
Test: Connect with HFP 1.7 headsets
Change-Id: I43e7aa04dee17ea7ba9e7d3992ec0860c11d23bc
(cherry picked from commit 79b4e0710b23f9bd96c0fc71d68e6649188b1bde)
/system/bt/bta/ag/bta_ag_main.cc
ca7d6f5912606a6306287fea372b660af117efc8 10-Jan-2018 Jack He <siyuanh@google.com> HFP: Add support for Multi-HFP (2/2)

* Allocate at most 6 control blocks for btif_hf and bta_ag,
this limit is defined by BTA_AG_MAX_NUM_CLIENTS
* Allow at most 6 RFCOMM connections to be managed by bta_ag
* Allow at most 6 SDP callbacks for each bta_ag
* Reject incoming SCO connection and do not start outgoing SCO
connection if not coming from the current active device
* Reject incoming AT+BCC request if the remote device is not an active
device
* Support only one device by default
* Fixed a bug in BTM_CreateSco where power mode was checked for old
device and new power mode is set for new device and caused BTM SCO
state machine to stuck in SCO_ST_PEND_UNPARK mode
* Added logs at failure conditions to be more verbose about connection
errors and removed logs from non-error conditions to reduce verbosity
in normal conditions

Bug: 68952570
Test: runtest -j40 bluetooth, native unit tests, HFP regression for 1
device, simple tests for multiple devices
Change-Id: I97d20f6a126d77a4ef3a0cd1706b48130b4a6aae
/system/bt/bta/ag/bta_ag_main.cc
8b699d1076885c6525153d927a6edae2fa1ba6f0 06-Jan-2018 Jack He <siyuanh@google.com> HFP: Use base::Bind instead of messages for bta_ag_api functions

Summary:
* Do not use bta_sys_sendmsg(BT_HDR) in bta/ag, use base::Bind instead
* Do not use BT_HDR in bta/ag
* Do not do memcpy during thread switch in bta/ag, instead, we use the
default copy constructor

Details:
* Currently, bta_ag_api functions use explicit messages to cross from
jni to bta thread. This adds unnecessary indirections that make it
hard to figure out which methods in bta actually get called
* Instead, base::Bind can bind to methods in bta directly without
putting parameters in an explicit struct. This greatly simplify our
code without breaking the current threading model
* With base:Bind, we no longer rely on bta_sys_sendmsg(BT_HDR) to send
event across threads. We can therefore get rid of BT_HDR in all
sub-types of tBTA_AG_DATA. Instead of using BT_HDR->layer_specific
flag to pass down handle IDs, we pass down handle ID directly,
resulting in less confusion on the actual meaning of data

Bug: 70538124
Test: runtest bluetooth, native unit tests
Change-Id: Ic0b4498dd623d0ea31b4513d6b7861cae390bc72
/system/bt/bta/ag/bta_ag_main.cc
a01bb1dd3fd8c0ac8a73d7d335af50855ee46c91 07-Jan-2018 Jack He <siyuanh@google.com> HFP: Print human readable event and state name by default

* Debug log in HFP's BTA code is gated by BTA_AG_SCO_DEBUG and
BTA_AG_DEBUG flags. These are non-standard flags that must be
configured at compile time. Instead, debug logs should be gated by
flags in bt_stack.conf only
* This change enables human readable debug output by default by removing
these flags, and refactor the string conversion functions

Bug: 70538124
Test: runtest bluetooth, native unit tests
Change-Id: I99fd00016020a9c6b14928906f07bca4f0ea482d
/system/bt/bta/ag/bta_ag_main.cc
0681fefcf5f5c9d7471986b7c9f20f69e94d4fb1 10-Jan-2018 Jack He <siyuanh@google.com> HFP: Remove used BTA call-in events and methods

* Since SCO over HCI is temporarily unsupported on the stack, SCO data
call-in methods are no longer used by the stack and thus should be
removed. For example, bta_ag_ci_sco_data() and BTA_AG_CI_SCO_DATA_EVT.
* Since raw RFCOMM access is disabled, various RFCOMM data call-in
methods are no longer used by the stack and thus should be removed.
For example, bta_ag_ci_rx_data() and BTA_AG_CI_RX_WRITE_EVT

Bug: 70538124
Test: runtest bluetooth, native unit test
Change-Id: Iacd60042e97b1be5f800319723836285eb68b2b9
/system/bt/bta/ag/bta_ag_main.cc
3f10b14ea5631a894bc2f1db31d5dc020922c28e 07-Jan-2018 Jack He <siyuanh@google.com> HFP: Remove AG RFCOMM data pass through mode

* In BTA_AG_PASS_THROUGH mode defined in bta_ag_api.h, RFCOMM data is
passed directly to the upper layer. In this case, AT commands are
parsed in the user application instead of being parsed within the fluoride
stack.
* However, this mode is never used on the stack as btif_hf.cc only call
BTA_AgEnable() with BTA_AG_PARSE parameter value. Currently, AT
commands are only parsed within the fluoride stack
* This change removes this feature since the pass through mode is
never used, tested, nor maintained

Bug: 70538124
Test: runtest bluetooth, native unit tests, no functional change
Change-Id: I921d5ee950e4abadea8433c5b2d5882a99923cb0
/system/bt/bta/ag/bta_ag_main.cc
c4829e81dfe3cbab3af677b6f806ca50b528711e 07-Jan-2018 Jack He <siyuanh@google.com> HFP: Remove redundant AG data callout code

* Methods in bta_ag_co.cc are almost empty and should be removed
* Only bta_ag_co_init() calls BTM_WriteVoiceSettings(). This can be
called directly from BTA. The callout wrapper is unnecessary

Bug: 70538124
Test: runtest bluetooth, native unit tests, no functional change
Change-Id: I20ab1c033d18f3405e7efb8446b44153b24f3cb0
/system/bt/bta/ag/bta_ag_main.cc
97611857726dbfb2a4308d7127e7649b7fff732c 07-Dec-2017 Jack He <siyuanh@google.com> HFP: Add APIs for set and get active device (3/3)

* Add set active device APIs to set active device from Java layer
* Set active device to the first connected device if no one set it
before
* Clear active device on RFCOMM disconnection if active device is the
one getting disconnected
* Currently, the active device value is not used in any functional code

Bug: 68951996
Test: runtest -j40 bluetooth
Change-Id: Id0c00e89178b0f963ed8642e72c7010160dd1d68
/system/bt/bta/ag/bta_ag_main.cc
6545d3f346764d796db65f403335f0d2e83ea35a 12-Dec-2017 Jack He <siyuanh@google.com> HFP: Fix static check errors

* In bta/ag and btif/btif_hf.cc
* Simplify boolean values
* Use nullptr intead of NULL
* Use C++ style include headers instead of C style ones
* Remove unused struct definitions
* Remove unused code from bta_ag_ci.h/cc
* Use range based for-loop when it can be converted automatically
* Use C++ style zero-initialization instead of memset so that non-POD
members of structs can be initialized properly
* Use "" to initliaze char array since the rest of the array will be
zero padded if the array is assigned to a shorter string than its
length

Bug: 68340193
Test: make, connect to HFP enabled device
Change-Id: I25c1e48ca1cb40629b9b60243ec462f498d8fc24
/system/bt/bta/ag/bta_ag_main.cc
ca42b5faeefaaa3cf605bf4c57636612abbb7482 04-Dec-2017 Vishwath Mohan <vishwath@google.com> Fix callback type mismatches in Bluetooth

This CL fixes some mismatches between defined callback signatures and
the signatures of the functions that are actually passed in as that
type.

Bug: 67507323
Test: lunch walleye_cfi && m -j50

Change-Id: Ia5c22ac614c34cc8bd8a370861d988bb9f8034a6
/system/bt/bta/ag/bta_ag_main.cc
5b790feeeb211c42bf78ca3ae9c26aa30e516765 18-Sep-2017 Jakub Pawlowski <jpawlowski@google.com> Make copyright headers consistent with Google template; remove "(C)"

Test: Comment changes only; still compiles...
Change-Id: Id699a8170112f06e4a2c9f2e0f0834d1817ace4e
/system/bt/bta/ag/bta_ag_main.cc
fbe265bd6274fb0ea004d77600723643fab64708 02-Oct-2017 Myles Watson <mylesgw@google.com> bta: Remove unsafe casts in BTA_AG

Test: build
Change-Id: I19659173498972f838ccc59dcac00e0f26417340
/system/bt/bta/ag/bta_ag_main.cc
be8bbd7a83ec8bc900fac58a03010fbcb74956c9 08-Sep-2017 Jakub Pawlowski <jpawlowski@google.com> Fix alarms being posted on wrong thread

Alarms from btu_bta_alarm_queue and btu_generic_alarm_queue should be
processed on the main MessageLoop thread.
Replaced obsoleted alarm_set_on_queue() alarm API with the new
alarm_set_on_mloop() API

Test: manual
Bug: 65078753
Change-Id: I54b472b39b44a6c541dbdcdad7414056d0dd4163
/system/bt/bta/ag/bta_ag_main.cc
a484a888196ddf8bcbf1ad3226d6451bc735a94b 25-Jun-2017 Jakub Pawlowski <jpawlowski@google.com> Rename bt_bdaddr_t into RawAddress (3/3)

Test: compilation test
Change-Id: I4571721a0c6165a66450ee157a53d8d15bfc45d0
/system/bt/bta/ag/bta_ag_main.cc
c752e135d66f80c0b2efc35292ab8ddfd8227d61 16-Jun-2017 Jakub Pawlowski <jpawlowski@google.com> Replace BT_ADDR with bd_addr_t in bta_sys related code

Test: compilation test
Change-Id: Idab6e9c03621c5540b4a3a7fa537dff71a25ce3f
/system/bt/bta/ag/bta_ag_main.cc
c2276b06572ab6fc1f900fbb1f41087e77d47e2a 10-Jun-2017 Jakub Pawlowski <jpawlowski@google.com> Use bt_bdaddr_t instead of BD_ADDR

Test: compilation test, sl4a GattReadTest
Change-Id: I8d1bd6914aec55bb53495b1d0d5e3d37b86865e6
/system/bt/bta/ag/bta_ag_main.cc
d3ae18b3b3c65e38bbce5e3bf2882f4e050077dd 08-Jun-2017 Jack He <siyuanh@google.com> eSCO: Limit number of retries after mSBC connection failure

* When peer device supports mSBC and codec negotiation, Fluoride stack
will try to do the following when establishing a eSCO/SCO connection:
1) Negotiate to mSBC by sending +BCS:2
2) Try establishing eSCO/SCO connection using mSBC T2 settings
3) If that failed, downgrade to mSBC T1 settings and retry
4) If that failed, re-negotiate codec to CVSD, by sending +BCS:1
5) Retry using CVSD S4 (HFP 1.7 and above) or S3 settings
6) If this failed stop trying and report failure to upper stack
* Retry is achieved by:
* Retry is only possible when inuse_codec = BTA_AG_CODEC_MSBC
* Set codec_msbc_settings to BTA_AG_SCO_MSBC_SETTINGS_T1 when T2
failed to connect in step 3 above
* Set codec_fallback to true when T1 failed so that CVSD is used
in step 4 above
* Retry stop is achieved by:
* Set inuse_codec = BTA_AG_CODEC_CVSD
* Set codec_msbc_settings back to BTA_AG_SCO_MSBC_SETTINGS_T2
* Set codec_fallback to false and codec_updated to true so that
the stack is ready for the next application triggerred SCO
connection attempt
* Removed retry_with_sco_only as both Setup Synchronous Connection
Command (0x0028) and Enhanced Setup Synchronous Connection Command
(0x003D) fall back to SCO connection if eSCO is not supported.
See page 858/2772 and 895/2772 of BT4.2 specification document
* Besides both code paths are the same for retry_with_sco_only after
eSCO changes went in

Bug: 62426841
Test: make, HFP regression, testplans/91406
Change-Id: I205311c55e8763c48b6eb43c27f242927384036e
/system/bt/bta/ag/bta_ag_main.cc
acdc11cae50e335175cfb16935dec160b0327966 19-Apr-2017 Zach Johnson <zachoverflow@google.com> Allow blocking AG SCO connects by policy

Needed for devices that support both HFP AG and HFP HF.

btsnoop logs show the sequence of events leading to failure:
(corroborated by bt logcat)

1. ACL connection with remote phone established on handle 0x01
2. ACL connection with remote headset established on handle 0x02
3. Incoming call in HF role from phone
4. Phone call locally published to telecom
5. Answer incoming call
6. SCO connection established with phone in HF role
7. AG role with headset picks up on call state change to answered
via BTA_AG_IN_CALL_CONN_RES
8. Inside handler for BTA_AG_IN_CALL_CONN_RES, bta_ag_sco_open called
to establish the SCO connection in the AG role with the headset,
stomping on the previous (wanted) SCO connection with the phone.

Fix is to publish the SCO audio route policy to fluoride, so we can
stop 8 from happening.

Bug: 32958838
Test: manual:
received incoming call in HF role, audio worked both ways;
recieved incoming MT call, headset audio in AG role worked both ways
Change-Id: I12961598e8200bd1d5adb46ee8ec3a802114b80a
/system/bt/bta/ag/bta_ag_main.cc
400ac497f45181d3c64f6a19687992de9b69b094 08-May-2017 Jack He <siyuanh@google.com> eSCO: Additional fix to get eSCO working for HFP and HSP (3/5)

* Removed vendor specific call after codec negotiation and before eSCO
command is sent to Bluetooth chip
* Removed vendor specific call after a SCO connection is requested by
the peer
* Removed vendor specific save audio state methods

Bug: 19540029
Test: make, HFP PTS test, testplans/86884, testplans/87103
Change-Id: I899405a8eaa2f38ee0de04949c5288f9eefa74df
/system/bt/bta/ag/bta_ag_main.cc
3e634d6c1e83f053005c9abdbd89e662ad81c4d4 10-Feb-2017 Myles Watson <mylesgw@google.com> eSCO: Remove BTM_WBS_INCLUDED from the stack (2/5)

All of our platforms support WBS.

Bug: 19540029
Test: make, HFP PTS test, testplans/86884, testplans/87103
Change-Id: I384d49f73935ebb35b17132e71c85174797c435e
/system/bt/bta/ag/bta_ag_main.cc
57f6508cf7b22788fa2e7a739cec241b785718fb 09-Feb-2017 Mudumba Ananth <ananthm%broadcom.com@gtempaccount.com> eSCO: BT 4.1 Enhanced SCO command (1/5)

Added support for BT 4.1 enhanced SCO feature on the stack.
This feature allows the stack to create a SCO connection with
remote device by using Hci_Enhanced_Setup_Synchronous_Connection
command after checking the controller (4.1) support for
enhanced SCO command.
Added the command parameters to use the command in both wide band
speech(WBS) and narrow band speech(NBS) scenarios.

Number of Broadcom vendor specific commands(VSCs)that are needed
to be sent to Broadcom controllers along with this command have
also been updated accordingly

NOTE: This change would also need a firmware patch for
the feature to work on Broadcom contollers which will
be delivered to Google in a separate change set.

Bug: 19540029
Test: make, HFP PTS test, testplans/86884, testplans/87103
Change-Id: I1014d81be5cbe91078a4484dd072ac3957bfdfe4
/system/bt/bta/ag/bta_ag_main.cc
f33b6f434f086b20fabe5913016bc423ac975057 23-Nov-2016 Marie Janssen <jamuraa@google.com> readability fix: No assigns in if conditionals

Coccinelle-assisted:
@@
variable i;
expression E;
statement S1, S2;
@@

+ i = E;
if (
(
- (i = E)
+ i
!= ...
|
- (i = E)
+ i
== ...
|
- (i = E)
+ i
< ...
|
- (i = E)
+ i
> ...
|
- (i = E)
+ i
<= ...
|
- (i = E)
+ i
>= ...
|
- (i = E)
+ i
)
) S1 else S2

for file in $(find . -name "*.cc"); do
spatch --sp no-if-assigns.cocci --in-place $file
done

clang-format --style=file -i bta/**/*.cc

Test: mma -j37 and basic sanity testing on angler, sailfish

Change-Id: I41a2964afac347c24e13869b6c172e321e646091
/system/bt/bta/ag/bta_ag_main.cc
cd1fd07f1306e08fe048682dd5918987e579f937 09-Nov-2016 Myles Watson <mylesgw@google.com> bta: Apply clang-format

clang-format -i --style=file bta/*/*

(twice)

Test: mma -j32
Change-Id: Ib118b1dfb6a34f9a5bfe153d65841e9041165264
/system/bt/bta/ag/bta_ag_main.cc
f355ef5a4d7fb667fc57a0dfb60f738d870e252e 09-Nov-2016 Myles Watson <mylesgw@google.com> bta: Prepare include statements for clang-format

bta: Separate includes of different types

Include "bta_sys.h" in bta/dm/bta_dm_int.h

Test: mma -j32
Change-Id: I292bc6518230201e1175937b9c6766c19709c9d5
/system/bt/bta/ag/bta_ag_main.cc
8af480e24549ba51a3f6858d9d9af504715e0bea 09-Nov-2016 Myles Watson <mylesgw@google.com> bta: Remove double asterisks in comments

Double asterisks at the beginning of the line
sed -i s,"^[*][*]"," *", bta/*/*

Double asterisks after a space
sed -i s,"^ [*][*]\([^*]\)"," *\1", bta/*/*
sed -i s,"^ [*][*]$"," *", bta/*/*

Test: mma -j32
Change-Id: Ib83b802c7000176683b4e7f24d1255b3c2c6c01c
/system/bt/bta/ag/bta_ag_main.cc
d7ffd64accbd50a27289a388856e56244ccbb5da 27-Oct-2016 Myles Watson <mylesgw@google.com> Remove deprecated UNUSED macro (5/5)

Include osi.h for UNUSED_ATTR.

Test: mma -j32

Change-Id: I43260669dc1f54639e46cc9620093d727ee86276
/system/bt/bta/ag/bta_ag_main.cc
d35a648d39710bbc5ac59f8add85166455af5af7 27-Oct-2016 Myles Watson <mylesgw@google.com> Remove deprecated UNUSED macro (1/5)

Generated automatically with coccinelle

/* This rule matches functions with arguments
* that have an UNUSED(arg) in the body.
*/
@r1@
identifier arg;
identifier fn;
type t;
parameter list[n] P;
@@

fn(P, const t arg) { ...
UNUSED(arg);
...
}

/* This rule removes the UNUSED line, and adds
* UNUSED_ATTR to the parameter list.
*/
@depends on r1@
identifier r1.arg;
identifier r1.fn;
type r1.t;
parameter list[r1.n] r1.P;
typedef UNUSED_ATTR;
@@

fn(P,
- const t arg
+ UNUSED_ATTR GETRIDOFTHISCOMMA, const t arg
) { ...
-UNUSED(arg);
...
}

Test: mma -j32

Change-Id: Idcaadd688d669d484e557becd050e69454508f3c
/system/bt/bta/ag/bta_ag_main.cc
b2a292b5d8df2f359c38b0787bc01181225a9bc9 15-Oct-2016 Pavlin Radoslavov <pavlin@google.com> Renamed most C files to C++: *.c to *.cc

Also:
- Fixed C++ related compilation errors.
- Added missing 'extern "C"' guards in some of the header files.
- Added missing LOCAL_CPP_EXTENSION to Android.mk files.
- Added-back btif/src/btif_mce.cc and bta/mce/bta_mce_* to
btif/Android.mk and bta/Android.mk respectively.
- Fixed the alphabetical ordering of the *.cc files in some
of the Android.mk files.
- Added missing Copyright header to "osi/include/list.h"
- Updated "osi/src/wakelock.cc" to use C++ std::string
instead of dynamic allocation of C-style strings.

Test: code compilation, unit tests, and A2DP streaming
Change-Id: Ia2f7215ed9df32775c701b68fc86b09875b942c7
/system/bt/bta/ag/bta_ag_main.cc