diff options
Diffstat (limited to 'tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetClientTest.java')
-rw-r--r-- | tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetClientTest.java | 59 |
1 files changed, 10 insertions, 49 deletions
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetClientTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetClientTest.java index 08f26cf5d83..69b57474ee6 100644 --- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetClientTest.java +++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetClientTest.java @@ -49,8 +49,8 @@ public class BluetoothHeadsetClientTest extends AndroidTestCase { private BluetoothHeadsetClient mBluetoothHeadsetClient; private boolean mIsHeadsetClientSupported; 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 BluetoothHeadsetClientTest extends AndroidTestCase { mAdapter = manager.getAdapter(); assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext)); - mProfileConnectionlock = new ReentrantLock(); - mConditionProfileConnection = mProfileConnectionlock.newCondition(); + mProfileConnectedlock = new ReentrantLock(); + mConditionProfileIsConnected = mProfileConnectedlock.newCondition(); mIsProfileReady = false; mBluetoothHeadsetClient = null; @@ -96,18 +96,6 @@ public class BluetoothHeadsetClientTest extends AndroidTestCase { mAdapter = null; } - public void test_closeProfileProxy() { - if (!(mHasBluetooth && mIsHeadsetClientSupported)) return; - - assertTrue(waitForProfileConnect()); - assertNotNull(mBluetoothHeadsetClient); - assertTrue(mIsProfileReady); - - mAdapter.closeProfileProxy(BluetoothProfile.HEADSET_CLIENT, mBluetoothHeadsetClient); - assertTrue(waitForProfileDisconnect()); - assertFalse(mIsProfileReady); - } - public void test_getConnectedDevices() { if (!(mHasBluetooth && mIsHeadsetClientSupported)) return; @@ -231,11 +219,11 @@ public class BluetoothHeadsetClientTest 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"); @@ -245,55 +233,28 @@ public class BluetoothHeadsetClientTest 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 BluetoothHeadsetClientServiceListener implements BluetoothProfile.ServiceListener { @Override public void onServiceConnected(int profile, BluetoothProfile proxy) { - mProfileConnectionlock.lock(); + mProfileConnectedlock.lock(); mBluetoothHeadsetClient = (BluetoothHeadsetClient) 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(); - } } } } |