summaryrefslogtreecommitdiff
path: root/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothSapTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothSapTest.java')
-rw-r--r--tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothSapTest.java59
1 files changed, 10 insertions, 49 deletions
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothSapTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothSapTest.java
index 2a679f3393f..ad5cfff19a4 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothSapTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothSapTest.java
@@ -48,8 +48,8 @@ public class BluetoothSapTest extends AndroidTestCase {
private BluetoothSap mBluetoothSap;
private boolean mIsProfileReady;
- private Condition mConditionProfileConnection;
- private ReentrantLock mProfileConnectionlock;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
private boolean mIsSapSupported;
@@ -70,8 +70,8 @@ public class BluetoothSapTest extends AndroidTestCase {
mAdapter = getContext().getSystemService(BluetoothManager.class).getAdapter();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mBluetoothSap = null;
@@ -97,18 +97,6 @@ public class BluetoothSapTest extends AndroidTestCase {
}
}
- public void test_closeProfileProxy() {
- if (!(mHasBluetooth && mIsSapSupported)) return;
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothSap);
- assertTrue(mIsProfileReady);
-
- mAdapter.closeProfileProxy(BluetoothProfile.SAP, mBluetoothSap);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
@MediumTest
public void test_getConnectedDevices() {
if (!mHasBluetooth || !mIsSapSupported) return;
@@ -173,11 +161,11 @@ public class BluetoothSapTest extends AndroidTestCase {
}
private boolean waitForProfileConnect() {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
try {
// Wait for the Adapter to be disabled
while (!mIsProfileReady) {
- if (!mConditionProfileConnection.await(
+ if (!mConditionProfileIsConnected.await(
PROXY_CONNECTION_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
// Timeout
Log.e(TAG, "Timeout while waiting for Profile Connect");
@@ -187,54 +175,27 @@ public class BluetoothSapTest extends AndroidTestCase {
} catch (InterruptedException e) {
Log.e(TAG, "waitForProfileConnect: interrrupted");
} finally {
- mProfileConnectionlock.unlock();
+ mProfileConnectedlock.unlock();
}
return mIsProfileReady;
}
- private boolean waitForProfileDisconnect() {
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
- mProfileConnectionlock.lock();
- try {
- while (mIsProfileReady) {
- if (!mConditionProfileConnection.await(
- PROXY_CONNECTION_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
- // Timeout
- Log.e(TAG, "Timeout while waiting for Profile Disconnect");
- break;
- } // else spurious wakeups
- }
- } catch (InterruptedException e) {
- Log.e(TAG, "waitForProfileDisconnect: interrrupted");
- } finally {
- mProfileConnectionlock.unlock();
- }
- return !mIsProfileReady;
- }
-
private final class BluetoothSapServiceListener implements BluetoothProfile.ServiceListener {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
mBluetoothSap = (BluetoothSap) proxy;
mIsProfileReady = true;
try {
- mConditionProfileConnection.signal();
+ mConditionProfileIsConnected.signal();
} finally {
- mProfileConnectionlock.unlock();
+ mProfileConnectedlock.unlock();
}
}
@Override
public void onServiceDisconnected(int profile) {
- mProfileConnectionlock.lock();
- mIsProfileReady = false;
- try {
- mConditionProfileConnection.signal();
- } finally {
- mProfileConnectionlock.unlock();
- }
}
}
}