Merge "Lost the registered cellinfo item after the aggregation"
This commit is contained in:
committed by
Android (Google) Code Review
commit
fd81a18b8e
@@ -52,6 +52,7 @@ import com.android.settingslib.utils.ThreadUtils;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
@@ -360,12 +361,19 @@ public class NetworkSelectSettings extends DashboardFragment {
|
|||||||
CellInfoUtil.getCellIdentityMccMnc(cellInfo.getCellIdentity()));
|
CellInfoUtil.getCellIdentityMccMnc(cellInfo.getCellIdentity()));
|
||||||
Class className = cellInfo.getClass();
|
Class className = cellInfo.getClass();
|
||||||
|
|
||||||
if (aggregatedList.stream().anyMatch(
|
Optional<CellInfo> itemInTheList = aggregatedList.stream().filter(
|
||||||
item -> {
|
item -> {
|
||||||
String itemPlmn = CellInfoUtil.getNetworkTitle(item.getCellIdentity(),
|
String itemPlmn = CellInfoUtil.getNetworkTitle(item.getCellIdentity(),
|
||||||
CellInfoUtil.getCellIdentityMccMnc(item.getCellIdentity()));
|
CellInfoUtil.getCellIdentityMccMnc(item.getCellIdentity()));
|
||||||
return itemPlmn.equals(plmn) && item.getClass().equals(className);
|
return itemPlmn.equals(plmn) && item.getClass().equals(className);
|
||||||
})) {
|
})
|
||||||
|
.findFirst();
|
||||||
|
if (itemInTheList.isPresent()) {
|
||||||
|
if (cellInfo.isRegistered() && !itemInTheList.get().isRegistered()) {
|
||||||
|
// Adding the registered cellinfo item into list. If there are two registered
|
||||||
|
// cellinfo items, then select first one from source list.
|
||||||
|
aggregatedList.set(aggregatedList.indexOf(itemInTheList.get()), cellInfo);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
aggregatedList.add(cellInfo);
|
aggregatedList.add(cellInfo);
|
||||||
|
@@ -267,6 +267,20 @@ public class NetworkSelectSettingsTest {
|
|||||||
assertThat(mNetworkSelectSettings.doAggregation(testList)).isEqualTo(expected);
|
assertThat(mNetworkSelectSettings.doAggregation(testList)).isEqualTo(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void doAggregation_hasDuplicateItemsDiffMccMncCase3_removeSamePlmnRatItem() {
|
||||||
|
mNetworkSelectSettings.onCreateInitialization();
|
||||||
|
List<CellInfo> testList = Arrays.asList(
|
||||||
|
createLteCellInfo(false, 123, "123", "232", "CarrierA"),
|
||||||
|
createLteCellInfo(false, 124, "123", "233", "CarrierA"),
|
||||||
|
createLteCellInfo(true, 125, "123", "234", "CarrierA"),
|
||||||
|
createGsmCellInfo(false, 126, "456", "232", "CarrierA"));
|
||||||
|
List<CellInfo> expected = Arrays.asList(
|
||||||
|
createLteCellInfo(true, 125, "123", "234", "CarrierA"),
|
||||||
|
createGsmCellInfo(false, 126, "456", "232", "CarrierA"));
|
||||||
|
assertThat(mNetworkSelectSettings.doAggregation(testList)).isEqualTo(expected);
|
||||||
|
}
|
||||||
|
|
||||||
private CellInfoLte createLteCellInfo(boolean registered, int cellId, String mcc, String mnc,
|
private CellInfoLte createLteCellInfo(boolean registered, int cellId, String mcc, String mnc,
|
||||||
String plmnName) {
|
String plmnName) {
|
||||||
CellIdentityLte cil = new CellIdentityLte(
|
CellIdentityLte cil = new CellIdentityLte(
|
||||||
|
Reference in New Issue
Block a user