File tree Expand file tree Collapse file tree 1 file changed +17
-12
lines changed
core/java/android/nfc/technology Expand file tree Collapse file tree 1 file changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -221,18 +221,23 @@ public boolean makeReadonly() throws IOException {
221221 checkConnected ();
222222
223223 try {
224- int errorCode = mTagService .ndefMakeReadOnly (mTag .getServiceHandle ());
225- switch (errorCode ) {
226- case ErrorCodes .SUCCESS :
227- return true ;
228- case ErrorCodes .ERROR_IO :
229- throw new IOException ();
230- case ErrorCodes .ERROR_INVALID_PARAM :
231- return false ;
232- default :
233- // Should not happen
234- throw new IOException ();
235- }
224+ if (mTagService .isNdef (mTag .getServiceHandle ())) {
225+ int errorCode = mTagService .ndefMakeReadOnly (mTag .getServiceHandle ());
226+ switch (errorCode ) {
227+ case ErrorCodes .SUCCESS :
228+ return true ;
229+ case ErrorCodes .ERROR_IO :
230+ throw new IOException ();
231+ case ErrorCodes .ERROR_INVALID_PARAM :
232+ return false ;
233+ default :
234+ // Should not happen
235+ throw new IOException ();
236+ }
237+ }
238+ else {
239+ throw new IOException ("Tag is not ndef" );
240+ }
236241 } catch (RemoteException e ) {
237242 Log .e (TAG , "NFC service dead" , e );
238243 return false ;
You can’t perform that action at this time.
0 commit comments