Skip to content

Commit

Permalink
[Fast Pair] Check for empty callback in gatt_service_client_impl
Browse files Browse the repository at this point in the history
Prevent crash if |GattDiscoveryCompleteForService| gets called
more than once with a valid FP service.

BUG=b:300596153
TEST=Unit tests and manual test initial FP with Pixel Buds A and
JBL TUNE230NC TWS.

(cherry picked from commit b2dbd2d)

Change-Id: Ic1e7a5de3054ff540835b8431d27e6b7130408f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4873848
Commit-Queue: Katherine Lai <laikatherine@chromium.org>
Reviewed-by: Juliet Lévesque <julietlevesque@google.com>
Cr-Original-Commit-Position: refs/heads/main@{#1198599}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4889800
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Katherine Lai <laikatherine@chromium.org>
Commit-Queue: Juliet Lévesque <julietlevesque@google.com>
Cr-Commit-Position: refs/branch-heads/5993@{#782}
Cr-Branched-From: 5113507-refs/heads/main@{#1192594}
  • Loading branch information
Katherine Lai authored and Chromium LUCI CQ committed Sep 25, 2023
1 parent c91ee62 commit eb10950
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Expand Up @@ -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);
Expand Down
Expand Up @@ -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

0 comments on commit eb10950

Please sign in to comment.