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

Commit 99f42c2a authored by Sarah Chin's avatar Sarah Chin
Browse files

DataRetryManager don't remove unthrottled entries on cleanup

Otherwise, it'll cause a ConcurrentModificationException
Cleanup will clear the list of entries anyways.

Test: atest DataRetryManagerTest
Bug: 228164116
Change-Id: I35fa1c762a3e97f0bfb4a9ce84aa13578557ac91
parent 5ecb8b7d
Loading
Loading
Loading
Loading
+7 −17
Original line number Diff line number Diff line
@@ -1000,7 +1000,7 @@ public class DataRetryManager extends Handler {
                } else if (ar.result instanceof DataProfile) {
                    dataProfile = (DataProfile) ar.result;
                }
                onDataProfileUnthrottled(dataProfile, apn, transport);
                onDataProfileUnthrottled(dataProfile, apn, transport, true);
                break;
            case EVENT_CANCEL_PENDING_HANDOVER_RETRY:
                onCancelPendingHandoverRetry((DataNetwork) msg.obj);
@@ -1217,24 +1217,11 @@ public class DataRetryManager extends Handler {
                .filter(entry -> entry.getState() == DataRetryEntry.RETRY_STATE_NOT_RETRIED)
                .forEach(entry -> entry.setState(DataRetryEntry.RETRY_STATE_CANCELLED));

        final List<ThrottleStatus> throttleStatusList = new ArrayList<>();
        for (DataThrottlingEntry dataThrottlingEntry : mDataThrottlingEntries) {
            DataProfile dataProfile = dataThrottlingEntry.dataProfile;
            String apn = dataProfile.getApnSetting() != null
                    ? dataProfile.getApnSetting().getApnName() : null;
            onDataProfileUnthrottled(dataProfile, apn, dataThrottlingEntry.transport);
            if (dataProfile.getApnSetting() != null) {
                throttleStatusList.addAll(dataProfile.getApnSetting().getApnTypes()
                        .stream()
                        .map(apnType -> new ThrottleStatus.Builder()
                                .setApnType(apnType)
                                .setSlotIndex(mPhone.getPhoneId())
                                .setNoThrottle()
                                .setRetryType(dataThrottlingEntry.retryType)
                                .setTransportType(dataThrottlingEntry.transport)
                                .build())
                        .collect(Collectors.toList()));
            }
            onDataProfileUnthrottled(dataProfile, apn, dataThrottlingEntry.transport, false);
        }

        mDataThrottlingEntries.clear();
@@ -1390,9 +1377,10 @@ public class DataRetryManager extends Handler {
     * @param apn The apn to be unthrottled. Note this should be only used for HIDL 1.6 or below.
     * When this is set, {@code dataProfile} must be {@code null}.
     * @param transport The transport that this unthrottling request is on.
     * @param remove Whether to remove unthrottled entries from the list of entries.
     */
    private void onDataProfileUnthrottled(@Nullable DataProfile dataProfile, @Nullable String apn,
            int transport) {
            int transport, boolean remove) {
        long now = SystemClock.elapsedRealtime();
        List<DataThrottlingEntry> dataUnthrottlingEntries = new ArrayList<>();
        if (dataProfile != null) {
@@ -1466,8 +1454,10 @@ public class DataRetryManager extends Handler {
                        .build());
            }
        }
        if (remove) {
            mDataThrottlingEntries.removeAll(dataUnthrottlingEntries);
        }
    }

    /**
     * Check if there is any similar network request scheduled to retry. The definition of similar