diff --git a/presence/BUILD b/presence/BUILD index 8db4ae9a..261e2864 100644 --- a/presence/BUILD +++ b/presence/BUILD @@ -135,6 +135,9 @@ cc_library( visibility = [ "//third_party/nearby:__subpackages__", ], + deps = [ + "//third_party/nearby/presence/proto:device_metadata_cc_proto", + ], ) cc_test( diff --git a/presence/credential.h b/presence/credential.h index f55ad32e..bae5f544 100644 --- a/presence/credential.h +++ b/presence/credential.h @@ -19,6 +19,8 @@ #include #include +#include "third_party/nearby/presence/proto/device_metadata.pb.h" + namespace nearby { namespace presence { @@ -38,30 +40,6 @@ enum class TrustType { kPublic = 4, }; -enum class DeviceType { - kUnspecified = 0, - kPhone = 1, - kTablet = 2, - kDisplay = 3, - kLaptop = 4, - kTV = 5, - kWatch = 6, -}; - -struct DeviceMetadata { - // Stable device identifier that does not rotate for a few months. - std::string stable_device_id; - // The account name which created the certificate. - std::string account_name; - // The name of the local device when the certificate is created. - std::string device_name; - // The icon url of the user whose device created the certificate. - std::string icon_url; - // The Bluetooth MAC address of the device which created the certificate. - std::string bluetooth_mac_address; - DeviceType device_type; -}; - struct PrivateCredential { TrustType trust_type; @@ -91,7 +69,7 @@ struct PrivateCredential { // The aes key to encrypt DeviceMetadata in public credential. std::vector metadata_encryption_key; - DeviceMetadata device_metadata; + proto::DeviceMetadata device_metadata; }; struct PublicCredential { diff --git a/presence/implementation/credential_manager.h b/presence/implementation/credential_manager.h index e6f281d2..7137c7a7 100644 --- a/presence/implementation/credential_manager.h +++ b/presence/implementation/credential_manager.h @@ -52,7 +52,7 @@ class CredentialManager { // The user’s own public credentials won’t be saved on local credential // storage. void GenerateCredentials( - DeviceMetadata device_metadata, std::vector trust_types, + proto::DeviceMetadata device_metadata, std::vector trust_types, GenerateCredentialsCallback credentials_generated_cb); // Update remote public credentials. diff --git a/presence/proto/BUILD b/presence/proto/BUILD new file mode 100644 index 00000000..99594c2a --- /dev/null +++ b/presence/proto/BUILD @@ -0,0 +1,12 @@ +proto_library( + name = "device_metadata_proto", + srcs = ["device_metadata.proto"], +) + +cc_proto_library( + name = "device_metadata_cc_proto", + visibility = [ + "//third_party/nearby:__subpackages__", + ], + deps = [":device_metadata_proto"], +) diff --git a/presence/proto/device_metadata.proto b/presence/proto/device_metadata.proto new file mode 100644 index 00000000..a45d2dc1 --- /dev/null +++ b/presence/proto/device_metadata.proto @@ -0,0 +1,34 @@ +syntax = "proto2"; + +package nearby.presence.proto; + +// A proto to store the local device's metadata. +message DeviceMetadata { + // Stable device identifier that does not rotate for a few months. + optional string stable_device_id = 1; + + // The account name which created the credential. + optional string account_name = 2; + + // The name of the local device when the credential is created. + optional string device_name = 3; + + // The icon url of the user whose device created the certificate. + optional string icon_url = 4; + + // The Bluetooth MAC address of the device which created the certificate. + optional string bluetooth_mac_address = 5; + + /** The version of the frame. */ + enum DeviceType { + UNSPECIFIED = 0; + PHONE = 1; + TABLET = 2; + DISPLAY = 3; + LAPTOP = 4; + TV = 5; + WATCH = 6; + } + + optional DeviceType device_type = 6; +}