diff --git a/ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl.cc b/ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl.cc index 15d34c3e36db7c..5199785bd054ec 100644 --- a/ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl.cc +++ b/ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl.cc @@ -524,7 +524,7 @@ void FastPairGattServiceClientImpl::GattDiscoveryCompleteForService( if (pair_failure.has_value()) { NotifyInitializedError(pair_failure.value()); - } else { + } else if (on_initialized_callback_) { is_initialized_ = true; RecordGattInitializationStep( FastPairGattConnectionSteps::kConnectionEstablished); diff --git a/ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl_unittest.cc b/ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl_unittest.cc index 1436d3958a2b89..66750eb7e6b2b6 100644 --- a/ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl_unittest.cc +++ b/ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl_unittest.cc @@ -1291,5 +1291,15 @@ TEST_F(FastPairGattServiceClientTest, WriteEmptyPersonalizedName) { WritePersonalizedName(empty); } +// Regression test for b/300596153 +TEST_F(FastPairGattServiceClientTest, + NoCrashWhenGattDiscoveryCompleteForServiceCalledTwice) { + SuccessfulGattConnectionSetUp(); + NotifyGattDiscoveryCompleteForService( + ash::quick_pair::kFastPairBluetoothUuid); + NotifyGattDiscoveryCompleteForService( + ash::quick_pair::kFastPairBluetoothUuid); +} + } // namespace quick_pair } // namespace ash