mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Update action bits to match spec
PiperOrigin-RevId: 531266917
This commit is contained in:
committed by
Copybara-Service
parent
7825f2c67a
commit
813a07116e
@@ -30,14 +30,12 @@ namespace presence {
|
||||
enum class ActionBit {
|
||||
kActiveUnlockAction = 8,
|
||||
kNearbyShareAction = 9,
|
||||
kFitCastAction = 10,
|
||||
kPresenceManagerAction = 11,
|
||||
kInstantTetheringAction = 12,
|
||||
kCrossDeviceCallingAction = 13,
|
||||
kPhoneHubAction = 14,
|
||||
kInstantTetheringAction = 10,
|
||||
kPhoneHubAction = 11,
|
||||
kPresenceManagerAction = 12,
|
||||
kFinderAction = 13,
|
||||
kFastPairSassAction = 14,
|
||||
kTapToTransferAction = 15,
|
||||
kEddystoneAction = 16,
|
||||
kFastPairAction = 17,
|
||||
kLastAction
|
||||
};
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace {
|
||||
using ::testing::ElementsAre;
|
||||
|
||||
constexpr uint32_t kActiveUnlockBitMask = 1 << 23;
|
||||
constexpr uint32_t kFastPairBitMask = 1 << 14;
|
||||
constexpr uint32_t kFastPairBitMask = 1 << 17;
|
||||
|
||||
TEST(ActionFactory, CreateActiveUnlockAction) {
|
||||
std::vector<DataElement> data_elements;
|
||||
@@ -71,7 +71,7 @@ TEST(ActionFactory, CreateContextTimestampAndFastPair) {
|
||||
std::vector<DataElement> data_elements;
|
||||
data_elements.emplace_back(DataElement::kContextTimestampFieldType,
|
||||
kTimestamp);
|
||||
data_elements.emplace_back(ActionBit::kFastPairAction);
|
||||
data_elements.emplace_back(ActionBit::kFastPairSassAction);
|
||||
|
||||
Action action = ActionFactory::CreateAction(data_elements);
|
||||
|
||||
@@ -99,7 +99,7 @@ TEST(ActionFactory, DecodeContextTimestampAndFastPair) {
|
||||
data_elements,
|
||||
ElementsAre(DataElement(DataElement::kContextTimestampFieldType,
|
||||
absl::HexStringToBytes("0B")),
|
||||
DataElement(DataElement(ActionBit::kFastPairAction))));
|
||||
DataElement(DataElement(ActionBit::kFastPairSassAction))));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -237,7 +237,6 @@ TEST(AdvertisementDecoder, DecodeBaseNpWithTxAndActionFields) {
|
||||
absl::HexStringToBytes("50")),
|
||||
DataElement(DataElement::kContextTimestampFieldType,
|
||||
absl::HexStringToBytes("0B")),
|
||||
DataElement(DataElement(ActionBit::kEddystoneAction)),
|
||||
DataElement(DataElement(ActionBit::kTapToTransferAction)),
|
||||
DataElement(DataElement(ActionBit::kNearbyShareAction))));
|
||||
}
|
||||
@@ -388,10 +387,10 @@ TEST(AdvertisementDecoder, MatchesLegacyPresenceScanFilterWithActions) {
|
||||
DataElement model_id =
|
||||
DataElement(DataElement::kModelIdFieldType, "model id");
|
||||
DataElement salt = DataElement(DataElement::kSaltFieldType, "salt");
|
||||
DataElement eddystone_action = DataElement(ActionBit::kEddystoneAction);
|
||||
DataElement ttt_action = DataElement(ActionBit::kTapToTransferAction);
|
||||
LegacyPresenceScanFilter filter = {
|
||||
.actions = {static_cast<int>(ActionBit::kActiveUnlockAction),
|
||||
static_cast<int>(ActionBit::kEddystoneAction)},
|
||||
static_cast<int>(ActionBit::kTapToTransferAction)},
|
||||
.extended_properties = {model_id, salt}};
|
||||
|
||||
AdvertisementDecoder decoder(
|
||||
@@ -399,7 +398,7 @@ TEST(AdvertisementDecoder, MatchesLegacyPresenceScanFilterWithActions) {
|
||||
ScanRequestBuilder().AddScanFilter(filter).Build());
|
||||
|
||||
EXPECT_FALSE(decoder.MatchesScanFilter({salt, model_id}));
|
||||
EXPECT_TRUE(decoder.MatchesScanFilter({salt, eddystone_action, model_id}));
|
||||
EXPECT_TRUE(decoder.MatchesScanFilter({salt, ttt_action, model_id}));
|
||||
}
|
||||
|
||||
TEST(AdvertisementDecoder, MatchesMultipleFilters) {
|
||||
@@ -408,11 +407,11 @@ TEST(AdvertisementDecoder, MatchesMultipleFilters) {
|
||||
DataElement model_id =
|
||||
DataElement(DataElement::kModelIdFieldType, "model id");
|
||||
DataElement salt = DataElement(DataElement::kSaltFieldType, "salt");
|
||||
DataElement eddystone_action = DataElement(ActionBit::kEddystoneAction);
|
||||
DataElement ttt_action = DataElement(ActionBit::kTapToTransferAction);
|
||||
PresenceScanFilter presence_filter = {.extended_properties = {model_id}};
|
||||
LegacyPresenceScanFilter legacy_filter = {
|
||||
.actions = {static_cast<int>(ActionBit::kActiveUnlockAction),
|
||||
static_cast<int>(ActionBit::kEddystoneAction)},
|
||||
static_cast<int>(ActionBit::kTapToTransferAction)},
|
||||
.extended_properties = {salt}};
|
||||
|
||||
AdvertisementDecoder decoder(ScanRequestBuilder()
|
||||
@@ -421,8 +420,8 @@ TEST(AdvertisementDecoder, MatchesMultipleFilters) {
|
||||
.Build());
|
||||
|
||||
EXPECT_TRUE(decoder.MatchesScanFilter({model_id}));
|
||||
EXPECT_TRUE(decoder.MatchesScanFilter({salt, eddystone_action}));
|
||||
EXPECT_FALSE(decoder.MatchesScanFilter({eddystone_action}));
|
||||
EXPECT_TRUE(decoder.MatchesScanFilter({salt, ttt_action}));
|
||||
EXPECT_FALSE(decoder.MatchesScanFilter({ttt_action}));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -86,7 +86,7 @@ TEST(AdvertisementFactory, CreateAdvertisementFromTrustedIdentity) {
|
||||
constexpr IdentityType kIdentity = IdentityType::IDENTITY_TYPE_TRUSTED;
|
||||
std::vector<DataElement> data_elements;
|
||||
data_elements.emplace_back(ActionBit::kActiveUnlockAction);
|
||||
data_elements.emplace_back(ActionBit::kFitCastAction);
|
||||
data_elements.emplace_back(ActionBit::kPresenceManagerAction);
|
||||
Action action = ActionFactory::CreateAction(data_elements);
|
||||
BaseBroadcastRequest request =
|
||||
BaseBroadcastRequest(BasePresenceRequestBuilder(kIdentity)
|
||||
@@ -102,7 +102,7 @@ TEST(AdvertisementFactory, CreateAdvertisementFromTrustedIdentity) {
|
||||
ASSERT_OK(result);
|
||||
EXPECT_FALSE(result->is_extended_advertisement);
|
||||
EXPECT_EQ(absl::BytesToHexString(result->content),
|
||||
"00524142099500aeef8bff5df05169a79726e11563b865");
|
||||
"005241428b213e608c378e9941444dcfbedfcb6958a73d");
|
||||
}
|
||||
|
||||
TEST(AdvertisementFactory, CreateAdvertisementFromProvisionedIdentity) {
|
||||
@@ -111,7 +111,7 @@ TEST(AdvertisementFactory, CreateAdvertisementFromProvisionedIdentity) {
|
||||
constexpr IdentityType kIdentity = IdentityType::IDENTITY_TYPE_PROVISIONED;
|
||||
std::vector<DataElement> data_elements;
|
||||
data_elements.emplace_back(ActionBit::kActiveUnlockAction);
|
||||
data_elements.emplace_back(ActionBit::kFitCastAction);
|
||||
data_elements.emplace_back(ActionBit::kPresenceManagerAction);
|
||||
Action action = ActionFactory::CreateAction(data_elements);
|
||||
BaseBroadcastRequest request =
|
||||
BaseBroadcastRequest(BasePresenceRequestBuilder(kIdentity)
|
||||
@@ -127,7 +127,7 @@ TEST(AdvertisementFactory, CreateAdvertisementFromProvisionedIdentity) {
|
||||
ASSERT_OK(result);
|
||||
EXPECT_FALSE(result->is_extended_advertisement);
|
||||
EXPECT_EQ(absl::BytesToHexString(result->content),
|
||||
"00544142099500aeef8bff5df05169a79726e11563b865");
|
||||
"005441428b213e608c378e9941444dcfbedfcb6958a73d");
|
||||
}
|
||||
#endif /*USE_RUST_LDT*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user