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

Commit 0ad1f820 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes from topic "unknown_handover"

* changes:
  Supported UNKNOWN in IWLAN handover rule
  Support dun for QNS
  Create separate groups for NetworkRequests with different enterprise IDs
  Bug fix of bandwidth estimator overflow
  Send IA to modem when SIM switch or refresh
  APN anomaly report - allow UNKNOWN lingering network
parents 8542ebc2 c2a10def
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -131,7 +131,8 @@ public class AccessNetworksManager extends Handler {
            ApnSetting.TYPE_CBS,
            ApnSetting.TYPE_SUPL,
            ApnSetting.TYPE_EMERGENCY,
            ApnSetting.TYPE_XCAP
            ApnSetting.TYPE_XCAP,
            ApnSetting.TYPE_DUN
    };

    private final Phone mPhone;
@@ -417,7 +418,7 @@ public class AccessNetworksManager extends Handler {
                int unsatisfied = satisfiedApnTypes ^ apnTypes;
                reportAnomaly("QNS requested unsupported APN Types:"
                        + Integer.toBinaryString(unsatisfied),
                        "3e89a3df-3524-45fa-b5f2-0fb0e4c77ec4");
                        "3e89a3df-3524-45fa-b5f2-0fb0e4c77ec5");
            }

            if (!qualifiedNetworksList.isEmpty()) {
+4 −3
Original line number Diff line number Diff line
@@ -460,6 +460,7 @@ public class DataNetworkController extends Handler {
            }
            return true;
        }

        /**
         * Get the first network request that contains all the provided network capabilities.
         *
@@ -710,9 +711,9 @@ public class DataNetworkController extends Handler {
                        + "\"" + ruleString + "\"");
            }

            if (source.contains(AccessNetworkType.UNKNOWN)) {
                throw new IllegalArgumentException("Source access networks contains unknown. "
                        + "\"" + ruleString + "\"");
            if (source.contains(AccessNetworkType.UNKNOWN) && type != RULE_TYPE_DISALLOWED) {
                throw new IllegalArgumentException("Unknown access network can be only specified in"
                        + " the disallowed rule. \"" + ruleString + "\"");
            }

            if (target.contains(AccessNetworkType.UNKNOWN)) {
+32 −13
Original line number Diff line number Diff line
@@ -77,6 +77,13 @@ public class DataProfileManager extends Handler {
    private final String mLogTag;
    private final LocalLog mLocalLog = new LocalLog(128);

    /**
     * Should only be used by update updateDataProfiles() to indicate whether resend IA to modem
     * regardless whether IA changed.
     **/
    private final boolean FORCED_UPDATE_IA = true;
    private final boolean ONLY_UPDATE_IA_IF_CHANGED = false;

    /** Data network controller. */
    private final @NonNull DataNetworkController mDataNetworkController;

