Skip to content

Commit d64d711

Browse files
Nick PellyAndroid (Google) Code Review
authored andcommitted
Merge "Change Tag.getTechnology(NfcAdapter, int) to NfcAdapter.getTechnology(Tag, int)" into gingerbread
2 parents 9aac2e2 + b4003bf commit d64d711

File tree

12 files changed

+38
-30
lines changed

12 files changed

+38
-30
lines changed

api/current.xml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100252,6 +100252,21 @@
100252100252
visibility="public"
100253100253
>
100254100254
</method>
100255+
<method name="getTechnology"
100256+
return="android.nfc.technology.TagTechnology"
100257+
abstract="false"
100258+
native="false"
100259+
synchronized="false"
100260+
static="false"
100261+
final="false"
100262+
deprecated="not deprecated"
100263+
visibility="public"
100264+
>
100265+
<parameter name="tag" type="android.nfc.Tag">
100266+
</parameter>
100267+
<parameter name="tech" type="int">
100268+
</parameter>
100269+
</method>
100255100270
<method name="isEnabled"
100256100271
return="boolean"
100257100272
abstract="false"
@@ -100399,21 +100414,6 @@
100399100414
visibility="public"
100400100415
>
100401100416
</method>
100402-
<method name="getTechnology"
100403-
return="android.nfc.technology.TagTechnology"
100404-
abstract="false"
100405-
native="false"
100406-
synchronized="false"
100407-
static="false"
100408-
final="false"
100409-
deprecated="not deprecated"
100410-
visibility="public"
100411-
>
100412-
<parameter name="adapter" type="android.nfc.NfcAdapter">
100413-
</parameter>
100414-
<parameter name="tech" type="int">
100415-
</parameter>
100416-
</method>
100417100417
<method name="getTechnologyList"
100418100418
return="int[]"
100419100419
abstract="false"

core/java/android/nfc/NfcAdapter.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.content.Context;
2323
import android.content.pm.IPackageManager;
2424
import android.content.pm.PackageManager;
25+
import android.nfc.technology.TagTechnology;
2526
import android.os.IBinder;
2627
import android.os.RemoteException;
2728
import android.os.ServiceManager;
@@ -370,6 +371,16 @@ public boolean disable() {
370371
}
371372
}
372373

