Merge "Throw IOException on multiple connects." am: 632e515468 am: ead7c0e489

Change-Id: I51690e73f8db042a7457afbcadc8003fe476b100
This commit is contained in:
Automerger Merge Worker
2020-01-22 01:36:23 +00:00
2 changed files with 9 additions and 6 deletions

View File

@@ -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;
} }
/** /**

View File

@@ -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 " +