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

Commit 60649e6b authored by Ling Ma's avatar Ling Ma
Browse files

Remove anomaly report detection for frequent QNS request

Due to most detected bugreports are intended behavior and conurrentModification when connectivityservice modified the request list while and ANM tries to iterate it.

Bug: 247487026
Test: basic data browsing + voice call
Change-Id: I25de116c522104f47d0661443ae85e7857c788b7
parent bb8155c6
Loading
Loading
Loading
Loading
+0 −30
Original line number Diff line number Diff line
@@ -365,18 +365,12 @@ public class AccessNetworksManager extends Handler {
            }

            List<QualifiedNetworks> qualifiedNetworksList = new ArrayList<>();
            // For anomaly report, only track frequent HO between cellular and IWLAN
            boolean isRequestedNetworkOnIwlan = Arrays.stream(qualifiedNetworkTypes)
                    .anyMatch(network -> network == AccessNetworkType.IWLAN);
            int satisfiedApnTypes = 0;
            for (int apnType : SUPPORTED_APN_TYPES) {
                if ((apnTypes & apnType) == apnType) {
                    // skip the APN anomaly detection if not using the T data stack
                    if (mDataConfigManager != null) {
                        satisfiedApnTypes |= apnType;
                        if (isRequestedNetworkOnIwlan) {
                            trackFrequentApnTypeChange(apnType);
                        }
                    }

                    if (mAvailableNetworks.get(apnType) != null) {
@@ -428,30 +422,6 @@ public class AccessNetworksManager extends Handler {
        }
    }

    /**
     * Called when receiving preferred transport change request for a specific apnType.
     *
     * @param apnType The requested apnType.
     */
    private void trackFrequentApnTypeChange(@ApnSetting.ApnType int apnType) {
        DataNetworkController dnc = mPhone.getDataNetworkController();
        // ignore the report when no existing network request
        if (!dnc.isCapabilityRequestExisting(DataUtils.apnTypeToNetworkCapability(apnType))) return;
        SlidingWindowEventCounter counter = mApnTypeToQnsChangeNetworkCounter.get(apnType);
        if (counter == null) {
            counter = new SlidingWindowEventCounter(
                    mDataConfigManager.getAnomalyQnsChangeThreshold().timeWindow,
                    mDataConfigManager.getAnomalyQnsChangeThreshold().eventNumOccurrence);
            mApnTypeToQnsChangeNetworkCounter.put(apnType, counter);
        }
        if (counter.addOccurrence()) {
            reportAnomaly("QNS requested network change for "
                            + ApnSetting.getApnTypeString(apnType) + " "
                            + counter.getFrequencyString(),
                    "3e89a3df-3524-45fa-b5f2-b8911abc7d56");
        }
    }

    /**
     * Access networks manager callback. This should be only used by {@link DataNetworkController}.
     */
+0 −18
Original line number Diff line number Diff line
@@ -233,11 +233,6 @@ public class DataConfigManager extends Handler {
     */
    private EventFrequency mNetworkUnwantedAnomalyReportThreshold;

    /**
     * Anomaly report thresholds for frequent APN type change at {@link AccessNetworksManager}
     */
    private EventFrequency mQnsFrequentApnTypeChangeAnomalyReportThreshold;

    /**
     * {@code true} if enabled anomaly detection for param when QNS wants to change preferred
     * network at {@link AccessNetworksManager}.
@@ -421,8 +416,6 @@ public class DataConfigManager extends Handler {
                properties.getString(KEY_ANOMALY_NETWORK_UNWANTED, null), 0, 12);
        mSetupDataCallAnomalyReportThreshold = parseSlidingWindowCounterThreshold(
                properties.getString(KEY_ANOMALY_SETUP_DATA_CALL_FAILURE, null), 0, 12);
        mQnsFrequentApnTypeChangeAnomalyReportThreshold = parseSlidingWindowCounterThreshold(
                properties.getString(KEY_ANOMALY_QNS_CHANGE_NETWORK, null), 0, 5);
        mIsInvalidQnsParamAnomalyReportEnabled = properties.getBoolean(
                KEY_ANOMALY_QNS_PARAM, false);
        mNetworkConnectingTimeout = properties.getInt(
@@ -868,15 +861,6 @@ public class DataConfigManager extends Handler {
        return mImsReleaseRequestAnomalyReportThreshold;
    }

    /**
     * Anomaly report thresholds for frequent QNS change of preferred network
     * at {@link AccessNetworksManager}
     * @return EventFrequency to trigger the anomaly report
     */
    public @NonNull EventFrequency getAnomalyQnsChangeThreshold() {
        return mQnsFrequentApnTypeChangeAnomalyReportThreshold;
    }

    /**
     * @return {@code true} if enabled anomaly report for invalid param when QNS wants to change
     * preferred network at {@link AccessNetworksManager}.
@@ -1292,8 +1276,6 @@ public class DataConfigManager extends Handler {
        pw.println("mSetupDataCallAnomalyReport=" + mSetupDataCallAnomalyReportThreshold);
        pw.println("mNetworkUnwantedAnomalyReport=" + mNetworkUnwantedAnomalyReportThreshold);
        pw.println("mImsReleaseRequestAnomalyReport=" + mImsReleaseRequestAnomalyReportThreshold);
        pw.println("mQnsFrequentApnTypeChangeAnomalyReportThreshold="
                + mQnsFrequentApnTypeChangeAnomalyReportThreshold);
        pw.println("mIsInvalidQnsParamAnomalyReportEnabled="
                + mIsInvalidQnsParamAnomalyReportEnabled);
        pw.println("mNetworkConnectingTimeout=" + mNetworkConnectingTimeout);
+0 −12
Original line number Diff line number Diff line
@@ -2103,18 +2103,6 @@ public class DataNetworkController extends Handler {
        return mAllNetworkRequestList.contains(networkRequest);
    }

    /**
     * Check if a request for the capability currently exists. Note this method id not thread safe
     * so can be only called within the modules in {@link com.android.internal.telephony.data}.
     *
     * @param capability Network capability to check
     * @return {@code true} if the request for the capability exists.
     */
    public boolean isCapabilityRequestExisting(@NetCapability int capability) {
        return mAllNetworkRequestList.stream()
                .anyMatch(request -> request.hasCapability(capability));
    }

    /**
     * Check if there are existing networks having the same interface name.
     *
+0 −2
Original line number Diff line number Diff line
@@ -108,8 +108,6 @@ public class AccessNetworksManagerTest extends TelephonyTest {
        }).when(mMockedCallback).invokeFromExecutor(any(Runnable.class));

        mMockedDataConfigManager = Mockito.mock(DataConfigManager.class);
        doReturn(new DataConfigManager.EventFrequency(0, 2))
                .when(mMockedDataConfigManager).getAnomalyQnsChangeThreshold();
        mAccessNetworksManager = new AccessNetworksManager(mPhone, Looper.myLooper());

        processAllMessages();