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

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: Rebase and add size limit check when tag is read. Created 4 years, 4 months 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..4b95010645cf6a9cef710258bed597900c111b41 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
@@ -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,6 +88,10 @@ 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) {
@@ -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