File: remote_device.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (84 lines) | stat: -rw-r--r-- 3,159 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_ASH_COMPONENTS_MULTIDEVICE_REMOTE_DEVICE_H_
#define CHROMEOS_ASH_COMPONENTS_MULTIDEVICE_REMOTE_DEVICE_H_

#include <map>
#include <string>
#include <vector>

#include "chromeos/ash/components/multidevice/beacon_seed.h"
#include "chromeos/ash/components/multidevice/software_feature.h"
#include "chromeos/ash/components/multidevice/software_feature_state.h"

namespace ash::multidevice {

struct RemoteDevice {
  // Generates the device ID for a device given its public key.
  static std::string GenerateDeviceId(const std::string& public_key);

  // Derives the public key that was used to generate the given device ID;
  // returns empty string if |device_id| is not a valid device ID.
  static std::string DerivePublicKey(const std::string& device_id);

  std::string user_email;

  // The Instance ID is the primary identifier for devices using CryptAuth v2,
  // but the Instance ID is not present in CryptAuth v1. This string is empty
  // for devices not using CryptAuth v2 Enrollment and v2 DeviceSync.
  // TODO(crbug.com/40105247): Remove comments when v1 DeviceSync is
  // disabled.
  std::string instance_id;

  std::string name;
  std::string pii_free_name;
  std::string public_key;
  std::string persistent_symmetric_key;

  // The last time a feature bit changed for the device in the CryptAuth server.
  // Beware that devices don't necessarily flip their own bits, for example,
  // exclusively enabling a feature will disable the bit on all other devices,
  // or a Chromebook can enable/disable a phone's BETTER_TOGETHER_HOST bit.
  // Note: Do not confuse with GetDevicesActivityStatus RPC response's
  // |last_update_time|.
  int64_t last_update_time_millis;

  std::map<SoftwareFeature, SoftwareFeatureState> software_features;
  std::vector<BeaconSeed> beacon_seeds;

  // Bluetooth public address, formatted as a hex string with colons and capital
  // letters (example: "01:23:45:67:89:AB"). If the device does not have a
  // synced address, this field is empty.
  std::string bluetooth_public_address;

  RemoteDevice();
  RemoteDevice(
      const std::string& user_email,
      const std::string& instance_id,
      const std::string& name,
      const std::string& pii_free_name,
      const std::string& public_key,
      const std::string& persistent_symmetric_key,
      int64_t last_update_time_millis,
      const std::map<SoftwareFeature, SoftwareFeatureState>& software_features,
      const std::vector<BeaconSeed>& beacon_seeds,
      const std::string& bluetooth_public_address);
  RemoteDevice(const RemoteDevice& other);
  ~RemoteDevice();

  std::string GetDeviceId() const;

  bool operator==(const RemoteDevice& other) const;

  // If at least one of the RemoteDevices has an Instance ID, compare by that;
  // otherwise, compare by public key.
  bool operator<(const RemoteDevice& other) const;
};

typedef std::vector<RemoteDevice> RemoteDeviceList;

}  // namespace ash::multidevice

#endif  // CHROMEOS_ASH_COMPONENTS_MULTIDEVICE_REMOTE_DEVICE_H_