Migrate Bluetooth CTS tests to new sysprop APIs
Bug: 217448211
Test: atest CtsBluetoothTestCases
Change-Id: I49ce7911f1cf3616a2b8b1a0b344cef4130b218c
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpSinkTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpSinkTest.java
index f3918c7..dde5621 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpSinkTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpSinkTest.java
@@ -26,8 +26,6 @@
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
-import android.content.pm.PackageManager;
-import android.content.res.Resources;
import android.test.AndroidTestCase;
import android.util.Log;
@@ -42,7 +40,6 @@
private static final String TAG = BluetoothA2dpSinkTest.class.getSimpleName();
private static final int PROXY_CONNECTION_TIMEOUT_MS = 500; // ms timeout for Proxy Connect
- private static final String PROFILE_SUPPORTED_A2DP_SINK = "profile_supported_a2dp_sink";
private boolean mHasBluetooth;
private BluetoothAdapter mAdapter;
@@ -57,17 +54,11 @@
@Override
public void setUp() throws Exception {
super.setUp();
- mHasBluetooth = getContext().getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_BLUETOOTH);
+ mHasBluetooth = TestUtils.hasBluetooth();
if (!mHasBluetooth) return;
- Resources bluetoothResources = mContext.getPackageManager().getResourcesForApplication(
- "com.android.bluetooth.services");
- int a2dpSinkSupportId = bluetoothResources.getIdentifier(
- PROFILE_SUPPORTED_A2DP_SINK, "bool", "com.android.bluetooth.services");
- assertTrue("resource profile_supported_a2dp not found", a2dpSinkSupportId != 0);
- mIsA2dpSinkSupported = bluetoothResources.getBoolean(a2dpSinkSupportId);
+ mIsA2dpSinkSupported = TestUtils.isProfileEnabled(BluetoothProfile.A2DP_SINK);
if (!mIsA2dpSinkSupported) return;
mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
@@ -89,15 +80,18 @@
@Override
public void tearDown() throws Exception {
super.tearDown();
- if (!(mHasBluetooth && mIsA2dpSinkSupported)) return;
-
+ if (!(mHasBluetooth && mIsA2dpSinkSupported)) {
+ return;
+ }
if (mAdapter != null && mBluetoothA2dpSink != null) {
mAdapter.closeProfileProxy(BluetoothProfile.A2DP_SINK, mBluetoothA2dpSink);
mBluetoothA2dpSink = null;
mIsProfileReady = false;
}
mUiAutomation.adoptShellPermissionIdentity(BLUETOOTH_CONNECT);
- assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ if (mAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ }
mUiAutomation.dropShellPermissionIdentity();
mAdapter = null;
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpTest.java
index 191c4a2..912bf70 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpTest.java
@@ -21,12 +21,9 @@
import android.app.UiAutomation;
import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothCodecConfig;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
-import android.content.pm.PackageManager;
-import android.content.res.Resources;
import android.test.AndroidTestCase;
import android.util.Log;
@@ -41,7 +38,6 @@
private static final String TAG = BluetoothA2dpTest.class.getSimpleName();
private static final int PROXY_CONNECTION_TIMEOUT_MS = 500; // ms timeout for Proxy Connect
- private static final String PROFILE_SUPPORTED_A2DP = "profile_supported_a2dp";
private boolean mHasBluetooth;
private BluetoothAdapter mAdapter;
@@ -56,10 +52,13 @@
@Override
public void setUp() throws Exception {
super.setUp();
- mHasBluetooth = getContext().getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_BLUETOOTH);
+ mHasBluetooth = TestUtils.hasBluetooth();
if (!mHasBluetooth) return;
+
+ mIsA2dpSupported = TestUtils.isProfileEnabled(BluetoothProfile.A2DP_SINK);
+ if (!mIsA2dpSupported) return;
+
mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
mUiAutomation.adoptShellPermissionIdentity(BLUETOOTH_CONNECT);
@@ -72,14 +71,6 @@
mIsProfileReady = false;
mBluetoothA2dp = null;
- Resources bluetoothResources = mContext.getPackageManager().getResourcesForApplication(
- "com.android.bluetooth.services");
- int a2dpSupportId = bluetoothResources.getIdentifier(
- PROFILE_SUPPORTED_A2DP, "bool", "com.android.bluetooth.services");
- assertTrue("resource profile_supported_a2dp not found", a2dpSupportId != 0);
- mIsA2dpSupported = bluetoothResources.getBoolean(a2dpSupportId);
- if (!mIsA2dpSupported) return;
-
mAdapter.getProfileProxy(getContext(), new BluetoothA2dpServiceListener(),
BluetoothProfile.A2DP);
}
@@ -87,16 +78,19 @@
@Override
public void tearDown() throws Exception {
super.tearDown();
- if (mHasBluetooth) {
- if (mAdapter != null && mBluetoothA2dp != null) {
- mAdapter.closeProfileProxy(BluetoothProfile.A2DP, mBluetoothA2dp);
- mBluetoothA2dp = null;
- mIsProfileReady = false;
- }
- assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
- mAdapter = null;
- mUiAutomation.dropShellPermissionIdentity();
+ if (!(mHasBluetooth && mIsA2dpSupported)) {
+ return;
}
+ if (mAdapter != null && mBluetoothA2dp != null) {
+ mAdapter.closeProfileProxy(BluetoothProfile.A2DP, mBluetoothA2dp);
+ mBluetoothA2dp = null;
+ mIsProfileReady = false;
+ }
+ if (mAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ }
+ mAdapter = null;
+ mUiAutomation.dropShellPermissionIdentity();
}
public void test_getConnectedDevices() {
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHapClientTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHapClientTest.java
index 6c7b933..c83f014 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHapClientTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHapClientTest.java
@@ -54,7 +54,6 @@
private static final String TAG = BluetoothHapClientTest.class.getSimpleName();
private static final int PROXY_CONNECTION_TIMEOUT_MS = 500; // ms timeout for Proxy Connect
- private static final String PROFILE_SUPPORTED_HAP_CLIENT = "profile_supported_hap_client";
private Context mContext;
private boolean mHasBluetooth;
@@ -76,37 +75,40 @@
if (!mHasBluetooth) {
return;
}
+
+ mIsHapClientSupported = TestUtils.isProfileEnabled(BluetoothProfile.HAP_CLIENT);
+ if (!mIsHapClientSupported) {
+ return;
+ }
+
TestUtils.adoptPermissionAsShellUid(BLUETOOTH_CONNECT);
mAdapter = TestUtils.getBluetoothAdapterOrDie();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
-
mProfileConnectedlock = new ReentrantLock();
mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mBluetoothHapClient = null;
- mIsHapClientSupported = TestUtils.getProfileConfigValueOrDie(BluetoothProfile.HAP_CLIENT);
- if (!mIsHapClientSupported) {
- return;
- }
-
mAdapter.getProfileProxy(mContext, new BluetoothHapClientServiceListener(),
BluetoothProfile.HAP_CLIENT);
}
@After
public void tearDown() throws Exception {
- if (mHasBluetooth) {
- if (mAdapter != null && mBluetoothHapClient != null) {
- mBluetoothHapClient.close();
- mBluetoothHapClient = null;
- mIsProfileReady = false;
- }
- assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
- mAdapter = null;
- TestUtils.dropPermissionAsShellUid();
+ if (!(mHasBluetooth && mIsHapClientSupported)) {
+ return;
}
+ if (mAdapter != null && mBluetoothHapClient != null) {
+ mBluetoothHapClient.close();
+ mBluetoothHapClient = null;
+ mIsProfileReady = false;
+ }
+ if (mAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ }
+ mAdapter = null;
+ TestUtils.dropPermissionAsShellUid();
}
@Test
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHapPresetInfoTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHapPresetInfoTest.java
index afafa39..df8ecf1 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHapPresetInfoTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHapPresetInfoTest.java
@@ -61,20 +61,27 @@
if (!mHasBluetooth) {
return;
}
+
+ mIsHapSupported = TestUtils.isProfileEnabled(BluetoothProfile.HAP_CLIENT);
+ if (!mIsHapSupported) {
+ return;
+ }
+
TestUtils.adoptPermissionAsShellUid(BLUETOOTH_CONNECT);
mAdapter = TestUtils.getBluetoothAdapterOrDie();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
-
- mIsHapSupported = TestUtils.getProfileConfigValueOrDie(BluetoothProfile.HAP_CLIENT);
}
@After
public void tearDown() {
- if (mHasBluetooth) {
- assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
- mAdapter = null;
- TestUtils.dropPermissionAsShellUid();
+ if (!(mHasBluetooth && mIsHapSupported)) {
+ return;
}
+ if (mAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ }
+ mAdapter = null;
+ TestUtils.dropPermissionAsShellUid();
}
@Test
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetTest.java
index cf8f1a2..6925d9e 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHeadsetTest.java
@@ -19,13 +19,12 @@
import static android.Manifest.permission.BLUETOOTH_CONNECT;
import android.app.UiAutomation;
-import android.bluetooth.BluetoothHeadset;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothHeadset;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
import android.content.pm.PackageManager;
-import android.content.res.Resources;
import android.test.AndroidTestCase;
import android.util.Log;
@@ -40,7 +39,6 @@
private static final String TAG = BluetoothHeadsetTest.class.getSimpleName();
private static final int PROXY_CONNECTION_TIMEOUT_MS = 500; // ms timeout for Proxy Connect
- private static final String PROFILE_SUPPORTED_HEADSET = "profile_supported_hs_hfp";
private boolean mHasBluetooth;
private BluetoothAdapter mAdapter;
@@ -57,8 +55,11 @@
super.setUp();
mHasBluetooth = getContext().getPackageManager().hasSystemFeature(
PackageManager.FEATURE_BLUETOOTH);
-
if (!mHasBluetooth) return;
+
+ mIsHeadsetSupported = TestUtils.isProfileEnabled(BluetoothProfile.HEADSET);
+ if (!mIsHeadsetSupported) return;
+
mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
mUiAutomation.adoptShellPermissionIdentity(BLUETOOTH_CONNECT);
@@ -71,14 +72,6 @@
mIsProfileReady = false;
mBluetoothHeadset = null;
- Resources bluetoothResources = mContext.getPackageManager().getResourcesForApplication(
- "com.android.bluetooth.services");
- int headsetSupportId = bluetoothResources.getIdentifier(
- PROFILE_SUPPORTED_HEADSET, "bool", "com.android.bluetooth.services");
- assertTrue("resource profile_supported_hs_hfp not found", headsetSupportId != 0);
- mIsHeadsetSupported = bluetoothResources.getBoolean(headsetSupportId);
- if (!mIsHeadsetSupported) return;
-
mAdapter.getProfileProxy(getContext(), new BluetoothHeadsetServiceListener(),
BluetoothProfile.HEADSET);
}
@@ -86,16 +79,19 @@
@Override
public void tearDown() throws Exception {
super.tearDown();
- if (mHasBluetooth) {
- if (mAdapter != null && mBluetoothHeadset != null) {
- mAdapter.closeProfileProxy(BluetoothProfile.HEADSET, mBluetoothHeadset);
- mBluetoothHeadset = null;
- mIsProfileReady = false;
- }
- assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
- mAdapter = null;
- mUiAutomation.dropShellPermissionIdentity();
+ if (!(mHasBluetooth && mIsHeadsetSupported)) {
+ return;
}
+ if (mAdapter != null && mBluetoothHeadset != null) {
+ mAdapter.closeProfileProxy(BluetoothProfile.HEADSET, mBluetoothHeadset);
+ mBluetoothHeadset = null;
+ mIsProfileReady = false;
+ }
+ if (mAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ }
+ mAdapter = null;
+ mUiAutomation.dropShellPermissionIdentity();
}
public void test_getConnectedDevices() {
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHidDeviceTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHidDeviceTest.java
index 857e12c..1a258bc 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHidDeviceTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothHidDeviceTest.java
@@ -39,7 +39,6 @@
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
import android.content.pm.PackageManager;
-import android.content.res.Resources;
import android.test.AndroidTestCase;
import android.util.Log;
@@ -56,7 +55,6 @@
private static final String TAG = BluetoothHidDevice.class.getSimpleName();
private static final int PROXY_CONNECTION_TIMEOUT_MS = 500; // ms timeout for Proxy Connect
- private static final String PROFILE_SUPPORTED_HID_DEVICE = "profile_supported_hid_device";
private boolean mHasBluetooth;
private boolean mIsHidSupported;
@@ -76,6 +74,10 @@
mHasBluetooth =
getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
if (!mHasBluetooth) return;
+
+ mIsHidSupported = TestUtils.isProfileEnabled(BluetoothProfile.HID_DEVICE);
+ if (!mIsHidSupported) return;
+
mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
mUiAutomation.adoptShellPermissionIdentity(BLUETOOTH_CONNECT);
@@ -89,13 +91,6 @@
mBluetoothHidDevice = null;
mExecutor = Executors.newSingleThreadExecutor();
- Resources bluetoothResources = mContext.getPackageManager().getResourcesForApplication(
- "com.android.bluetooth.services");
- int hidSupportId = bluetoothResources.getIdentifier(PROFILE_SUPPORTED_HID_DEVICE, "bool",
- "com.android.bluetooth.services");
- mIsHidSupported = bluetoothResources.getBoolean(hidSupportId);
- if (!mIsHidSupported) return;
-
mAdapter.getProfileProxy(getContext(), new BluetoothHidServiceListener(),
BluetoothProfile.HID_DEVICE);
}
@@ -103,17 +98,20 @@
@Override
public void tearDown() throws Exception {
super.tearDown();
- if (mHasBluetooth) {
- if (mAdapter != null && mBluetoothHidDevice != null) {
- mAdapter.closeProfileProxy(BluetoothProfile.HID_DEVICE, mBluetoothHidDevice);
- mBluetoothHidDevice = null;
- mIsProfileReady = false;
- }
- mUiAutomation.adoptShellPermissionIdentity(BLUETOOTH_CONNECT);
- assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
- mAdapter = null;
- mUiAutomation.dropShellPermissionIdentity();
+ if (!(mHasBluetooth && mIsHidSupported)) {
+ return;
}
+ if (mAdapter != null && mBluetoothHidDevice != null) {
+ mAdapter.closeProfileProxy(BluetoothProfile.HID_DEVICE, mBluetoothHidDevice);
+ mBluetoothHidDevice = null;
+ mIsProfileReady = false;
+ }
+ mUiAutomation.adoptShellPermissionIdentity(BLUETOOTH_CONNECT);
+ if (mAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ }
+ mAdapter = null;
+ mUiAutomation.dropShellPermissionIdentity();
}
public void test_getDevicesMatchingConnectionStates() {
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioCodecConfigMetadataTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioCodecConfigMetadataTest.java
index 0100442..0446adb 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioCodecConfigMetadataTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioCodecConfigMetadataTest.java
@@ -75,8 +75,7 @@
mAdapter.isLeAudioBroadcastAssistantSupported() == FEATURE_SUPPORTED;
if (mIsBroadcastAssistantSupported) {
boolean isBroadcastAssistantEnabledInConfig =
- TestUtils.getProfileConfigValueOrDie(
- BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
+ TestUtils.isProfileEnabled(BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
assertTrue("Config must be true when profile is supported",
isBroadcastAssistantEnabledInConfig);
}
@@ -85,8 +84,7 @@
mAdapter.isLeAudioBroadcastSourceSupported() == FEATURE_SUPPORTED;
if (!mIsBroadcastSourceSupported) {
boolean isBroadcastSourceEnabledInConfig =
- TestUtils.getProfileConfigValueOrDie(
- BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
+ TestUtils.isProfileEnabled(BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
assertTrue("Config must be true when profile is supported",
isBroadcastSourceEnabledInConfig);
}
@@ -95,7 +93,9 @@
@After
public void tearDown() {
if (mHasBluetooth) {
- assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ if (mAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ }
mAdapter = null;
TestUtils.dropPermissionAsShellUid();
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioContentMetadataTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioContentMetadataTest.java
index 08deed4..c22e77d5 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioContentMetadataTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioContentMetadataTest.java
@@ -81,8 +81,7 @@
mAdapter.isLeAudioBroadcastAssistantSupported() == FEATURE_SUPPORTED;
if (mIsBroadcastAssistantSupported) {
boolean isBroadcastAssistantEnabledInConfig =
- TestUtils.getProfileConfigValueOrDie(
- BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
+ TestUtils.isProfileEnabled(BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
assertTrue("Config must be true when profile is supported",
isBroadcastAssistantEnabledInConfig);
}
@@ -91,8 +90,7 @@
mAdapter.isLeAudioBroadcastSourceSupported() == FEATURE_SUPPORTED;
if (!mIsBroadcastSourceSupported) {
boolean isBroadcastSourceEnabledInConfig =
- TestUtils.getProfileConfigValueOrDie(
- BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
+ TestUtils.isProfileEnabled(BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
assertTrue("Config must be true when profile is supported",
isBroadcastSourceEnabledInConfig);
}
@@ -101,7 +99,9 @@
@After
public void tearDown() {
if (mHasBluetooth) {
- assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ if (mAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ }
mAdapter = null;
TestUtils.dropPermissionAsShellUid();
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioTest.java
index 9f0185c..2a1f31d 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioTest.java
@@ -115,8 +115,11 @@
if (ApiLevelUtil.isAtLeast(Build.VERSION_CODES.TIRAMISU)) {
mHasBluetooth = getContext().getPackageManager().hasSystemFeature(
PackageManager.FEATURE_BLUETOOTH);
-
if (!mHasBluetooth) return;
+
+ mIsLeAudioSupported = TestUtils.isProfileEnabled(BluetoothProfile.LE_AUDIO);
+ if (!mIsLeAudioSupported) return;
+
TestUtils.adoptPermissionAsShellUid(BLUETOOTH_CONNECT, BLUETOOTH_PRIVILEGED);
BluetoothManager manager = getContext().getSystemService(BluetoothManager.class);
@@ -128,9 +131,6 @@
mIsProfileReady = false;
mBluetoothLeAudio = null;
- mIsLeAudioSupported = TestUtils.getProfileConfigValueOrDie(BluetoothProfile.LE_AUDIO);
- if (!mIsLeAudioSupported) return;
-
mAdapter.getProfileProxy(getContext(), new BluetoothLeAudioServiceListener(),
BluetoothProfile.LE_AUDIO);
@@ -142,18 +142,19 @@
@Override
public void tearDown() throws Exception {
super.tearDown();
- if (mHasBluetooth) {
- if (mBluetoothLeAudio != null) {
- mBluetoothLeAudio.close();
- mBluetoothLeAudio = null;
- mIsProfileReady = false;
- }
- if (mAdapter != null) {
- assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
- mAdapter = null;
- }
- TestUtils.dropPermissionAsShellUid();
+ if (!(mHasBluetooth && mIsLeAudioSupported)) {
+ return;
}
+ if (mBluetoothLeAudio != null) {
+ mBluetoothLeAudio.close();
+ mBluetoothLeAudio = null;
+ mIsProfileReady = false;
+ }
+ if (mAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ }
+ TestUtils.dropPermissionAsShellUid();
+ mAdapter = null;
}
public void testGetConnectedDevices() {
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastAssistantTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastAssistantTest.java
index 667aa52..1d800bd 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastAssistantTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastAssistantTest.java
@@ -95,8 +95,7 @@
mAdapter.isLeAudioBroadcastAssistantSupported() == FEATURE_SUPPORTED;
if (mIsBroadcastAssistantSupported) {
boolean isBroadcastAssistantEnabledInConfig =
- TestUtils.getProfileConfigValueOrDie(
- BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
+ TestUtils.isProfileEnabled(BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
assertTrue("Config must be true when profile is supported",
isBroadcastAssistantEnabledInConfig);
}
@@ -114,7 +113,9 @@
mBluetoothLeBroadcastAssistant = null;
mIsProfileReady = false;
}
- assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ if (mAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ }
mAdapter = null;
TestUtils.dropPermissionAsShellUid();
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastChannelTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastChannelTest.java
index 7390b82..b72a04c 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastChannelTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastChannelTest.java
@@ -69,8 +69,7 @@
mAdapter.isLeAudioBroadcastAssistantSupported() == FEATURE_SUPPORTED;
if (mIsBroadcastAssistantSupported) {
boolean isBroadcastAssistantEnabledInConfig =
- TestUtils.getProfileConfigValueOrDie(
- BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
+ TestUtils.isProfileEnabled(BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
assertTrue("Config must be true when profile is supported",
isBroadcastAssistantEnabledInConfig);
}
@@ -79,8 +78,8 @@
mAdapter.isLeAudioBroadcastSourceSupported() == FEATURE_SUPPORTED;
if (!mIsBroadcastSourceSupported) {
boolean isBroadcastSourceEnabledInConfig =
- TestUtils.getProfileConfigValueOrDie(
- BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
+ TestUtils.isProfileEnabled(
+ BluetoothProfile.LE_AUDIO_BROADCAST);
assertTrue("Config must be true when profile is supported",
isBroadcastSourceEnabledInConfig);
}
@@ -89,7 +88,9 @@
@After
public void tearDown() {
if (mHasBluetooth) {
- assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ if (mAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ }
mAdapter = null;
TestUtils.dropPermissionAsShellUid();
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastMetadataTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastMetadataTest.java
index ad96fe0..bd1d9b9 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastMetadataTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastMetadataTest.java
@@ -92,8 +92,7 @@
mAdapter.isLeAudioBroadcastAssistantSupported() == FEATURE_SUPPORTED;
if (mIsBroadcastAssistantSupported) {
boolean isBroadcastAssistantEnabledInConfig =
- TestUtils.getProfileConfigValueOrDie(
- BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
+ TestUtils.isProfileEnabled(BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
assertTrue("Config must be true when profile is supported",
isBroadcastAssistantEnabledInConfig);
}
@@ -102,8 +101,7 @@
mAdapter.isLeAudioBroadcastSourceSupported() == FEATURE_SUPPORTED;
if (!mIsBroadcastSourceSupported) {
boolean isBroadcastSourceEnabledInConfig =
- TestUtils.getProfileConfigValueOrDie(
- BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
+ TestUtils.isProfileEnabled(BluetoothProfile.LE_AUDIO_BROADCAST);
assertTrue("Config must be true when profile is supported",
isBroadcastSourceEnabledInConfig);
}
@@ -112,7 +110,9 @@
@After
public void tearDown() {
if (mHasBluetooth) {
- assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ if (mAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ }
mAdapter = null;
TestUtils.dropPermissionAsShellUid();
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastReceiveStateTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastReceiveStateTest.java
index cc28740..edb8b06 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastReceiveStateTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastReceiveStateTest.java
@@ -87,8 +87,7 @@
mAdapter.isLeAudioBroadcastAssistantSupported() == FEATURE_SUPPORTED;
if (mIsBroadcastAssistantSupported) {
boolean isBroadcastAssistantEnabledInConfig =
- TestUtils.getProfileConfigValueOrDie(
- BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
+ TestUtils.isProfileEnabled(BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
assertTrue("Config must be true when profile is supported",
isBroadcastAssistantEnabledInConfig);
}
@@ -97,8 +96,7 @@
mAdapter.isLeAudioBroadcastSourceSupported() == FEATURE_SUPPORTED;
if (!mIsBroadcastSourceSupported) {
boolean isBroadcastSourceEnabledInConfig =
- TestUtils.getProfileConfigValueOrDie(
- BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
+ TestUtils.isProfileEnabled(BluetoothProfile.LE_AUDIO_BROADCAST);
assertTrue("Config must be true when profile is supported",
isBroadcastSourceEnabledInConfig);
}
@@ -107,7 +105,9 @@
@After
public void tearDown() {
if (mHasBluetooth) {
- assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ if (mAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ }
mAdapter = null;
TestUtils.dropPermissionAsShellUid();
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastSubgroupTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastSubgroupTest.java
index 910e55d..4f36364 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastSubgroupTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastSubgroupTest.java
@@ -83,8 +83,7 @@
mAdapter.isLeAudioBroadcastAssistantSupported() == FEATURE_SUPPORTED;
if (mIsBroadcastAssistantSupported) {
boolean isBroadcastAssistantEnabledInConfig =
- TestUtils.getProfileConfigValueOrDie(
- BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
+ TestUtils.isProfileEnabled(BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
assertTrue("Config must be true when profile is supported",
isBroadcastAssistantEnabledInConfig);
}
@@ -93,8 +92,7 @@
mAdapter.isLeAudioBroadcastSourceSupported() == FEATURE_SUPPORTED;
if (!mIsBroadcastSourceSupported) {
boolean isBroadcastSourceEnabledInConfig =
- TestUtils.getProfileConfigValueOrDie(
- BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
+ TestUtils.isProfileEnabled(BluetoothProfile.LE_AUDIO_BROADCAST);
assertTrue("Config must be true when profile is supported",
isBroadcastSourceEnabledInConfig);
}
@@ -103,7 +101,9 @@
@After
public void tearDown() {
if (mHasBluetooth) {
- assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ if (mAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ }
mAdapter = null;
TestUtils.dropPermissionAsShellUid();
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastTest.java
index d73f721..a58ae03 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeBroadcastTest.java
@@ -55,7 +55,6 @@
private static final String TAG = BluetoothLeBroadcastTest.class.getSimpleName();
private static final int PROXY_CONNECTION_TIMEOUT_MS = 500; // ms timeout for Proxy Connect
- private static final String PROFILE_SUPPORTED_LE_BROADCAST = "profile_supported_le_broadcast";
private Context mContext;
private boolean mHasBluetooth;
@@ -90,7 +89,7 @@
mAdapter.isLeAudioBroadcastSourceSupported() == FEATURE_SUPPORTED;
if (mIsLeBroadcastSupported) {
boolean isBroadcastSourceEnabledInConfig =
- TestUtils.getProfileConfigValueOrDie(BluetoothProfile.LE_AUDIO_BROADCAST);
+ TestUtils.isProfileEnabled(BluetoothProfile.LE_AUDIO_BROADCAST);
assertTrue("Config must be true when profile is supported",
isBroadcastSourceEnabledInConfig);
}
@@ -111,7 +110,9 @@
mBluetoothLeBroadcast = null;
mIsProfileReady = false;
}
- assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ if (mAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ }
mAdapter = null;
TestUtils.dropPermissionAsShellUid();
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothSapTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothSapTest.java
index 29d9bd5..1f220cd 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothSapTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothSapTest.java
@@ -27,7 +27,6 @@
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothSap;
import android.content.pm.PackageManager;
-import android.sysprop.BluetoothProperties;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import android.util.Log;
@@ -62,7 +61,7 @@
if (!mHasBluetooth) return;
- mIsSapSupported = BluetoothProperties.isProfileSapServerEnabled().orElse(false);
+ mIsSapSupported = TestUtils.isProfileEnabled(BluetoothProfile.SAP);
if (!mIsSapSupported) return;
mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
@@ -90,7 +89,9 @@
mIsProfileReady = false;
}
mUiAutomation.adoptShellPermissionIdentity(BLUETOOTH_CONNECT);
- assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ if (mAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ }
mUiAutomation.dropShellPermissionIdentity();
mAdapter = null;
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/HearingAidProfileTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/HearingAidProfileTest.java
index 7a227fc..2ed393f 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/HearingAidProfileTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/HearingAidProfileTest.java
@@ -83,6 +83,9 @@
if (!isBleSupported()) return;
mIsBleSupported = true;
+ mIsHearingAidSupported = TestUtils.isProfileEnabled(BluetoothProfile.HEARING_AID);
+ if (!mIsHearingAidSupported) return;
+
mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
mUiAutomation.adoptShellPermissionIdentity(BLUETOOTH_CONNECT);
@@ -95,17 +98,18 @@
mConditionProfileIsConnected = mProfileConnectedlock.newCondition();
mIsProfileReady = false;
mService = null;
- mIsHearingAidSupported = mBluetoothAdapter.getProfileProxy(getContext(),
- new HearingAidsServiceListener(),
- BluetoothProfile.HEARING_AID);
- if (!mIsHearingAidSupported) return;
+ mBluetoothAdapter.getProfileProxy(getContext(), new HearingAidsServiceListener(),
+ BluetoothProfile.HEARING_AID);
}
@Override
public void tearDown() {
- if (!mIsBleSupported) return;
-
- assertTrue(BTAdapterUtils.disableAdapter(mBluetoothAdapter, mContext));
+ if (!(mIsBleSupported && mIsHearingAidSupported)) {
+ return;
+ }
+ if (mBluetoothAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mBluetoothAdapter, mContext));
+ }
mUiAutomation.dropShellPermissionIdentity();
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/LeL2capSocketTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/LeL2capSocketTest.java
index d152d84..62d1c6a 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/LeL2capSocketTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/LeL2capSocketTest.java
@@ -51,7 +51,9 @@
if (!TestUtils.isBleSupported(getContext())) {
return;
}
- assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ if (mAdapter != null) {
+ assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
+ }
mAdapter = null;
InstrumentationRegistry.getInstrumentation().getUiAutomation()
.dropShellPermissionIdentity();
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/TestUtils.java b/tests/tests/bluetooth/src/android/bluetooth/cts/TestUtils.java
index 75dfba6..34bc0a3 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/TestUtils.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/TestUtils.java
@@ -16,9 +16,7 @@
package android.bluetooth.cts;
-import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -28,8 +26,8 @@
import android.bluetooth.le.ScanRecord;
import android.content.Context;
import android.content.pm.PackageManager;
-import android.content.res.Resources;
import android.provider.Settings;
+import android.sysprop.BluetoothProperties;
import android.util.Log;
import androidx.test.platform.app.InstrumentationRegistry;
@@ -50,93 +48,6 @@
static final String BLUETOOTH_PACKAGE_NAME = "com.android.bluetooth.services";
/**
- * Get the Config.xml name tag for a particular Bluetooth profile
- * @param profile profile id from {@link BluetoothProfile}
- * @return config name tag, or null if the tag name is not available
- */
- @Nullable static String profileIdToConfigTag(int profile) {
- switch (profile) {
- case BluetoothProfile.A2DP:
- return "profile_supported_a2dp";
- case BluetoothProfile.A2DP_SINK:
- return "profile_supported_a2dp_sink";
- case BluetoothProfile.HEADSET:
- return "profile_supported_hs_hfp";
- case BluetoothProfile.HEADSET_CLIENT:
- return "profile_supported_hfpclient";
- case BluetoothProfile.HID_HOST:
- return "profile_supported_hid_host";
- case BluetoothProfile.OPP:
- return "profile_supported_opp";
- case BluetoothProfile.PAN:
- return "profile_supported_pan";
- case BluetoothProfile.PBAP:
- return "profile_supported_pbap";
- case BluetoothProfile.GATT:
- return "profile_supported_gatt";
- case BluetoothProfile.MAP:
- return "profile_supported_map";
- // Hidden profile
- // case BluetoothProfile.AVRCP:
- // return "profile_supported_avrcp_target";
- case BluetoothProfile.AVRCP_CONTROLLER:
- return "profile_supported_avrcp_controller";
- case BluetoothProfile.SAP:
- return "profile_supported_sap";
- case BluetoothProfile.PBAP_CLIENT:
- return "profile_supported_pbapclient";
- case BluetoothProfile.MAP_CLIENT:
- return "profile_supported_mapmce";
- case BluetoothProfile.HID_DEVICE:
- return "profile_supported_hid_device";
- case BluetoothProfile.LE_AUDIO:
- return "profile_supported_le_audio";
- case BluetoothProfile.LE_AUDIO_BROADCAST:
- return "profile_supported_le_audio_broadcast";
- case BluetoothProfile.VOLUME_CONTROL:
- return "profile_supported_vc";
- // Hidden profile
- // case BluetoothProfile.MCP_SERVER:
- // return "profile_supported_mcp_server";
- case BluetoothProfile.CSIP_SET_COORDINATOR:
- return "profile_supported_csip_set_coordinator";
- // Hidden profile
- // case BluetoothProfile.LE_CALL_CONTROL:
- // return "profile_supported_le_call_control";
- case BluetoothProfile.HAP_CLIENT:
- return "profile_supported_hap_client";
- case BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT:
- return "profile_supported_bass_client";
- default:
- return null;
- }
- }
-
- /**
- * Checks if a particular Bluetooth profile is configured for this device
- * Fail the test if profile config status cannot be obtained
- */
- static boolean getProfileConfigValueOrDie(int profile) {
- String profileConfigValueTag = profileIdToConfigTag(profile);
- assertNotNull(profileConfigValueTag);
- assertNotEquals("profile tag cannot be empty", 0, profileConfigValueTag.length());
- Context context = InstrumentationRegistry.getInstrumentation().getContext();
- Resources bluetoothResources = null;
- try {
- bluetoothResources = context.getPackageManager().getResourcesForApplication(
- BLUETOOTH_PACKAGE_NAME);
- } catch (PackageManager.NameNotFoundException e) {
- fail("Cannot get Bluetooth package resource");
- }
- int resourceId = bluetoothResources.getIdentifier(
- profileConfigValueTag, "bool", BLUETOOTH_PACKAGE_NAME);
- if (resourceId == 0) {
- return false;
- }
- return bluetoothResources.getBoolean(resourceId);
- }
-
- /**
* Checks whether this device has Bluetooth feature
* @return true if this device has Bluetooth feature
*/
@@ -147,6 +58,70 @@
}
/**
+ * Get the current enabled status of a given profile
+ */
+ static boolean isProfileEnabled(int profile) {
+ switch (profile) {
+ case BluetoothProfile.A2DP:
+ return BluetoothProperties.isProfileA2dpSourceEnabled().orElse(false);
+ case BluetoothProfile.A2DP_SINK:
+ return BluetoothProperties.isProfileA2dpSinkEnabled().orElse(false);
+ // Hidden profile
+ // case BluetoothProfile.AVRCP:
+ // return BluetoothProperties.isProfileAvrcpTargetEnabled().orElse(false);
+ case BluetoothProfile.AVRCP_CONTROLLER:
+ return BluetoothProperties.isProfileAvrcpControllerEnabled().orElse(false);
+ case BluetoothProfile.CSIP_SET_COORDINATOR:
+ return BluetoothProperties.isProfileCsipSetCoordinatorEnabled().orElse(false);
+ case BluetoothProfile.GATT:
+ return BluetoothProperties.isProfileGattEnabled().orElse(false);
+ case BluetoothProfile.HAP_CLIENT:
+ return BluetoothProperties.isProfileHapClientEnabled().orElse(false);
+ case BluetoothProfile.HEADSET:
+ return BluetoothProperties.isProfileHfpAgEnabled().orElse(false);
+ case BluetoothProfile.HEADSET_CLIENT:
+ return BluetoothProperties.isProfileHfpHfEnabled().orElse(false);
+ case BluetoothProfile.HEARING_AID:
+ return BluetoothProperties.isProfileAshaCentralEnabled().orElse(false);
+ case BluetoothProfile.HID_DEVICE:
+ return BluetoothProperties.isProfileHidDeviceEnabled().orElse(false);
+ case BluetoothProfile.HID_HOST:
+ return BluetoothProperties.isProfileHidHostEnabled().orElse(false);
+ case BluetoothProfile.LE_AUDIO:
+ return BluetoothProperties.isProfileBapUnicastServerEnabled().orElse(false);
+ case BluetoothProfile.LE_AUDIO_BROADCAST:
+ return BluetoothProperties.isProfileBapBroadcastSourceEnabled().orElse(false);
+ case BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT:
+ return BluetoothProperties.isProfileBapBroadcastAssistEnabled().orElse(false);
+ // Hidden profile
+ // case BluetoothProfile.LE_CALL_CONTROL:
+ // return BluetoothProperties.isProfileTbsServerEnabled().orElse(false);
+ case BluetoothProfile.MAP:
+ return BluetoothProperties.isProfileMapServerEnabled().orElse(false);
+ case BluetoothProfile.MAP_CLIENT:
+ return BluetoothProperties.isProfileMapClientEnabled().orElse(false);
+ // Hidden profile
+ // case BluetoothProfile.MCP_SERVER:
+ // return BluetoothProperties.isProfileMcpServerEnabled().orElse(false);
+ case BluetoothProfile.OPP:
+ return BluetoothProperties.isProfileOppEnabled().orElse(false);
+ case BluetoothProfile.PAN:
+ return BluetoothProperties.isProfilePanNapEnabled().orElse(false)
+ || BluetoothProperties.isProfilePanPanuEnabled().orElse(false);
+ case BluetoothProfile.PBAP:
+ return BluetoothProperties.isProfilePbapServerEnabled().orElse(false);
+ case BluetoothProfile.PBAP_CLIENT:
+ return BluetoothProperties.isProfilePbapClientEnabled().orElse(false);
+ case BluetoothProfile.SAP:
+ return BluetoothProperties.isProfileSapServerEnabled().orElse(false);
+ case BluetoothProfile.VOLUME_CONTROL:
+ return BluetoothProperties.isProfileVcServerEnabled().orElse(false);
+ default:
+ return false;
+ }
+ }
+
+ /**
* Adopt shell UID's permission via {@link android.app.UiAutomation}
* @param permission permission to adopt
*/