[CrOS Cellular] Add logic to migrate networks w/o APNs in ApnMigrator
This change adds the logic to migrate networks that do not have any custom APNs. In this case, it is only required to send an empty list to Shill. Bug: b:162365553 Test: chromeos_unittests --gtest_filter=ApnMigratorTest.* Change-Id: I32215d5973f099f65319cab6929374edd2e3e90b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4057131 Reviewed-by: Chad Duffin <chadduffin@chromium.org> Commit-Queue: Emmanuel Arias Soto <eariassoto@google.com> Cr-Commit-Position: refs/heads/main@{#1080280}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
e74cc6c04c
commit
00dfc62d2e
chromeos/ash/components/network
@ -63,7 +63,22 @@ void ApnMigrator::NetworkListChanged() {
|
||||
// TODO(b/162365553): Ignore stub cellular networks
|
||||
if (!managed_cellular_pref_handler_->ContainsApnMigratedIccid(
|
||||
network->iccid())) {
|
||||
// TODO(b/162365553): Implement this case: Network needs to be migrated
|
||||
if (!ash::features::IsApnRevampEnabled()) {
|
||||
continue;
|
||||
}
|
||||
// Network needs to be migrated to the APN revamp
|
||||
const base::Value::List* custom_apn_list =
|
||||
network_metadata_store_->GetCustomApnList(network->guid());
|
||||
if (!custom_apn_list) {
|
||||
base::Value::List empty_apn_list;
|
||||
SetShillUserApnListForNetwork(*network, &empty_apn_list);
|
||||
} else if (custom_apn_list->empty()) {
|
||||
SetShillUserApnListForNetwork(*network, custom_apn_list);
|
||||
} else {
|
||||
// TODO(b/162365553): Implement this case: Network with custom APNs
|
||||
// needs to be migrated
|
||||
}
|
||||
managed_cellular_pref_handler_->AddApnMigratedIccid(network->iccid());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ TEST_F(ApnMigratorTest, ApnRevampFlagDisabled) {
|
||||
TriggerNetworkListChanged();
|
||||
}
|
||||
|
||||
TEST_F(ApnMigratorTest, ApnRevampFlagEnabled_MigratedNetworks) {
|
||||
TEST_F(ApnMigratorTest, ApnRevampFlagEnabled_AllNetworksMigrated) {
|
||||
base::test::ScopedFeatureList scoped_feature_list;
|
||||
scoped_feature_list.InitAndEnableFeature(ash::features::kApnRevamp);
|
||||
|
||||
@ -296,4 +296,79 @@ TEST_F(ApnMigratorTest, ApnRevampFlagEnabled_MigratedNetworks) {
|
||||
TriggerNetworkListChanged();
|
||||
}
|
||||
|
||||
TEST_F(ApnMigratorTest, ApnRevampFlagEnabled_MigrateNetworks) {
|
||||
base::test::ScopedFeatureList scoped_feature_list;
|
||||
scoped_feature_list.InitAndEnableFeature(ash::features::kApnRevamp);
|
||||
|
||||
// Every network should be evaluated, pretend that all network need to be
|
||||
// migrated.
|
||||
EXPECT_CALL(*managed_cellular_pref_handler(),
|
||||
ContainsApnMigratedIccid(Eq(kTestCellularIccid1)))
|
||||
.Times(1)
|
||||
.WillOnce(Return(false));
|
||||
EXPECT_CALL(*managed_cellular_pref_handler(),
|
||||
ContainsApnMigratedIccid(Eq(kTestCellularIccid2)))
|
||||
.Times(1)
|
||||
.WillOnce(Return(false));
|
||||
EXPECT_CALL(*managed_cellular_pref_handler(),
|
||||
ContainsApnMigratedIccid(Eq(kTestCellularIccid3)))
|
||||
.Times(1)
|
||||
.WillOnce(Return(false));
|
||||
|
||||
// Simulate that all networks do not have custom APNs
|
||||
EXPECT_CALL(*network_metadata_store(), GetCustomApnList(kTestCellularGuid1))
|
||||
.Times(1)
|
||||
.WillOnce(Return(nullptr));
|
||||
base::Value::List empty_apn_list;
|
||||
EXPECT_CALL(*network_metadata_store(), GetCustomApnList(kTestCellularGuid2))
|
||||
.Times(1)
|
||||
.WillOnce(Return(&empty_apn_list));
|
||||
EXPECT_CALL(*network_metadata_store(), GetCustomApnList(kTestCellularGuid3))
|
||||
.Times(1)
|
||||
.WillOnce(Return(&empty_apn_list));
|
||||
|
||||
// The function should only update Shill with empty user APN lists.
|
||||
base::Value::Dict expected_onc_1 = chromeos::network_config::UserApnListToOnc(
|
||||
kTestCellularGuid1, &empty_apn_list);
|
||||
EXPECT_CALL(*managed_network_configuration_handler(),
|
||||
SetProperties(cellular_service_path_1(),
|
||||
Truly([&expected_onc_1](const base::Value& value) {
|
||||
return expected_onc_1 == value.GetDict();
|
||||
}),
|
||||
_, _))
|
||||
.Times(1);
|
||||
base::Value::Dict expected_onc_2 = chromeos::network_config::UserApnListToOnc(
|
||||
kTestCellularGuid2, &empty_apn_list);
|
||||
EXPECT_CALL(*managed_network_configuration_handler(),
|
||||
SetProperties(cellular_service_path_2(),
|
||||
Truly([&expected_onc_2](const base::Value& value) {
|
||||
return expected_onc_2 == value.GetDict();
|
||||
}),
|
||||
_, _))
|
||||
.Times(1);
|
||||
base::Value::Dict expected_onc_3 = chromeos::network_config::UserApnListToOnc(
|
||||
kTestCellularGuid3, &empty_apn_list);
|
||||
EXPECT_CALL(*managed_network_configuration_handler(),
|
||||
SetProperties(cellular_service_path_3(),
|
||||
Truly([&expected_onc_3](const base::Value& value) {
|
||||
return expected_onc_3 == value.GetDict();
|
||||
}),
|
||||
_, _))
|
||||
.Times(1);
|
||||
|
||||
// All network should be marked as migrated
|
||||
EXPECT_CALL(*managed_cellular_pref_handler(),
|
||||
AddApnMigratedIccid(Eq(kTestCellularIccid1)))
|
||||
.Times(1);
|
||||
EXPECT_CALL(*managed_cellular_pref_handler(),
|
||||
AddApnMigratedIccid(Eq(kTestCellularIccid2)))
|
||||
.Times(1);
|
||||
EXPECT_CALL(*managed_cellular_pref_handler(),
|
||||
AddApnMigratedIccid(Eq(kTestCellularIccid3)))
|
||||
.Times(1);
|
||||
|
||||
// Function under test.
|
||||
TriggerNetworkListChanged();
|
||||
}
|
||||
|
||||
} // namespace ash
|
||||
|
Reference in New Issue
Block a user