diff options
| -rw-r--r-- | nfc/api/current.txt | 4 | ||||
| -rw-r--r-- | nfc/java/android/nfc/NfcAdapter.java | 23 |
2 files changed, 19 insertions, 8 deletions
diff --git a/nfc/api/current.txt b/nfc/api/current.txt index 91e460324289..0ab2ef7ed7cb 100644 --- a/nfc/api/current.txt +++ b/nfc/api/current.txt @@ -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 diff --git a/nfc/java/android/nfc/NfcAdapter.java b/nfc/java/android/nfc/NfcAdapter.java index 979855e5e25c..079172142145 100644 --- a/nfc/java/android/nfc/NfcAdapter.java +++ b/nfc/java/android/nfc/NfcAdapter.java @@ -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) |