Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(695)

Unified Diff: device/nfc/android/java/src/org/chromium/device/nfc/NfcTagHandler.java

Issue 1765533004: [webnfc] Implement watch method for Android nfc mojo service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@implement_nfc_watch_in_blink
Patch Set: Rebased to master Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.

Powered by Google App Engine
This is Rietveld 408576698