aggregate the items of network selection list
According to bug comment#44, modem only report one PLMN per RAT for different cells reported for the same PLMN/RAT combination, UI affregate those items. Bug: 173387374 Test: atest NetworkSelectSettingsTest Change-Id: I155abc8dda7c8ec42cf4fd677bd2aa99d1033ad1 Merged-In: I8e05b9f6784bad7f0de4e79cc6e707749745f0c1
This commit is contained in:
committed by
SongFerng Wang
parent
d7753f4c23
commit
7f5c984655
@@ -143,29 +143,71 @@ public final class CellInfoUtil {
|
||||
public static String cellInfoToString(CellInfo cellInfo) {
|
||||
final String cellType = cellInfo.getClass().getSimpleName();
|
||||
final CellIdentity cid = getCellIdentity(cellInfo);
|
||||
String mcc = null;
|
||||
String mnc = null;
|
||||
if (cid != null) {
|
||||
if (cid instanceof CellIdentityGsm) {
|
||||
mcc = ((CellIdentityGsm) cid).getMccString();
|
||||
mnc = ((CellIdentityGsm) cid).getMncString();
|
||||
} else if (cid instanceof CellIdentityWcdma) {
|
||||
mcc = ((CellIdentityWcdma) cid).getMccString();
|
||||
mnc = ((CellIdentityWcdma) cid).getMncString();
|
||||
} else if (cid instanceof CellIdentityTdscdma) {
|
||||
mcc = ((CellIdentityTdscdma) cid).getMccString();
|
||||
mnc = ((CellIdentityTdscdma) cid).getMncString();
|
||||
} else if (cid instanceof CellIdentityLte) {
|
||||
mcc = ((CellIdentityLte) cid).getMccString();
|
||||
mnc = ((CellIdentityLte) cid).getMncString();
|
||||
} else if (cid instanceof CellIdentityNr) {
|
||||
mcc = ((CellIdentityNr) cid).getMccString();
|
||||
mnc = ((CellIdentityNr) cid).getMncString();
|
||||
}
|
||||
}
|
||||
String mcc = getCellIdentityMcc(cid);
|
||||
String mnc = getCellIdentityMnc(cid);
|
||||
return String.format(
|
||||
"{CellType = %s, isRegistered = %b, mcc = %s, mnc = %s, alphaL = %s, alphaS = %s}",
|
||||
cellType, cellInfo.isRegistered(), mcc, mnc,
|
||||
cid.getOperatorAlphaLong(), cid.getOperatorAlphaShort());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the MccMnc.
|
||||
*
|
||||
* @param cid contains the identity of the network.
|
||||
* @return MccMnc string.
|
||||
*/
|
||||
public static String getCellIdentityMccMnc(CellIdentity cid) {
|
||||
String mcc = getCellIdentityMcc(cid);
|
||||
String mnc = getCellIdentityMnc(cid);
|
||||
return (mcc == null || mnc == null) ? null : mcc + mnc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Mcc.
|
||||
*
|
||||
* @param cid contains the identity of the network.
|
||||
* @return Mcc string.
|
||||
*/
|
||||
public static String getCellIdentityMcc(CellIdentity cid) {
|
||||
String mcc = null;
|
||||
if (cid != null) {
|
||||
if (cid instanceof CellIdentityGsm) {
|
||||
mcc = ((CellIdentityGsm) cid).getMccString();
|
||||
} else if (cid instanceof CellIdentityWcdma) {
|
||||
mcc = ((CellIdentityWcdma) cid).getMccString();
|
||||
} else if (cid instanceof CellIdentityTdscdma) {
|
||||
mcc = ((CellIdentityTdscdma) cid).getMccString();
|
||||
} else if (cid instanceof CellIdentityLte) {
|
||||
mcc = ((CellIdentityLte) cid).getMccString();
|
||||
} else if (cid instanceof CellIdentityNr) {
|
||||
mcc = ((CellIdentityNr) cid).getMccString();
|
||||
}
|
||||
}
|
||||
return (mcc == null) ? null : mcc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Mnc.
|
||||
*
|
||||
* @param cid contains the identity of the network.
|
||||
* @return Mcc string.
|
||||
*/
|
||||
public static String getCellIdentityMnc(CellIdentity cid) {
|
||||
String mnc = null;
|
||||
if (cid != null) {
|
||||
if (cid instanceof CellIdentityGsm) {
|
||||
mnc = ((CellIdentityGsm) cid).getMncString();
|
||||
} else if (cid instanceof CellIdentityWcdma) {
|
||||
mnc = ((CellIdentityWcdma) cid).getMncString();
|
||||
} else if (cid instanceof CellIdentityTdscdma) {
|
||||
mnc = ((CellIdentityTdscdma) cid).getMncString();
|
||||
} else if (cid instanceof CellIdentityLte) {
|
||||
mnc = ((CellIdentityLte) cid).getMncString();
|
||||
} else if (cid instanceof CellIdentityNr) {
|
||||
mnc = ((CellIdentityNr) cid).getMncString();
|
||||
}
|
||||
}
|
||||
return (mnc == null) ? null : mnc;
|
||||
}
|
||||
}
|
||||
|
@@ -66,6 +66,7 @@ public class NetworkSelectSettings extends DashboardFragment {
|
||||
private static final int EVENT_NETWORK_SCAN_COMPLETED = 4;
|
||||
|
||||
private static final String PREF_KEY_NETWORK_OPERATORS = "network_operators_preference";
|
||||
private static final int MIN_NUMBER_OF_SCAN_REQUIRED = 2;
|
||||
|
||||
@VisibleForTesting
|
||||
PreferenceCategory mPreferenceCategory;
|
||||
@@ -87,8 +88,8 @@ public class NetworkSelectSettings extends DashboardFragment {
|
||||
private long mRequestIdManualNetworkSelect;
|
||||
private long mRequestIdManualNetworkScan;
|
||||
private long mWaitingForNumberOfScanResults;
|
||||
|
||||
private static final int MIN_NUMBER_OF_SCAN_REQUIRED = 2;
|
||||
@VisibleForTesting
|
||||
boolean mIsAggregationEnabled = false;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
@@ -115,6 +116,11 @@ public class NetworkSelectSettings extends DashboardFragment {
|
||||
|
||||
mMetricsFeatureProvider = FeatureFactory
|
||||
.getFactory(getContext()).getMetricsFeatureProvider();
|
||||
|
||||
mIsAggregationEnabled = getContext().getResources().getBoolean(
|
||||
R.bool.config_network_selection_list_aggregation_enabled);
|
||||
Log.d(TAG, "init: mUseNewApi:" + mUseNewApi
|
||||
+ " ,mIsAggregationEnabled:" + mIsAggregationEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -244,7 +250,7 @@ public class NetworkSelectSettings extends DashboardFragment {
|
||||
stopNetworkQuery();
|
||||
}
|
||||
|
||||
mCellInfoList = new ArrayList<>(results);
|
||||
mCellInfoList = doAggregation(results);
|
||||
Log.d(TAG, "CellInfoList: " + CellInfoUtil.cellInfoListToString(mCellInfoList));
|
||||
if (mCellInfoList != null && mCellInfoList.size() != 0) {
|
||||
final NetworkOperatorPreference connectedPref =
|
||||
@@ -308,6 +314,31 @@ public class NetworkSelectSettings extends DashboardFragment {
|
||||
}
|
||||
};
|
||||
|
||||
@VisibleForTesting
|
||||
List<CellInfo> doAggregation(List<CellInfo> cellInfoListInput) {
|
||||
if (!mIsAggregationEnabled) {
|
||||
Log.d(TAG, "no aggregation");
|
||||
return new ArrayList<>(cellInfoListInput);
|
||||
}
|
||||
ArrayList<CellInfo> aggregatedList = new ArrayList<>();
|
||||
for (CellInfo cellInfo : cellInfoListInput) {
|
||||
String plmn = CellInfoUtil.getNetworkTitle(cellInfo.getCellIdentity(),
|
||||
CellInfoUtil.getCellIdentityMccMnc(cellInfo.getCellIdentity()));
|
||||
Class className = cellInfo.getClass();
|
||||
|
||||
if (aggregatedList.stream().anyMatch(
|
||||
i -> {
|
||||
return (CellInfoUtil.getNetworkTitle(i.getCellIdentity(),
|
||||
CellInfoUtil.getCellIdentityMccMnc(i.getCellIdentity())) == plmn)
|
||||
&& i.getClass().equals(className);
|
||||
})) {
|
||||
continue;
|
||||
}
|
||||
aggregatedList.add(cellInfo);
|
||||
}
|
||||
return aggregatedList;
|
||||
}
|
||||
|
||||
private final NetworkScanHelper.NetworkScanCallback mCallback =
|
||||
new NetworkScanHelper.NetworkScanCallback() {
|
||||
public void onResults(List<CellInfo> results) {
|
||||
|
Reference in New Issue
Block a user