summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-06-22 10:25:52 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-06-22 10:25:52 +0000
commit2e398f48ced7557f159da674227528cf3a67034d (patch)
tree50094b30fcb342b6ff25463a18f33861bec67970
parent8708c09ddf80a046e60682c5d14f0bd6c01b54a9 (diff)
parent038cbfea4ae8c00c5a325ee9113b96412267b7d5 (diff)
Snap for 8752685 from 038cbfea4ae8c00c5a325ee9113b96412267b7d5 to t-keystone-qcom-release
Change-Id: I0d7d40624614134b902694372d21e9570e07da30
-rw-r--r--android/app/AndroidManifest.xml1
-rw-r--r--android/app/src/com/android/bluetooth/btservice/AdapterService.java2
-rw-r--r--android/app/src/com/android/bluetooth/btservice/storage/DatabaseManager.java7
-rw-r--r--android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java6
-rw-r--r--framework/java/android/bluetooth/BluetoothDevice.java5
-rw-r--r--system/bta/hearing_aid/hearing_aid.cc16
-rw-r--r--system/common/metrics.cc15
-rw-r--r--system/common/metrics.h1
-rw-r--r--system/gd/hci/acl_manager/le_impl.h11
-rw-r--r--system/gd/hci/hci_metrics_logging.cc15
-rw-r--r--system/gd/hci/hci_metrics_logging.h7
-rw-r--r--system/gd/hci/le_advertising_manager.cc30
-rw-r--r--system/gd/os/android/metrics.cc16
-rw-r--r--system/gd/os/host/metrics.cc1
-rw-r--r--system/gd/os/linux/metrics.cc1
-rw-r--r--system/gd/os/metrics.h1
-rw-r--r--system/main/shim/acl.cc4
-rw-r--r--system/main/shim/metrics_api.cc5
-rw-r--r--system/main/shim/metrics_api.h2
-rw-r--r--system/stack/acl/ble_acl.cc7
-rw-r--r--system/stack/btm/btm_ble_bgconn.cc17
-rw-r--r--system/stack/btm/btm_ble_privacy.cc12
-rw-r--r--system/stack/btm/btm_dev.cc9
-rw-r--r--system/stack/gatt/connection_manager.cc15
-rw-r--r--system/stack/gatt/connection_manager.h1
-rw-r--r--system/stack/include/gatt_api.h2
-rw-r--r--system/stack/include/stack_metrics_logging.h1
-rw-r--r--system/stack/metrics/stack_metrics_logging.cc5
-rw-r--r--system/stack/sdp/sdp_utils.cc5
-rw-r--r--system/test/mock/mock_main_shim_metrics_api.cc3
-rw-r--r--system/test/mock/mock_main_shim_metrics_api.h7
-rw-r--r--system/test/mock/mock_stack_gatt_connection_manager.cc5
32 files changed, 160 insertions, 75 deletions
diff --git a/android/app/AndroidManifest.xml b/android/app/AndroidManifest.xml
index ed7daa182d..8a1c3c2c54 100644
--- a/android/app/AndroidManifest.xml
+++ b/android/app/AndroidManifest.xml
@@ -54,7 +54,6 @@
<uses-permission android:name="android.permission.NETWORK_FACTORY"/>
<uses-permission android:name="android.permission.TETHER_PRIVILEGED"/>
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE"/>
- <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"/>
<uses-permission android:name="android.permission.BLUETOOTH_STACK"/>
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS"/>
<uses-permission android:name="android.permission.MANAGE_USERS"/>
diff --git a/android/app/src/com/android/bluetooth/btservice/AdapterService.java b/android/app/src/com/android/bluetooth/btservice/AdapterService.java
index 410e906b0e..8621fd8a6f 100644
--- a/android/app/src/com/android/bluetooth/btservice/AdapterService.java
+++ b/android/app/src/com/android/bluetooth/btservice/AdapterService.java
@@ -2691,7 +2691,7 @@ public class AdapterService extends Service {
ParcelUuid[] parcels = service.getRemoteUuids(device);
if (parcels == null) {
- parcels = new ParcelUuid[0];
+ return null;
}
return Arrays.asList(parcels);
}
diff --git a/android/app/src/com/android/bluetooth/btservice/storage/DatabaseManager.java b/android/app/src/com/android/bluetooth/btservice/storage/DatabaseManager.java
index 66fe33b334..4bc32b414d 100644
--- a/android/app/src/com/android/bluetooth/btservice/storage/DatabaseManager.java
+++ b/android/app/src/com/android/bluetooth/btservice/storage/DatabaseManager.java
@@ -1046,10 +1046,15 @@ public class DatabaseManager {
// Do not log anything if metadata doesn't fall into above categories
return;
}
+ String[] macAddress = device.getAddress().split(":");
BluetoothStatsLog.write(BluetoothStatsLog.BLUETOOTH_DEVICE_INFO_REPORTED,
mAdapterService.obfuscateAddress(device),
BluetoothProtoEnums.DEVICE_INFO_EXTERNAL, callingApp, manufacturerName, modelName,
- hardwareVersion, softwareVersion, mAdapterService.getMetricId(device));
+ hardwareVersion, softwareVersion, mAdapterService.getMetricId(device),
+ device.getAddressType(),
+ Integer.parseInt(macAddress[0], 16),
+ Integer.parseInt(macAddress[1], 16),
+ Integer.parseInt(macAddress[2], 16));
}
private void logMetadataChange(String address, String log) {
diff --git a/android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java b/android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
index 39d372f6e5..e431c43bde 100644
--- a/android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
+++ b/android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
@@ -1914,10 +1914,14 @@ public class HeadsetStateMachine extends StateMachine {
String vendorId = deviceInfo[0];
String productId = deviceInfo[1];
String version = deviceInfo[2];
+ String[] macAddress = device.getAddress().split(":");
BluetoothStatsLog.write(BluetoothStatsLog.BLUETOOTH_DEVICE_INFO_REPORTED,
mAdapterService.obfuscateAddress(device), BluetoothProtoEnums.DEVICE_INFO_INTERNAL,
BluetoothHeadset.VENDOR_SPECIFIC_HEADSET_EVENT_XAPL, vendorId, productId, version,
- null, mAdapterService.getMetricId(device));
+ null, mAdapterService.getMetricId(device),
+ device.getAddressType(),
+ Integer.parseInt(macAddress[0], 16),
+ Integer.parseInt(macAddress[1], 16), Integer.parseInt(macAddress[2], 16));
// feature = 2 indicates that we support battery level reporting only
mNativeInterface.atResponseString(device, "+XAPL=iPhone," + String.valueOf(2));
}
diff --git a/framework/java/android/bluetooth/BluetoothDevice.java b/framework/java/android/bluetooth/BluetoothDevice.java
index 5ab621f627..d2921cf170 100644
--- a/framework/java/android/bluetooth/BluetoothDevice.java
+++ b/framework/java/android/bluetooth/BluetoothDevice.java
@@ -88,7 +88,6 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeoutException;
@@ -2411,8 +2410,8 @@ public final class BluetoothDevice implements Parcelable, Attributable {
new SynchronousResultReceiver();
service.getRemoteUuids(this, mAttributionSource, recv);
List<ParcelUuid> parcels = recv.awaitResultNoInterrupt(getSyncTimeout())
- .getValue(new ArrayList<>());
- return parcels.toArray(new ParcelUuid[parcels.size()]);
+ .getValue(null);
+ return parcels != null ? parcels.toArray(new ParcelUuid[parcels.size()]) : null;
} catch (RemoteException | TimeoutException e) {
Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
}
diff --git a/system/bta/hearing_aid/hearing_aid.cc b/system/bta/hearing_aid/hearing_aid.cc
index 61a83cdda0..0e48ae40f9 100644
--- a/system/bta/hearing_aid/hearing_aid.cc
+++ b/system/bta/hearing_aid/hearing_aid.cc
@@ -584,6 +584,7 @@ class HearingAidImpl : public HearingAid {
}
}
+ // Just take care phy update successful case to avoid loop excuting.
void OnPhyUpdateEvent(uint16_t conn_id, uint8_t tx_phys, uint8_t rx_phys,
tGATT_STATUS status) {
HearingDevice* hearingDevice = hearingDevices.FindByConnId(conn_id);
@@ -591,14 +592,19 @@ class HearingAidImpl : public HearingAid {
DVLOG(2) << "Skipping unknown device, conn_id=" << loghex(conn_id);
return;
}
- if (status == GATT_SUCCESS && tx_phys == PHY_LE_2M &&
- rx_phys == PHY_LE_2M) {
+ if (status != GATT_SUCCESS) {
+ LOG(WARNING) << hearingDevice->address
+ << " phy update fail with status: " << status;
+ return;
+ }
+ if (tx_phys == PHY_LE_2M && rx_phys == PHY_LE_2M) {
LOG(INFO) << hearingDevice->address << " phy update to 2M successful";
return;
}
- LOG(INFO) << hearingDevice->address
- << " phy update to 2M fail, try again. status: " << status
- << ", tx_phys: " << tx_phys << ", rx_phys: " << rx_phys;
+ LOG(INFO)
+ << hearingDevice->address
+ << " phy update successful but not target phy, try again. tx_phys: "
+ << tx_phys << ", rx_phys: " << rx_phys;
BTM_BleSetPhy(hearingDevice->address, PHY_LE_2M, PHY_LE_2M, 0);
}
diff --git a/system/common/metrics.cc b/system/common/metrics.cc
index be1d1b3bac..0664186cac 100644
--- a/system/common/metrics.cc
+++ b/system/common/metrics.cc
@@ -859,6 +859,7 @@ void LogSocketConnectionState(
}
void LogManufacturerInfo(const RawAddress& address,
+ android::bluetooth::AddressTypeEnum address_type,
android::bluetooth::DeviceInfoSrcEnum source_type,
const std::string& source_name,
const std::string& manufacturer,
@@ -875,16 +876,20 @@ void LogManufacturerInfo(const RawAddress& address,
BytesField obfuscated_id_field(
address.IsEmpty() ? nullptr : obfuscated_id.c_str(),
address.IsEmpty() ? 0 : obfuscated_id.size());
- int ret = stats_write(BLUETOOTH_DEVICE_INFO_REPORTED, obfuscated_id_field,
- source_type, source_name.c_str(), manufacturer.c_str(),
- model.c_str(), hardware_version.c_str(),
- software_version.c_str(), metric_id);
+ int ret = stats_write(
+ BLUETOOTH_DEVICE_INFO_REPORTED, obfuscated_id_field, source_type,
+ source_name.c_str(), manufacturer.c_str(), model.c_str(),
+ hardware_version.c_str(), software_version.c_str(), metric_id,
+ address_type, address.address[5], address.address[4], address.address[3]);
if (ret < 0) {
LOG(WARNING) << __func__ << ": failed for " << address << ", source_type "
<< source_type << ", source_name " << source_name
<< ", manufacturer " << manufacturer << ", model " << model
<< ", hardware_version " << hardware_version
- << ", software_version " << software_version << ", error "
+ << ", software_version " << software_version
+ << " MAC address type " << address_type
+ << " MAC address prefix " << address.address[5] << " "
+ << address.address[4] << " " << address.address[3] << ", error "
<< ret;
}
}
diff --git a/system/common/metrics.h b/system/common/metrics.h
index 53cad5c3d0..9d33e1b81f 100644
--- a/system/common/metrics.h
+++ b/system/common/metrics.h
@@ -487,6 +487,7 @@ void LogSocketConnectionState(
* @param software_version software version of this device
*/
void LogManufacturerInfo(const RawAddress& address,
+ android::bluetooth::AddressTypeEnum address_type,
android::bluetooth::DeviceInfoSrcEnum source_type,
const std::string& source_name,
const std::string& manufacturer,
diff --git a/system/gd/hci/acl_manager/le_impl.h b/system/gd/hci/acl_manager/le_impl.h
index ea2eb1354e..21c77b727d 100644
--- a/system/gd/hci/acl_manager/le_impl.h
+++ b/system/gd/hci/acl_manager/le_impl.h
@@ -265,6 +265,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
// connection canceled by LeAddressManager.OnPause(), will auto reconnect by LeAddressManager.OnResume()
void on_le_connection_canceled_on_pause() {
ASSERT_LOG(pause_connection, "Connection must be paused to ack the le address manager");
+ arm_on_resume_ = true;
connectability_state_ = ConnectabilityState::DISARMED;
le_address_manager_->AckPause(this);
}
@@ -464,12 +465,9 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
if (background_connections_.count(remote_address) == 1) {
LOG_INFO("re-add device to connect list");
+ arm_on_resume_ = true;
add_device_to_connect_list(remote_address);
}
- if (!connect_list.empty() && connectability_state_ == ConnectabilityState::DISARMED) {
- LOG_INFO("connect_list is not empty, send a new connection request");
- arm_connectability();
- }
}
void on_le_connection_update_complete(LeMetaEventView view) {
@@ -585,6 +583,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
return;
}
connect_list.erase(address_with_type);
+ connecting_le_.erase(address_with_type);
direct_connections_.erase(address_with_type);
register_with_address_manager();
le_address_manager_->RemoveDeviceFromFilterAcceptList(
@@ -643,6 +642,10 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
connectability_state_machine_text(connectability_state_).c_str());
return;
}
+ if (connect_list.empty()) {
+ LOG_ERROR("Attempting to re-arm le connection state machine when filter accept list is empty");
+ return;
+ }
AddressWithType empty(Address::kEmpty, AddressType::RANDOM_DEVICE_ADDRESS);
connectability_state_ = ConnectabilityState::ARMING;
connecting_le_ = connect_list;
diff --git a/system/gd/hci/hci_metrics_logging.cc b/system/gd/hci/hci_metrics_logging.cc
index 80655d5162..9c864ac8ad 100644
--- a/system/gd/hci/hci_metrics_logging.cc
+++ b/system/gd/hci/hci_metrics_logging.cc
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h>
#include <frameworks/proto_logging/stats/enums/bluetooth/hci/enums.pb.h>
#include "common/strings.h"
@@ -512,7 +511,12 @@ void log_link_layer_connection_other_hci_event(EventView packet, storage::Storag
status = connection_complete_view.GetStatus();
// besides log link layer connection events, also log remote device manufacturer info
- log_remote_device_information(address, connection_handle, status, storage_module);
+ log_remote_device_information(
+ address,
+ android::bluetooth::ADDRESS_TYPE_PUBLIC,
+ connection_handle,
+ status,
+ storage_module);
break;
}
case EventCode::CONNECTION_REQUEST: {
@@ -1048,7 +1052,11 @@ void log_classic_pairing_command_complete(EventView event_view, std::unique_ptr<
}
void log_remote_device_information(
- const Address& address, uint32_t connection_handle, ErrorCode status, storage::StorageModule* storage_module) {
+ const Address& address,
+ android::bluetooth::AddressTypeEnum address_type,
+ uint32_t connection_handle,
+ ErrorCode status,
+ storage::StorageModule* storage_module) {
if (address.IsEmpty()) {
return;
}
@@ -1059,6 +1067,7 @@ void log_remote_device_information(
sdp_di_vendor_id_source << "N:SDP::DIP::" << common::ToHexString(device.GetSdpDiVendorIdSource().value_or(0)).c_str();
os::LogMetricManufacturerInfo(
address,
+ address_type,
android::bluetooth::DeviceInfoSrcEnum::DEVICE_INFO_INTERNAL,
sdp_di_vendor_id_source.str(),
common::ToHexString(device.GetSdpDiManufacturer().value_or(0)).c_str(),
diff --git a/system/gd/hci/hci_metrics_logging.h b/system/gd/hci/hci_metrics_logging.h
index de463db944..37a230aa7e 100644
--- a/system/gd/hci/hci_metrics_logging.h
+++ b/system/gd/hci/hci_metrics_logging.h
@@ -15,6 +15,7 @@
*/
#pragma once
+#include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h>
#include "hci/hci_packets.h"
#include "storage/storage_module.h"
@@ -34,6 +35,10 @@ void log_classic_pairing_command_complete(EventView event, std::unique_ptr<Comma
void log_classic_pairing_other_hci_event(EventView packet);
void log_remote_device_information(
- const Address& address, uint32_t connection_handle, ErrorCode status, storage::StorageModule* storage_module);
+ const Address& address,
+ android::bluetooth::AddressTypeEnum address_type,
+ uint32_t connection_handle,
+ ErrorCode status,
+ storage::StorageModule* storage_module);
} // namespace hci
} // namespace bluetooth \ No newline at end of file
diff --git a/system/gd/hci/le_advertising_manager.cc b/system/gd/hci/le_advertising_manager.cc
index 95979bf683..0832c25790 100644
--- a/system/gd/hci/le_advertising_manager.cc
+++ b/system/gd/hci/le_advertising_manager.cc
@@ -223,6 +223,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
id++;
}
if (id == num_instances_) {
+ LOG_WARN("Number of max instances %d reached", (uint16_t)num_instances_);
return kInvalidId;
}
advertising_sets_[id].in_use = true;
@@ -1259,6 +1260,11 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
ErrorCodeText(status_view.GetStatus()).c_str());
}
}
+
+ void start_advertising_fail(int reg_id, AdvertisingCallback::AdvertisingStatus status) {
+ ASSERT(status != AdvertisingCallback::AdvertisingStatus::SUCCESS);
+ advertising_callbacks_->OnAdvertisingSetStarted(reg_id, kInvalidId, 0, status);
+ }
};
LeAdvertisingManager::LeAdvertisingManager() {
@@ -1298,16 +1304,26 @@ AdvertiserId LeAdvertisingManager::create_advertiser(
if (config.own_address_type == hci::OwnAddressType::RESOLVABLE_OR_PUBLIC_ADDRESS ||
config.own_address_type == hci::OwnAddressType::RESOLVABLE_OR_RANDOM_ADDRESS) {
LOG_WARN("Peer address can not be empty");
+ CallOn(
+ pimpl_.get(), &impl::start_advertising_fail, reg_id, AdvertisingCallback::AdvertisingStatus::INTERNAL_ERROR);
return kInvalidId;
}
if (config.advertising_type == hci::AdvertisingType::ADV_DIRECT_IND ||
config.advertising_type == hci::AdvertisingType::ADV_DIRECT_IND_LOW) {
LOG_WARN("Peer address can not be empty for directed advertising");
+ CallOn(
+ pimpl_.get(), &impl::start_advertising_fail, reg_id, AdvertisingCallback::AdvertisingStatus::INTERNAL_ERROR);
return kInvalidId;
}
}
AdvertiserId id = pimpl_->allocate_advertiser();
if (id == kInvalidId) {
+ LOG_WARN("Number of max instances reached");
+ CallOn(
+ pimpl_.get(),
+ &impl::start_advertising_fail,
+ reg_id,
+ AdvertisingCallback::AdvertisingStatus::TOO_MANY_ADVERTISERS);
return id;
}
GetHandler()->Post(common::BindOnce(
@@ -1338,29 +1354,43 @@ AdvertiserId LeAdvertisingManager::ExtendedCreateAdvertiser(
if (config.directed) {
if (config.peer_address == Address::kEmpty) {
LOG_INFO("Peer address can not be empty for directed advertising");
+ CallOn(
+ pimpl_.get(), &impl::start_advertising_fail, reg_id, AdvertisingCallback::AdvertisingStatus::INTERNAL_ERROR);
return kInvalidId;
}
}
if (config.channel_map == 0) {
LOG_INFO("At least one channel must be set in the map");
+ CallOn(pimpl_.get(), &impl::start_advertising_fail, reg_id, AdvertisingCallback::AdvertisingStatus::INTERNAL_ERROR);
return kInvalidId;
}
if (!config.legacy_pdus) {
if (config.connectable && config.scannable) {
LOG_INFO("Extended advertising PDUs can not be connectable and scannable");
+ CallOn(
+ pimpl_.get(), &impl::start_advertising_fail, reg_id, AdvertisingCallback::AdvertisingStatus::INTERNAL_ERROR);
return kInvalidId;
}
if (config.high_duty_directed_connectable) {
LOG_INFO("Extended advertising PDUs can not be high duty cycle");
+ CallOn(
+ pimpl_.get(), &impl::start_advertising_fail, reg_id, AdvertisingCallback::AdvertisingStatus::INTERNAL_ERROR);
return kInvalidId;
}
}
if (config.interval_min > config.interval_max) {
LOG_INFO("Advertising interval: min (%hu) > max (%hu)", config.interval_min, config.interval_max);
+ CallOn(pimpl_.get(), &impl::start_advertising_fail, reg_id, AdvertisingCallback::AdvertisingStatus::INTERNAL_ERROR);
return kInvalidId;
}
AdvertiserId id = pimpl_->allocate_advertiser();
if (id == kInvalidId) {
+ LOG_WARN("Number of max instances reached");
+ CallOn(
+ pimpl_.get(),
+ &impl::start_advertising_fail,
+ reg_id,
+ AdvertisingCallback::AdvertisingStatus::TOO_MANY_ADVERTISERS);
return id;
}
CallOn(
diff --git a/system/gd/os/android/metrics.cc b/system/gd/os/android/metrics.cc
index 8286ad170f..3be618823e 100644
--- a/system/gd/os/android/metrics.cc
+++ b/system/gd/os/android/metrics.cc
@@ -355,6 +355,7 @@ void LogMetricSocketConnectionState(
void LogMetricManufacturerInfo(
const Address& address,
+ android::bluetooth::AddressTypeEnum address_type,
android::bluetooth::DeviceInfoSrcEnum source_type,
const std::string& source_name,
const std::string& manufacturer,
@@ -374,11 +375,16 @@ void LogMetricManufacturerInfo(
model.c_str(),
hardware_version.c_str(),
software_version.c_str(),
- metric_id);
+ metric_id,
+ address_type,
+ address.address[5],
+ address.address[4],
+ address.address[3]);
if (ret < 0) {
LOG_WARN(
- "Failed for %s, source_type %d, source_name %s, manufacturer %s, model %s, hardware_version %s, "
- "software_version %s, error %d",
+ "Failed for %s, source_type %d, source_name %s, manufacturer %s, model %s, "
+ "hardware_version %s, "
+ "software_version %s, MAC address type %d MAC address prefix %d %d %d, error %d",
address.ToString().c_str(),
source_type,
source_name.c_str(),
@@ -386,6 +392,10 @@ void LogMetricManufacturerInfo(
model.c_str(),
hardware_version.c_str(),
software_version.c_str(),
+ address_type,
+ address.address[5],
+ address.address[4],
+ address.address[3],
ret);
}
}
diff --git a/system/gd/os/host/metrics.cc b/system/gd/os/host/metrics.cc
index f83e59c053..b17571452a 100644
--- a/system/gd/os/host/metrics.cc
+++ b/system/gd/os/host/metrics.cc
@@ -80,6 +80,7 @@ void LogMetricLinkLayerConnectionEvent(
void LogMetricManufacturerInfo(
const Address& address,
+ android::bluetooth::AddressTypeEnum address_type,
android::bluetooth::DeviceInfoSrcEnum source_type,
const std::string& source_name,
const std::string& manufacturer,
diff --git a/system/gd/os/linux/metrics.cc b/system/gd/os/linux/metrics.cc
index 926f545d36..37bd67356a 100644
--- a/system/gd/os/linux/metrics.cc
+++ b/system/gd/os/linux/metrics.cc
@@ -80,6 +80,7 @@ void LogMetricLinkLayerConnectionEvent(
void LogMetricManufacturerInfo(
const Address& address,
+ android::bluetooth::AddressTypeEnum address_type,
android::bluetooth::DeviceInfoSrcEnum source_type,
const std::string& source_name,
const std::string& manufacturer,
diff --git a/system/gd/os/metrics.h b/system/gd/os/metrics.h
index 73b9484042..3b1ae51850 100644
--- a/system/gd/os/metrics.h
+++ b/system/gd/os/metrics.h
@@ -245,6 +245,7 @@ void LogMetricSocketConnectionState(
*/
void LogMetricManufacturerInfo(
const hci::Address& address,
+ android::bluetooth::AddressTypeEnum address_type,
android::bluetooth::DeviceInfoSrcEnum source_type,
const std::string& source_name,
const std::string& manufacturer,
diff --git a/system/main/shim/acl.cc b/system/main/shim/acl.cc
index 86edaa0e8b..fc0c4b8130 100644
--- a/system/main/shim/acl.cc
+++ b/system/main/shim/acl.cc
@@ -1338,12 +1338,16 @@ void shim::legacy::Acl::CancelClassicConnection(const hci::Address& address) {
void shim::legacy::Acl::AcceptLeConnectionFrom(
const hci::AddressWithType& address_with_type, bool is_direct,
std::promise<bool> promise) {
+ LOG_DEBUG("AcceptLeConnectionFrom %s",
+ PRIVATE_ADDRESS(address_with_type.GetAddress()));
handler_->CallOn(pimpl_.get(), &Acl::impl::accept_le_connection_from,
address_with_type, is_direct, std::move(promise));
}
void shim::legacy::Acl::IgnoreLeConnectionFrom(
const hci::AddressWithType& address_with_type) {
+ LOG_DEBUG("IgnoreLeConnectionFrom %s",
+ PRIVATE_ADDRESS(address_with_type.GetAddress()));
handler_->CallOn(pimpl_.get(), &Acl::impl::ignore_le_connection_from,
address_with_type);
}
diff --git a/system/main/shim/metrics_api.cc b/system/main/shim/metrics_api.cc
index 74784f879c..99832be023 100644
--- a/system/main/shim/metrics_api.cc
+++ b/system/main/shim/metrics_api.cc
@@ -128,13 +128,14 @@ void LogMetricSocketConnectionState(
void LogMetricManufacturerInfo(
const RawAddress& raw_address,
+ android::bluetooth::AddressTypeEnum address_type,
android::bluetooth::DeviceInfoSrcEnum source_type,
const std::string& source_name, const std::string& manufacturer,
const std::string& model, const std::string& hardware_version,
const std::string& software_version) {
Address address = bluetooth::ToGdAddress(raw_address);
- bluetooth::os::LogMetricManufacturerInfo(address, source_type, source_name,
- manufacturer, model,
+ bluetooth::os::LogMetricManufacturerInfo(address, address_type, source_type,
+ source_name, manufacturer, model,
hardware_version, software_version);
}
diff --git a/system/main/shim/metrics_api.h b/system/main/shim/metrics_api.h
index 51ee8df2ba..ce13876180 100644
--- a/system/main/shim/metrics_api.h
+++ b/system/main/shim/metrics_api.h
@@ -202,7 +202,7 @@ void LogMetricSocketConnectionState(
* @param software_version software version of this device
*/
void LogMetricManufacturerInfo(
- const RawAddress& address,
+ const RawAddress& address, android::bluetooth::AddressTypeEnum address_type,
android::bluetooth::DeviceInfoSrcEnum source_type,
const std::string& source_name, const std::string& manufacturer,
const std::string& model, const std::string& hardware_version,
diff --git a/system/stack/acl/ble_acl.cc b/system/stack/acl/ble_acl.cc
index a09012a37b..08b74489c9 100644
--- a/system/stack/acl/ble_acl.cc
+++ b/system/stack/acl/ble_acl.cc
@@ -125,12 +125,7 @@ void acl_ble_enhanced_connection_complete_from_shim(
uint16_t conn_interval, uint16_t conn_latency, uint16_t conn_timeout,
const RawAddress& local_rpa, const RawAddress& peer_rpa,
tBLE_ADDR_TYPE peer_addr_type) {
- if (!connection_manager::remove_unconditional_from_shim(
- address_with_type.bda)) {
- LOG_WARN(
- "Unable to remove from legacy connection manager accept list addr:%s",
- PRIVATE_ADDRESS(address_with_type.bda));
- }
+ connection_manager::on_connection_complete(address_with_type.bda);
tBLE_BD_ADDR resolved_address_with_type;
const bool is_in_security_db = maybe_resolve_received_address(
diff --git a/system/stack/btm/btm_ble_bgconn.cc b/system/stack/btm/btm_ble_bgconn.cc
index d093aa5a2a..ef07cdb011 100644
--- a/system/stack/btm/btm_ble_bgconn.cc
+++ b/system/stack/btm/btm_ble_bgconn.cc
@@ -205,8 +205,14 @@ bool BTM_AcceptlistAdd(const RawAddress& address) {
LOG_WARN("Controller does not support Le");
return false;
}
+
+ tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address);
+ if (p_dev_rec != NULL && p_dev_rec->device_type & BT_DEVICE_TYPE_BLE) {
+ p_dev_rec->ble.in_controller_list |= BTM_ACCEPTLIST_BIT;
+ }
+
return bluetooth::shim::ACL_AcceptLeConnectionFrom(
- convert_to_address_with_type(address, btm_find_dev(address)),
+ convert_to_address_with_type(address, p_dev_rec),
/* is_direct */ false);
}
@@ -216,8 +222,15 @@ void BTM_AcceptlistRemove(const RawAddress& address) {
LOG_WARN("Controller does not support Le");
return;
}
+
+ tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address);
+ if (p_dev_rec != NULL && p_dev_rec->device_type & BT_DEVICE_TYPE_BLE) {
+ p_dev_rec->ble.in_controller_list &= ~BTM_ACCEPTLIST_BIT;
+ }
+
bluetooth::shim::ACL_IgnoreLeConnectionFrom(
- convert_to_address_with_type(address, btm_find_dev(address)));
+ convert_to_address_with_type(address, p_dev_rec));
+ return;
}
/** Clear the acceptlist, end any pending acceptlist connections */
diff --git a/system/stack/btm/btm_ble_privacy.cc b/system/stack/btm/btm_ble_privacy.cc
index 0a3035dadf..b2f26faf15 100644
--- a/system/stack/btm/btm_ble_privacy.cc
+++ b/system/stack/btm/btm_ble_privacy.cc
@@ -434,10 +434,9 @@ tBTM_STATUS btm_ble_remove_resolving_list_entry(tBTM_SEC_DEV_REC* p_dev_rec) {
BTM_VendorSpecificCommand(HCI_VENDOR_BLE_RPA_VSC,
BTM_BLE_META_REMOVE_IRK_LEN, param,
btm_ble_resolving_list_vsc_op_cmpl);
+ btm_ble_enq_resolving_list_pending(p_dev_rec->bd_addr,
+ BTM_BLE_META_REMOVE_IRK_ENTRY);
}
-
- btm_ble_enq_resolving_list_pending(p_dev_rec->bd_addr,
- BTM_BLE_META_REMOVE_IRK_ENTRY);
return BTM_CMD_STARTED;
}
@@ -495,11 +494,10 @@ bool btm_ble_read_resolving_list_entry(tBTM_SEC_DEV_REC* p_dev_rec) {
BTM_VendorSpecificCommand(HCI_VENDOR_BLE_RPA_VSC, BTM_BLE_META_READ_IRK_LEN,
param, btm_ble_resolving_list_vsc_op_cmpl);
- }
-
- btm_ble_enq_resolving_list_pending(p_dev_rec->bd_addr,
- BTM_BLE_META_READ_IRK_ENTRY);
+ btm_ble_enq_resolving_list_pending(p_dev_rec->bd_addr,
+ BTM_BLE_META_READ_IRK_ENTRY);
+ }
return true;
}
diff --git a/system/stack/btm/btm_dev.cc b/system/stack/btm/btm_dev.cc
index eeb37be055..4067e3d46e 100644
--- a/system/stack/btm/btm_dev.cc
+++ b/system/stack/btm/btm_dev.cc
@@ -136,6 +136,9 @@ void wipe_secrets_and_remove(tBTM_SEC_DEV_REC* p_dev_rec) {
list_remove(btm_cb.sec_dev_rec, p_dev_rec);
}
+/** Removes the device from acceptlist */
+extern void BTM_AcceptlistRemove(const RawAddress& address);
+
/** Free resources associated with the device associated with |bd_addr| address.
*
* *** WARNING ***
@@ -162,6 +165,12 @@ bool BTM_SecDeleteDevice(const RawAddress& bd_addr) {
if (p_dev_rec != NULL) {
RawAddress bda = p_dev_rec->bd_addr;
+ if (p_dev_rec->ble.in_controller_list & BTM_ACCEPTLIST_BIT) {
+ LOG_INFO("Remove device %s from filter accept list before delete record",
+ PRIVATE_ADDRESS(bd_addr));
+ BTM_AcceptlistRemove(p_dev_rec->bd_addr);
+ }
+
/* Clear out any saved BLE keys */
btm_sec_clear_ble_keys(p_dev_rec);
wipe_secrets_and_remove(p_dev_rec);
diff --git a/system/stack/gatt/connection_manager.cc b/system/stack/gatt/connection_manager.cc
index c6052c236c..fd38bb5e05 100644
--- a/system/stack/gatt/connection_manager.cc
+++ b/system/stack/gatt/connection_manager.cc
@@ -149,21 +149,6 @@ bool remove_unconditional(const RawAddress& address) {
return true;
}
-/** Removes the registrations for connection for given device.
- * but does not change the controller acceptlist. Used for
- * shim purposes.
- * Returns true if anything was removed, false otherwise */
-bool remove_unconditional_from_shim(const RawAddress& address) {
- LOG_DEBUG("address=%s", address.ToString().c_str());
- auto it = bgconn_dev.find(address);
- if (it == bgconn_dev.end()) {
- LOG_WARN("address %s is not found", address.ToString().c_str());
- return false;
- }
- bgconn_dev.erase(it);
- return true;
-}
-
/** Remove device from the background connection device list or listening to
* advertising list. Returns true if device was on the list and was
* successfully removed */
diff --git a/system/stack/gatt/connection_manager.h b/system/stack/gatt/connection_manager.h
index fe2bd93299..d3eb3e39b9 100644
--- a/system/stack/gatt/connection_manager.h
+++ b/system/stack/gatt/connection_manager.h
@@ -41,7 +41,6 @@ extern bool background_connect_add(tAPP_ID app_id, const RawAddress& address);
extern bool background_connect_remove(tAPP_ID app_id,
const RawAddress& address);
extern bool remove_unconditional(const RawAddress& address);
-extern bool remove_unconditional_from_shim(const RawAddress& address);
extern void reset(bool after_reset);
diff --git a/system/stack/include/gatt_api.h b/system/stack/include/gatt_api.h
index 33a6eaee6d..b38e943302 100644
--- a/system/stack/include/gatt_api.h
+++ b/system/stack/include/gatt_api.h
@@ -247,7 +247,7 @@ inline std::string gatt_disconnection_reason_text(
/* max legth of an attribute value
*/
#ifndef GATT_MAX_ATTR_LEN
-#define GATT_MAX_ATTR_LEN 600
+#define GATT_MAX_ATTR_LEN 512
#endif
/* default GATT MTU size over LE link
diff --git a/system/stack/include/stack_metrics_logging.h b/system/stack/include/stack_metrics_logging.h
index 56921ddbdf..158c98f610 100644
--- a/system/stack/include/stack_metrics_logging.h
+++ b/system/stack/include/stack_metrics_logging.h
@@ -43,6 +43,7 @@ void log_sdp_attribute(const RawAddress& address, uint16_t protocol_uuid,
const char* attribute_value);
void log_manufacturer_info(const RawAddress& address,
+ android::bluetooth::AddressTypeEnum address_type,
android::bluetooth::DeviceInfoSrcEnum source_type,
const std::string& source_name,
const std::string& manufacturer,
diff --git a/system/stack/metrics/stack_metrics_logging.cc b/system/stack/metrics/stack_metrics_logging.cc
index 50f029f803..4e23bd2a08 100644
--- a/system/stack/metrics/stack_metrics_logging.cc
+++ b/system/stack/metrics/stack_metrics_logging.cc
@@ -57,6 +57,7 @@ void log_sdp_attribute(const RawAddress& address, uint16_t protocol_uuid,
}
void log_manufacturer_info(const RawAddress& address,
+ android::bluetooth::AddressTypeEnum address_type,
android::bluetooth::DeviceInfoSrcEnum source_type,
const std::string& source_name,
const std::string& manufacturer,
@@ -64,8 +65,8 @@ void log_manufacturer_info(const RawAddress& address,
const std::string& hardware_version,
const std::string& software_version) {
bluetooth::shim::LogMetricManufacturerInfo(
- address, source_type, source_name, manufacturer, model, hardware_version,
- software_version);
+ address, address_type, source_type, source_name, manufacturer, model,
+ hardware_version, software_version);
}
void log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum key,
diff --git a/system/stack/sdp/sdp_utils.cc b/system/stack/sdp/sdp_utils.cc
index 44078ae720..8e8f98f214 100644
--- a/system/stack/sdp/sdp_utils.cc
+++ b/system/stack/sdp/sdp_utils.cc
@@ -273,8 +273,9 @@ void sdpu_log_attribute_metrics(const RawAddress& bda,
// [N - native]::SDP::[DIP - Device ID Profile]
ss << "N:SDP::DIP::" << loghex(di_record.rec.vendor_id_source);
log_manufacturer_info(
- bda, android::bluetooth::DeviceInfoSrcEnum::DEVICE_INFO_INTERNAL,
- ss.str(), loghex(di_record.rec.vendor), loghex(di_record.rec.product),
+ bda, android::bluetooth::AddressTypeEnum::ADDRESS_TYPE_PUBLIC,
+ android::bluetooth::DeviceInfoSrcEnum::DEVICE_INFO_INTERNAL, ss.str(),
+ loghex(di_record.rec.vendor), loghex(di_record.rec.product),
loghex(di_record.rec.version), "");
std::string bda_string = bda.ToString();
diff --git a/system/test/mock/mock_main_shim_metrics_api.cc b/system/test/mock/mock_main_shim_metrics_api.cc
index 25b32283fc..30aeeb1111 100644
--- a/system/test/mock/mock_main_shim_metrics_api.cc
+++ b/system/test/mock/mock_main_shim_metrics_api.cc
@@ -165,13 +165,14 @@ void bluetooth::shim::LogMetricSocketConnectionState(
}
void bluetooth::shim::LogMetricManufacturerInfo(
const RawAddress& raw_address,
+ android::bluetooth::AddressTypeEnum address_type,
android::bluetooth::DeviceInfoSrcEnum source_type,
const std::string& source_name, const std::string& manufacturer,
const std::string& model, const std::string& hardware_version,
const std::string& software_version) {
mock_function_count_map[__func__]++;
test::mock::main_shim_metrics_api::LogMetricManufacturerInfo(
- raw_address, source_type, source_name, manufacturer, model,
+ raw_address, address_type, source_type, source_name, manufacturer, model,
hardware_version, software_version);
}
bool bluetooth::shim::CountCounterMetrics(int32_t key, int64_t count) {
diff --git a/system/test/mock/mock_main_shim_metrics_api.h b/system/test/mock/mock_main_shim_metrics_api.h
index 39f4e7f866..b42529f8a7 100644
--- a/system/test/mock/mock_main_shim_metrics_api.h
+++ b/system/test/mock/mock_main_shim_metrics_api.h
@@ -258,24 +258,27 @@ extern struct LogMetricSocketConnectionState LogMetricSocketConnectionState;
// std::string& software_version Returns: void
struct LogMetricManufacturerInfo {
std::function<void(const RawAddress& raw_address,
+ android::bluetooth::AddressTypeEnum address_type,
android::bluetooth::DeviceInfoSrcEnum source_type,
const std::string& source_name,
const std::string& manufacturer, const std::string& model,
const std::string& hardware_version,
const std::string& software_version)>
body{[](const RawAddress& raw_address,
+ android::bluetooth::AddressTypeEnum address_type,
android::bluetooth::DeviceInfoSrcEnum source_type,
const std::string& source_name, const std::string& manufacturer,
const std::string& model, const std::string& hardware_version,
const std::string& software_version) {}};
void operator()(const RawAddress& raw_address,
+ android::bluetooth::AddressTypeEnum address_type,
android::bluetooth::DeviceInfoSrcEnum source_type,
const std::string& source_name,
const std::string& manufacturer, const std::string& model,
const std::string& hardware_version,
const std::string& software_version) {
- body(raw_address, source_type, source_name, manufacturer, model,
- hardware_version, software_version);
+ body(raw_address, address_type, source_type, source_name, manufacturer,
+ model, hardware_version, software_version);
};
};
extern struct LogMetricManufacturerInfo LogMetricManufacturerInfo;
diff --git a/system/test/mock/mock_stack_gatt_connection_manager.cc b/system/test/mock/mock_stack_gatt_connection_manager.cc
index 70505501ca..99f2904289 100644
--- a/system/test/mock/mock_stack_gatt_connection_manager.cc
+++ b/system/test/mock/mock_stack_gatt_connection_manager.cc
@@ -71,11 +71,6 @@ bool connection_manager::remove_unconditional(const RawAddress& address) {
mock_function_count_map[__func__]++;
return false;
}
-bool connection_manager::remove_unconditional_from_shim(
- const RawAddress& address) {
- mock_function_count_map[__func__]++;
- return false;
-}
std::set<tAPP_ID> connection_manager::get_apps_connecting_to(
const RawAddress& address) {
mock_function_count_map[__func__]++;