Merge "Support VCN network in the default network tracker" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2e1f03a6c7
@@ -364,11 +364,11 @@ public class NetworkControllerImpl extends BroadcastReceiver
|
||||
if (network.equals(mLastNetwork) && validated == lastValidated) {
|
||||
// Should not rely on getTransportTypes() returning the same order of transport
|
||||
// types. So sort the array before comparing.
|
||||
int[] newTypes = networkCapabilities.getTransportTypes();
|
||||
int[] newTypes = getProcessedTransportTypes(networkCapabilities);
|
||||
Arrays.sort(newTypes);
|
||||
|
||||
int[] lastTypes = (mLastNetworkCapabilities != null)
|
||||
? mLastNetworkCapabilities.getTransportTypes() : null;
|
||||
? getProcessedTransportTypes(mLastNetworkCapabilities) : null;
|
||||
if (lastTypes != null) Arrays.sort(lastTypes);
|
||||
|
||||
if (Arrays.equals(newTypes, lastTypes)) {
|
||||
@@ -533,6 +533,21 @@ public class NetworkControllerImpl extends BroadcastReceiver
|
||||
return mPhone.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE;
|
||||
}
|
||||
|
||||
private int[] getProcessedTransportTypes(NetworkCapabilities networkCapabilities) {
|
||||
int[] transportTypes = networkCapabilities.getTransportTypes();
|
||||
for (int i = 0; i < transportTypes.length; i++) {
|
||||
// For VCN over WiFi, the transportType is set to be TRANSPORT_CELLULAR in the
|
||||
// NetworkCapabilities, but we need to convert it into TRANSPORT_WIFI in order to
|
||||
// distinguish it from VCN over Cellular.
|
||||
if (transportTypes[i] == NetworkCapabilities.TRANSPORT_CELLULAR
|
||||
&& Utils.tryGetWifiInfoForVcn(networkCapabilities) != null) {
|
||||
transportTypes[i] = NetworkCapabilities.TRANSPORT_WIFI;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return transportTypes;
|
||||
}
|
||||
|
||||
private MobileSignalController getDataController() {
|
||||
int dataSubId = mSubDefaults.getActiveDataSubId();
|
||||
return getControllerWithSubId(dataSubId);
|
||||
|
||||
Reference in New Issue
Block a user