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

Commit 07054da8 authored by Brad Lassey's avatar Brad Lassey
Browse files

Add boolean autoTransact flag to registerPollingLoopForService()

Bug: b/326430356
Test: tested with a new CTS test
Change-Id: Iee80ffe23242da2dba059577fd5d3aef8017fa1e
parent 5190facc
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -10422,8 +10422,7 @@ package android.nfc.cardemulation {
  @FlaggedApi("android.nfc.enable_nfc_mainline") public final class ApduServiceInfo implements android.os.Parcelable {
    ctor @FlaggedApi("android.nfc.enable_nfc_mainline") public ApduServiceInfo(@NonNull android.content.pm.PackageManager, @NonNull android.content.pm.ResolveInfo, boolean) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
    method @FlaggedApi("android.nfc.nfc_read_polling_loop") public void addPollingLoopFilter(@NonNull String);
    method @FlaggedApi("android.nfc.nfc_read_polling_loop") public void addPollingLoopFilterToAutoTransact(@NonNull String);
    method @FlaggedApi("android.nfc.nfc_read_polling_loop") public void addPollingLoopFilter(@NonNull String, boolean);
    method @FlaggedApi("android.nfc.nfc_observe_mode") public boolean defaultToObserveMode();
    method @FlaggedApi("android.nfc.enable_nfc_mainline") public int describeContents();
    method @FlaggedApi("android.nfc.enable_nfc_mainline") public void dump(@NonNull android.os.ParcelFileDescriptor, @NonNull java.io.PrintWriter, @NonNull String[]);
+1 −1
Original line number Diff line number Diff line
@@ -204,7 +204,7 @@ package android.nfc.cardemulation {
    method public boolean isDefaultServiceForAid(android.content.ComponentName, String);
    method public boolean isDefaultServiceForCategory(android.content.ComponentName, String);
    method public boolean registerAidsForService(android.content.ComponentName, String, java.util.List<java.lang.String>);
    method @FlaggedApi("android.nfc.nfc_read_polling_loop") public boolean registerPollingLoopFilterForService(@NonNull android.content.ComponentName, @NonNull String);
    method @FlaggedApi("android.nfc.nfc_read_polling_loop") public boolean registerPollingLoopFilterForService(@NonNull android.content.ComponentName, @NonNull String, boolean);
    method public boolean removeAidsForService(android.content.ComponentName, String);
    method @FlaggedApi("android.nfc.nfc_observe_mode") public boolean setDefaultToObserveModeForService(@NonNull android.content.ComponentName, boolean);
    method @NonNull @RequiresPermission(android.Manifest.permission.NFC) public boolean setOffHostForService(@NonNull android.content.ComponentName, @NonNull String);
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ interface INfcCardEmulation
    boolean setDefaultForNextTap(int userHandle, in ComponentName service);
    boolean setDefaultToObserveModeForService(int userId, in android.content.ComponentName service, boolean enable);
    boolean registerAidGroupForService(int userHandle, in ComponentName service, in AidGroup aidGroup);
    boolean registerPollingLoopFilterForService(int userHandle, in ComponentName service, in String pollingLoopFilter);
    boolean registerPollingLoopFilterForService(int userHandle, in ComponentName service, in String pollingLoopFilter, boolean autoTransact);
    boolean setOffHostForService(int userHandle, in ComponentName service, in String offHostSecureElement);
    boolean unsetOffHostForService(int userHandle, in ComponentName service);
    AidGroup getAidGroupForService(int userHandle, in ComponentName service, String category);
+5 −21
Original line number Diff line number Diff line
@@ -668,33 +668,17 @@ public final class ApduServiceInfo implements Parcelable {

    /**
     * Add a Polling Loop Filter. Custom NFC polling frames that match this filter will be
     * delivered to {@link HostApduService#processPollingFrames(List)}. Adding a key with this or
     * {@link  ApduServiceInfo#addPollingLoopFilterToAutoTransact(String)} multiple times will
     * cause the value to be overwritten each time.
     * delivered to {@link HostApduService#processPollingFrames(List)}. Adding a key with this
     * multiple times will cause the value to be overwritten each time.
     * @param pollingLoopFilter the polling loop filter to add, must be a  valide hexadecimal string
     */
    @FlaggedApi(Flags.FLAG_NFC_READ_POLLING_LOOP)
    public void addPollingLoopFilter(@NonNull String pollingLoopFilter) {
        mAutoTransact.put(pollingLoopFilter.toUpperCase(Locale.ROOT), false);
    public void addPollingLoopFilter(@NonNull String pollingLoopFilter,
            boolean autoTransact) {
        mAutoTransact.put(pollingLoopFilter, autoTransact);

    }

    /**
     * Add a Polling Loop Filter. Custom NFC polling frames that match this filter will cause the
     * device to exit observe mode, just as if
     * {@link android.nfc.NfcAdapter#setObserveModeEnabled(boolean)} had been called with true,
     * allowing transactions to proceed. The matching frame will also be delivered to
     * {@link HostApduService#processPollingFrames(List)}. Adding a key with this or
     * {@link  ApduServiceInfo#addPollingLoopFilter(String)} multiple times will
     * cause the value to be overwritten each time.
     *
     * @param pollingLoopFilter the polling loop filter to add, must be a  valide hexadecimal string
     */
    @FlaggedApi(Flags.FLAG_NFC_READ_POLLING_LOOP)
    public void addPollingLoopFilterToAutoTransact(@NonNull String pollingLoopFilter) {
        mAutoTransact.put(pollingLoopFilter.toUpperCase(Locale.ROOT), true);
    }

    /**
     * Remove a Polling Loop Filter. Custom NFC polling frames that match this filter will no
     * longer be delivered to {@link HostApduService#processPollingFrames(List)}.
+11 −7
Original line number Diff line number Diff line
@@ -360,21 +360,24 @@ public final class CardEmulation {
    }

    /**
     * Register a polling loop filter (PLF) for a HostApduService. The PLF can be sequence of an
     * even number of hexadecimal numbers (0-9, A-F or a-f). When non-standard polling loop frame
     * matches this sequence exactly, it may be delivered to
     * {@link HostApduService#processPollingFrames(List)}  if this service is currently
     * Register a polling loop filter (PLF) for a HostApduService and indicate whether it should
     * auto-transact or not.  When non-standard polling loop frame matches this sequence exactly,
     *  it may be delivered to {@link HostApduService#processPollingFrames(List)}. If auto-transact
     * is set to true, then observe mode will also be disabled.  if this service is currently
     * preferred or there are no other services registered for this filter.
     * @param service The HostApduService to register the filter for
     * @param pollingLoopFilter The filter to register
     * @param autoTransact true to have the NFC stack automatically disable observe mode and allow
     *         transactions to proceed when this filter matches, false otherwise
     * @return true if the filter was registered, false otherwise
     */
    @FlaggedApi(Flags.FLAG_NFC_READ_POLLING_LOOP)
    public boolean registerPollingLoopFilterForService(@NonNull ComponentName service,
            @NonNull String pollingLoopFilter) {
            @NonNull String pollingLoopFilter, boolean autoTransact) {

        try {
            return sService.registerPollingLoopFilterForService(mContext.getUser().getIdentifier(),
                    service, pollingLoopFilter);
                    service, pollingLoopFilter, autoTransact);
        } catch (RemoteException e) {
            // Try one more time
            recoverService();
@@ -384,7 +387,8 @@ public final class CardEmulation {
            }
            try {
                return sService.registerPollingLoopFilterForService(
                        mContext.getUser().getIdentifier(), service, pollingLoopFilter);
                        mContext.getUser().getIdentifier(), service,
                        pollingLoopFilter, autoTransact);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to reach CardEmulationService.");
                return false;