File: cellular_util.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 (85 lines) | stat: -rw-r--r-- 3,122 bytes parent folder | download | duplicates (6)
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
85
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_TEST_BASE_ASH_INTERACTIVE_CELLULAR_CELLULAR_UTIL_H_
#define CHROME_TEST_BASE_ASH_INTERACTIVE_CELLULAR_CELLULAR_UTIL_H_

#include <optional>
#include <string>

#include "base/values.h"
#include "chromeos/ash/components/network/network_state_handler.h"
#include "chromeos/ash/components/network/network_state_handler_observer.h"
#include "ui/base/interaction/state_observer.h"

namespace ash {

// Helper class to simplify the definition of eUICC constants.
class EuiccInfo {
 public:
  // The `id` parameter is used when generating values for each of the
  // different eUICC properties below.
  explicit EuiccInfo(unsigned int id);
  ~EuiccInfo();

  const std::string& path() const { return path_; }
  const std::string& eid() const { return eid_; }

 private:
  const std::string path_;
  const std::string eid_;
};

// Helper class to simplify the definition of SIM profile constants.
class SimInfo {
 public:
  // The `id` parameter is used when generating values for each of the different
  // SIM properties below.
  explicit SimInfo(unsigned int id);
  ~SimInfo();

  // Connects to the cellular network corresponding to the eSIM profile matching
  // the properties of this class.
  void Connect() const;

  // Disconnects from the cellular network corresponding to the eSIM profile
  // matching the properties of this class.
  void Disconnect() const;

  const std::string& guid() const { return guid_; }
  const std::string& profile_path() const { return profile_path_; }
  const std::string& iccid() const { return iccid_; }
  const std::string& name() const { return name_; }
  const std::string& nickname() const { return nickname_; }
  const std::string& service_provider() const { return service_provider_; }
  const std::string& service_path() const { return service_path_; }
  const std::string& activation_code() const { return activation_code_; }

 private:
  const std::string guid_;
  const std::string profile_path_;
  const std::string iccid_;
  const std::string name_;
  const std::string nickname_;
  const std::string service_provider_;
  const std::string service_path_;
  std::string activation_code_;
};

// Helper function to configure an eSIM profile and corresponding Shill service.
void ConfigureEsimProfile(const EuiccInfo& euicc_info,
                          const SimInfo& esim_info,
                          bool connected);

// Helper function to build a policy dictionary for a particualar cellular
// network. This function implements logic that is normally handled when the
// policy is ingested by ChromeOS but before it is applied; for example,
// automatically marking the `CustomAPNList` property as recommended.
base::Value::Dict GenerateCellularPolicy(const SimInfo& info,
                                         bool allow_apn_modification = true,
                                         bool allow_roaming = true);

}  // namespace ash

#endif  // CHROME_TEST_BASE_ASH_INTERACTIVE_CELLULAR_CELLULAR_UTIL_H_