Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f6b84600 authored by yinxu's avatar yinxu
Browse files

Support VCN network in the default network tracker

Bug: 186025257
Test: manual tests
Change-Id: If9cde3ba634544e37b6847ac53c962b5419dcef3
parent edec7fd6
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -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);