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

Commit 658b0cad authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Verify polling loop patterns and filters in ApduServiceInfo" into main...

Merge "Verify polling loop patterns and filters in ApduServiceInfo" into main am: fa086ff0 am: 61cf0de0

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/3490910



Change-Id: I92682d610e67e3741a4c20ffb1dac7fe613fa39a
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 7dc3dcde 61cf0de0
Loading
Loading
Loading
Loading
+28 −3
Original line number Diff line number Diff line
@@ -70,6 +70,11 @@ import java.util.regex.Pattern;
public final class ApduServiceInfo implements Parcelable {
    private static final String TAG = "ApduServiceInfo";

    private static final Pattern PLPF_PATTERN =
            Pattern.compile("[0-9A-Fa-f]{2,}[0-9A-Fa-f,\\?,\\*\\.]*");
    private static final Pattern PLF_PATTERN =
            Pattern.compile("[0-9A-Fa-f]{2,}");

    /**
     * Component level {@link android.content.pm.PackageManager.Property PackageManager
     * .Property} for a system application to change its icon and label
@@ -472,7 +477,12 @@ public final class ApduServiceInfo implements Parcelable {
                    boolean autoTransact = a.getBoolean(
                            com.android.internal.R.styleable.PollingLoopFilter_autoTransact,
                            false);
                    if (!mOnHost && !autoTransact) {
                    boolean isValidFilter = PLF_PATTERN.matcher(plf).matches()
                            && plf.length() % 2 == 0;
                    if (!isValidFilter) {
                        Log.e(TAG, "Ignoring polling-loop-filter " + plf
                                + " it is not a valid filter");
                    } else if (!mOnHost && !autoTransact) {
                        Log.e(TAG, "Ignoring polling-loop-filter " + plf
                                + " for offhost service that isn't autoTransact");
                    } else {
@@ -489,8 +499,12 @@ public final class ApduServiceInfo implements Parcelable {
                    boolean autoTransact = a.getBoolean(
                            com.android.internal.R.styleable.PollingLoopFilter_autoTransact,
                            false);
                    if (!mOnHost && !autoTransact) {
                        Log.e(TAG, "Ignoring polling-loop-filter " + plf
                    boolean isValidFilter = PLPF_PATTERN.matcher(plf).matches();
                    if (!isValidFilter) {
                        Log.e(TAG, "Ignoring polling-loop-pattern-filter " + plf
                                + " it is not a valid pattern filter");
                    } else if (!mOnHost && !autoTransact) {
                        Log.e(TAG, "Ignoring polling-loop-pattern-filter " + plf
                                + " for offhost service that isn't autoTransact");
                    } else {
                        mAutoTransactPatterns.put(Pattern.compile(plf), autoTransact);
@@ -814,6 +828,12 @@ public final class ApduServiceInfo implements Parcelable {
    @FlaggedApi(Flags.FLAG_NFC_READ_POLLING_LOOP)
    public void addPollingLoopFilter(@NonNull String pollingLoopFilter,
            boolean autoTransact) {
        if (!PLF_PATTERN.matcher(pollingLoopFilter).matches()
                || pollingLoopFilter.length() % 2 != 0) {
            throw new IllegalArgumentException(
                    "Polling loop filter must contain an even number of characters 0-9 or A-F"
            );
        }
        if (!mOnHost && !autoTransact) {
            return;
        }
@@ -842,6 +862,11 @@ public final class ApduServiceInfo implements Parcelable {
    @FlaggedApi(Flags.FLAG_NFC_READ_POLLING_LOOP)
    public void addPollingLoopPatternFilter(@NonNull String pollingLoopPatternFilter,
            boolean autoTransact) {
        if (!PLPF_PATTERN.matcher(pollingLoopPatternFilter).matches()) {
            throw new IllegalArgumentException(
                    "Polling loop pattern filter is invalid"
            );
        }
        if (!mOnHost && !autoTransact) {
            return;
        }