Change device metadata from struct to proto.

PiperOrigin-RevId: 463583244
This commit is contained in:
hai007
2022-07-27 07:44:54 -07:00
committed by Copybara-Service
parent 3ed4bfcfe1
commit d4b40ed9a7
5 changed files with 53 additions and 26 deletions
+3
View File
@@ -135,6 +135,9 @@ cc_library(
visibility = [
"//third_party/nearby:__subpackages__",
],
deps = [
"//third_party/nearby/presence/proto:device_metadata_cc_proto",
],
)
cc_test(
+3 -25
View File
@@ -19,6 +19,8 @@
#include <string>
#include <vector>
#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<uint8_t> metadata_encryption_key;
DeviceMetadata device_metadata;
proto::DeviceMetadata device_metadata;
};
struct PublicCredential {
+1 -1
View File
@@ -52,7 +52,7 @@ class CredentialManager {
// The users own public credentials wont be saved on local credential
// storage.
void GenerateCredentials(
DeviceMetadata device_metadata, std::vector<TrustType> trust_types,
proto::DeviceMetadata device_metadata, std::vector<TrustType> trust_types,
GenerateCredentialsCallback credentials_generated_cb);
// Update remote public credentials.
+12
View File
@@ -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"],
)
+34
View File
@@ -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;
}