Skip to content

Commit 25be536

Browse files
Martijn CoenenNick Pelly
authored andcommitted
Implement canMakeReadonly().
The method is needed since makeReadOnly() only works on T1T/T2T. Also removed makeLowlevelReadonly(), since NFC forum does not allow setting the CC and the lock bits separately. Change-Id: I8e6d7c065b1f017ef07d878c41df05e1a8193f5a
1 parent 13d1cb5 commit 25be536

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

core/java/android/nfc/technology/Ndef.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,22 @@ public void writeExtraNdefMessage(int i, NdefMessage msg) throws IOException, Fo
224224
}
225225

226226
/**
227-
* Set the CC field to indicate this tag is read-only
227+
* Indicates whether a tag can be made read-only with
228+
* {@link #makeReadonly()}
229+
*/
230+
public boolean canMakeReadonly() {
231+
if (mNdefType == NFC_FORUM_TYPE_1 || mNdefType == NFC_FORUM_TYPE_2) {
232+
return true;
233+
} else {
234+
return false;
235+
}
236+
}
237+
238+
/**
239+
* Sets the CC field to indicate this tag is read-only
240+
* and permanently sets the lock bits to prevent any further NDEF
241+
* modifications.
242+
* This is a one-way process and can not be reverted!
228243
* @throws IOException
229244
*/
230245
public boolean makeReadonly() throws IOException {
@@ -249,17 +264,6 @@ public boolean makeReadonly() throws IOException {
249264
}
250265
}
251266

252-
/**
253-
* Attempt to use tag specific technology to really make
254-
* the tag read-only
255-
* For NFC Forum Type 1 and 2 only.
256-
*/
257-
public void makeLowLevelReadonly() {
258-
checkConnected();
259-
260-
throw new UnsupportedOperationException();
261-
}
262-
263267
@Override
264268
public byte[] transceive(byte[] data) {
265269
checkConnected();

0 commit comments

Comments
 (0)