mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Add Pair failure info for fast pair pairing
PiperOrigin-RevId: 527087848
This commit is contained in:
committed by
Copybara-Service
parent
748dcc4a43
commit
a826f2d627
@@ -39,3 +39,17 @@ cc_test(
|
|||||||
"@com_google_googletest//:gtest_main",
|
"@com_google_googletest//:gtest_main",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "pair_failure_test",
|
||||||
|
size = "small",
|
||||||
|
srcs = [
|
||||||
|
"pair_failure_test.cc",
|
||||||
|
],
|
||||||
|
shard_count = 16,
|
||||||
|
deps = [
|
||||||
|
":common",
|
||||||
|
"@com_github_protobuf_matchers//protobuf-matchers",
|
||||||
|
"@com_google_googletest//:gtest_main",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|||||||
@@ -90,6 +90,15 @@ std::ostream& operator<<(std::ostream& stream, PairFailure failure) {
|
|||||||
stream
|
stream
|
||||||
<< "[Potential pairing device lost between GATT connection attempts]";
|
<< "[Potential pairing device lost between GATT connection attempts]";
|
||||||
break;
|
break;
|
||||||
|
case PairFailure::kDeviceLostMidPairing:
|
||||||
|
stream << "[Potential pairing device lost during pairing.]";
|
||||||
|
break;
|
||||||
|
case PairFailure::kPairingAndConnect:
|
||||||
|
stream << "[Failed to pair with discovered device.]";
|
||||||
|
break;
|
||||||
|
case PairFailure::kPairingTimeout:
|
||||||
|
stream << "[Potential pairing failed with timeout.]";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
|
|||||||
@@ -68,7 +68,13 @@ enum class PairFailure {
|
|||||||
kPasskeyMismatch = 19,
|
kPasskeyMismatch = 19,
|
||||||
// Potential pairing device lost between GATT connection attempts.
|
// Potential pairing device lost between GATT connection attempts.
|
||||||
kPairingDeviceLostBetweenGattConnectionAttempts = 20,
|
kPairingDeviceLostBetweenGattConnectionAttempts = 20,
|
||||||
kMaxValue = kPairingDeviceLostBetweenGattConnectionAttempts,
|
// Potential pairing device lost during pairing.
|
||||||
|
kDeviceLostMidPairing = 21,
|
||||||
|
// Failed to pair and connect with discovered device.
|
||||||
|
kPairingAndConnect = 22,
|
||||||
|
// Potential pairing timeout.
|
||||||
|
kPairingTimeout = 23,
|
||||||
|
kMaxValue = kPairingTimeout,
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& stream, PairFailure failure);
|
std::ostream& operator<<(std::ostream& stream, PairFailure failure);
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
// Copyright 2023 Google LLC
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "fastpair/common/pair_failure.h"
|
||||||
|
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
namespace nearby {
|
||||||
|
namespace fastpair {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
TEST(PairFailureTest, PairFailureValue) {
|
||||||
|
EXPECT_EQ(static_cast<int>(PairFailure::kCreateGattConnection), 0);
|
||||||
|
EXPECT_EQ(static_cast<int>(PairFailure::kGattServiceDiscovery), 1);
|
||||||
|
EXPECT_EQ(static_cast<int>(PairFailure::kGattServiceDiscoveryTimeout), 2);
|
||||||
|
EXPECT_EQ(static_cast<int>(PairFailure::kDataEncryptorRetrieval), 3);
|
||||||
|
EXPECT_EQ(
|
||||||
|
static_cast<int>(PairFailure::kKeyBasedPairingCharacteristicDiscovery),
|
||||||
|
4);
|
||||||
|
EXPECT_EQ(static_cast<int>(PairFailure::kPasskeyCharacteristicDiscovery), 5);
|
||||||
|
EXPECT_EQ(static_cast<int>(PairFailure::kAccountKeyCharacteristicDiscovery),
|
||||||
|
6);
|
||||||
|
EXPECT_EQ(
|
||||||
|
static_cast<int>(PairFailure::kKeyBasedPairingCharacteristicSubscription),
|
||||||
|
7);
|
||||||
|
EXPECT_EQ(static_cast<int>(PairFailure::kPasskeyCharacteristicSubscription),
|
||||||
|
8);
|
||||||
|
EXPECT_EQ(static_cast<int>(
|
||||||
|
PairFailure::kKeyBasedPairingCharacteristicSubscriptionTimeout),
|
||||||
|
9);
|
||||||
|
EXPECT_EQ(
|
||||||
|
static_cast<int>(PairFailure::kPasskeyCharacteristicSubscriptionTimeout),
|
||||||
|
10);
|
||||||
|
EXPECT_EQ(static_cast<int>(PairFailure::kKeyBasedPairingCharacteristicWrite),
|
||||||
|
11);
|
||||||
|
EXPECT_EQ(static_cast<int>(PairFailure::kPasskeyPairingCharacteristicWrite),
|
||||||
|
12);
|
||||||
|
EXPECT_EQ(static_cast<int>(PairFailure::kKeyBasedPairingResponseTimeout), 13);
|
||||||
|
EXPECT_EQ(static_cast<int>(PairFailure::kPasskeyResponseTimeout), 14);
|
||||||
|
EXPECT_EQ(
|
||||||
|
static_cast<int>(PairFailure::kKeybasedPairingResponseDecryptFailure),
|
||||||
|
15);
|
||||||
|
EXPECT_EQ(
|
||||||
|
static_cast<int>(PairFailure::kIncorrectKeyBasedPairingResponseType), 16);
|
||||||
|
EXPECT_EQ(static_cast<int>(PairFailure::kPasskeyDecryptFailure), 17);
|
||||||
|
EXPECT_EQ(static_cast<int>(PairFailure::kIncorrectPasskeyResponseType), 18);
|
||||||
|
EXPECT_EQ(static_cast<int>(PairFailure::kPasskeyMismatch), 19);
|
||||||
|
EXPECT_EQ(static_cast<int>(
|
||||||
|
PairFailure::kPairingDeviceLostBetweenGattConnectionAttempts),
|
||||||
|
20);
|
||||||
|
EXPECT_EQ(static_cast<int>(PairFailure::kDeviceLostMidPairing), 21);
|
||||||
|
EXPECT_EQ(static_cast<int>(PairFailure::kPairingAndConnect), 22);
|
||||||
|
EXPECT_EQ(static_cast<int>(PairFailure::kPairingTimeout), 23);
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
} // namespace fastpair
|
||||||
|
} // namespace nearby
|
||||||
Reference in New Issue
Block a user