Skip to content

Commit 39cf3a4

Browse files
author
Nick Pelly
committed
Document NFC permissions.
Change-Id: Ib1b1625058c9c673692f3fbcb3546ec7c2d54a07
1 parent 584afa8 commit 39cf3a4

File tree

11 files changed

+93
-12
lines changed

11 files changed

+93
-12
lines changed

core/java/android/nfc/NfcAdapter.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
* <p>
3838
* Use the helper {@link #getDefaultAdapter(Context)} to get the default NFC
3939
* adapter for this Android device.
40-
* <p>
4140
*/
4241
public final class NfcAdapter {
4342
private static final String TAG = "NFC";
@@ -437,6 +436,8 @@ public boolean disable() {
437436
* the completion of their {@link Activity#onPause} callback to disable foreground dispatch
438437
* after it has been enabled.
439438
*
439+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
440+
*
440441
* @param activity the Activity to dispatch to
441442
* @param intent the PendingIntent to start for the dispatch
442443
* @param filters the IntentFilters to override dispatching for, or null to always dispatch
@@ -476,6 +477,8 @@ public void enableForegroundDispatch(Activity activity, PendingIntent intent,
476477
*
477478
* <p>This method must be called from the main thread.
478479
*
480+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
481+
*
479482
* @param activity the Activity to disable dispatch to
480483
* @throws IllegalStateException if the Activity has already been paused
481484
*/
@@ -513,10 +516,12 @@ void disableForegroundDispatchInternal(Activity activity, boolean force) {
513516
*
514517
* <p>This method must be called from the main thread.
515518
*
516-
* <p><em>NOTE</em> While foreground NDEF push is active standard tag dispatch is disabled.
519+
* <p class="note"><em>NOTE:</em> While foreground NDEF push is active standard tag dispatch is disabled.
517520
* Only the foreground activity may receive tag discovered dispatches via
518521
* {@link #enableForegroundDispatch}.
519522
*
523+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
524+
*
520525
* @param activity the foreground Activity
521526
* @param msg a NDEF Message to push over P2P
522527
* @throws IllegalStateException if the Activity is not currently in the foreground
@@ -548,6 +553,8 @@ public void enableForegroundNdefPush(Activity activity, NdefMessage msg) {
548553
*
549554
* <p>This method must be called from the main thread.
550555
*
556+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
557+
*
551558
* @param activity the Foreground activity
552559
* @throws IllegalStateException if the Activity has already been paused
553560
* @throws OperationNotSupportedException if this Android device does not support NDEF push

core/java/android/nfc/tech/IsoDep.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@
2626
/**
2727
* Provides access to ISO-DEP (ISO 14443-4) properties and I/O operations on a {@link Tag}.
2828
*
29-
* <p>Acquire a {@link IsoDep} object using {@link #get}.
29+
* <p>Acquire an {@link IsoDep} object using {@link #get}.
3030
* <p>The primary ISO-DEP I/O operation is {@link #transceive}. Applications must
3131
* implement their own protocol stack on top of {@link #transceive}.
3232
* <p>Tags that enumerate the {@link IsoDep} technology in {@link Tag#getTechList}
3333
* will also enumerate
3434
* {@link NfcA} or {@link NfcB} (since IsoDep builds on top of either of these).
35+
*
36+
* <p class="note"><strong>Note:</strong> Methods that perform I/O operations
37+
* require the {@link android.Manifest.permission#NFC} permission.
3538
*/
3639
public final class IsoDep extends BasicTagTechnology {
3740
private static final String TAG = "NFC";
@@ -80,6 +83,9 @@ public IsoDep(Tag tag)
8083
* <p>Setting a longer timeout may be useful when performing
8184
* transactions that require a long processing time on the tag
8285
* such as key generation.
86+
*
87+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
88+
*
8389
* @param timeout timeout value in milliseconds
8490
*/
8591
public void setTimeout(int timeout) {
@@ -142,6 +148,8 @@ public byte[] getHiLayerResponse() {
142148
* not be called from the main application thread. A blocked call will be canceled with
143149
* {@link IOException} if {@link #close} is called from another thread.
144150
*
151+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
152+
*
145153
* @param data command bytes to send, must not be null
146154
* @return response bytes received, will not be null
147155
* @throws TagLostException if the tag leaves the field

core/java/android/nfc/tech/MifareClassic.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
* MIFARE Classic cards that have been formatted according to the
5656
* MIFARE Application Directory (MAD) specification.
5757
* <li>{@link #KEY_NFC_FORUM} is the well-known key for MIFARE Classic cards that
58-
* have been formatted according to the NFC
58+
* have been formatted according to the NXP specification for NDEF on MIFARE Classic.
5959
*
6060
* <p>Implementation of this class on a Android NFC device is optional.
6161
* If it is not implemented, then
@@ -64,6 +64,9 @@
6464
* and {@link Ndef#MIFARE_CLASSIC} NDEF tags will also be supported. In either case,
6565
* {@link NfcA} will also be enumerated on the tag, because all MIFARE Classic tags are also
6666
* {@link NfcA}.
67+
*
68+
* <p class="note"><strong>Note:</strong> Methods that perform I/O operations
69+
* require the {@link android.Manifest.permission#NFC} permission.
6770
*/
6871
public final class MifareClassic extends BasicTagTechnology {
6972
/**
@@ -319,6 +322,8 @@ public int sectorToBlock(int sectorIndex) {
319322
* not be called from the main application thread. A blocked call will be canceled with
320323
* {@link IOException} if {@link #close} is called from another thread.
321324
*
325+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
326+
*
322327
* @param sectorIndex index of sector to authenticate, starting from 0
323328
* @param key 6-byte authentication key
324329
* @return true on success, false on authentication failure
@@ -344,6 +349,8 @@ public boolean authenticateSectorWithKeyA(int sectorIndex, byte[] key) throws IO
344349
* not be called from the main application thread. A blocked call will be canceled with
345350
* {@link IOException} if {@link #close} is called from another thread.
346351
*
352+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
353+
*
347354
* @param sectorIndex index of sector to authenticate, starting from 0
348355
* @param key 6-byte authentication key
349356
* @return true on success, false on authentication failure
@@ -398,6 +405,8 @@ private boolean authenticate(int sector, byte[] key, boolean keyA) throws IOExce
398405
* not be called from the main application thread. A blocked call will be canceled with
399406
* {@link IOException} if {@link #close} is called from another thread.
400407
*
408+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
409+
*
401410
* @param blockIndex index of block to read, starting from 0
402411
* @return 16 byte block
403412
* @throws TagLostException if the tag leaves the field
@@ -418,6 +427,8 @@ public byte[] readBlock(int blockIndex) throws IOException {
418427
* not be called from the main application thread. A blocked call will be canceled with
419428
* {@link IOException} if {@link #close} is called from another thread.
420429
*
430+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
431+
*
421432
* @param blockIndex index of block to write, starting from 0
422433
* @param data 16 bytes of data to write
423434
* @throws TagLostException if the tag leaves the field
@@ -445,6 +456,8 @@ public void writeBlock(int blockIndex, byte[] data) throws IOException {
445456
* not be called from the main application thread. A blocked call will be canceled with
446457
* {@link IOException} if {@link #close} is called from another thread.
447458
*
459+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
460+
*
448461
* @param blockIndex index of block to increment, starting from 0
449462
* @param value non-negative to increment by
450463
* @throws TagLostException if the tag leaves the field
@@ -471,6 +484,8 @@ public void increment(int blockIndex, int value) throws IOException {
471484
* not be called from the main application thread. A blocked call will be canceled with
472485
* {@link IOException} if {@link #close} is called from another thread.
473486
*
487+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
488+
*
474489
* @param blockIndex index of block to decrement, starting from 0
475490
* @param value non-negative to decrement by
476491
* @throws TagLostException if the tag leaves the field
@@ -497,6 +512,8 @@ public void decrement(int blockIndex, int value) throws IOException {
497512
* not be called from the main application thread. A blocked call will be canceled with
498513
* {@link IOException} if {@link #close} is called from another thread.
499514
*
515+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
516+
*
500517
* @param blockIndex index of block to copy to
501518
* @throws TagLostException if the tag leaves the field
502519
* @throws IOException if there is an I/O failure, or the operation is canceled
@@ -517,6 +534,8 @@ public void transfer(int blockIndex) throws IOException {
517534
* not be called from the main application thread. A blocked call will be canceled with
518535
* {@link IOException} if {@link #close} is called from another thread.
519536
*
537+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
538+
*
520539
* @param blockIndex index of block to copy from
521540
* @throws TagLostException if the tag leaves the field
522541
* @throws IOException if there is an I/O failure, or the operation is canceled
@@ -541,6 +560,8 @@ public void restore(int blockIndex) throws IOException {
541560
* not be called from the main application thread. A blocked call will be canceled with
542561
* {@link IOException} if {@link #close} is called from another thread.
543562
*
563+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
564+
*
544565
* @see NfcA#transceive
545566
*/
546567
public byte[] transceive(byte[] data) throws IOException {

core/java/android/nfc/tech/MifareUltralight.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
* If it is enumerated, then all {@link MifareUltralight} I/O operations will be supported.
5252
* In either case, {@link NfcA} will also be enumerated on the tag,
5353
* because all MIFARE Ultralight tags are also {@link NfcA} tags.
54+
*
55+
* <p class="note"><strong>Note:</strong> Methods that perform I/O operations
56+
* require the {@link android.Manifest.permission#NFC} permission.
5457
*/
5558
public final class MifareUltralight extends BasicTagTechnology {
5659
/** A MIFARE Ultralight compatible tag of unknown type */
@@ -136,6 +139,8 @@ public int getType() {
136139
* not be called from the main application thread. A blocked call will be canceled with
137140
* {@link IOException} if {@link #close} is called from another thread.
138141
*
142+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
143+
*
139144
* @param pageOffset index of first page to read, starting from 0
140145
* @return 4 pages (16 bytes)
141146
* @throws TagLostException if the tag leaves the field
@@ -159,6 +164,8 @@ public byte[] readPages(int pageOffset) throws IOException {
159164
* not be called from the main application thread. A blocked call will be canceled with
160165
* {@link IOException} if {@link #close} is called from another thread.
161166
*
167+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
168+
*
162169
* @param pageOffset index of page to write, starting from 0
163170
* @param data 4 bytes to write
164171
* @throws TagLostException if the tag leaves the field
@@ -187,6 +194,8 @@ public void writePage(int pageOffset, byte[] data) throws IOException {
187194
* not be called from the main application thread. A blocked call will be canceled with
188195
* {@link IOException} if {@link #close} is called from another thread.
189196
*
197+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
198+
*
190199
* @see NfcA#transceive
191200
*/
192201
public byte[] transceive(byte[] data) throws IOException {

core/java/android/nfc/tech/Ndef.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
* formatted to contain NDEF data.
4545
* <ul>
4646
* <li>NFC Forum Type 1 Tag ({@link #NFC_FORUM_TYPE_1}), such as the Innovision Topaz
47-
* <li>NFC Forum Type 2 Tag ({@link #NFC_FORUM_TYPE_2}), such as the NXP Mifare Ultralight
47+
* <li>NFC Forum Type 2 Tag ({@link #NFC_FORUM_TYPE_2}), such as the NXP MIFARE Ultralight
4848
* <li>NFC Forum Type 3 Tag ({@link #NFC_FORUM_TYPE_3}), such as Sony Felica
4949
* <li>NFC Forum Type 4 Tag ({@link #NFC_FORUM_TYPE_4}), such as NXP MIFARE Desfire
5050
* </ul>
@@ -66,9 +66,8 @@
6666
* recommended to use NFC Forum Types 1-4 in new deployments of NFC tags
6767
* with NDEF payload. Vendor NDEF formats will not work on all Android devices.
6868
*
69-
* <p class="note"><strong>Note:</strong>
70-
* Use of this class requires the {@link android.Manifest.permission#NFC}
71-
* permission.
69+
* <p class="note"><strong>Note:</strong> Methods that perform I/O operations
70+
* require the {@link android.Manifest.permission#NFC} permission.
7271
*/
7372
public final class Ndef extends BasicTagTechnology {
7473
private static final String TAG = "NFC";
@@ -284,6 +283,8 @@ public NdefMessage getNdefMessage() throws IOException, FormatException {
284283
* not be called from the main application thread. A blocked call will be canceled with
285284
* {@link IOException} if {@link #close} is called from another thread.
286285
*
286+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
287+
*
287288
* @param msg the NDEF Message to write, must not be null
288289
* @throws TagLostException if the tag leaves the field
289290
* @throws IOException if there is an I/O failure, or the operation is canceled
@@ -344,6 +345,8 @@ public boolean canMakeReadOnly() {
344345
* not be called from the main application thread. A blocked call will be canceled with
345346
* {@link IOException} if {@link #close} is called from another thread.
346347
*
348+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
349+
*
347350
* @return true on success, false if it is not possible to make this tag read-only
348351
* @throws TagLostException if the tag leaves the field
349352
* @throws IOException if there is an I/O failure, or the operation is canceled

core/java/android/nfc/tech/NdefFormatable.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@
4141
* there is no mandatory set of tags for which all Android devices with NFC
4242
* must support {@link NdefFormatable}.
4343
*
44-
* <p class="note"><strong>Note:</strong>
45-
* Use of this class requires the {@link android.Manifest.permission#NFC}
46-
* permission.
44+
* <p class="note"><strong>Note:</strong> Methods that perform I/O operations
45+
* require the {@link android.Manifest.permission#NFC} permission.
4746
*/
4847
public final class NdefFormatable extends BasicTagTechnology {
4948
private static final String TAG = "NFC";
@@ -85,7 +84,9 @@ public NdefFormatable(Tag tag) throws RemoteException {
8584
* not be called from the main application thread. A blocked call will be canceled with
8685
* {@link IOException} if {@link #close} is called from another thread.
8786
*
88-
* @param firstMessage the NDEF message to write after formatting
87+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
88+
*
89+
* @param firstMessage the NDEF message to write after formatting, can be null
8990
* @throws TagLostException if the tag leaves the field
9091
* @throws IOException if there is an I/O failure, or the operation is canceled
9192
* @throws FormatException if the NDEF Message to write is malformed
@@ -105,6 +106,8 @@ public void format(NdefMessage firstMessage) throws IOException, FormatException
105106
* not be called from the main application thread. A blocked call will be canceled with
106107
* {@link IOException} if {@link #close} is called from another thread.
107108
*
109+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
110+
*
108111
* @param firstMessage the NDEF message to write after formatting
109112
* @throws TagLostException if the tag leaves the field
110113
* @throws IOException if there is an I/O failure, or the operation is canceled

core/java/android/nfc/tech/NfcA.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
* <p>Acquire a {@link NfcA} object using {@link #get}.
2929
* <p>The primary NFC-A I/O operation is {@link #transceive}. Applications must
3030
* implement their own protocol stack on top of {@link #transceive}.
31+
*
32+
* <p class="note"><strong>Note:</strong> Methods that perform I/O operations
33+
* require the {@link android.Manifest.permission#NFC} permission.
3134
*/
3235
public final class NfcA extends BasicTagTechnology {
3336
/** @hide */
@@ -99,6 +102,8 @@ public short getSak() {
99102
* not be called from the main application thread. A blocked call will be canceled with
100103
* {@link IOException} if {@link #close} is called from another thread.
101104
*
105+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
106+
*
102107
* @param data bytes to send
103108
* @return bytes received in response
104109
* @throws TagLostException if the tag leaves the field

core/java/android/nfc/tech/NfcB.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
* <p>Acquire a {@link NfcB} object using {@link #get}.
2929
* <p>The primary NFC-B I/O operation is {@link #transceive}. Applications must
3030
* implement their own protocol stack on top of {@link #transceive}.
31+
*
32+
* <p class="note"><strong>Note:</strong> Methods that perform I/O operations
33+
* require the {@link android.Manifest.permission#NFC} permission.
3134
*/
3235
public final class NfcB extends BasicTagTechnology {
3336
/** @hide */
@@ -98,6 +101,8 @@ public byte[] getProtocolInfo() {
98101
* not be called from the main application thread. A blocked call will be canceled with
99102
* {@link IOException} if {@link #close} is called from another thread.
100103
*
104+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
105+
*
101106
* @param data bytes to send
102107
* @return bytes received in response
103108
* @throws TagLostException if the tag leaves the field

core/java/android/nfc/tech/NfcF.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
* <p>Acquire a {@link NfcF} object using {@link #get}.
2929
* <p>The primary NFC-F I/O operation is {@link #transceive}. Applications must
3030
* implement their own protocol stack on top of {@link #transceive}.
31+
*
32+
* <p class="note"><strong>Note:</strong> Methods that perform I/O operations
33+
* require the {@link android.Manifest.permission#NFC} permission.
3134
*/
3235
public final class NfcF extends BasicTagTechnology {
3336
/** @hide */
@@ -98,6 +101,8 @@ public byte[] getManufacturer() {
98101
* not be called from the main application thread. A blocked call will be canceled with
99102
* {@link IOException} if {@link #close} is called from another thread.
100103
*
104+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
105+
*
101106
* @param data bytes to send
102107
* @return bytes received in response
103108
* @throws TagLostException if the tag leaves the field

core/java/android/nfc/tech/NfcV.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
* <p>Acquire a {@link NfcV} object using {@link #get}.
2929
* <p>The primary NFC-V I/O operation is {@link #transceive}. Applications must
3030
* implement their own protocol stack on top of {@link #transceive}.
31+
*
32+
* <p class="note"><strong>Note:</strong> Methods that perform I/O operations
33+
* require the {@link android.Manifest.permission#NFC} permission.
3134
*/
3235
public final class NfcV extends BasicTagTechnology {
3336
/** @hide */
@@ -98,6 +101,8 @@ public byte getDsfId() {
98101
* not be called from the main application thread. A blocked call will be canceled with
99102
* {@link IOException} if {@link #close} is called from another thread.
100103
*
104+
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
105+
*
101106
* @param data bytes to send
102107
* @return bytes received in response
103108
* @throws TagLostException if the tag leaves the field

0 commit comments

Comments
 (0)