OSDN Git Service

API: Make close() throw an IOException.
authorNick Pelly <npelly@google.com>
Thu, 27 Jan 2011 22:47:02 +0000 (14:47 -0800)
committerNick Pelly <npelly@google.com>
Fri, 28 Jan 2011 00:17:14 +0000 (16:17 -0800)
IOException on close() can be useful to indicate that in-progress transactions
were canceled.

I also audited all of our tech classes to make sure every function that needs
to throw IOException does so.

Change-Id: Iaa9c43d79d59ff85772d5c3e4b4d57a6fa8df4cf

api/current.xml
core/java/android/nfc/tech/BasicTagTechnology.java
core/java/android/nfc/tech/IsoDep.java
core/java/android/nfc/tech/TagTechnology.java

index f0b0233..ad54650 100644 (file)
  deprecated="not deprecated"
  visibility="public"
 >
+<exception name="IOException" type="java.io.IOException">
+</exception>
 </method>
 <method name="connect"
  return="void"
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="java.io.Closeable">
+</implements>
 <method name="close"
  return="void"
  abstract="true"
  deprecated="not deprecated"
  visibility="public"
 >
+<exception name="IOException" type="java.io.IOException">
+</exception>
 </method>
 <method name="connect"
  return="void"
index e635f21..32a850d 100644 (file)
@@ -117,7 +117,7 @@ import java.io.IOException;
     }
 
     @Override
-    public void close() {
+    public void close() throws IOException {
         try {
             /* Note that we don't want to physically disconnect the tag,
              * but just reconnect to it to reset its state
index f6d141a..774982e 100644 (file)
@@ -92,7 +92,7 @@ public final class IsoDep extends BasicTagTechnology {
     }
 
     @Override
-    public void close() {
+    public void close() throws IOException {
         try {
             mTag.getTagService().resetIsoDepTimeout();
         } catch (RemoteException e) {
index aebb3e8..c8ccdcf 100644 (file)
@@ -18,9 +18,10 @@ package android.nfc.tech;
 
 import android.nfc.Tag;
 
+import java.io.Closeable;
 import java.io.IOException;
 
-public interface TagTechnology {
+public interface TagTechnology extends Closeable {
     /**
      * This technology is an instance of {@link NfcA}.
      * <p>Support for this technology type is mandatory.
@@ -135,5 +136,5 @@ public interface TagTechnology {
      * @see #connect()
      * @see #reconnect()
      */
-    public void close();
+    public void close() throws IOException;
 }