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

Commit 465b413d authored by Brad Lassey's avatar Brad Lassey
Browse files

Offhost NFC services shouldn't be able to register non-autotransact polling loop filters

Bug: 336301469
Test: Tested with CTS
Change-Id: Idbf4fd98531532274c8af437aa35ff99f1c4ce3e
parent 7d3c993f
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -4477,8 +4477,8 @@
    </declare-styleable>
    <!-- Specify one or more <code>polling-loop-filter</code> elements inside a
         <code>host-apdu-service</code> to indicate polling loop frames that
         your service can handle. -->
         <code>host-apdu-service</code> or <code>offhost-apdu-service</code> to indicate polling
         loop frames that your service can handle. -->
    <!-- @FlaggedApi("android.nfc.nfc_read_polling_loop") -->
    <declare-styleable name="PollingLoopFilter">
        <!-- The polling loop frame. This attribute is mandatory. -->
@@ -4490,8 +4490,8 @@
    </declare-styleable>
    <!-- Specify one or more <code>polling-loop-pattern-filter</code> elements inside a
         <code>host-apdu-service</code> to indicate polling loop frames that
         your service can handle. -->
         <code>host-apdu-service</code> or <code>offhost-apdu-service</code>  to indicate polling
         loop frames that your service can handle. -->
    <!-- @FlaggedApi("android.nfc.nfc_read_polling_loop") -->
    <declare-styleable name="PollingLoopPatternFilter">
        <!-- The patter to match polling loop frames to, must to be compatible with
+18 −4
Original line number Diff line number Diff line
@@ -410,7 +410,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
                                + " for offhost service that isn't autoTranact");
                    } else {
                        mAutoTransact.put(plf, autoTransact);
                    }
                    a.recycle();
                } else if (eventType == XmlPullParser.START_TAG
                        && "polling-loop-pattern-filter".equals(tagName) && currentGroup == null) {
@@ -422,7 +427,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
                                + " for offhost service that isn't autoTranact");
                    } else {
                        mAutoTransactPatterns.put(Pattern.compile(plf), autoTransact);
                    }
                    a.recycle();
                }
            }
@@ -729,8 +739,10 @@ public final class ApduServiceInfo implements Parcelable {
    @FlaggedApi(Flags.FLAG_NFC_READ_POLLING_LOOP)
    public void addPollingLoopFilter(@NonNull String pollingLoopFilter,
            boolean autoTransact) {
        if (!mOnHost && !autoTransact) {
            return;
        }
        mAutoTransact.put(pollingLoopFilter, autoTransact);

    }

    /**
@@ -755,8 +767,10 @@ public final class ApduServiceInfo implements Parcelable {
    @FlaggedApi(Flags.FLAG_NFC_READ_POLLING_LOOP)
    public void addPollingLoopPatternFilter(@NonNull String pollingLoopPatternFilter,
            boolean autoTransact) {
        if (!mOnHost && !autoTransact) {
            return;
        }
        mAutoTransactPatterns.put(Pattern.compile(pollingLoopPatternFilter), autoTransact);

    }

    /**