@@ -182,11 +189,11 @@ public class DataProfileManager extends Handler {
        switch (msg.what) {
            case EVENT_SIM_REFRESH:
                log("Update data profiles due to SIM refresh.");
                updateDataProfiles();
                updateDataProfiles(FORCED_UPDATE_IA);
                break;
            case EVENT_APN_DATABASE_CHANGED:
                log("Update data profiles due to APN db updated.");
                updateDataProfiles();
                updateDataProfiles(ONLY_UPDATE_IA_IF_CHANGED);
                break;
            default:
                loge("Unexpected event " + msg);
@@ -199,7 +206,7 @@ public class DataProfileManager extends Handler {
     */
    private void onCarrierConfigUpdated() {
        log("Update data profiles due to carrier config updated.");
        updateDataProfiles();
        updateDataProfiles(FORCED_UPDATE_IA);

        //TODO: more works needed to be done here.
    }
@@ -237,8 +244,10 @@ public class DataProfileManager extends Handler {
    /**
     * Update all data profiles, including preferred data profile, and initial attach data profile.
     * Also send those profiles down to the modem if needed.
     *
     * @param forceUpdateIa If {@code true}, we should always send IA again to modem.
     */
    private void updateDataProfiles() {
    private void updateDataProfiles(boolean forceUpdateIa) {
        List<DataProfile> profiles = new ArrayList<>();
        if (mDataConfigManager.isConfigCarrierSpecific()) {
            Cursor cursor = mPhone.getContext().getContentResolver().query(
@@ -345,7 +354,7 @@ public class DataProfileManager extends Handler {
        }

        updateDataProfilesAtModem();
        updateInitialAttachDataProfileAtModem();
        updateInitialAttachDataProfileAtModem(forceUpdateIa);

        if (profilesChanged) {
            mDataProfileManagerCallbacks.forEach(callback -> callback.invokeFromExecutor(
@@ -403,7 +412,7 @@ public class DataProfileManager extends Handler {
                .orElse(null);
        // Save the preferred data profile into database.
        setPreferredDataProfile(dataProfile);
        updateDataProfiles();
        updateDataProfiles(ONLY_UPDATE_IA_IF_CHANGED);
    }

    /**
@@ -525,8 +534,10 @@ public class DataProfileManager extends Handler {
     * Some carriers might explicitly require that using "user-added" APN for initial
     * attach. In this case, exception can be configured through
     * {@link CarrierConfigManager#KEY_ALLOWED_INITIAL_ATTACH_APN_TYPES_STRING_ARRAY}.
     *
     * @param forceUpdateIa If {@code true}, we should always send IA again to modem.
     */
    private void updateInitialAttachDataProfileAtModem() {
    private void updateInitialAttachDataProfileAtModem(boolean forceUpdateIa) {
        DataProfile initialAttachDataProfile = null;

        // Sort the data profiles so the preferred data profile is at the beginning.
@@ -542,11 +553,12 @@ public class DataProfileManager extends Handler {
            if (initialAttachDataProfile != null) break;
        }

        if (!Objects.equals(mInitialAttachDataProfile, initialAttachDataProfile)) {
        if (forceUpdateIa || !Objects.equals(mInitialAttachDataProfile, initialAttachDataProfile)) {
            mInitialAttachDataProfile = initialAttachDataProfile;
            logl("Initial attach data profile updated as " + mInitialAttachDataProfile);
            logl("Initial attach data profile updated as " + mInitialAttachDataProfile
                    + " or forceUpdateIa= " + forceUpdateIa);
            // TODO: Push the null data profile to modem on new AIDL HAL. Modem should clear the IA
            //  APN.
            //  APN, tracking for U b/227579876, now using forceUpdateIa which always push to modem
            if (mInitialAttachDataProfile != null) {
                mWwanDataServiceManager.setInitialAttachApn(mInitialAttachDataProfile,
                        mPhone.getServiceState().getDataRoamingFromRegistration(), null);
@@ -815,10 +827,17 @@ public class DataProfileManager extends Handler {
        for (int i = 0; i < profiles.size(); i++) {
            ApnSetting a = profiles.get(i).getApnSetting();
            if (a == null) continue;
            if ((a.getNetworkTypeBitmask() | a.getLingeringNetworkTypeBitmask())
            if (// Lingering network is not the default and doesn't cover all the regular networks
                    (int) TelephonyManager.NETWORK_TYPE_BITMASK_UNKNOWN
                    != a.getLingeringNetworkTypeBitmask()
                            && (a.getNetworkTypeBitmask() | a.getLingeringNetworkTypeBitmask())
                    != a.getLingeringNetworkTypeBitmask()) {
                reportAnomaly("Apn[" + a.getApnName()
                                + "] supported network should be a subset of the lingering network",
                reportAnomaly("Apn[" + a.getApnName() + "] network "
                                + TelephonyManager.convertNetworkTypeBitmaskToString(
                                        a.getNetworkTypeBitmask()) + " should be a subset of "
                                + "the lingering network "
                                + TelephonyManager.convertNetworkTypeBitmaskToString(
                                a.getLingeringNetworkTypeBitmask()),
                        "9af73e18-b523-4dc5-adab-4bb24355d838");
            }
            for (int j = i + 1; j < profiles.size(); j++) {
+21 −3
Original line number Diff line number Diff line
@@ -404,9 +404,27 @@ public class DataUtils {
                            .boxed().collect(Collectors.toSet()),
                    v -> new NetworkRequestList()).add(networkRequest);
        }
        // Sort the list, so the network request list contains higher priority will be in the front
        // of the list.
        return new ArrayList<>(requestsMap.values()).stream()
        List<NetworkRequestList> requests = new ArrayList<>();
        // Create separate groups for enterprise requests with different enterprise IDs.
        for (NetworkRequestList requestList : requestsMap.values()) {
            List<TelephonyNetworkRequest> enterpriseRequests = requestList.stream()
                    .filter(request ->
                            request.hasCapability(NetworkCapabilities.NET_CAPABILITY_ENTERPRISE))
                    .collect(Collectors.toList());
            if (enterpriseRequests.isEmpty()) {
                requests.add(requestList);
                continue;
            }
            // Key is the enterprise ID
            Map<Integer, NetworkRequestList> enterpriseRequestsMap = new ArrayMap<>();
            for (TelephonyNetworkRequest request : enterpriseRequests) {
                enterpriseRequestsMap.computeIfAbsent(request.getCapabilityDifferentiator(),
                        v -> new NetworkRequestList()).add(request);
            }
            requests.addAll(enterpriseRequestsMap.values());
        }
        // Sort the requests so the network request list with higher priority will be at the front.
        return requests.stream()
                .sorted((list1, list2) -> Integer.compare(
                        list2.get(0).getPriority(), list1.get(0).getPriority()))
                .collect(Collectors.toList());
+1 −1
Original line number Diff line number Diff line
@@ -715,7 +715,7 @@ public class LinkBandwidthEstimator extends Handler {
            int filterInKbps = mBwSampleValid ? mBwSampleKbps : avgKbps;

            long currTimeMs = mTelephonyFacade.getElapsedSinceBootMillis();
            int timeDeltaSec = (int) (currTimeMs - mBwSampleValidTimeMs) / 1000;
            int timeDeltaSec = (int) ((currTimeMs - mBwSampleValidTimeMs) / 1000);

            // If the operation condition changes significantly since the last update
            // or the sample has higher BW, use a faster filter. Otherwise, use a slow filter
Loading