Skip to content

Commit 3fcedf7

Browse files
author
Nick Pelly
committed
API: Make close() throw an IOException.
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
1 parent 21d0a17 commit 3fcedf7

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

api/current.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101107,6 +101107,8 @@
101107101107
deprecated="not deprecated"
101108101108
visibility="public"
101109101109
>
101110+
<exception name="IOException" type="java.io.IOException">
101111+
</exception>
101110101112
</method>
101111101113
<method name="connect"
101112101114
return="void"
@@ -102205,6 +102207,8 @@
102205102207
deprecated="not deprecated"
102206102208
visibility="public"
102207102209
>
102210+
<implements name="java.io.Closeable">
102211+
</implements>
102208102212
<method name="close"
102209102213
return="void"
102210102214
abstract="true"
@@ -102215,6 +102219,8 @@
102215102219
deprecated="not deprecated"
102216102220
visibility="public"
102217102221
>
102222+
<exception name="IOException" type="java.io.IOException">
102223+
</exception>
102218102224
</method>
102219102225
<method name="connect"
102220102226
return="void"

core/java/android/nfc/tech/BasicTagTechnology.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public void reconnect() throws IOException {
117117
}
118118

119119
@Override
120-
public void close() {
120+
public void close() throws IOException {
121121
try {
122122
/* Note that we don't want to physically disconnect the tag,
123123
* but just reconnect to it to reset its state

core/java/android/nfc/tech/IsoDep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void setTimeout(int timeout) {
9292
}
9393

9494
@Override
95-
public void close() {
95+
public void close() throws IOException {
9696
try {
9797
mTag.getTagService().resetIsoDepTimeout();
9898
} catch (RemoteException e) {

core/java/android/nfc/tech/TagTechnology.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818

1919
import android.nfc.Tag;
2020

21+
import java.io.Closeable;
2122
import java.io.IOException;
2223

23-
public interface TagTechnology {
24+
public interface TagTechnology extends Closeable {
2425
/**
2526
* This technology is an instance of {@link NfcA}.
2627
* <p>Support for this technology type is mandatory.
@@ -135,5 +136,5 @@ public interface TagTechnology {
135136
* @see #connect()
136137
* @see #reconnect()
137138
*/
138-
public void close();
139+
public void close() throws IOException;
139140
}

0 commit comments

Comments
 (0)