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

Commit 3e2defe1 authored by Kyle Hsiao's avatar Kyle Hsiao
Browse files

Use Concurrent Map instead to avoid ConcurrentModificationException with mAutoTransactPatterns.

Bug: 428371423
Test: manual
Flag: EXEMPT bugfix
Change-Id: Iae784e359d9b2a6aeb52dd9e118b096ad943ae55
parent f012564c
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -58,6 +58,9 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.regex.Pattern;

/**
@@ -138,7 +141,7 @@ public final class ApduServiceInfo implements Parcelable {

    private final Map<String, Boolean> mAutoTransact;

    private final Map<Pattern, Boolean> mAutoTransactPatterns;
    private final ConcurrentMap<Pattern, Boolean> mAutoTransactPatterns;

    /**
     * Whether this service should only be started when the device is unlocked.
@@ -251,7 +254,7 @@ public final class ApduServiceInfo implements Parcelable {
        this.mStaticAidGroups = new HashMap<String, AidGroup>();
        this.mDynamicAidGroups = new HashMap<String, AidGroup>();
        this.mAutoTransact = autoTransact;
        this.mAutoTransactPatterns = autoTransactPatterns;
        this.mAutoTransactPatterns = new ConcurrentHashMap<>(autoTransactPatterns);
        this.mOffHostName = offHost;
        this.mStaticOffHostName = staticOffHost;
        this.mOnHost = onHost;
@@ -383,8 +386,8 @@ public final class ApduServiceInfo implements Parcelable {
            mStaticAidGroups = new HashMap<String, AidGroup>();
            mDynamicAidGroups = new HashMap<String, AidGroup>();
            mAutoTransact = new HashMap<String, Boolean>();
            mAutoTransactPatterns = new TreeMap<Pattern, Boolean>(
                    Comparator.comparing(Pattern::toString));
            mAutoTransactPatterns =
                     new ConcurrentSkipListMap<>(Comparator.comparing(Pattern::toString));
            mOnHost = onHost;

            final int depth = parser.getDepth();