Merge "Fix a bunch of incorrect syntax statements"
am: 84cf37a3c4
Change-Id: Ifd68da108a3cfb58322e4bc35f6d15ba0c2f23aa
diff --git a/bta/hearing_aid/hearing_aid.cc b/bta/hearing_aid/hearing_aid.cc
index a96d9de..73d573f 100644
--- a/bta/hearing_aid/hearing_aid.cc
+++ b/bta/hearing_aid/hearing_aid.cc
@@ -246,17 +246,6 @@
BTA_GATTC_Open(gatt_if, address, true, GATT_TRANSPORT_LE, false);
}
- void AddToWhiteList(const RawAddress& address) override {
- VLOG(2) << __func__ << " address: " << address;
- hearingDevices.Add(HearingDevice(address, true));
- BTA_GATTC_Open(gatt_if, address, false, GATT_TRANSPORT_LE, false);
- }
-
- void RemoveFromWhiteList(const RawAddress& address) override {
- VLOG(2) << __func__ << " address: " << address;
- BTA_GATTC_CancelOpen(gatt_if, address, false);
- }
-
void AddFromStorage(const HearingDevice& dev_info, uint16_t is_white_listed) {
DVLOG(2) << __func__ << " " << dev_info.address
<< ", hiSyncId=" << loghex(dev_info.hi_sync_id)
@@ -1263,10 +1252,6 @@
LOG(INFO) << "GAP_EVT_CONN_CLOSED: " << hearingDevice->address
<< ", playback_started=" << hearingDevice->playback_started;
- LOG(INFO) << "GAP_EVT_CONN_CLOSED: " << hearingDevice->address
- << ", playback_started=" << hearingDevice->playback_started;
- hearingDevice->playback_started = false;
-
if (hearingDevice->connecting_actively) {
// cancel pending direct connect
BTA_GATTC_CancelOpen(gatt_if, address, true);
@@ -1282,8 +1267,6 @@
DoDisconnectCleanUp(hearingDevice);
- DoDisconnectCleanUp(hearingDevice);
-
hearingDevices.Remove(address);
if (connected)
diff --git a/bta/include/bta_hearing_aid_api.h b/bta/include/bta_hearing_aid_api.h
index 3d37329..8473575 100644
--- a/bta/include/bta_hearing_aid_api.h
+++ b/bta/include/bta_hearing_aid_api.h
@@ -176,8 +176,6 @@
virtual void Connect(const RawAddress& address) = 0;
virtual void Disconnect(const RawAddress& address) = 0;
- virtual void AddToWhiteList(const RawAddress& address) = 0;
- virtual void RemoveFromWhiteList(const RawAddress& address) = 0;
virtual void SetVolume(int8_t volume) = 0;
};
diff --git a/btif/include/btif_storage.h b/btif/include/btif_storage.h
index 12af661..30615ce 100644
--- a/btif/include/btif_storage.h
+++ b/btif/include/btif_storage.h
@@ -227,9 +227,6 @@
/** Deletes the bonded hearing aid device info from NVRAM */
void btif_storage_remove_hearing_aid(const RawAddress& address);
-/** Add the hearing aid device to white list */
-void btif_storage_add_hearing_aid_to_white_list(const RawAddress& address);
-
/** Remove the hearing aid device from white list */
void btif_storage_remove_hearing_aid_white_list(const RawAddress& address);
diff --git a/btif/src/btif_hearing_aid.cc b/btif/src/btif_hearing_aid.cc
index 204fe15..efba57d 100644
--- a/btif/src/btif_hearing_aid.cc
+++ b/btif/src/btif_hearing_aid.cc
@@ -96,22 +96,6 @@
FROM_HERE, Bind(&btif_storage_remove_hearing_aid_white_list, address));
}
- void AddToWhiteList(const RawAddress& address) override {
- DVLOG(2) << __func__ << " address: " << address;
- do_in_main_thread(FROM_HERE, Bind(&HearingAid::AddToWhiteList,
- Unretained(HearingAid::Get()), address));
- do_in_jni_thread(
- FROM_HERE, Bind(&btif_storage_add_hearing_aid_to_white_list, address));
- }
-
- void RemoveFromWhiteList(const RawAddress& address) override {
- DVLOG(2) << __func__ << " address: " << address;
- do_in_main_thread(FROM_HERE, Bind(&HearingAid::RemoveFromWhiteList,
- Unretained(HearingAid::Get()), address));
- do_in_jni_thread(
- FROM_HERE, Bind(&btif_storage_remove_hearing_aid_white_list, address));
- }
-
void SetVolume(int8_t volume) override {
DVLOG(2) << __func__ << " volume: " << +volume;
do_in_main_thread(FROM_HERE, Bind(&HearingAid::SetVolume,
diff --git a/btif/src/btif_storage.cc b/btif/src/btif_storage.cc
index a4b73a3..4216dbf 100644
--- a/btif/src/btif_storage.cc
+++ b/btif/src/btif_storage.cc
@@ -1560,13 +1560,6 @@
btif_config_save();
}
-/** Add the hearing aid device to white list */
-void btif_storage_add_hearing_aid_to_white_list(const RawAddress& address) {
- std::string addrstr = address.ToString();
-
- btif_config_set_int(addrstr, HEARING_AID_IS_WHITE_LISTED, true);
-}
-
/** Remove the hearing aid device from white list */
void btif_storage_remove_hearing_aid_white_list(const RawAddress& address) {
std::string addrstr = address.ToString();
diff --git a/include/hardware/bt_hearing_aid.h b/include/hardware/bt_hearing_aid.h
index 7ab0dc7..a54f82a 100644
--- a/include/hardware/bt_hearing_aid.h
+++ b/include/hardware/bt_hearing_aid.h
@@ -59,12 +59,6 @@
/** Disconnect from Hearing Aid */
virtual void Disconnect(const RawAddress& address) = 0;
- /** Add a hearing aid device to white list */
- virtual void AddToWhiteList(const RawAddress& address) = 0;
-
- /** Remove a hearing aid device from white list */
- virtual void RemoveFromWhiteList(const RawAddress& address) = 0;
-
/** Set the volume */
virtual void SetVolume(int8_t volume) = 0;
diff --git a/stack/l2cap/l2c_fcr.cc b/stack/l2cap/l2c_fcr.cc
index 6e8e34c..857a0bf 100644
--- a/stack/l2cap/l2c_fcr.cc
+++ b/stack/l2cap/l2c_fcr.cc
@@ -835,7 +835,16 @@
}
if (p_ccb->is_first_seg) {
+ if (p_buf->len < sizeof(sdu_length)) {
+ L2CAP_TRACE_ERROR("%s: buffer length=%d too small. Need at least 2.",
+ __func__, p_buf->len);
+ android_errorWriteWithInfoLog(0x534e4554, "120665616", -1, NULL, 0);
+ /* Discard the buffer */
+ osi_free(p_buf);
+ return;
+ }
STREAM_TO_UINT16(sdu_length, p);
+
/* Check the SDU Length with local MTU size */
if (sdu_length > p_ccb->local_conn_cfg.mtu) {
/* Discard the buffer */
@@ -844,6 +853,7 @@
}
p_buf->len -= sizeof(sdu_length);
+ p_buf->offset += sizeof(sdu_length);
if (sdu_length < p_buf->len) {
L2CAP_TRACE_ERROR("%s: Invalid sdu_length: %d", __func__, sdu_length);
@@ -863,7 +873,6 @@
p_data->len = 0;
p_ccb->ble_sdu_length = sdu_length;
L2CAP_TRACE_DEBUG("%s SDU Length = %d", __func__, sdu_length);
- p_buf->offset += sizeof(sdu_length);
p_data->offset = 0;
} else {
diff --git a/stack/smp/smp_act.cc b/stack/smp/smp_act.cc
index 1e02e42..db6ed66 100644
--- a/stack/smp/smp_act.cc
+++ b/stack/smp/smp_act.cc
@@ -908,6 +908,15 @@
uint8_t* p = p_data->p_data;
SMP_TRACE_DEBUG("%s", __func__);
+
+ if (smp_command_has_invalid_parameters(p_cb)) {
+ tSMP_INT_DATA smp_int_data;
+ smp_int_data.status = SMP_INVALID_PARAMETERS;
+ android_errorWriteLog(0x534e4554, "111937065");
+ smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
+ return;
+ }
+
STREAM_TO_ARRAY(p_cb->ltk.data(), p, OCTET16_LEN);
smp_key_distribution(p_cb, NULL);
@@ -919,6 +928,14 @@
tBTM_LE_KEY_VALUE le_key;
SMP_TRACE_DEBUG("%s", __func__);
+
+ if (p_cb->rcvd_cmd_len < 11) { // 1(Code) + 2(EDIV) + 8(Rand)
+ android_errorWriteLog(0x534e4554, "111937027");
+ SMP_TRACE_ERROR("%s: Invalid command length: %d, should be at least 11",
+ __func__, p_cb->rcvd_cmd_len);
+ return;
+ }
+
smp_update_key_mask(p_cb, SMP_SEC_KEY_TYPE_ENC, true);
STREAM_TO_UINT16(le_key.penc_key.ediv, p);
@@ -941,6 +958,15 @@
uint8_t* p = p_data->p_data;
SMP_TRACE_DEBUG("%s", __func__);
+
+ if (smp_command_has_invalid_parameters(p_cb)) {
+ tSMP_INT_DATA smp_int_data;
+ smp_int_data.status = SMP_INVALID_PARAMETERS;
+ android_errorWriteLog(0x534e4554, "111937065");
+ smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
+ return;
+ }
+
STREAM_TO_ARRAY(p_cb->tk.data(), p, OCTET16_LEN); /* reuse TK for IRK */
smp_key_distribution_by_transport(p_cb, NULL);
}