0

[CrOS Cellular] Do not show click to activate for eSIM networks

This CL removed the "Click to activate" text from non pSIM cellular
networks and also adds eid to NetworkInfo.

screenshot: https://screenshot.googleplex.com/BkMePjMEDrESsR4.png

Bug: b/217831844
Test: Manually verified changes.
Change-Id: Id2655e75720b18206048da67054e006e28597d7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3503048
Reviewed-by: Chad Duffin <chadduffin@chromium.org>
Reviewed-by: Gordon Seto <gordonseto@google.com>
Reviewed-by: James Cook <jamescook@chromium.org>
Commit-Queue: Theo Johnson-kanu <tjohnsonkanu@google.com>
Cr-Commit-Position: refs/heads/main@{#978837}
This commit is contained in:
Theo Johnson-Kanu
2022-03-08 20:43:19 +00:00
committed by Chromium LUCI CQ
parent 5f3fa81aac
commit 1c508e9123
9 changed files with 54 additions and 9 deletions

@ -2096,6 +2096,12 @@ This file contains the strings for ash.
<message name="IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CLICK_TO_ACTIVATE" desc="The label used in quick settings to indicate an unactivated cellular network that can be clicked to launch activation through setup flow. [CHAR_LIMIT=29]">
Click to activate
</message>
<message name="IDS_ASH_STATUS_TRAY_NETWORK_UNAVAILABLE_SIM_NETWORK" desc="Label used in quick settings to indicate a SIM network that is not available to be setup. [CHAR_LIMIT=29]">
Not activated. Contact your carrier.
</message>
<message name="IDS_ASH_STATUS_TRAY_NETWORK_A11Y_UNAVAILABLE_SIM_NETWORK" desc="Accessibility label used in quick settings to indicate for a SIM network that is not available to be setup. [CHAR_LIMIT=29]">
<ph name="NETWORK_NAME">$1<ex>Verizon</ex></ph> is not activated.
</message>
<message name="IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CLICK_TO_UNLOCK" desc="The label used in quick settings to indicate a cellular network is locked and clicking on it will open unlock dialog in chrome OS settings. [CHAR_LIMIT=29]">
Click to unlock
</message>
@ -4689,7 +4695,7 @@ New install
Delete this search from your history?
</message>
<message name="IDS_REMOVE_ZERO_STATE_SUGGESTION_DETAILS" desc="Detailed explanation message for removing removing an omnibox search result from launcher search results UI. This is a text in the dialog shown to the user when they try to remove a suggested omnibox search result from list of results shown in the launcher search - the omnibox search result may appear if the search query in launcher search matches a previous user search. The dialog asks the user to confirm the result removal.">
You searched for this query before. Deleting this search from your history will permanently remove it from your Google Account across all of your devices.
You searched for this query before. Deleting this search from your history will permanently remove it from your Google Account across all of your devices.
</message>
<message name="IDS_REMOVE_SUGGESTION_BUTTON_LABEL" desc="Remove suggestion button label">
Delete

@ -0,0 +1 @@
f437d238a125ca1c9d5f63e08726d81c7c6ee870

@ -0,0 +1 @@
f437d238a125ca1c9d5f63e08726d81c7c6ee870

@ -25,7 +25,7 @@ bool NetworkInfo::operator==(const NetworkInfo& other) const {
return guid == other.guid && label == other.label &&
tooltip == other.tooltip && image.BackedBySameObjectAs(other.image) &&
type == other.type && disable == other.disable &&
sim_locked == other.sim_locked &&
sim_locked == other.sim_locked && sim_eid == other.sim_eid &&
connection_state == other.connection_state && source == other.source &&
activation_state == other.activation_state &&
battery_percentage == other.battery_percentage;

@ -35,6 +35,9 @@ struct NetworkInfo {
bool secured = false;
bool connectable = false;
bool sim_locked = false;
// Only set for eSIM cellular networks. This is used to uniquely identity
// eSIM networks.
std::string sim_eid;
// Initialized in .cc file because full (non-forward) mojom headers are large.
chromeos::network_config::mojom::ConnectionStateType connection_state;
chromeos::network_config::mojom::NetworkType type;

@ -86,7 +86,14 @@ bool IsManagedByPolicy(const NetworkInfo& info) {
bool ShouldShowActivateCellularNetwork(const NetworkInfo& info) {
return NetworkTypeMatchesType(info.type, NetworkType::kCellular) &&
info.activation_state == ActivationStateType::kNotActivated;
info.activation_state == ActivationStateType::kNotActivated &&
info.sim_eid.empty();
}
bool ShouldShowContactCarrier(const NetworkInfo& info) {
return NetworkTypeMatchesType(info.type, NetworkType::kCellular) &&
info.activation_state == ActivationStateType::kNotActivated &&
!info.sim_eid.empty();
}
gfx::ImageSkia GetNetworkImageForNetwork(const NetworkInfo& info) {
@ -122,6 +129,8 @@ bool ShouldShowUnlockCellularNetwork(const NetworkInfo& info) {
int GetCellularNetworkSubText(const NetworkInfo& info) {
if (ShouldShowActivateCellularNetwork(info))
return IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CLICK_TO_ACTIVATE;
if (ShouldShowContactCarrier(info))
return IDS_ASH_STATUS_TRAY_NETWORK_UNAVAILABLE_SIM_NETWORK;
if (!ShouldShowUnlockCellularNetwork(info))
return 0;
if (Shell::Get()->session_controller()->IsActiveUserSessionStarted())
@ -258,6 +267,8 @@ void NetworkListView::OnGetNetworkStateList(
network->type_state->get_cellular()->activation_state;
info->activation_state = activation_state;
info->sim_locked = network->type_state->get_cellular()->sim_locked;
info->sim_eid = network->type_state->get_cellular()->eid;
if (cellular_device && IsInhibited(cellular_device))
inhibited = true;
// If cellular is not enabled, skip cellular networks with no service.
@ -518,7 +529,7 @@ void NetworkListView::UpdateViewForNetwork(HoverHighlightView* view,
std::u16string NetworkListView::GenerateAccessibilityLabel(
const NetworkInfo& info) {
if (CanNetworkConnect(info.connection_state, info.type, info.activation_state,
info.connectable)) {
info.connectable, info.sim_eid)) {
return l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_NETWORK_A11Y_LABEL_CONNECT, info.label);
}
@ -528,6 +539,11 @@ std::u16string NetworkListView::GenerateAccessibilityLabel(
IDS_ASH_STATUS_TRAY_NETWORK_A11Y_LABEL_ACTIVATE, info.label);
}
if (ShouldShowContactCarrier(info)) {
return l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_NETWORK_A11Y_UNAVAILABLE_SIM_NETWORK, info.label);
}
return l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_NETWORK_A11Y_LABEL_OPEN,
info.label);
}
@ -584,10 +600,14 @@ std::u16string NetworkListView::GenerateAccessibilityDescription(
base::FormatPercent(info.signal_strength));
}
case NetworkType::kCellular:
if (info.activation_state == ActivationStateType::kNotActivated) {
if (ShouldShowActivateCellularNetwork(info)) {
return l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CLICK_TO_ACTIVATE);
}
if (ShouldShowContactCarrier(info)) {
return l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_NETWORK_UNAVAILABLE_SIM_NETWORK);
}
if (info.sim_locked) {
if (Shell::Get()->session_controller()->IsActiveUserSessionStarted()) {
return l10n_util::GetStringUTF16(

@ -98,7 +98,8 @@ bool CanNetworkConnect(
chromeos::network_config::mojom::ConnectionStateType connection_state,
chromeos::network_config::mojom::NetworkType type,
chromeos::network_config::mojom::ActivationStateType activation_state,
bool connectable) {
bool connectable,
std::string sim_eid) {
// Network can be connected to if the network is not connected and:
// * The network is connectable or
// * The active user is primary and the network is configurable or
@ -106,6 +107,14 @@ bool CanNetworkConnect(
if (connection_state != ConnectionStateType::kNotConnected) {
return false;
}
// Network cannot be connected to if it is an unactivated eSIM network.
if (type == NetworkType::kCellular &&
activation_state == ActivationStateType::kNotActivated &&
!sim_eid.empty()) {
return false;
}
if (connectable) {
return true;
}
@ -315,7 +324,10 @@ void NetworkStateListDetailedView::HandleViewClickedImpl(
network->type == NetworkType::kCellular
? network->type_state->get_cellular()->activation_state
: ActivationStateType::kUnknown,
network->connectable)) {
network->connectable,
network->type == NetworkType::kCellular
? network->type_state->get_cellular()->eid
: "")) {
Shell::Get()->metrics()->RecordUserMetricsAction(
list_type_ == LIST_TYPE_VPN
? UMA_STATUS_AREA_CONNECT_TO_VPN

@ -28,7 +28,8 @@ bool CanNetworkConnect(
chromeos::network_config::mojom::ConnectionStateType connection_state,
chromeos::network_config::mojom::NetworkType type,
chromeos::network_config::mojom::ActivationStateType activation_state,
bool is_connectable);
bool is_connectable,
std::string sim_eid);
// Exported for tests.
class ASH_EXPORT NetworkStateListDetailedView

@ -126,7 +126,8 @@ bool ShouldOpenCellularSetupPsimFlowOnClick(const std::string& network_id) {
const chromeos::NetworkState* network_state = GetNetworkState(network_id);
return network_state && network_state->type() == shill::kTypeCellular &&
network_state->activation_state() ==
shill::kActivationStateNotActivated;
shill::kActivationStateNotActivated &&
network_state->eid().empty();
}
apps::AppServiceProxyAsh* GetActiveUserAppServiceProxyAsh() {