Commit ce7367c8 authored by Azeem Arshad's avatar Azeem Arshad Committed by Commit Bot

[CrOS Cellular] Add ESimManager mojo interface

This CL adds ESimManager class and mojo interface.
ESimManager communicates with Hermes, the ChromeOS
eSIM LPA daemon, to provide eSIM management methods
over mojo. See http://go/cros-esim-design-doc for
details.

An in-process instance of ESimManager is owned in Ash
in the same way as network_config service.

Bug: 1093185
Change-Id: I444ae644d020c7df7eea68025d1cb479cdec7c11
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315925
Commit-Queue: Azeem Arshad <azeemarshad@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798685}
parent 52c4880c
...@@ -117,6 +117,8 @@ component("cpp") { ...@@ -117,6 +117,8 @@ component("cpp") {
"default_scale_factor_retriever.h", "default_scale_factor_retriever.h",
"desks_helper.cc", "desks_helper.cc",
"desks_helper.h", "desks_helper.h",
"esim_manager.cc",
"esim_manager.h",
"fps_counter.cc", "fps_counter.cc",
"fps_counter.h", "fps_counter.h",
"frame_header.cc", "frame_header.cc",
...@@ -306,6 +308,7 @@ component("cpp") { ...@@ -306,6 +308,7 @@ component("cpp") {
"//chromeos/constants", "//chromeos/constants",
"//chromeos/dbus/power:power_manager_proto", "//chromeos/dbus/power:power_manager_proto",
"//chromeos/services/assistant/public/cpp", "//chromeos/services/assistant/public/cpp",
"//chromeos/services/cellular_setup:in_process_esim_manager",
"//chromeos/services/network_config:in_process_instance", "//chromeos/services/network_config:in_process_instance",
"//components/prefs", "//components/prefs",
"//components/sync:rest_of_sync", "//components/sync:rest_of_sync",
...@@ -330,6 +333,7 @@ component("cpp") { ...@@ -330,6 +333,7 @@ component("cpp") {
"//base", "//base",
"//chromeos/components/security_token_pin", "//chromeos/components/security_token_pin",
"//chromeos/services/assistant/public/mojom", "//chromeos/services/assistant/public/mojom",
"//chromeos/services/cellular_setup/public/mojom",
"//chromeos/services/network_config/public/mojom", "//chromeos/services/network_config/public/mojom",
"//components/arc/mojom:notifications", "//components/arc/mojom:notifications",
"//components/session_manager:base", "//components/session_manager:base",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/public/cpp/esim_manager.h"
#include "chromeos/services/cellular_setup/in_process_esim_manager.h"
namespace ash {
void GetESimManager(
mojo::PendingReceiver<chromeos::cellular_setup::mojom::ESimManager>
receiver) {
chromeos::cellular_setup::BindToInProcessESimManager(std::move(receiver));
}
} // namespace ash
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_PUBLIC_CPP_ESIM_MANAGER_H_
#define ASH_PUBLIC_CPP_ESIM_MANAGER_H_
#include "ash/public/cpp/ash_public_export.h"
#include "chromeos/services/cellular_setup/public/mojom/esim_manager.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
namespace ash {
ASH_PUBLIC_EXPORT void GetESimManager(
mojo::PendingReceiver<chromeos::cellular_setup::mojom::ESimManager>
receiver);
} // namespace ash
#endif // ASH_PUBLIC_CPP_ESIM_MANAGER_H_
...@@ -26,6 +26,42 @@ static_library("cellular_setup") { ...@@ -26,6 +26,42 @@ static_library("cellular_setup") {
] ]
} }
static_library("esim_manager") {
sources = [
"esim_manager.cc",
"esim_manager.h",
]
deps = [
"//base",
"//chromeos/dbus/hermes",
"//chromeos/services/cellular_setup/public/mojom",
"//components/device_event_log",
"//dbus",
]
}
component("in_process_esim_manager") {
sources = [
"in_process_esim_manager.cc",
"in_process_esim_manager.h",
]
defines = [ "IS_IN_PROCESS_ESIM_MANAGER_IMPL" ]
public_deps = [
"//chromeos/services/cellular_setup/public/mojom",
"//mojo/public/cpp/bindings",
]
deps = [
":esim_manager",
"//chromeos/services/cellular_setup/public/mojom",
"//dbus",
"//mojo/public/cpp/bindings",
]
}
static_library("test_support") { static_library("test_support") {
testonly = true testonly = true
...@@ -47,17 +83,21 @@ source_set("unit_tests") { ...@@ -47,17 +83,21 @@ source_set("unit_tests") {
sources = [ sources = [
"cellular_setup_impl_unittest.cc", "cellular_setup_impl_unittest.cc",
"cellular_setup_service_unittest.cc", "cellular_setup_service_unittest.cc",
"esim_manager_unittest.cc",
"ota_activator_impl_unittest.cc", "ota_activator_impl_unittest.cc",
] ]
deps = [ deps = [
":cellular_setup", ":cellular_setup",
":esim_manager",
":test_support", ":test_support",
"//base", "//base",
"//base/test:test_support", "//base/test:test_support",
"//chromeos/dbus/hermes",
"//chromeos/dbus/shill", "//chromeos/dbus/shill",
"//chromeos/network:test_support", "//chromeos/network:test_support",
"//chromeos/services/cellular_setup/public/cpp:test_support", "//chromeos/services/cellular_setup/public/cpp:test_support",
"//dbus",
"//testing/gmock", "//testing/gmock",
"//testing/gtest", "//testing/gtest",
] ]
......
This diff is collapsed.
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_SERVICES_CELLULAR_SETUP_ESIM_MANAGER_H_
#define CHROMEOS_SERVICES_CELLULAR_SETUP_ESIM_MANAGER_H_
#include "base/memory/weak_ptr.h"
#include "chromeos/dbus/hermes/hermes_euicc_client.h"
#include "chromeos/dbus/hermes/hermes_manager_client.h"
#include "chromeos/dbus/hermes/hermes_profile_client.h"
#include "chromeos/services/cellular_setup/public/mojom/esim_manager.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote_set.h"
namespace chromeos {
namespace cellular_setup {
// Implementation of mojom::ESimManager. This class uses the Hermes
// DBus clients to communicate with the Hermes daemon and provide
// eSIM management methods. ESimManager mojo interface is provided
// in WebUI for cellular settings and eSIM setup.
class ESimManager : public mojom::ESimManager,
HermesManagerClient::Observer,
HermesEuiccClient::Observer,
HermesProfileClient::Observer {
public:
ESimManager();
ESimManager(const ESimManager&) = delete;
ESimManager& operator=(const ESimManager&) = delete;
~ESimManager() override;
void BindReceiver(mojo::PendingReceiver<mojom::ESimManager> receiver);
// mojom::ESimManager
void AddObserver(
mojo::PendingRemote<mojom::ESimManagerObserver> observer) override;
void GetAvailableEuiccs(GetAvailableEuiccsCallback callback) override;
void GetProfiles(const std::string& eid,
GetProfilesCallback callback) override;
void RequestPendingProfiles(const std::string& eid,
RequestPendingProfilesCallback callback) override;
void InstallProfileFromActivationCode(
const std::string& eid,
const std::string& activation_code,
const std::string& confirmation_code,
InstallProfileFromActivationCodeCallback callback) override;
void InstallProfile(const std::string& iccid,
const std::string& confirmation_code,
InstallProfileCallback callback) override;
void UninstallProfile(const std::string& iccid,
UninstallProfileCallback callback) override;
void EnableProfile(const std::string& iccid,
EnableProfileCallback callback) override;
void DisableProfile(const std::string& iccid,
DisableProfileCallback callback) override;
void SetProfileNickname(const std::string& iccid,
const base::string16& nickname,
SetProfileNicknameCallback callback) override;
// HermesManagerClient::Observer:
void OnAvailableEuiccListChanged() override;
// HermesEuiccClient::Observer:
void OnEuiccPropertyChanged(const dbus::ObjectPath& euicc_path,
const std::string& property_name) override;
// HermesProfileClient::Observer:
void OnCarrierProfilePropertyChanged(
const dbus::ObjectPath& carrier_profile_path,
const std::string& property_name) override;
private:
// EuiccInfo object is used to track state of Hermes Euicc objects.
// It holds mojom::Euicc object along with other related values.
class EuiccInfo {
public:
EuiccInfo(const dbus::ObjectPath& path,
HermesEuiccClient::Properties* properties);
~EuiccInfo();
// Returns a boolean indicating whether |iccid| exists
// in installed or pending profiles for this Euicc.
bool ContainsIccid(const std::string& iccid);
void CopyProperties(HermesEuiccClient::Properties* properties);
mojom::Euicc* euicc() { return euicc_.get(); }
const dbus::ObjectPath& path() { return path_; }
void set_profile_iccids(const std::set<std::string>& profile_iccids) {
profile_iccids_ = std::move(profile_iccids);
}
const std::set<std::string>& profile_iccids() { return profile_iccids_; }
private:
mojom::EuiccPtr euicc_;
dbus::ObjectPath path_;
std::set<std::string> profile_iccids_;
};
// ESimProfileInfo is used to track state of Hermes Profile objects.
// It holds mojom::ESimProfile object along with other related values.
class ESimProfileInfo {
public:
ESimProfileInfo(const dbus::ObjectPath& path,
const std::string& eid,
HermesProfileClient::Properties* properties);
~ESimProfileInfo();
void CopyProperties(HermesProfileClient::Properties* properties);
mojom::ESimProfile* esim_profile() { return esim_profile_.get(); }
const dbus::ObjectPath& path() { return path_; }
private:
mojom::ESimProfilePtr esim_profile_;
dbus::ObjectPath path_;
};
// Type of callback for profile installation methods.
using ProfileInstallResultCallback =
base::OnceCallback<void(mojom::ESimManager::ProfileInstallResult,
mojom::ESimProfilePtr)>;
// Type of callback for other esim manager methods.
using ESimOperationResultCallback =
base::OnceCallback<void(mojom::ESimManager::ESimOperationResult)>;
void CallInstallPendingProfile(ESimProfileInfo* profile_info,
const std::string& confirmation_code,
ProfileInstallResultCallback callback);
void OnRequestPendingEventsResult(RequestPendingProfilesCallback callback,
HermesResponseStatus status);
void OnPendingProfileInstallResult(ProfileInstallResultCallback callback,
ESimProfileInfo* profile_info,
HermesResponseStatus status);
void OnProfileInstallResult(ProfileInstallResultCallback callback,
const std::string& eid,
HermesResponseStatus status,
const dbus::ObjectPath* object_path);
void OnESimOperationResult(ESimOperationResultCallback callback,
HermesResponseStatus status);
void OnProfilePropertySet(ESimOperationResultCallback callback, bool success);
void UpdateAvailableEuiccs();
void UpdateProfileList(EuiccInfo* euicc_info);
void RemoveUntrackedEuiccs();
void RemoveUntrackedProfiles(EuiccInfo* euicc_info);
EuiccInfo* GetOrCreateEuiccInfo(HermesEuiccClient::Properties* properties,
const dbus::ObjectPath& euicc_path);
ESimProfileInfo* GetOrCreateESimProfileInfo(
HermesProfileClient::Properties* properties,
const dbus::ObjectPath& carrier_profile_path,
const std::string& eid);
EuiccInfo* GetEuiccInfoFromPath(const dbus::ObjectPath& path);
ESimProfileInfo* GetProfileInfoFromPath(const dbus::ObjectPath& path);
ProfileInstallResult GetPendingProfileInfoFromActivationCode(
const std::string& eid,
const std::string& activation_code,
ESimProfileInfo** profile_info);
ESimProfileInfo* GetPendingProfileInfoFromIccid(const std::string& iccid);
ESimProfileInfo* GetInstalledProfileInfoFromIccid(const std::string& iccid);
HermesManagerClient* hermes_manager_client_;
HermesEuiccClient* hermes_euicc_client_;
HermesProfileClient* hermes_profile_client_;
std::set<std::string> available_euicc_eids_;
std::map<std::string, std::unique_ptr<EuiccInfo>> eid_euicc_info_map_;
std::map<std::string, std::unique_ptr<ESimProfileInfo>>
iccid_esim_profile_info_map_;
mojo::RemoteSet<mojom::ESimManagerObserver> observers_;
mojo::ReceiverSet<mojom::ESimManager> receivers_;
base::WeakPtrFactory<ESimManager> weak_ptr_factory_{this};
};
} // namespace cellular_setup
} // namespace chromeos
#endif // CHROMEOS_SERVICES_CELLULAR_SETUP_ESIM_MANAGER_H_
This diff is collapsed.
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/services/cellular_setup/in_process_esim_manager.h"
#include "base/no_destructor.h"
#include "chromeos/services/cellular_setup/esim_manager.h"
namespace chromeos {
namespace cellular_setup {
void BindToInProcessESimManager(
mojo::PendingReceiver<mojom::ESimManager> receiver) {
static base::NoDestructor<ESimManager> instance;
instance->BindReceiver(std::move(receiver));
}
} // namespace cellular_setup
} // namespace chromeos
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_SERVICES_CELLULAR_SETUP_IN_PROCESS_ESIM_MANAGER_H_
#define CHROMEOS_SERVICES_CELLULAR_SETUP_IN_PROCESS_ESIM_MANAGER_H_
#include "base/component_export.h"
#include "chromeos/services/cellular_setup/public/mojom/esim_manager.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
namespace chromeos {
namespace cellular_setup {
COMPONENT_EXPORT(IN_PROCESS_ESIM_MANAGER)
void BindToInProcessESimManager(
mojo::PendingReceiver<mojom::ESimManager> receiver);
} // namespace cellular_setup
} // namespace chromeos
#endif // CHROMEOS_SERVICES_CELLULAR_SETUP_IN_PROCESS_ESIM_MANAGER_H_
...@@ -5,7 +5,13 @@ ...@@ -5,7 +5,13 @@
import("//mojo/public/tools/bindings/mojom.gni") import("//mojo/public/tools/bindings/mojom.gni")
mojom("mojom") { mojom("mojom") {
sources = [ "cellular_setup.mojom" ] sources = [
"cellular_setup.mojom",
"esim_manager.mojom",
]
public_deps = [ "//url/mojom:url_mojom_gurl" ] public_deps = [
"//mojo/public/mojom/base",
"//url/mojom:url_mojom_gurl",
]
} }
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module chromeos.cellular_setup.mojom;
import "mojo/public/mojom/base/string16.mojom";
// Represents the current state of an ESimProfile
enum ProfileState {
kPending, // Profile is not installed on the device.
kInstalling, // Profile is being installed.
kInactive, // Profile is installed but inactive.
kActive, // Profile is installed and active.
};
// Represents an EUICC (Embedded Universal Integrated Circuit Card) hardware
// available on the device. Each Euicc may have multiple ESimProfiles
// installed on it.
struct Euicc {
// A 32 digit unique id for the Euicc.
string eid;
// Boolean indicating whether the Euicc is active or not.
bool is_active;
};
// Represents an eSIM profile.
struct ESimProfile {
// EID of the Euicc in which this profile is installed or available for
// installation.
string eid;
// A 19-20 character long numeric id that uniquely identifies this profile.
string iccid;
// Service provider’s name for this profile. e.g. “Verizon Plan 1”
mojo_base.mojom.String16 name;
// A user configurable nickname for this profile. e.g. “My Personal SIM”
mojo_base.mojom.String16 nickname;
// Name of the service provider. e.g. “Verizon Wireless”
mojo_base.mojom.String16 service_provider;
// State of the profile
ProfileState state;
// An alphanumeric code that can be used to install this profile.
string activation_code;
};
// ESimManagerObserver is implemented by any module that
// needs to observe changes to the eSIM module.
interface ESimManagerObserver {
// Called when a new Euicc is added or removed from the system.
OnAvailableEuiccListChanged();
// Called when a new eSIM profile is added or removed to the
// Euicc with the given |eid|.
OnProfileListChanged(string eid);
// Called when an Euicc object's active state changes.
OnEuiccChanged(Euicc euicc);
// Called when an eSIM profile’s state or nickname changes.
OnProfileChanged(ESimProfile profile);
};
// ESimManager interface provides eSIM profile management methods. An instance
// of this interface is owned in the browser process in Ash. It will be
// accessed from WebUI or System UI code in the browser process.
interface ESimManager {
// Result codes for profile installation.
enum ProfileInstallResult {
kSuccess, // Installation succeeded.
kFailure, // Installation failed.
kErrorNeedsConfirmationCode, // Installation requires a valid
// confirmation code.
kErrorInvalidActivationCode, // Given activation code is invalid.
};
// Result code for ESimManager methods.
enum ESimOperationResult {
kSuccess, // Operation succeeded.
kFailure // Operation failed.
};
// Adds an observer for eSIM changes.
AddObserver(pending_remote<ESimManagerObserver> observer);
// Returns a list of Euiccs available on the device.
GetAvailableEuiccs() => (array<Euicc> euiccs);
// Returns a list of all profiles installed or pending on the Euicc
// with given |eid|. An empty list could be returned if there are
// no installed or pending profiles on the Euicc.
GetProfiles(string eid) => (array<ESimProfile>? profiles);
// Starts a request for pending profiles for the Euicc with given |eid|
// from SMDS. Returns a status indicating result of the operation. This
// method updates the pending profiles list before succeeding. This method
// is used to allow the user to explicit trigger a request to check for
// new profiles that may have been pushed to SMDS.
RequestPendingProfiles(string eid) => (ESimOperationResult result);
// Installs a profile with given |activation_code| on the Euicc with
// given |eid| and returns the ESimProfile that was just installed. A
// non-success result code is returned in case of errors. |activation_code|
// may be obtained from ESimProfiles retrieved with a previous call to
// GetPendingProfiles or directly from the user through a QR code. If
// |confirmation_code| is required but not supplied or if it’s invalid
// then a kErrorNeedsConfirmationCode result is returned.
InstallProfileFromActivationCode(string eid, string activation_code,
string confirmation_code) =>
(ProfileInstallResult result, ESimProfile? profile);
// Installs an eSIM profile given it’s |iccid| and returns the
// ESimProfile that was just installed. A non success result code
// is returned in case of errors.
InstallProfile(string iccid, string confirmation_code) =>
(ProfileInstallResult result, ESimProfile? profile);
// Uninstalls an eSIM profile given it’s |iccid|. Returns the result
// code for the operation.
UninstallProfile(string iccid) => (ESimOperationResult result);
// Enables an eSIM profile with the given |iccid|. Returns the result
// code for the operation.
EnableProfile(string iccid) => (ESimOperationResult result);
// Disables an eSIM profile with the given |iccid|. Returns the result
// code for the operation.
DisableProfile(string iccid) => (ESimOperationResult result);
// Sets a nickname for an eSIM profile with given |iccid|. Returns the
// result code for the operation.
SetProfileNickname(string iccid, mojo_base.mojom.String16 nickname) =>
(ESimOperationResult result);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment