Skip to content

Commit

Permalink
cellular: Fix cellular page labels
Browse files Browse the repository at this point in the history
This change fixes the labels that are shown on the Cellular page so that
they accurately reflect the cellular/modem state, e.g., when installing
a profile they will say that rather than "no profiles installed".

https://screenshot.googleplex.com/5LhhoHs2hzCSkNB.png
https://screenshot.googleplex.com/5M37fY8VzJfFcFN.png
https://screenshot.googleplex.com/BwE6mSqmCnUBpCD.png
https://screenshot.googleplex.com/6dBBk7D87Zbcgj3.png

Video: https://drive.google.com/file/d/1GzRMnFSNhxT3uap2vlu6nE-TehYLIkpL/view?usp=sharing

Bug: b/300538167
Test: Unit tests and manually verified on device.
Change-Id: I2d3d4b78f92634397f090fffc9d3e2ed3946e8a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4916198
Commit-Queue: Chad Duffin <chadduffin@chromium.org>
Reviewed-by: Wes Okuhara <wesokuhara@google.com>
Reviewed-by: Theo Johnson-kanu <tjohnsonkanu@google.com>
Cr-Commit-Position: refs/heads/main@{#1209568}
  • Loading branch information
Chad Duffin authored and Chromium LUCI CQ committed Oct 13, 2023
1 parent 461c691 commit 45910e8
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 86 deletions.
9 changes: 6 additions & 3 deletions chrome/app/os_settings_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -4139,12 +4139,12 @@ Press an assigned switch or key to remove assignment.
<message name="IDS_SETTINGS_INTERNET_NETWORK_CELLULAR_INSTALLING_PROFILE" desc="Settings > Internet > Mobile data: Message indicating that an eSIM profile is being installed and notifying the user why mobile settings are temporarily disabled.">
Adding profile. This may take a few minutes.
</message>
<message name="IDS_SETTINGS_INTERNET_NETWORK_CELLULAR_REMOVING_PROFILE" desc="Settings > Internet > Mobile data: Message indicating that an eSIM profile is being uninstalled and notifying the user why mobile settings are temporarily disabled.">
Removing profile. This may take a few minutes.
</message>
<message name="IDS_SETTINGS_INTERNET_NETWORK_CELLULAR_RENAMING_PROFILE" desc="Settings > Internet > Mobile data: Message indicating that an eSIM profile is being renamed and notifying the user why mobile settings are temporarily disabled.">
Renaming profile. This may take a few minutes.
</message>
<message name="IDS_SETTINGS_INTERNET_NETWORK_CELLULAR_REMOVING_PROFILE" desc="Settings > Internet > Mobile data: Message indicating that an eSIM profile is being uninstalled and notifying the user why mobile settings are temporarily disabled.">
Removing profile. This may take a few minutes.
</message>
<message name="IDS_SETTINGS_INTERNET_NETWORK_CELLULAR_CONNECTING_TO_PROFILE" desc="Settings > Internet > Mobile data: Message indicating that an eSIM profile connection is currently in progress and notifying the user why mobile settings are temporarily disabled.">
Connecting to profile. This may take a few minutes.
</message>
Expand All @@ -4154,6 +4154,9 @@ Press an assigned switch or key to remove assignment.
<message name="IDS_SETTINGS_INTERNET_NETWORK_CELLULAR_RESETTING_ESIM" desc="Settings > Internet > Mobile data: Message indicating that the eSIM is being reset and notifying the user why mobile settings are temporarily disabled.">
Your administrator is resetting your eSIM. This may take a few minutes.
</message>
<message name="IDS_SETTINGS_INTERNET_NETWORK_CELLULAR_REQUESTING_AVAILABLE_PROFILES" desc="Settings > Internet > Mobile data: Message indicating that we are looking for eSIM profiles that are available for installation and notifying the user why mobile settings are temporarily disabled.">
Looking for available profiles. This may take a few minutes.
</message>
<message name="IDS_SETTINGS_INTERNET_NETWORK_REMOVE_PROFILE_DIALOG_ERROR_MESSAGE" desc="Settings > Internet > Network details > Remove eSIM cellular profile dialog: Error message shown when remove fails">
Profile could not be removed. Please try again or contact your carrier for technical support.
</message>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7f58791df5390f46ed4a76a2807340879cf525b5
Original file line number Diff line number Diff line change
Expand Up @@ -123,28 +123,29 @@
</network-list>
</div>
</template>
<template is="dom-if" if="[[shouldShowEsimNoNetworksMessage_(
cellularDeviceState.inhibitReason, eSimNetworks_,
eSimPendingProfileItems_)]]" restamp>
<div class="cellular-network-content cellular-not-setup flex">
<div id="noEsimNetworksMessage"
hidden="[[!shouldShowAddEsimNetworksMessage_(
cellularDeviceState.inhibitReason,
globalPolicy.allowOnlyPolicyCellularNetworks)]]">
[[getEsimNoNetworksMessage_(cellularDeviceState.inhibitReason,
globalPolicy.allowOnlyPolicyCellularNetworks)]]
</div>
<localized-link
id="noEsimNetworksMessageWithLink"
link-disabled = "[[isDeviceInhibited_]]"
on-link-clicked="onAddEsimLinkClicked_"
localized-string="$i18n{eSimNetworkNotSetupWithDownloadLink}"
hidden="[[shouldShowAddEsimNetworksMessage_(
cellularDeviceState.inhibitReason,
globalPolicy.allowOnlyPolicyCellularNetworks)]]">
</localized-link>
<div class="cellular-network-content cellular-not-setup flex">
<div id="noEsimNetworksMessage"
hidden="[[!shouldShowNoEsimNetworksMessageWithoutLink_(
cellularDeviceState,
cellularDeviceState.inhibitReason,
eSimNetworks_,
eSimPendingProfileItems_,
globalPolicy.allowOnlyPolicyCellularNetworks)]]">
$i18n{eSimNetworkNotSetup}
</div>
</template>
<localized-link
id="noEsimNetworksMessageWithLink"
link-disabled="[[isDeviceInhibited_]]"
on-link-clicked="onAddEsimLinkClicked_"
localized-string="$i18n{eSimNetworkNotSetupWithDownloadLink}"
hidden="[[!shouldShowAddEsimMessageWithLink(
cellularDeviceState,
cellularDeviceState.inhibitReason,
eSimNetworks_,
eSimPendingProfileItems_,
globalPolicy.allowOnlyPolicyCellularNetworks)]]">
</localized-link>
</div>
</template>
<template is="dom-if"
if="[[shouldShowPsimSection_(pSimNetworks_, cellularDeviceState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,43 +575,62 @@ export class CellularNetworksListElement extends
return this.i18n('cellularNetworRefreshingProfileListProfile');
case InhibitReason.kResettingEuiccMemory:
return this.i18n('cellularNetworkResettingESim');
case InhibitReason.kRequestingAvailableProfiles:
return this.i18n('cellularNetworkRequestingAvailableProfiles');
}

