summaryrefslogtreecommitdiff
path: root/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetTest.java')
-rw-r--r--tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetTest.java59
1 files changed, 10 insertions, 49 deletions
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetTest.java
index d7ab5da893d..cb2c2b4ee44 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetTest.java
@@ -49,8 +49,8 @@ public class BluetoothHeadsetTest extends AndroidTestCase {
private BluetoothHeadset mBluetoothHeadset;
private boolean mIsHeadsetSupported;
private boolean mIsProfileReady;
- private Condition mConditionProfileConnection;
- private ReentrantLock mProfileConnectionlock;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
@Override
public void setUp() throws Exception {
@@ -69,8 +69,8 @@ public class BluetoothHeadsetTest extends AndroidTestCase {
mAdapter = manager.getAdapter();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mBluetoothHeadset = null;
@@ -96,18 +96,6 @@ public class BluetoothHeadsetTest extends AndroidTestCase {
mUiAutomation.dropShellPermissionIdentity();
}
- public void test_closeProfileProxy() {
- if (!(mHasBluetooth && mIsHeadsetSupported)) return;
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothHeadset);
- assertTrue(mIsProfileReady);
-
- mAdapter.closeProfileProxy(BluetoothProfile.HEADSET, mBluetoothHeadset);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
public void test_getConnectedDevices() {
if (!(mHasBluetooth && mIsHeadsetSupported)) return;
@@ -388,11 +376,11 @@ public class BluetoothHeadsetTest 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");
@@ -402,55 +390,28 @@ public class BluetoothHeadsetTest 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 BluetoothHeadsetServiceListener implements
BluetoothProfile.ServiceListener {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
mBluetoothHeadset = (BluetoothHeadset) 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();
- }
}
}
}