Loading android/app/src/com/android/bluetooth/gatt/GattService.java +60 −1 Original line number Diff line number Diff line Loading @@ -1334,6 +1334,13 @@ public class GattService extends ProfileService { if (app != null) { app.callback.onClientConnectionState( status, clientIf, (status == BluetoothGatt.GATT_SUCCESS), address); MetricsLogger.getInstance() .logBluetoothEvent( getDevice(address), BluetoothStatsLog .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__GATT_CONNECT_JAVA, connectionStatusToState(status), app.appUid); } statsLogGattConnectionStateChange( BluetoothProfile.GATT, address, clientIf, connectionState, status); Loading Loading @@ -1379,6 +1386,13 @@ public class GattService extends ProfileService { if (app != null) { app.callback.onClientConnectionState(status, clientIf, false, address); MetricsLogger.getInstance() .logBluetoothEvent( getDevice(address), BluetoothStatsLog .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__GATT_DISCONNECT_JAVA, BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__SUCCESS, app.appUid); } statsLogGattConnectionStateChange( BluetoothProfile.GATT, Loading Loading @@ -1930,7 +1944,6 @@ public class GattService extends ProfileService { for (Map.Entry<Integer, String> entry : connMap.entrySet()) { Log.d(TAG, "disconnecting addr:" + entry.getValue()); clientDisconnect(entry.getKey(), entry.getValue(), attributionSource); // clientDisconnect(int clientIf, String address) } } Loading Loading @@ -2156,6 +2169,15 @@ public class GattService extends ProfileService { } Log.d(TAG, "unregisterClient() - clientIf=" + clientIf); for (ContextMap.Connection conn : mClientMap.getConnectionByApp(clientIf)) { MetricsLogger.getInstance() .logBluetoothEvent( getDevice(conn.address), BluetoothStatsLog .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__GATT_DISCONNECT_JAVA, BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__END, attributionSource.getUid()); } mClientMap.remove(clientIf); mNativeInterface.gattClientUnregisterApp(clientIf); } Loading Loading @@ -2198,6 +2220,18 @@ public class GattService extends ProfileService { BluetoothProtoEnums.CONNECTION_STATE_CONNECTING, -1); MetricsLogger.getInstance() .logBluetoothEvent( getDevice(address), BluetoothStatsLog .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__GATT_CONNECT_JAVA, isDirect ? BluetoothStatsLog .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__DIRECT_CONNECT : BluetoothStatsLog .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__INDIRECT_CONNECT, attributionSource.getUid()); int preferredMtu = 0; // Some applications expect MTU to be exchanged immediately on connections Loading Loading @@ -2248,6 +2282,13 @@ public class GattService extends ProfileService { clientIf, BluetoothProtoEnums.CONNECTION_STATE_DISCONNECTING, -1); MetricsLogger.getInstance() .logBluetoothEvent( getDevice(address), BluetoothStatsLog .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__GATT_DISCONNECT_JAVA, BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__START, attributionSource.getUid()); mNativeInterface.gattClientDisconnect(clientIf, address, connId != null ? connId : 0); } Loading Loading @@ -3797,6 +3838,24 @@ public class GattService extends ProfileService { mTransitionalScanHelper.dumpProto(builder); } private BluetoothDevice getDevice(String address) { byte[] addressBytes = Utils.getBytesFromAddress(address); return mAdapterService.getDeviceFromByte(addressBytes); } private static int connectionStatusToState(int status) { return switch (status) { // GATT_SUCCESS case 0x00 -> BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__SUCCESS; // GATT_CONNECTION_TIMEOUT case 0x93 -> BluetoothStatsLog .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__CONNECTION_TIMEOUT; // For now all other errors are bucketed together. default -> BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__FAIL; }; } /************************************************************************** * GATT Test functions *************************************************************************/ Loading system/bta/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -428,6 +428,7 @@ cc_test { "libbluetooth_core_rs_bridge", "libbluetooth_crypto_toolbox", "libbluetooth_gd", "libbluetooth_hci_pdl", "libbluetooth_log", "libbt-audio-hal-interface", "libbt-bta", Loading system/btif/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -504,6 +504,7 @@ cc_test { static_libs: [ "libbluetooth-types", "libbluetooth_core_rs_bridge", "libbluetooth_hci_pdl", "libbluetooth_log", "libbt-platform-protos-lite", "libchrome", Loading Loading @@ -591,6 +592,7 @@ cc_test { "libbluetooth_core_rs_bridge", "libbluetooth_crypto_toolbox", "libbluetooth_gd", "libbluetooth_hci_pdl", "libbluetooth_log", "libbt-audio-hal-interface", "libbt-common", Loading system/gd/Android.bp +13 −0 Original line number Diff line number Diff line Loading @@ -254,7 +254,9 @@ cc_binary { ":BluetoothFacade_hci_hal", ":BluetoothFacade_hci_layer", ":BluetoothFacade_neighbor", ":TestCommonMockFunctions", ":TestMockMainShimStack", ":TestMockStackMetrics", "facade/facade_main.cc", "facade/grpc_root_server.cc", "facade/read_only_property_server.cc", Loading @@ -280,6 +282,7 @@ cc_binary { "libbluetooth_ras_pdl", "libbluetooth_smp_pdl", "libbt-common", "libbt-platform-protos-lite", "libchrome", "libcom.android.sysprop.bluetooth.wrapped", "libflatbuffers-cpp", Loading Loading @@ -425,6 +428,8 @@ cc_test { ":BluetoothOsTestSources", ":BluetoothPacketTestSources", ":BluetoothStorageUnitTestSources", ":TestCommonMockFunctions", ":TestMockStackMetrics", "module_unittest.cc", "stack_manager_unittest.cc", ], Loading Loading @@ -586,8 +591,16 @@ cc_fuzz { name: "bluetooth_gd_acl_manager_fuzz_test", defaults: ["gd_fuzz_defaults"], srcs: [ ":TestCommonMockFunctions", ":TestMockStackMetrics", "hci/fuzz/acl_manager_fuzz_test.cc", ], include_dirs: [ "packages/modules/Bluetooth/system", ], static_libs: [ "libbt-platform-protos-lite", ], fuzz_config: { cc: ["android-bluetooth-security@google.com"], componentid: 27441, Loading system/gd/hci/acl_manager/le_impl.h +6 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ #include "os/alarm.h" #include "os/handler.h" #include "os/system_properties.h" #include "stack/include/stack_metrics_logging.h" namespace bluetooth { namespace hci { Loading Loading @@ -404,6 +405,8 @@ public: return; } log_le_connection_status(address, true /* is_connect */, status); const bool in_filter_accept_list = is_device_in_accept_list(remote_address); if (role == hci::Role::CENTRAL) { Loading Loading @@ -560,6 +563,7 @@ public: arm_on_resume_ = true; add_device_to_accept_list(remote_address); } log_le_connection_status(remote_address.GetAddress(), false /* is_connect */, reason); } void on_le_connection_update_complete(LeMetaEventView view) { Loading Loading @@ -697,6 +701,7 @@ public: } void add_device_to_accept_list(AddressWithType address_with_type) { log_le_device_in_accept_list(address_with_type.GetAddress(), true /* is_add */); if (connections.alreadyConnected(address_with_type)) { log::info("Device already connected, return"); return; Loading @@ -719,6 +724,7 @@ public: } void remove_device_from_accept_list(AddressWithType address_with_type) { log_le_device_in_accept_list(address_with_type.GetAddress(), false /* is_add */); if (accept_list.find(address_with_type) == accept_list.end()) { log::warn("Device not in acceptlist and cannot be removed: {}", address_with_type); return; Loading Loading
android/app/src/com/android/bluetooth/gatt/GattService.java +60 −1 Original line number Diff line number Diff line Loading @@ -1334,6 +1334,13 @@ public class GattService extends ProfileService { if (app != null) { app.callback.onClientConnectionState( status, clientIf, (status == BluetoothGatt.GATT_SUCCESS), address); MetricsLogger.getInstance() .logBluetoothEvent( getDevice(address), BluetoothStatsLog .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__GATT_CONNECT_JAVA, connectionStatusToState(status), app.appUid); } statsLogGattConnectionStateChange( BluetoothProfile.GATT, address, clientIf, connectionState, status); Loading Loading @@ -1379,6 +1386,13 @@ public class GattService extends ProfileService { if (app != null) { app.callback.onClientConnectionState(status, clientIf, false, address); MetricsLogger.getInstance() .logBluetoothEvent( getDevice(address), BluetoothStatsLog .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__GATT_DISCONNECT_JAVA, BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__SUCCESS, app.appUid); } statsLogGattConnectionStateChange( BluetoothProfile.GATT, Loading Loading @@ -1930,7 +1944,6 @@ public class GattService extends ProfileService { for (Map.Entry<Integer, String> entry : connMap.entrySet()) { Log.d(TAG, "disconnecting addr:" + entry.getValue()); clientDisconnect(entry.getKey(), entry.getValue(), attributionSource); // clientDisconnect(int clientIf, String address) } } Loading Loading @@ -2156,6 +2169,15 @@ public class GattService extends ProfileService { } Log.d(TAG, "unregisterClient() - clientIf=" + clientIf); for (ContextMap.Connection conn : mClientMap.getConnectionByApp(clientIf)) { MetricsLogger.getInstance() .logBluetoothEvent( getDevice(conn.address), BluetoothStatsLog .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__GATT_DISCONNECT_JAVA, BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__END, attributionSource.getUid()); } mClientMap.remove(clientIf); mNativeInterface.gattClientUnregisterApp(clientIf); } Loading Loading @@ -2198,6 +2220,18 @@ public class GattService extends ProfileService { BluetoothProtoEnums.CONNECTION_STATE_CONNECTING, -1); MetricsLogger.getInstance() .logBluetoothEvent( getDevice(address), BluetoothStatsLog .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__GATT_CONNECT_JAVA, isDirect ? BluetoothStatsLog .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__DIRECT_CONNECT : BluetoothStatsLog .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__INDIRECT_CONNECT, attributionSource.getUid()); int preferredMtu = 0; // Some applications expect MTU to be exchanged immediately on connections Loading Loading @@ -2248,6 +2282,13 @@ public class GattService extends ProfileService { clientIf, BluetoothProtoEnums.CONNECTION_STATE_DISCONNECTING, -1); MetricsLogger.getInstance() .logBluetoothEvent( getDevice(address), BluetoothStatsLog .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__EVENT_TYPE__GATT_DISCONNECT_JAVA, BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__START, attributionSource.getUid()); mNativeInterface.gattClientDisconnect(clientIf, address, connId != null ? connId : 0); } Loading Loading @@ -3797,6 +3838,24 @@ public class GattService extends ProfileService { mTransitionalScanHelper.dumpProto(builder); } private BluetoothDevice getDevice(String address) { byte[] addressBytes = Utils.getBytesFromAddress(address); return mAdapterService.getDeviceFromByte(addressBytes); } private static int connectionStatusToState(int status) { return switch (status) { // GATT_SUCCESS case 0x00 -> BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__SUCCESS; // GATT_CONNECTION_TIMEOUT case 0x93 -> BluetoothStatsLog .BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__CONNECTION_TIMEOUT; // For now all other errors are bucketed together. default -> BluetoothStatsLog.BLUETOOTH_CROSS_LAYER_EVENT_REPORTED__STATE__FAIL; }; } /************************************************************************** * GATT Test functions *************************************************************************/ Loading
system/bta/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -428,6 +428,7 @@ cc_test { "libbluetooth_core_rs_bridge", "libbluetooth_crypto_toolbox", "libbluetooth_gd", "libbluetooth_hci_pdl", "libbluetooth_log", "libbt-audio-hal-interface", "libbt-bta", Loading
system/btif/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -504,6 +504,7 @@ cc_test { static_libs: [ "libbluetooth-types", "libbluetooth_core_rs_bridge", "libbluetooth_hci_pdl", "libbluetooth_log", "libbt-platform-protos-lite", "libchrome", Loading Loading @@ -591,6 +592,7 @@ cc_test { "libbluetooth_core_rs_bridge", "libbluetooth_crypto_toolbox", "libbluetooth_gd", "libbluetooth_hci_pdl", "libbluetooth_log", "libbt-audio-hal-interface", "libbt-common", Loading
system/gd/Android.bp +13 −0 Original line number Diff line number Diff line Loading @@ -254,7 +254,9 @@ cc_binary { ":BluetoothFacade_hci_hal", ":BluetoothFacade_hci_layer", ":BluetoothFacade_neighbor", ":TestCommonMockFunctions", ":TestMockMainShimStack", ":TestMockStackMetrics", "facade/facade_main.cc", "facade/grpc_root_server.cc", "facade/read_only_property_server.cc", Loading @@ -280,6 +282,7 @@ cc_binary { "libbluetooth_ras_pdl", "libbluetooth_smp_pdl", "libbt-common", "libbt-platform-protos-lite", "libchrome", "libcom.android.sysprop.bluetooth.wrapped", "libflatbuffers-cpp", Loading Loading @@ -425,6 +428,8 @@ cc_test { ":BluetoothOsTestSources", ":BluetoothPacketTestSources", ":BluetoothStorageUnitTestSources", ":TestCommonMockFunctions", ":TestMockStackMetrics", "module_unittest.cc", "stack_manager_unittest.cc", ], Loading Loading @@ -586,8 +591,16 @@ cc_fuzz { name: "bluetooth_gd_acl_manager_fuzz_test", defaults: ["gd_fuzz_defaults"], srcs: [ ":TestCommonMockFunctions", ":TestMockStackMetrics", "hci/fuzz/acl_manager_fuzz_test.cc", ], include_dirs: [ "packages/modules/Bluetooth/system", ], static_libs: [ "libbt-platform-protos-lite", ], fuzz_config: { cc: ["android-bluetooth-security@google.com"], componentid: 27441, Loading
system/gd/hci/acl_manager/le_impl.h +6 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ #include "os/alarm.h" #include "os/handler.h" #include "os/system_properties.h" #include "stack/include/stack_metrics_logging.h" namespace bluetooth { namespace hci { Loading Loading @@ -404,6 +405,8 @@ public: return; } log_le_connection_status(address, true /* is_connect */, status); const bool in_filter_accept_list = is_device_in_accept_list(remote_address); if (role == hci::Role::CENTRAL) { Loading Loading @@ -560,6 +563,7 @@ public: arm_on_resume_ = true; add_device_to_accept_list(remote_address); } log_le_connection_status(remote_address.GetAddress(), false /* is_connect */, reason); } void on_le_connection_update_complete(LeMetaEventView view) { Loading Loading @@ -697,6 +701,7 @@ public: } void add_device_to_accept_list(AddressWithType address_with_type) { log_le_device_in_accept_list(address_with_type.GetAddress(), true /* is_add */); if (connections.alreadyConnected(address_with_type)) { log::info("Device already connected, return"); return; Loading @@ -719,6 +724,7 @@ public: } void remove_device_from_accept_list(AddressWithType address_with_type) { log_le_device_in_accept_list(address_with_type.GetAddress(), false /* is_add */); if (accept_list.find(address_with_type) == accept_list.end()) { log::warn("Device not in acceptlist and cannot be removed: {}", address_with_type); return; Loading