return '';
}

/**
* Return true if there are currently no eSIM networks configured. This
* message should not be shown when adding new eSIM profiles.
*/
private shouldShowEsimNoNetworksMessage_(
inhibitReason: InhibitReason,
eSimNetworks: NetworkList.NetworkListItemType[],
eSimPendingProfiles: NetworkList.CustomItemState[]): boolean {
if (inhibitReason === InhibitReason.kRefreshingProfileList) {
return false;
private isInhibitedOrAffectedByPolicy_(): boolean {
if (this.cellularDeviceState &&
this.cellularDeviceState.inhibitReason !== undefined &&
this.cellularDeviceState.inhibitReason !==
InhibitReason.kNotInhibited) {
return true;
}

return !this.shouldShowNetworkSublist_(eSimNetworks, eSimPendingProfiles);
return !!this.globalPolicy &&
this.globalPolicy.allowOnlyPolicyCellularNetworks;
}

private shouldShowAddEsimNetworksMessage_(inhibitReason: InhibitReason):
boolean {
if (inhibitReason === InhibitReason.kInstallingProfile ||
(this.globalPolicy &&
this.globalPolicy.allowOnlyPolicyCellularNetworks)) {
return true;
/**
* Return true IFF there are no eSIM profiles installed and we are not
* installing a profile, refreshing the profile list, or requesting available
* profiles.
*/
private shouldShowNoEsimNetworksMessage_(): boolean {
if (this.cellularDeviceState &&
this.cellularDeviceState.inhibitReason !== undefined) {
const inhibitReason = this.cellularDeviceState.inhibitReason;
if (inhibitReason === InhibitReason.kInstallingProfile ||
inhibitReason === InhibitReason.kRefreshingProfileList ||
inhibitReason === InhibitReason.kRequestingAvailableProfiles) {
return false;
}
}

return false;
return !this.shouldShowNetworkSublist_(
this.eSimNetworks_, this.eSimPendingProfileItems_);
}

private getEsimNoNetworksMessage_(inhibitReason: InhibitReason): string {
if (inhibitReason === InhibitReason.kInstallingProfile) {
return this.i18n('cellularNetworkInstallingProfile');
}
/**
* Return true IFF there are no eSIM profiles installed, and the cellular
* device is inhibited for any reason NOT related to changes to the eSIM
* profile list or policy restricts the user from adding an eSIM profile.
*/
private shouldShowNoEsimNetworksMessageWithoutLink_(): boolean {
return this.shouldShowNoEsimNetworksMessage_() &&
this.isInhibitedOrAffectedByPolicy_();
}

return this.i18n('eSimNetworkNotSetup');
/**
* Return true IFF there are no eSIM profiles installed, and the cellular
* device is NOT inhibited for any reason related to changes to the eSIM
* profile list and policy does NOT restrict the user from adding an eSIM
* profile.
*/
private shouldShowAddEsimMessageWithLink(): boolean {
return this.shouldShowNoEsimNetworksMessage_() &&
!this.isInhibitedOrAffectedByPolicy_();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,8 @@ void InternetSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
IDS_SETTINGS_INTERNET_NETWORK_CELLULAR_REFRESHING_PROFILE_LIST},
{"cellularNetworkResettingESim",
IDS_SETTINGS_INTERNET_NETWORK_CELLULAR_RESETTING_ESIM},
{"cellularNetworkRequestingAvailableProfiles",
IDS_SETTINGS_INTERNET_NETWORK_CELLULAR_REQUESTING_AVAILABLE_PROFILES},
{"hotspotPageTitle", IDS_SETTINGS_INTERNET_HOTSPOT},
{"hotspotToggleA11yLabel",
IDS_SETTINGS_INTERNET_HOTSPOT_TOGGLE_A11Y_LABEL},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ suite('CellularNetworksList', function() {
init();
addESimSlot();
await flushAsync();
const esimNoNetworkAnchor =
const noEsimNetworksMessageWithLinkAnchor =
cellularNetworkList.shadowRoot
.querySelector('#noEsimNetworksMessageWithLink')
.shadowRoot.querySelector('a');
assertTrue(!!esimNoNetworkAnchor);
assertTrue(!!noEsimNetworksMessageWithLinkAnchor);

const showEsimCellularSetupPromise =
eventToPromise('show-cellular-setup', cellularNetworkList);
esimNoNetworkAnchor.click();
noEsimNetworksMessageWithLinkAnchor.click();
const eSimCellularEvent = await showEsimCellularSetupPromise;
assertEquals(
eSimCellularEvent.detail.pageName,
Expand Down Expand Up @@ -219,11 +219,11 @@ suite('CellularNetworksList', function() {
eSimNetworkList =
cellularNetworkList.shadowRoot.querySelector('#esimNetworkList');
assertNull(eSimNetworkList);
const esimNoNetworkAnchor =
const noEsimNetworksMessageWithLinkAnchor =
cellularNetworkList.shadowRoot
.querySelector('#noEsimNetworksMessageWithLink')
.shadowRoot.querySelector('a');
assertTrue(!!esimNoNetworkAnchor);
assertTrue(!!noEsimNetworksMessageWithLinkAnchor);
});
});

Expand Down Expand Up @@ -398,54 +398,73 @@ suite('CellularNetworksList', function() {
};
addESimSlot();
await flushAsync();
const getEsimLocalizedLink = () => {

const getAddEsimLink = () => {
return cellularNetworkList.shadowRoot.querySelector(
'#noEsimNetworksMessageWithLink');
};
const getNoESimFoundMessage = () => {
const getNoEsimFoundMessage = () => {
return cellularNetworkList.shadowRoot.querySelector(
'#noEsimNetworksMessage');
};

assertTrue(!!getEsimLocalizedLink());
assertTrue(!!getNoESimFoundMessage());
assertTrue(getEsimLocalizedLink().hidden);
assertFalse(getNoESimFoundMessage().hidden);
cellularNetworkList.globalPolicy = {
allowOnlyPolicyCellularNetworks: true,
};
await flushAsync();

assertTrue(!!getAddEsimLink());
assertTrue(!!getNoEsimFoundMessage());
assertTrue(getAddEsimLink().hidden);
assertFalse(getNoEsimFoundMessage().hidden);

assertEquals(
getNoESimFoundMessage().textContent.trim(),
getNoEsimFoundMessage().textContent.trim(),
cellularNetworkList.i18n('eSimNetworkNotSetup'));

cellularNetworkList.globalPolicy = {
allowOnlyPolicyCellularNetworks: false,
};

await flushAsync();
assertFalse(getEsimLocalizedLink().hidden);
assertTrue(getNoESimFoundMessage().hidden);

assertTrue(!!getAddEsimLink());
assertTrue(!!getNoEsimFoundMessage());
assertFalse(getAddEsimLink().hidden);
assertTrue(getNoEsimFoundMessage().hidden);

for (const inhibitReason
of [InhibitReason.kInstallingProfile,
InhibitReason.kRefreshingProfileList]) {
cellularNetworkList.cellularDeviceState = {
type: NetworkType.kCellular,
deviceState: DeviceStateType.kEnabled,
inhibitReason: inhibitReason,
};
addESimSlot();
of [InhibitReason.kNotInhibited,
InhibitReason.kInstallingProfile,
InhibitReason.kRenamingProfile,
InhibitReason.kRemovingProfile,
InhibitReason.kConnectingToProfile,
InhibitReason.kRefreshingProfileList,
InhibitReason.kResettingEuiccMemory,
InhibitReason.kDisablingProfile,
InhibitReason.kRequestingAvailableProfiles]) {
cellularNetworkList.set(
'cellularDeviceState.inhibitReason', inhibitReason);
await flushAsync();

if (inhibitReason === InhibitReason.kInstallingProfile) {
assertFalse(getNoESimFoundMessage().hidden);
assertTrue(getEsimLocalizedLink().hidden);
assertEquals(
getNoESimFoundMessage().textContent.trim(),
cellularNetworkList.i18n('cellularNetworkInstallingProfile'));
continue;
const noEsimNetworksMessageWithLink = getAddEsimLink();
const noEsimFoundMessage = getNoEsimFoundMessage();

assertTrue(!!noEsimNetworksMessageWithLink);
assertTrue(!!noEsimFoundMessage);

if (inhibitReason === InhibitReason.kNotInhibited) {
assertFalse(noEsimNetworksMessageWithLink.hidden);
assertTrue(noEsimFoundMessage.hidden);
} else if (
inhibitReason === InhibitReason.kInstallingProfile ||
inhibitReason === InhibitReason.kRefreshingProfileList ||
inhibitReason === InhibitReason.kRequestingAvailableProfiles) {
assertTrue(noEsimNetworksMessageWithLink.hidden);
assertTrue(noEsimFoundMessage.hidden);
} else {
assertTrue(noEsimNetworksMessageWithLink.hidden);
assertFalse(noEsimFoundMessage.hidden);
}

assertFalse(!!getNoESimFoundMessage());
assertFalse(!!getEsimLocalizedLink());
}
});

Expand Down Expand Up @@ -537,9 +556,10 @@ suite('CellularNetworksList', function() {

await flushAsync();

const esimLocalizedLink = cellularNetworkList.shadowRoot.querySelector(
'#noEsimNetworksMessageWithLink');
assertFalse(esimLocalizedLink.linkDisabled);
const noEsimNetworksMessageWithLink =
cellularNetworkList.shadowRoot.querySelector(
'#noEsimNetworksMessageWithLink');
assertFalse(noEsimNetworksMessageWithLink.linkDisabled);

cellularNetworkList.cellularDeviceState = {
type: NetworkType.kCellular,
Expand All @@ -548,7 +568,7 @@ suite('CellularNetworksList', function() {
};
addESimSlot();
await flushAsync();
assertTrue(esimLocalizedLink.linkDisabled);
assertTrue(noEsimNetworksMessageWithLink.linkDisabled);
});

test('Show inhibited subtext and spinner when inhibited', async () => {
Expand Down

0 comments on commit 45910e8

Please sign in to comment.