Revert "Add tests for BluetoothProfile.close"
Revert submission 19938469-BluetoothProfile_close
Reason for revert: Creating a revert CL only for QPR1
Reverted Changes:
I51ad4e0ec:Make onServiceDisconnected be called
Ic5188c62e:Add tests for BluetoothProfile.close
Bug: 249213217
Change-Id: I083ca9eb695de67f4c8e875a2fc90197e32baa29
(cherry picked from commit 7db0bcf701425ba33ee5236c5c0f68c35f2b574e)
Merged-In: I083ca9eb695de67f4c8e875a2fc90197e32baa29
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpSinkTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpSinkTest.java
index 8675697..7a20e9b 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpSinkTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpSinkTest.java
@@ -48,8 +48,8 @@
private BluetoothA2dpSink mBluetoothA2dpSink;
private boolean mIsA2dpSinkSupported;
private boolean mIsProfileReady;
- private Condition mConditionProfileConnection;
- private ReentrantLock mProfileConnectionlock;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
@Override
public void setUp() throws Exception {
@@ -68,8 +68,8 @@
mAdapter = manager.getAdapter();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mBluetoothA2dpSink = null;
@@ -96,18 +96,6 @@
mAdapter = null;
}
- public void test_closeProfileProxy() {
- if (!(mHasBluetooth && mIsA2dpSinkSupported)) return;
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothA2dpSink);
- assertTrue(mIsProfileReady);
-
- mAdapter.closeProfileProxy(BluetoothProfile.A2DP_SINK, mBluetoothA2dpSink);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
public void test_getConnectedDevices() {
if (!(mHasBluetooth && mIsA2dpSinkSupported)) return;
@@ -205,11 +193,11 @@
}
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");
@@ -219,55 +207,28 @@
} 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 BluetoothA2dpSinkServiceListener implements
BluetoothProfile.ServiceListener {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
mBluetoothA2dpSink = (BluetoothA2dpSink) 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();
- }
}
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpTest.java
index 10bd060..515f0ef 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpTest.java
@@ -49,8 +49,8 @@
private BluetoothA2dp mBluetoothA2dp;
private boolean mIsA2dpSupported;
private boolean mIsProfileReady;
- private ReentrantLock mProfileConnectionlock;
- private Condition mConditionProfileConnection;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
@Override
public void setUp() throws Exception {
@@ -69,9 +69,8 @@
mAdapter = manager.getAdapter();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
-
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mBluetoothA2dp = null;
@@ -97,18 +96,6 @@
mUiAutomation.dropShellPermissionIdentity();
}
- public void test_closeProfileProxy() {
- if (!(mHasBluetooth && mIsA2dpSupported)) return;
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothA2dp);
- assertTrue(mIsProfileReady);
-
- mAdapter.closeProfileProxy(BluetoothProfile.A2DP, mBluetoothA2dp);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
public void test_getConnectedDevices() {
if (!(mHasBluetooth && mIsA2dpSupported)) return;
@@ -345,11 +332,11 @@
}
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");
@@ -359,55 +346,28 @@
} 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 BluetoothA2dpServiceListener implements
BluetoothProfile.ServiceListener {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
mBluetoothA2dp = (BluetoothA2dp) 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();
- }
}
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothCsipSetCoordinatorTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothCsipSetCoordinatorTest.java
index c31ecf0..50a8c46 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothCsipSetCoordinatorTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothCsipSetCoordinatorTest.java
@@ -21,19 +21,23 @@
import static org.junit.Assert.assertThrows;
+import android.app.UiAutomation;
import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothCsipSetCoordinator;
import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothCsipSetCoordinator;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothStatusCodes;
import android.bluetooth.BluetoothUuid;
import android.content.pm.PackageManager;
+import android.content.res.Resources;
import android.os.Build;
import android.os.ParcelUuid;
import android.test.AndroidTestCase;
import android.util.Log;
+import androidx.test.InstrumentationRegistry;
+
import com.android.compatibility.common.util.ApiLevelUtil;
import java.util.List;
@@ -55,8 +59,8 @@
private BluetoothCsipSetCoordinator mBluetoothCsipSetCoordinator;
private boolean mIsCsipSetCoordinatorSupported;
private boolean mIsProfileReady;
- private Condition mConditionProfileConnection;
- private ReentrantLock mProfileConnectionlock;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
private boolean mGroupLockCallbackCalled;
private TestCallback mTestCallback;
private Executor mTestExecutor;
@@ -90,8 +94,8 @@
mAdapter = manager.getAdapter();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mBluetoothCsipSetCoordinator = null;
@@ -138,19 +142,6 @@
}
}
- public void testCloseProfileProxy() {
- if (!(mHasBluetooth && mIsCsipSetCoordinatorSupported)) return;
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothCsipSetCoordinator);
- assertTrue(mIsProfileReady);
-
- mAdapter.closeProfileProxy(
- BluetoothProfile.CSIP_SET_COORDINATOR, mBluetoothCsipSetCoordinator);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
public void testGetConnectedDevices() {
if (!(mHasBluetooth && mIsCsipSetCoordinatorSupported)) return;
@@ -274,11 +265,11 @@
}
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");
@@ -288,55 +279,28 @@
} 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 BluetoothCsipServiceListener implements
BluetoothProfile.ServiceListener {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
mBluetoothCsipSetCoordinator = (BluetoothCsipSetCoordinator) 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();
- }
}
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHapClientTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHapClientTest.java
index 15fd9bd..fb5f241 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHapClientTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHapClientTest.java
@@ -20,7 +20,6 @@
import static android.Manifest.permission.BLUETOOTH_PRIVILEGED;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;
@@ -70,8 +69,8 @@
private BluetoothHapClient mBluetoothHapClient;
private boolean mIsHapClientSupported;
private boolean mIsProfileReady;
- private Condition mConditionProfileConnection;
- private ReentrantLock mProfileConnectionlock;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
private boolean mOnPresetSelected = false;
private boolean mOnPresetSelectionFailed = false;
@@ -108,8 +107,8 @@
mAdapter = TestUtils.getBluetoothAdapterOrDie();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mBluetoothHapClient = null;
@@ -135,21 +134,6 @@
}
@Test
- public void test_closeProfileProxy() {
- if (shouldSkipTest()) {
- return;
- }
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothHapClient);
- assertTrue(mIsProfileReady);
-
- mAdapter.closeProfileProxy(BluetoothProfile.HAP_CLIENT, mBluetoothHapClient);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
- @Test
public void testGetConnectedDevices() {
if (shouldSkipTest()) {
return;
@@ -482,11 +466,11 @@
}
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");
@@ -496,55 +480,28 @@
} catch (InterruptedException e) {
Log.e(TAG, "waitForProfileConnect: interrupted");
} 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 BluetoothHapClientServiceListener implements
BluetoothProfile.ServiceListener {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
mBluetoothHapClient = (BluetoothHapClient) 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();
- }
}
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetClientTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetClientTest.java
index 08f26cf..69b5747 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 @@
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 @@
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 @@
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 @@
}
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 @@
} 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();
- }
}
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetTest.java
index d7ab5da..cb2c2b4 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 @@
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 @@
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 @@
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 @@
}
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 @@
} 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();
- }
}
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHidDeviceTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHidDeviceTest.java
index 1815d76..d94deab 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHidDeviceTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHidDeviceTest.java
@@ -59,8 +59,8 @@
private boolean mIsProfileReady;
private BluetoothAdapter mAdapter;
private UiAutomation mUiAutomation;
- private Condition mConditionProfileConnection;
- private ReentrantLock mProfileConnectionlock;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
private BluetoothHidDevice mBluetoothHidDevice;
@@ -81,8 +81,8 @@
mAdapter = manager.getAdapter();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mBluetoothHidDevice = null;
@@ -109,18 +109,6 @@
mUiAutomation.dropShellPermissionIdentity();
}
- public void test_closeProfileProxy() {
- if (!(mHasBluetooth && mIsHidSupported)) return;
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothHidDevice);
- assertTrue(mIsProfileReady);
-
- mAdapter.closeProfileProxy(BluetoothProfile.HID_DEVICE, mBluetoothHidDevice);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
public void test_getDevicesMatchingConnectionStates() {
if (!(mHasBluetooth && mIsHidSupported)) return;
@@ -218,12 +206,13 @@
testDevice, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN));
}
+
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");
@@ -233,54 +222,28 @@
} 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 BluetoothHidServiceListener implements
BluetoothProfile.ServiceListener {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
mBluetoothHidDevice = (BluetoothHidDevice) 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();
- }
+
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHidHostTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHidHostTest.java
index e7db6d2..5c2e86e 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHidHostTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHidHostTest.java
@@ -50,8 +50,8 @@
private UiAutomation mUiAutomation;
private boolean mIsProfileReady;
- private Condition mConditionProfileConnection;
- private ReentrantLock mProfileConnectionlock;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
@Override
public void setUp() throws Exception {
@@ -71,8 +71,8 @@
mAdapter = manager.getAdapter();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mHidHost = null;
@@ -96,18 +96,6 @@
mAdapter = null;
}
- public void test_closeProfileProxy() {
- if (!(mHasBluetooth && mIsHidHostSupported)) return;
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mHidHost);
- assertTrue(mIsProfileReady);
-
- mAdapter.closeProfileProxy(BluetoothProfile.HID_HOST, mHidHost);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
public void test_getConnectedDevices() {
if (!(mHasBluetooth && mIsHidHostSupported)) return;
@@ -214,11 +202,11 @@
}
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");
@@ -228,54 +216,28 @@
} catch (InterruptedException e) {
Log.e(TAG, "waitForProfileConnect: interrupted");
} 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 BluetoothHidHostListener implements BluetoothProfile.ServiceListener {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
try {
mHidHost = (BluetoothHidHost) proxy;
mIsProfileReady = true;
- 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();
- }
+ // Do nothing
}
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioTest.java
index f75b344..3df5b1f 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioTest.java
@@ -54,8 +54,8 @@
private BluetoothLeAudio mBluetoothLeAudio;
private boolean mIsLeAudioSupported;
private boolean mIsProfileReady;
- private Condition mConditionProfileConnection;
- private ReentrantLock mProfileConnectionlock;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
private Executor mTestExecutor;
private TestCallback mTestCallback;
private boolean mCodecConfigChangedCalled;
@@ -124,8 +124,8 @@
mAdapter = manager.getAdapter();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mBluetoothLeAudio = null;
@@ -159,18 +159,6 @@
mAdapter = null;
}
- public void test_closeProfileProxy() {
- if (!(mHasBluetooth && mIsLeAudioSupported)) return;
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothLeAudio);
- assertTrue(mIsProfileReady);
-
- mAdapter.closeProfileProxy(BluetoothProfile.LE_AUDIO, mBluetoothLeAudio);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
public void test_getConnectedDevices() {
if (!(mHasBluetooth && mIsLeAudioSupported)) return;
@@ -372,11 +360,11 @@
}
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");
@@ -386,55 +374,28 @@
} 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 BluetoothLeAudioServiceListener implements
BluetoothProfile.ServiceListener {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
mBluetoothLeAudio = (BluetoothLeAudio) 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();
- }
}
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastAssistantTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastAssistantTest.java
index 5853c53..6138f38 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastAssistantTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastAssistantTest.java
@@ -98,8 +98,8 @@
private BluetoothLeBroadcastAssistant mBluetoothLeBroadcastAssistant;
private boolean mIsBroadcastAssistantSupported;
private boolean mIsProfileReady;
- private Condition mConditionProfileConnection;
- private ReentrantLock mProfileConnectionlock;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedLock;
@Mock
BluetoothLeBroadcastAssistant.Callback mCallbacks;
@@ -120,8 +120,8 @@
mAdapter = TestUtils.getBluetoothAdapterOrDie();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
+ mProfileConnectedLock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedLock.newCondition();
mIsProfileReady = false;
mBluetoothLeBroadcastAssistant = null;
@@ -156,22 +156,6 @@
}
@Test
- public void testCloseProfileProxy() {
- if (shouldSkipTest()) {
- return;
- }
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothLeBroadcastAssistant);
- assertTrue(mIsProfileReady);
-
- mAdapter.closeProfileProxy(
- BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT, mBluetoothLeBroadcastAssistant);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
- @Test
public void testAddSource() {
if (shouldSkipTest()) {
return;
@@ -557,11 +541,11 @@
}
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");
@@ -571,54 +555,27 @@
} 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 ServiceListener implements BluetoothProfile.ServiceListener {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedLock.lock();
mBluetoothLeBroadcastAssistant = (BluetoothLeBroadcastAssistant) 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();
- }
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastTest.java
index 794a50d..e70d6ba 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastTest.java
@@ -93,8 +93,8 @@
private BluetoothLeBroadcast mBluetoothLeBroadcast;
private boolean mIsLeBroadcastSupported;
private boolean mIsProfileReady;
- private Condition mConditionProfileConnection;
- private ReentrantLock mProfileConnectionlock;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
private boolean mOnBroadcastStartedCalled = false;
private boolean mOnBroadcastStartFailedCalled = false;
@@ -167,8 +167,8 @@
mAdapter = TestUtils.getBluetoothAdapterOrDie();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mBluetoothLeBroadcast = null;
@@ -207,21 +207,6 @@
}
@Test
- public void testCloseProfileProxy() {
- if (shouldSkipTest()) {
- return;
- }
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothLeBroadcast);
- assertTrue(mIsProfileReady);
-
- mAdapter.closeProfileProxy(BluetoothProfile.LE_AUDIO_BROADCAST, mBluetoothLeBroadcast);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
- @Test
public void testGetConnectedDevices() {
if (shouldSkipTest()) {
return;
@@ -567,11 +552,11 @@
}
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");
@@ -581,55 +566,28 @@
} 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 ServiceListener implements
BluetoothProfile.ServiceListener {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
mBluetoothLeBroadcast = (BluetoothLeBroadcast) 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();
- }
}
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothMapClientTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothMapClientTest.java
index fa547bc..4a6cd06 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothMapClientTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothMapClientTest.java
@@ -62,8 +62,8 @@
private BluetoothMapClient mBluetoothMapClient;
private boolean mIsMapClientSupported;
private boolean mIsProfileReady;
- private Condition mConditionProfileConnection;
- private ReentrantLock mProfileConnectionlock;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
@Override
public void setUp() throws Exception {
@@ -83,8 +83,8 @@
mAdapter = manager.getAdapter();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mBluetoothMapClient = null;
@@ -111,18 +111,6 @@
mAdapter = null;
}
- public void test_closeProfileProxy() {
- if (!(mHasBluetooth && mIsMapClientSupported)) return;
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothMapClient);
- assertTrue(mIsProfileReady);
-
- mAdapter.closeProfileProxy(BluetoothProfile.MAP_CLIENT, mBluetoothMapClient);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
public void test_getConnectedDevices() {
if (!(mHasBluetooth && mIsMapClientSupported)) return;
@@ -237,11 +225,11 @@
}
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");
@@ -251,55 +239,28 @@
} 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 BluetoothMapClientServiceListener implements
BluetoothProfile.ServiceListener {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
mBluetoothMapClient = (BluetoothMapClient) 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();
- }
}
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothMapTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothMapTest.java
index 4bfd2f2..6a7fe34 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothMapTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothMapTest.java
@@ -51,8 +51,8 @@
private BluetoothMap mBluetoothMap;
private boolean mIsMapSupported;
private boolean mIsProfileReady;
- private Condition mConditionProfileConnection;
- private ReentrantLock mProfileConnectionlock;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
@Override
public void setUp() throws Exception {
@@ -72,8 +72,8 @@
mAdapter = manager.getAdapter();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mBluetoothMap = null;
@@ -99,18 +99,6 @@
mAdapter = null;
}
- public void test_closeProfileProxy() {
- if (!(mHasBluetooth && mIsMapSupported)) return;
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothMap);
- assertTrue(mIsProfileReady);
-
- mAdapter.closeProfileProxy(BluetoothProfile.MAP, mBluetoothMap);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
public void test_getConnectedDevices() {
if (!(mHasBluetooth && mIsMapSupported)) return;
@@ -198,11 +186,11 @@
}
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");
@@ -212,55 +200,28 @@
} catch (InterruptedException e) {
Log.e(TAG, "waitForProfileConnect: interrupted");
} 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 BluetoothMapServiceListener implements
BluetoothProfile.ServiceListener {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
try {
mBluetoothMap = (BluetoothMap) proxy;
mIsProfileReady = true;
- 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();
- }
}
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothPanTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothPanTest.java
index b417d61..733d9f3 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothPanTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothPanTest.java
@@ -46,8 +46,8 @@
private BluetoothPan mBluetoothPan;
private boolean mIsPanSupported;
private boolean mIsProfileReady;
- private Condition mConditionProfileConnection;
- private ReentrantLock mProfileConnectionlock;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
@Override
public void setUp() throws Exception {
@@ -66,8 +66,8 @@
mAdapter = manager.getAdapter();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mBluetoothPan = null;
@@ -93,18 +93,6 @@
TestUtils.dropPermissionAsShellUid();
}
- public void test_closeProfileProxy() {
- if (!(mHasBluetooth && mIsPanSupported)) return;
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothPan);
- assertTrue(mIsProfileReady);
-
- mAdapter.closeProfileProxy(BluetoothProfile.PAN, mBluetoothPan);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
public void test_getConnectedDevices() {
if (!(mHasBluetooth && mIsPanSupported)) return;
@@ -188,11 +176,11 @@
}
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");
@@ -202,54 +190,27 @@
} 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 BluetoothPanServiceListener implements BluetoothProfile.ServiceListener {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
mBluetoothPan = (BluetoothPan) 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();
- }
}
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothPbapClientTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothPbapClientTest.java
index 89a1b46..7b3df4e3 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothPbapClientTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothPbapClientTest.java
@@ -48,8 +48,8 @@
private BluetoothPbapClient mBluetoothPbapClient;
private boolean mIsPbapClientSupported;
private boolean mIsProfileReady;
- private Condition mConditionProfileConnection;
- private ReentrantLock mProfileConnectionlock;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
@Override
public void setUp() throws Exception {
@@ -68,8 +68,8 @@
mAdapter = manager.getAdapter();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mBluetoothPbapClient = null;
@@ -95,18 +95,6 @@
mAdapter = null;
}
- public void test_closeProfileProxy() {
- if (!(mHasBluetooth && mIsPbapClientSupported)) return;
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothPbapClient);
- assertTrue(mIsProfileReady);
-
- mAdapter.closeProfileProxy(BluetoothProfile.PBAP_CLIENT, mBluetoothPbapClient);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
public void test_getConnectedDevices() {
if (!(mHasBluetooth && mIsPbapClientSupported)) return;
@@ -194,11 +182,11 @@
}
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");
@@ -208,55 +196,28 @@
} 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 BluetoothPbapClientServiceListener implements
BluetoothProfile.ServiceListener {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
mBluetoothPbapClient = (BluetoothPbapClient) 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();
- }
}
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothPbapTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothPbapTest.java
index e8fe8cd..382a292 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothPbapTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothPbapTest.java
@@ -49,8 +49,8 @@
private BluetoothPbap mBluetoothPbap;
private boolean mIsPbapSupported;
private boolean mIsProfileReady;
- private Condition mConditionProfileConnection;
- private ReentrantLock mProfileConnectionlock;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
@Override
public void setUp() throws Exception {
@@ -70,8 +70,8 @@
mAdapter = manager.getAdapter();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mBluetoothPbap = null;
@@ -97,18 +97,6 @@
mAdapter = null;
}
- public void test_closeProfileProxy() {
- if (!(mHasBluetooth && mIsPbapSupported)) return;
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothPbap);
- assertTrue(mIsProfileReady);
-
- mAdapter.closeProfileProxy(BluetoothProfile.PBAP, mBluetoothPbap);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
public void test_getConnectedDevices() {
if (!(mHasBluetooth && mIsPbapSupported)) return;
@@ -177,11 +165,11 @@
}
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");
@@ -191,55 +179,28 @@
} catch (InterruptedException e) {
Log.e(TAG, "waitForProfileConnect: interrupted");
} 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 BluetoothPbapServiceListener implements
BluetoothProfile.ServiceListener {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
try {
mBluetoothPbap = (BluetoothPbap) proxy;
mIsProfileReady = true;
- 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();
- }
}
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothSapTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothSapTest.java
index 2a679f3..ad5cfff 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 @@
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 @@
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 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 @@
}
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 @@
} 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();
- }
}
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothVolumeControlTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothVolumeControlTest.java
index 7bbed5b..26237c1 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothVolumeControlTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothVolumeControlTest.java
@@ -47,8 +47,8 @@
private BluetoothVolumeControl mBluetoothVolumeControl;
private boolean mIsVolumeControlSupported;
private boolean mIsProfileReady;
- private Condition mConditionProfileConnection;
- private ReentrantLock mProfileConnectionlock;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
private boolean mVolumeOffsetChangedCallbackCalled;
private TestCallback mTestCallback;
private Executor mTestExecutor;
@@ -78,8 +78,8 @@
mAdapter = manager.getAdapter();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mBluetoothVolumeControl = null;
@@ -125,18 +125,6 @@
}
}
- public void testCloseProfileProxy() {
- if (!(mHasBluetooth && mIsVolumeControlSupported)) return;
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mBluetoothVolumeControl);
- assertTrue(mIsProfileReady);
-
- mAdapter.closeProfileProxy(BluetoothProfile.VOLUME_CONTROL, mBluetoothVolumeControl);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
public void testGetConnectedDevices() {
if (!(mHasBluetooth && mIsVolumeControlSupported)) return;
@@ -302,11 +290,11 @@
}
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");
@@ -316,55 +304,28 @@
} 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 BluetoothVolumeControlServiceListener implements
BluetoothProfile.ServiceListener {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
mBluetoothVolumeControl = (BluetoothVolumeControl) 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();
- }
}
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/HearingAidProfileTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/HearingAidProfileTest.java
index fa78672..2ed393f 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/HearingAidProfileTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/HearingAidProfileTest.java
@@ -69,8 +69,8 @@
private BroadcastReceiver mIntentReceiver;
private UiAutomation mUiAutomation;;
- private Condition mConditionProfileConnection;
- private ReentrantLock mProfileConnectionlock;
+ private Condition mConditionProfileIsConnected;
+ private ReentrantLock mProfileConnectedlock;
private boolean mIsProfileReady;
private static List<Integer> mValidConnectionStates = new ArrayList<Integer>(
@@ -94,8 +94,8 @@
mBluetoothAdapter = manager.getAdapter();
assertTrue(BTAdapterUtils.enableAdapter(mBluetoothAdapter, mContext));
- mProfileConnectionlock = new ReentrantLock();
- mConditionProfileConnection = mProfileConnectionlock.newCondition();
+ mProfileConnectedlock = new ReentrantLock();
+ mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mService = null;
mBluetoothAdapter.getProfileProxy(getContext(), new HearingAidsServiceListener(),
@@ -113,18 +113,6 @@
mUiAutomation.dropShellPermissionIdentity();
}
- public void test_closeProfileProxy() {
- if (!(mIsBleSupported && mIsHearingAidSupported)) return;
-
- assertTrue(waitForProfileConnect());
- assertNotNull(mService);
- assertTrue(mIsProfileReady);
-
- mBluetoothAdapter.closeProfileProxy(BluetoothProfile.HEARING_AID, mService);
- assertTrue(waitForProfileDisconnect());
- assertFalse(mIsProfileReady);
- }
-
/**
* Basic test case to make sure that Hearing Aid Profile Proxy can connect.
*/
@@ -287,11 +275,11 @@
}
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");
@@ -301,54 +289,30 @@
} 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 HearingAidsServiceListener
implements BluetoothProfile.ServiceListener {
public void onServiceConnected(int profile, BluetoothProfile proxy) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
mService = (BluetoothHearingAid) proxy;
mIsProfileReady = true;
try {
- mConditionProfileConnection.signal();
+ mConditionProfileIsConnected.signal();
} finally {
- mProfileConnectionlock.unlock();
+ mProfileConnectedlock.unlock();
}
}
public void onServiceDisconnected(int profile) {
- mProfileConnectionlock.lock();
+ mProfileConnectedlock.lock();
mIsProfileReady = false;
mService = null;
- try {
- mConditionProfileConnection.signal();
- } finally {
- mProfileConnectionlock.unlock();
- }
+ mProfileConnectedlock.unlock();
}
}