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

Commit 641ad042 authored by Alisher Alikhodjaev's avatar Alisher Alikhodjaev Committed by Gerrit Code Review
Browse files

Merge "Address API council feedback for setDiscoveryTechnology flags" into main

parents 45e63e8f 8ebe7a3f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -97,12 +97,12 @@ package android.nfc {
    field public static final String EXTRA_SECURE_ELEMENT_NAME = "android.nfc.extra.SECURE_ELEMENT_NAME";
    field public static final String EXTRA_TAG = "android.nfc.extra.TAG";
    field @FlaggedApi("android.nfc.enable_nfc_set_discovery_tech") public static final int FLAG_LISTEN_DISABLE = 0; // 0x0
    field @FlaggedApi("android.nfc.enable_nfc_set_discovery_tech") public static final int FLAG_LISTEN_KEEP = -1; // 0xffffffff
    field @FlaggedApi("android.nfc.enable_nfc_set_discovery_tech") public static final int FLAG_LISTEN_KEEP = -2147483648; // 0x80000000
    field @FlaggedApi("android.nfc.enable_nfc_set_discovery_tech") public static final int FLAG_LISTEN_NFC_PASSIVE_A = 1; // 0x1
    field @FlaggedApi("android.nfc.enable_nfc_set_discovery_tech") public static final int FLAG_LISTEN_NFC_PASSIVE_B = 2; // 0x2
    field @FlaggedApi("android.nfc.enable_nfc_set_discovery_tech") public static final int FLAG_LISTEN_NFC_PASSIVE_F = 4; // 0x4
    field @FlaggedApi("android.nfc.enable_nfc_set_discovery_tech") public static final int FLAG_READER_DISABLE = 0; // 0x0
    field @FlaggedApi("android.nfc.enable_nfc_set_discovery_tech") public static final int FLAG_READER_KEEP = -1; // 0xffffffff
    field @FlaggedApi("android.nfc.enable_nfc_set_discovery_tech") public static final int FLAG_READER_KEEP = -2147483648; // 0x80000000
    field public static final int FLAG_READER_NFC_A = 1; // 0x1
    field public static final int FLAG_READER_NFC_B = 2; // 0x2
    field public static final int FLAG_READER_NFC_BARCODE = 16; // 0x10
+17 −6
Original line number Diff line number Diff line
@@ -414,18 +414,18 @@ public final class NfcAdapter {
    /**
     * Flags for use with {@link #setDiscoveryTechnology(Activity, int, int)}.
     * <p>
     * Setting this flag makes listening to use current flags.
     * Setting this flag makes listening to keep the current technology configuration.
     */
    @FlaggedApi(Flags.FLAG_ENABLE_NFC_SET_DISCOVERY_TECH)
    public static final int FLAG_LISTEN_KEEP = -1;
    public static final int FLAG_LISTEN_KEEP = 0x80000000;

    /**
     * Flags for use with {@link #setDiscoveryTechnology(Activity, int, int)}.
     * <p>
     * Setting this flag makes polling to use current flags.
     * Setting this flag makes polling to keep the current technology configuration.
     */
    @FlaggedApi(Flags.FLAG_ENABLE_NFC_SET_DISCOVERY_TECH)
    public static final int FLAG_READER_KEEP = -1;
    public static final int FLAG_READER_KEEP = 0x80000000;

    /** @hide */
    public static final int FLAG_USE_ALL_TECH = 0xff;
@@ -1793,6 +1793,8 @@ public final class NfcAdapter {
     *
     * Use {@link #FLAG_READER_KEEP} to keep current polling technology.
     * Use {@link #FLAG_LISTEN_KEEP} to keep current listenig technology.
     * (if the _KEEP flag is specified the other technology flags shouldn't be set
     * and are quietly ignored otherwise).
     * Use {@link #FLAG_READER_DISABLE} to disable polling.
     * Use {@link #FLAG_LISTEN_DISABLE} to disable listening.
     * Also refer to {@link #resetDiscoveryTechnology(Activity)} to restore these changes.
@@ -1824,6 +1826,15 @@ public final class NfcAdapter {
    @FlaggedApi(Flags.FLAG_ENABLE_NFC_SET_DISCOVERY_TECH)
    public void setDiscoveryTechnology(@NonNull Activity activity,
            @PollTechnology int pollTechnology, @ListenTechnology int listenTechnology) {

        // A special treatment of the _KEEP flags
        if ((listenTechnology & FLAG_LISTEN_KEEP) != 0) {
            listenTechnology = -1;
        }
        if ((pollTechnology & FLAG_READER_KEEP) != 0) {
            pollTechnology = -1;
        }

        if (listenTechnology == FLAG_LISTEN_DISABLE) {
            synchronized (sLock) {
                if (!sHasNfcFeature) {
@@ -1850,10 +1861,10 @@ public final class NfcAdapter {
    }

    /**
     * Restore the poll/listen technologies of NFC controller,
     * Restore the poll/listen technologies of NFC controller to its default state,
     * which were changed by {@link #setDiscoveryTechnology(Activity , int , int)}
     *
     * @param activity The Activity that requests to changed technologies.
     * @param activity The Activity that requested to change technologies.
     */

    @FlaggedApi(Flags.FLAG_ENABLE_NFC_SET_DISCOVERY_TECH)