am 29f9ee97: Merge "Need to check ndef before writing ndef." into gingerbread

* commit '29f9ee973eefea3c68382ed38e69db1f1a396f3f':
  Need to check ndef before writing ndef.
This commit is contained in:
Nick Pelly
2010-12-20 11:29:40 -08:00
committed by Android Git Automerger

View File

@@ -148,17 +148,23 @@ public final class Ndef extends BasicTagTechnology {
checkConnected();
try {
int errorCode = mTagService.ndefWrite(mTag.getServiceHandle(), msg);
switch (errorCode) {
case ErrorCodes.SUCCESS:
break;
case ErrorCodes.ERROR_IO:
throw new IOException();
case ErrorCodes.ERROR_INVALID_PARAM:
throw new FormatException();
default:
// Should not happen
throw new IOException();
int serviceHandle = mTag.getServiceHandle();
if (mTagService.isNdef(serviceHandle)) {
int errorCode = mTagService.ndefWrite(serviceHandle, msg);
switch (errorCode) {
case ErrorCodes.SUCCESS:
break;
case ErrorCodes.ERROR_IO:
throw new IOException();
case ErrorCodes.ERROR_INVALID_PARAM:
throw new FormatException();
default:
// Should not happen
throw new IOException();
}
}
else {
throw new IOException("Tag is not ndef");
}
} catch (RemoteException e) {
attemptDeadServiceRecovery(e);