374+
/**
375+
* Retrieve a TagTechnology object used to interact with a Tag that is
376+
* in field.
377+
* <p>
378+
* @return TagTechnology object, or null if not present
379+
*/
380+
public TagTechnology getTechnology(Tag tag, int tech) {
381+
return tag.getTechnology(NfcAdapter.this, tech);
382+
}
383+
373384
/**
374385
* Set the NDEF Message that this NFC adapter should appear as to Tag
375386
* readers.

core/java/android/nfc/Tag.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* in {@link NfcAdapter#ACTION_TAG_DISCOVERED} intents. A {@link Tag} object is immutable
4646
* and represents the state of the tag at the time of discovery. It can be
4747
* directly queried for its UID and Type, or used to create a {@link TagTechnology}
48-
* (with {@link Tag#getTechnology}).
48+
* (with {@link NfcAdapter#getTechnology}).
4949
* <p>
5050
* A {@link Tag} can be used to create a {@link TagTechnology} only while the tag is in
5151
* range. If it is removed and then returned to range, then the most recent
@@ -84,7 +84,7 @@ public Tag(byte[] id, int[] techList, Bundle[] techListExtras, int serviceHandle
8484
/**
8585
* Construct a mock Tag.
8686
* <p>This is an application constructed tag, so NfcAdapter methods on this
87-
* Tag such as {@link #getTechnology} may fail with
87+
* Tag such as {@link NfcAdapter#getTechnology} may fail with
8888
* {@link IllegalArgumentException} since it does not represent a physical Tag.
8989
* <p>This constructor might be useful for mock testing.
9090
* @param id The tag identifier, can be null
@@ -127,10 +127,7 @@ public int[] getTechnologyList() {
127127
return Arrays.copyOf(mTechList, mTechList.length);
128128
}
129129

130-
/**
131-
* Returns the technology, or null if not present
132-
*/
133-
public TagTechnology getTechnology(NfcAdapter adapter, int tech) {
130+
/*package*/ TagTechnology getTechnology(NfcAdapter adapter, int tech) {
134131
int pos = -1;
135132
for (int idx = 0; idx < mTechList.length; idx++) {
136133
if (mTechList[idx] == tech) {

core/java/android/nfc/technology/IsoDep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* A low-level connection to a {@link Tag} using the ISO-DEP technology, also known as
2828
* ISO1443-4.
2929
*
30-
* <p>You can acquire this kind of connection with {@link Tag#getTechnology}.
30+
* <p>You can acquire this kind of connection with {@link NfcAdapter#getTechnology}.
3131
* Use this class to send and receive data with {@link #transceive transceive()}.
3232
*
3333
* <p>Applications must implement their own protocol stack on top of

core/java/android/nfc/technology/MifareClassic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public MifareClassic(NfcAdapter adapter, Tag tag, Bundle extras) throws RemoteEx
7474
super(adapter, tag, TagTechnology.MIFARE_CLASSIC);
7575

7676
// Check if this could actually be a Mifare
77-
NfcA a = (NfcA) tag.getTechnology(adapter, TagTechnology.NFC_A);
77+
NfcA a = (NfcA) adapter.getTechnology(tag, TagTechnology.NFC_A);
7878
//short[] ATQA = getATQA(tag);
7979

8080
mIsEmulated = false;

core/java/android/nfc/technology/MifareUltralight.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public MifareUltralight(NfcAdapter adapter, Tag tag, Bundle extras) throws Remot
4747
super(adapter, tag, TagTechnology.MIFARE_ULTRALIGHT);
4848

4949
// Check if this could actually be a Mifare
50-
NfcA a = (NfcA) tag.getTechnology(adapter, TagTechnology.NFC_A);
50+
NfcA a = (NfcA) adapter.getTechnology(tag, TagTechnology.NFC_A);
5151

5252
mType = TYPE_UNKNOWN;
5353

core/java/android/nfc/technology/Ndef.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* to interact with NDEF data. MiFare Classic cards that present NDEF data may also be used
3232
* via this class. To determine the exact technology being used call {@link #getTechnologyId()}
3333
*
34-
* <p>You can acquire this kind of connection with {@link Tag#getTechnology}.
34+
* <p>You can acquire this kind of connection with {@link NfcAdapter#getTechnology}.
3535
*
3636
* <p class="note"><strong>Note:</strong>
3737
* Use of this class requires the {@link android.Manifest.permission#NFC}

core/java/android/nfc/technology/NdefFormatable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
/**
3030
* An interface to a {@link Tag} allowing to format the tag as NDEF.
3131
*
32-
* <p>You can acquire this kind of interface with {@link Tag#getTechnology}.
32+
* <p>You can acquire this kind of interface with {@link NfcAdapter#getTechnology}.
3333
*
3434
* <p class="note"><strong>Note:</strong>
3535
* Use of this class requires the {@link android.Manifest.permission#NFC}

core/java/android/nfc/technology/NfcA.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* A low-level connection to a {@link Tag} using the NFC-A technology, also known as
2626
* ISO1443-3A.
2727
*
28-
* <p>You can acquire this kind of connection with {@link Tag#getTechnology}.
28+
* <p>You can acquire this kind of connection with {@link NfcAdapter#getTechnology}.
2929
* Use this class to send and receive data with {@link #transceive transceive()}.
3030
*
3131
* <p>Applications must implement their own protocol stack on top of

core/java/android/nfc/technology/NfcB.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* A low-level connection to a {@link Tag} using the NFC-B technology, also known as
2626
* ISO1443-3B.
2727
*
28-
* <p>You can acquire this kind of connection with {@link Tag#getTechnology}.
28+
* <p>You can acquire this kind of connection with {@link NfcAdapter#getTechnology}.
2929
* Use this class to send and receive data with {@link #transceive transceive()}.
3030
*
3131
* <p>Applications must implement their own protocol stack on top of

0 commit comments

Comments
 (0)