Add GetFastPairVersion to DeviceMetadata

PiperOrigin-RevId: 520094589
This commit is contained in:
Qin Wang
2023-03-28 12:03:52 -07:00
committed by Copybara-Service
parent b25314c34c
commit ec0944a61b
+10
View File
@@ -18,6 +18,7 @@
#include <utility>
#include "fastpair/proto/fastpair_rpcs.proto.h"
#include "fastpair/common/fast_pair_device.h"
namespace nearby {
namespace fastpair {
@@ -35,6 +36,15 @@ class DeviceMetadata {
return response_;
}
DeviceFastPairVersion GetFastPairVersion() const {
// Anti-spoofing keys were introduced in Fast Pair v2, so if this isn't
// available then the device is v1.
if (GetDetails().anti_spoofing_key_pair().public_key().empty()) {
return DeviceFastPairVersion::kV1;
}
return DeviceFastPairVersion::kHigherThanV1;
}
private:
const proto::GetObservedDeviceResponse response_;
};