Merge "Throw IOException on multiple connects."
am: 632e515468
Change-Id: I055acd5e71b7eb67369226402c47a5ecbe09db4c
This commit is contained in:
@@ -455,12 +455,12 @@ public final class Tag implements Parcelable {
|
|||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public synchronized void setConnectedTechnology(int technology) {
|
public synchronized boolean setConnectedTechnology(int technology) {
|
||||||
if (mConnectedTechnology == -1) {
|
if (mConnectedTechnology != -1) {
|
||||||
mConnectedTechnology = technology;
|
return false;
|
||||||
} else {
|
|
||||||
throw new IllegalStateException("Close other technology first!");
|
|
||||||
}
|
}
|
||||||
|
mConnectedTechnology = technology;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -75,7 +75,10 @@ abstract class BasicTagTechnology implements TagTechnology {
|
|||||||
|
|
||||||
if (errorCode == ErrorCodes.SUCCESS) {
|
if (errorCode == ErrorCodes.SUCCESS) {
|
||||||
// Store this in the tag object
|
// Store this in the tag object
|
||||||
mTag.setConnectedTechnology(mSelectedTechnology);
|
if (!mTag.setConnectedTechnology(mSelectedTechnology)) {
|
||||||
|
Log.e(TAG, "Close other technology first!");
|
||||||
|
throw new IOException("Only one TagTechnology can be connected at a time.");
|
||||||
|
}
|
||||||
mIsConnected = true;
|
mIsConnected = true;
|
||||||
} else if (errorCode == ErrorCodes.ERROR_NOT_SUPPORTED) {
|
} else if (errorCode == ErrorCodes.ERROR_NOT_SUPPORTED) {
|
||||||
throw new UnsupportedOperationException("Connecting to " +
|
throw new UnsupportedOperationException("Connecting to " +
|
||||||
|
|||||||
Reference in New Issue
Block a user