Index: device/nfc/android/java/src/org/chromium/device/nfc/NfcTagHandler.java |
diff --git a/device/nfc/android/java/src/org/chromium/device/nfc/NfcTagHandler.java b/device/nfc/android/java/src/org/chromium/device/nfc/NfcTagHandler.java |
index a7adab7047e2b3b879f0a905dbd9050c965f2433..96508aa25dbae7ab9d0c9ef1311bd8275f6e28d2 100644 |
--- a/device/nfc/android/java/src/org/chromium/device/nfc/NfcTagHandler.java |
+++ b/device/nfc/android/java/src/org/chromium/device/nfc/NfcTagHandler.java |
@@ -17,7 +17,7 @@ import java.io.IOException; |
/** |
* Utility class that provides I/O operations for NFC tags. |
*/ |
-public final class NfcTagHandler { |
+public class NfcTagHandler { |
private final TagTechnology mTech; |
private final TagTechnologyHandler mTechHandler; |
private boolean mWasConnected; |
@@ -49,7 +49,7 @@ public final class NfcTagHandler { |
private interface TagTechnologyHandler { |
public void write(NdefMessage message) |
throws IOException, TagLostException, FormatException; |
- // TODO(crbug.com/625589): add read method for nfc.watch. |
+ public NdefMessage read() throws IOException, TagLostException, FormatException; |
} |
/** |
@@ -67,6 +67,10 @@ public final class NfcTagHandler { |
throws IOException, TagLostException, FormatException { |
mNdef.writeNdefMessage(message); |
} |
+ |
+ public NdefMessage read() throws IOException, TagLostException, FormatException { |
+ return mNdef.getNdefMessage(); |
+ } |
} |
/** |
@@ -84,9 +88,13 @@ public final class NfcTagHandler { |
throws IOException, TagLostException, FormatException { |
mNdefFormattable.format(message); |
} |
+ |
+ public NdefMessage read() throws IOException, TagLostException, FormatException { |
+ return NfcTypeConverter.emptyNdefMessage(); |
+ } |
} |
- private NfcTagHandler(TagTechnology tech, TagTechnologyHandler handler) { |
+ protected NfcTagHandler(TagTechnology tech, TagTechnologyHandler handler) { |
mTech = tech; |
mTechHandler = handler; |
} |
@@ -102,6 +110,13 @@ public final class NfcTagHandler { |
} |
/** |
+ * Checks if NFC tag is connected. |
+ */ |
+ public boolean isConnected() { |
+ return mTech.isConnected(); |
+ } |
+ |
+ /** |
* Closes connection. |
*/ |
public void close() throws IOException { |
@@ -115,6 +130,10 @@ public final class NfcTagHandler { |
mTechHandler.write(message); |
} |
+ public NdefMessage read() throws IOException, TagLostException, FormatException { |
+ return mTechHandler.read(); |
+ } |
+ |
/** |
* If tag was previously connected and subsequent connection to the same tag fails, consider |
* tag to be out of range. |