Merge "Update biometrics OWNERS."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index e10b17d..ec4d8ef 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2290,6 +2290,7 @@
android:exported="true">
<intent-filter>
<action android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
+ <action android:name="android.bluetooth.action.CSIS_SET_MEMBER_AVAILABLE"/>
</intent-filter>
</receiver>
diff --git a/res/layout/bluetooth_pin_confirm.xml b/res/layout/bluetooth_pin_confirm.xml
index 4891275..28ad1f6 100644
--- a/res/layout/bluetooth_pin_confirm.xml
+++ b/res/layout/bluetooth_pin_confirm.xml
@@ -65,6 +65,18 @@
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:visibility="gone" />
+ <TextView
+ android:id="@+id/pairing_group_message"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="@dimen/bluetooth_dialog_padding"
+ android:layout_marginEnd="@dimen/bluetooth_dialog_padding"
+ android:layout_marginBottom="@dimen/bluetooth_dialog_padding"
+ android:gravity="center_vertical"
+ android:text="@string/bluetooth_paring_group_msg"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
+ android:visibility="gone" />
+
<CheckBox
android:id="@+id/phonebook_sharing_message_confirm_pin"
android:layout_width="wrap_content"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index aec90e1..86c80c3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1832,6 +1832,9 @@
<!-- Message for confirmation of passkey to complete pairing. [CHAR LIMIT=NONE] -->
<string name="bluetooth_confirm_passkey_msg">To pair with:<br><b><xliff:g id="device_name">%1$s</xliff:g></b><br><br>Make sure it is showing this passkey:<br><b><xliff:g id="passkey">%2$s</xliff:g></b></string>
+ <!-- Pairing dialog text to remind user the pairing including all of the devices in a coordinated set. [CHAR LIMIT=NONE] -->
+ <string name="bluetooth_paring_group_msg">Confirm to pair with the coordinated set</string>
+
<!-- Message when bluetooth incoming pairing request for (2.1 devices) dialog is showing -->
<string name="bluetooth_incoming_pairing_msg">From:<br><b><xliff:g id="device_name">%1$s</xliff:g></b><br><br>Pair with this device?</string>
@@ -1909,6 +1912,8 @@
<string name="device_details_title">Device details</string>
<!-- Title of the item to show device MAC address -->
<string name="bluetooth_device_mac_address">Device\'s Bluetooth address: <xliff:g id="address">%1$s</xliff:g></string>
+ <!-- Title of the items to show multuple devices MAC address [CHAR LIMIT=NONE]-->
+ <string name="bluetooth_multuple_devices_mac_address">Device\'s Bluetooth address:\n<xliff:g id="address">%1$s</xliff:g></string>
<!-- Bluetooth device details. The title of a confirmation dialog for unpairing a paired device. [CHAR LIMIT=60] -->
<string name="bluetooth_unpair_dialog_title">Forget device?</string>
<!-- Content Description for companion device app associations removal button [CHAR LIMIT=28]-->
diff --git a/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java
index 27d63bf..14c20f1 100644
--- a/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java
@@ -70,9 +70,10 @@
if (DBG) {
Log.d(TAG, "isFilterMatched() current audio profile : " + currentAudioProfile);
}
- // If device is Hearing Aid, it is compatible with HFP and A2DP.
+ // If device is Hearing Aid or LE Audio, it is compatible with HFP and A2DP.
// It would show in Available Devices group.
- if (cachedDevice.isConnectedHearingAidDevice()) {
+ if (cachedDevice.isConnectedHearingAidDevice()
+ || cachedDevice.isConnectedLeAudioDevice()) {
return true;
}
// According to the current audio profile type,
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsMacAddressController.java b/src/com/android/settings/bluetooth/BluetoothDetailsMacAddressController.java
index dda247e..ec3e11f 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsMacAddressController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsMacAddressController.java
@@ -16,6 +16,7 @@
package com.android.settings.bluetooth;
+import android.bluetooth.BluetoothCsipSetCoordinator;
import android.content.Context;
import androidx.preference.PreferenceFragmentCompat;
@@ -50,8 +51,17 @@
@Override
protected void refresh() {
- mFooterPreference.setTitle(mContext.getString(
+ if (mCachedDevice.getGroupId() != BluetoothCsipSetCoordinator.GROUP_ID_INVALID) {
+ StringBuilder title = new StringBuilder(mContext.getString(
+ R.string.bluetooth_multuple_devices_mac_address, mCachedDevice.getAddress()));
+ for (CachedBluetoothDevice member: mCachedDevice.getMemberDevice()) {
+ title.append("\n").append(member.getAddress());
+ }
+ mFooterPreference.setTitle(title);
+ } else {
+ mFooterPreference.setTitle(mContext.getString(
R.string.bluetooth_device_mac_address, mCachedDevice.getAddress()));
+ }
}
@Override
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingController.java b/src/com/android/settings/bluetooth/BluetoothPairingController.java
index ca3dda6..b75e02a 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingController.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingController.java
@@ -28,6 +28,7 @@
import com.android.settings.R;
import com.android.settings.bluetooth.BluetoothPairingDialogFragment.BluetoothPairingDialogListener;
+import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.bluetooth.LocalBluetoothProfile;
@@ -64,6 +65,7 @@
private String mDeviceName;
private LocalBluetoothProfile mPbapClientProfile;
private boolean mPbapAllowed;
+ private boolean mIsCoordinatedSetMember;
/**
* Creates an instance of a BluetoothPairingController.
@@ -90,6 +92,10 @@
mDeviceName = mBluetoothManager.getCachedDeviceManager().getName(mDevice);
mPbapClientProfile = mBluetoothManager.getProfileManager().getPbapClientProfile();
mPasskeyFormatted = formatKey(mPasskey);
+ final CachedBluetoothDevice cachedDevice =
+ mBluetoothManager.getCachedDeviceManager().findDevice(mDevice);
+ mIsCoordinatedSetMember = cachedDevice != null
+ ? cachedDevice.isCoordinatedSetMemberDevice() : false;
}
@Override
@@ -156,6 +162,15 @@
}
/**
+ * A method for querying if the bluetooth device is a LE coordinated set member device.
+ *
+ * @return - A boolean indicating if the device is a CSIP supported device.
+ */
+ public boolean isCoordinatedSetMemberDevice() {
+ return mIsCoordinatedSetMember;
+ }
+
+ /**
* A method for querying if the bluetooth device has a profile already set up on this device.
*
* @return - A boolean indicating if the device has previous knowledge of a profile for this
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java
index d38302d..9e36247 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java
@@ -344,6 +344,9 @@
pairingViewContent.setVisibility(View.VISIBLE);
pairingViewContent.setText(mPairingController.getPairingContent());
}
+ final TextView messagePairingSet = (TextView) view.findViewById(R.id.pairing_group_message);
+ messagePairingSet.setVisibility(mPairingController.isCoordinatedSetMemberDevice()
+ ? View.VISIBLE : View.GONE);
return view;
}
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingRequest.java b/src/com/android/settings/bluetooth/BluetoothPairingRequest.java
index 993f584..6b80256 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingRequest.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingRequest.java
@@ -16,12 +16,16 @@
package com.android.settings.bluetooth;
+import android.bluetooth.BluetoothCsipSetCoordinator;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
import android.os.UserHandle;
+import android.text.TextUtils;
+
+import com.android.settingslib.bluetooth.LocalBluetoothManager;
/**
* BluetoothPairingRequest is a receiver for any Bluetooth pairing request. It
@@ -34,36 +38,55 @@
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
- if (action == null || !action.equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) {
+ if (action == null) {
return;
}
- PowerManager powerManager = context.getSystemService(PowerManager.class);
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
- int pairingVariant = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
- BluetoothDevice.ERROR);
- String deviceAddress = device != null ? device.getAddress() : null;
- String deviceName = device != null ? device.getName() : null;
- boolean shouldShowDialog = LocalBluetoothPreferences.shouldShowDialogInForeground(
- context, deviceAddress, deviceName);
+ final LocalBluetoothManager mBluetoothManager = Utils.getLocalBtManager(context);
+ if (TextUtils.equals(action, BluetoothDevice.ACTION_PAIRING_REQUEST)) {
+ PowerManager powerManager = context.getSystemService(PowerManager.class);
+ int pairingVariant = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
+ BluetoothDevice.ERROR);
+ String deviceAddress = device != null ? device.getAddress() : null;
+ String deviceName = device != null ? device.getName() : null;
+ boolean shouldShowDialog = LocalBluetoothPreferences.shouldShowDialogInForeground(
+ context, deviceAddress, deviceName);
- // Skips consent pairing dialog if the device was recently associated with CDM
- if (pairingVariant == BluetoothDevice.PAIRING_VARIANT_CONSENT
- && device.canBondWithoutDialog()) {
- device.setPairingConfirmation(true);
- } else if (powerManager.isInteractive() && shouldShowDialog) {
- // Since the screen is on and the BT-related activity is in the foreground,
- // just open the dialog
- // convert broadcast intent into activity intent (same action string)
- Intent pairingIntent = BluetoothPairingService.getPairingDialogIntent(context, intent,
- BluetoothDevice.EXTRA_PAIRING_INITIATOR_FOREGROUND);
+ // Skips consent pairing dialog if the device was recently associated with CDM
+ if (pairingVariant == BluetoothDevice.PAIRING_VARIANT_CONSENT
+ && (device.canBondWithoutDialog()
+ || mBluetoothManager.getCachedDeviceManager().isOngoingPairByCsip(device))) {
+ device.setPairingConfirmation(true);
+ } else if (powerManager.isInteractive() && shouldShowDialog) {
+ // Since the screen is on and the BT-related activity is in the foreground,
+ // just open the dialog
+ // convert broadcast intent into activity intent (same action string)
+ Intent pairingIntent = BluetoothPairingService.getPairingDialogIntent(context,
+ intent, BluetoothDevice.EXTRA_PAIRING_INITIATOR_FOREGROUND);
- context.startActivityAsUser(pairingIntent, UserHandle.CURRENT);
- } else {
- // Put up a notification that leads to the dialog
- intent.setClass(context, BluetoothPairingService.class);
- intent.setAction(BluetoothDevice.ACTION_PAIRING_REQUEST);
- context.startServiceAsUser(intent, UserHandle.CURRENT);
+ context.startActivityAsUser(pairingIntent, UserHandle.CURRENT);
+ } else {
+ // Put up a notification that leads to the dialog
+ intent.setClass(context, BluetoothPairingService.class);
+ intent.setAction(BluetoothDevice.ACTION_PAIRING_REQUEST);
+ context.startServiceAsUser(intent, UserHandle.CURRENT);
+ }
+ } else if (TextUtils.equals(action,
+ BluetoothCsipSetCoordinator.ACTION_CSIS_SET_MEMBER_AVAILABLE)) {
+ if (device == null) {
+ return;
+ }
+
+ final int groupId = intent.getIntExtra(BluetoothCsipSetCoordinator.EXTRA_CSIS_GROUP_ID,
+ BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
+ if (groupId == BluetoothCsipSetCoordinator.GROUP_ID_INVALID) {
+ return;
+ }
+
+ if (mBluetoothManager.getCachedDeviceManager().shouldPairByCsip(device, groupId)) {
+ device.createBond(BluetoothDevice.TRANSPORT_LE);
+ }
}
}
}
diff --git a/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java
index fc1b9b7..d1c45b6 100644
--- a/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java
@@ -70,9 +70,10 @@
if (DBG) {
Log.d(TAG, "isFilterMatched() current audio profile : " + currentAudioProfile);
}
- // If device is Hearing Aid, it is compatible with HFP and A2DP.
+ // If device is Hearing Aid or LE Audio, it is compatible with HFP and A2DP.
// It would not show in Connected Devices group.
- if (cachedDevice.isConnectedHearingAidDevice()) {
+ if (cachedDevice.isConnectedHearingAidDevice()
+ || cachedDevice.isConnectedLeAudioDevice()) {
return false;
}
// According to the current audio profile type,
diff --git a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
index dab4f23..f5bc279 100644
--- a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
@@ -65,7 +65,7 @@
removePreferenceIfNecessary(bluetoothDevices, cachedManager);
for (BluetoothDevice device : bluetoothDevices) {
final CachedBluetoothDevice cachedDevice = cachedManager.findDevice(device);
- if (cachedDevice != null) {
+ if (cachedDevice != null && !cachedManager.isSubDevice(device)) {
update(cachedDevice);
}
}
diff --git a/src/com/android/settings/development/BluetoothA2dpConfigStore.java b/src/com/android/settings/development/BluetoothA2dpConfigStore.java
index 0b154d2..7fd7b13 100644
--- a/src/com/android/settings/development/BluetoothA2dpConfigStore.java
+++ b/src/com/android/settings/development/BluetoothA2dpConfigStore.java
@@ -71,10 +71,16 @@
}
public BluetoothCodecConfig createCodecConfig() {
- return new BluetoothCodecConfig(mCodecType, mCodecPriority,
- mSampleRate, mBitsPerSample,
- mChannelMode, mCodecSpecific1Value,
- mCodecSpecific2Value, mCodecSpecific3Value,
- mCodecSpecific4Value);
+ return new BluetoothCodecConfig.Builder()
+ .setCodecType(mCodecType)
+ .setCodecPriority(mCodecPriority)
+ .setSampleRate(mSampleRate)
+ .setBitsPerSample(mBitsPerSample)
+ .setChannelMode(mChannelMode)
+ .setCodecSpecific1(mCodecSpecific1Value)
+ .setCodecSpecific2(mCodecSpecific2Value)
+ .setCodecSpecific3(mCodecSpecific3Value)
+ .setCodecSpecific4(mCodecSpecific4Value)
+ .build();
}
}
diff --git a/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java b/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java
index 765c5f8..1af6e96 100644
--- a/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java
+++ b/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java
@@ -30,6 +30,8 @@
import com.android.settings.development.BluetoothA2dpConfigStore;
import com.android.settingslib.core.lifecycle.Lifecycle;
+import java.util.List;
+
/**
* Abstract class for Bluetooth A2DP config dialog controller in developer option.
*/
@@ -170,7 +172,7 @@
*
* @return Array of {@link BluetoothCodecConfig}.
*/
- protected BluetoothCodecConfig[] getSelectableConfigs(BluetoothDevice device) {
+ protected List<BluetoothCodecConfig> getSelectableConfigs(BluetoothDevice device) {
final BluetoothA2dp bluetoothA2dp = mBluetoothA2dp;
if (bluetoothA2dp == null) {
return null;
@@ -198,11 +200,7 @@
Log.d(TAG, "Unable to get selectable config. No active device.");
return null;
}
- final BluetoothCodecConfig[] configs = getSelectableConfigs(activeDevice);
- if (configs == null) {
- Log.d(TAG, "Unable to get selectable config. Selectable configs is empty.");
- return null;
- }
+ final List<BluetoothCodecConfig> configs = getSelectableConfigs(activeDevice);
for (BluetoothCodecConfig config : configs) {
if (config.getCodecType() == codecTypeValue) {
return config;
@@ -220,7 +218,7 @@
public void onHDAudioEnabled(boolean enabled) {}
static int getHighestCodec(BluetoothA2dp bluetoothA2dp, BluetoothDevice activeDevice,
- BluetoothCodecConfig[] configs) {
+ List<BluetoothCodecConfig> configs) {
if (configs == null) {
Log.d(TAG, "Unable to get highest codec. Configs are empty");
return BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID;
@@ -231,8 +229,8 @@
return BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC;
}
for (int i = 0; i < CODEC_TYPES.length; i++) {
- for (int j = 0; j < configs.length; j++) {
- if ((configs[j].getCodecType() == CODEC_TYPES[i])) {
+ for (BluetoothCodecConfig config : configs) {
+ if (config.getCodecType() == CODEC_TYPES[i]) {
return CODEC_TYPES[i];
}
}
diff --git a/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java b/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java
index b1b58e5..5f916f3 100644
--- a/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java
+++ b/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java
@@ -77,7 +77,7 @@
// Check HD audio is enabled, display the available list.
if (bluetoothA2dp.isOptionalCodecsEnabled(activeDevice)
== BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED) {
- BluetoothCodecConfig[] configs = getSelectableConfigs(activeDevice);
+ List<BluetoothCodecConfig> configs = getSelectableConfigs(activeDevice);
if (configs != null) {
return getIndexFromConfig(configs);
}
@@ -153,10 +153,10 @@
writeConfigurationValues(/* index= */ 0);
}
- private List<Integer> getIndexFromConfig(BluetoothCodecConfig[] configs) {
+ private List<Integer> getIndexFromConfig(List<BluetoothCodecConfig> configs) {
List<Integer> indexArray = new ArrayList<>();
- for (int i = 0; i < configs.length; i++) {
- indexArray.add(convertCfgToBtnIndex(configs[i].getCodecType()));
+ for (BluetoothCodecConfig config : configs) {
+ indexArray.add(convertCfgToBtnIndex(config.getCodecType()));
}
return indexArray;
}
diff --git a/src/com/android/settings/network/apn/ApnSettings.java b/src/com/android/settings/network/apn/ApnSettings.java
index 4df2e5e..dbd4ae0 100755
--- a/src/com/android/settings/network/apn/ApnSettings.java
+++ b/src/com/android/settings/network/apn/ApnSettings.java
@@ -322,6 +322,8 @@
final StringBuilder where =
new StringBuilder("NOT (type='ia' AND (apn=\"\" OR apn IS NULL)) AND "
+ "user_visible!=0");
+ // Remove Emergency type, users should not mess with that
+ where.append(" AND NOT (type='emergency')");
if (mHideImsApn) {
where.append(" AND NOT (type='ims')");
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
index 924e246..3cdff6e 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
@@ -235,6 +235,32 @@
}
@Test
+ public void onProfileConnectionStateChanged_leAudioDeviceConnected_notInCall_addsPreference() {
+ mAudioManager.setMode(AudioManager.MODE_NORMAL);
+ when(mBluetoothDeviceUpdater
+ .isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
+ when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
+
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO);
+
+ verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
+ }
+
+ @Test
+ public void onProfileConnectionStateChanged_leAudioDeviceConnected_inCall_addsPreference() {
+ mAudioManager.setMode(AudioManager.MODE_IN_CALL);
+ when(mBluetoothDeviceUpdater
+ .isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
+ when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
+
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO);
+
+ verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
+ }
+
+ @Test
public void onProfileConnectionStateChanged_deviceDisconnected_removePreference() {
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.A2DP);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java
index be733ec..a53e693 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java
@@ -427,6 +427,34 @@
userEntryDialogExistingTextTest("test");
}
+ @Test
+ public void groupPairing_setMemberDevice_showsMessageHint() {
+ // set the correct dialog type
+ when(controller.getDialogType()).thenReturn(BluetoothPairingController.CONFIRMATION_DIALOG);
+ when(controller.isCoordinatedSetMemberDevice()).thenReturn(true);
+
+ // build the fragment
+ BluetoothPairingDialogFragment frag = makeFragment();
+
+ // verify message is what we expect it to be and is visible
+ TextView message = frag.getmDialog().findViewById(R.id.pairing_group_message);
+ assertThat(message.getVisibility()).isEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ public void groupPairing_nonSetMemberDevice_hidesMessageHint() {
+ // set the correct dialog type
+ when(controller.getDialogType()).thenReturn(BluetoothPairingController.CONFIRMATION_DIALOG);
+ when(controller.isCoordinatedSetMemberDevice()).thenReturn(false);
+
+ // build the fragment
+ BluetoothPairingDialogFragment frag = makeFragment();
+
+ // verify message is what we expect it to be and is visible
+ TextView message = frag.getmDialog().findViewById(R.id.pairing_group_message);
+ assertThat(message.getVisibility()).isEqualTo(View.GONE);
+ }
+
// Runs a test simulating the user entry dialog type in a situation like device rotation, where
// the dialog fragment gets created and we already have some existing text entered into the
// pin field.
diff --git a/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
index ea91fed..98f1fe3 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
@@ -235,6 +235,33 @@
}
@Test
+ public void onProfileConnectionStateChanged_leAudioDeviceConnected_inCall_removesPreference() {
+ mAudioManager.setMode(AudioManager.MODE_IN_CALL);
+ when(mBluetoothDeviceUpdater
+ .isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
+ when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
+
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO);
+
+ verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
+ }
+
+ @Test
+ public void onProfileConnectionStateChanged_leAudioDeviceConnected_notInCall_removesPreference()
+ {
+ mAudioManager.setMode(AudioManager.MODE_NORMAL);
+ when(mBluetoothDeviceUpdater
+ .isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
+ when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
+
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO);
+
+ verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
+ }
+
+ @Test
public void onProfileConnectionStateChanged_deviceDisconnected_removePreference() {
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.A2DP);
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java
index a12131d..c1648bf 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java
@@ -47,6 +47,7 @@
import org.robolectric.RuntimeEnvironment;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
@@ -85,8 +86,12 @@
mBluetoothA2dpConfigStore));
mPreference = spy(new BaseBluetoothDialogPreferenceImpl(mContext));
- mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC);
- mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC);
+ mCodecConfigAAC = new BluetoothCodecConfig.Builder()
+ .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
+ .build();
+ mCodecConfigSBC = new BluetoothCodecConfig.Builder()
+ .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
+ .build();
mCodecConfigs[0] = mCodecConfigAAC;
mCodecConfigs[1] = mCodecConfigSBC;
@@ -160,17 +165,19 @@
@Test
public void getSelectableConfigs_verifyConfig() {
- mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
+ mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
+ Arrays.asList(mCodecConfigs));
when(mBluetoothA2dp.getCodecStatus(
mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
- assertThat(mController.getSelectableConfigs(null)).isEqualTo(mCodecConfigs);
+ assertThat(mController.getSelectableConfigs(null)).isEqualTo(Arrays.asList(mCodecConfigs));
}
@Test
public void getSelectableByCodecType_verifyConfig() {
- mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
+ mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
+ Arrays.asList(mCodecConfigs));
when(mBluetoothA2dp.getCodecStatus(
mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
@@ -181,7 +188,8 @@
@Test
public void getSelectableByCodecType_unavailable() {
- mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
+ mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
+ Arrays.asList(mCodecConfigs));
when(mBluetoothA2dp.getCodecStatus(
mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
@@ -192,7 +200,8 @@
@Test
public void onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore() {
- mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
+ mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
+ Arrays.asList(mCodecConfigs));
when(mBluetoothA2dp.getCodecStatus(
mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java
index 0996ae3..a042ebe 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java
@@ -44,6 +44,7 @@
import org.robolectric.RuntimeEnvironment;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
@@ -80,25 +81,23 @@
mPreference = new BluetoothBitPerSampleDialogPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
mController.displayPreference(mScreen);
- mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
- BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
- BluetoothCodecConfig.SAMPLE_RATE_NONE,
- BluetoothCodecConfig.BITS_PER_SAMPLE_16 | BluetoothCodecConfig.BITS_PER_SAMPLE_24,
- BluetoothCodecConfig.CHANNEL_MODE_NONE,
- 0, 0, 0, 0);
- mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
- BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
- BluetoothCodecConfig.SAMPLE_RATE_NONE,
- BluetoothCodecConfig.BITS_PER_SAMPLE_24,
- BluetoothCodecConfig.CHANNEL_MODE_NONE,
- 0, 0, 0, 0);
+ mCodecConfigAAC = new BluetoothCodecConfig.Builder()
+ .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
+ .setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_16
+ | BluetoothCodecConfig.BITS_PER_SAMPLE_24)
+ .build();
+ mCodecConfigSBC = new BluetoothCodecConfig.Builder()
+ .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
+ .setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_24)
+ .build();
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
}
@Test
public void writeConfigurationValues_selectDefault_setHighest() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
- mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
+ mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
+ Arrays.asList(mCodecConfigs));
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
@@ -127,7 +126,8 @@
@Test
public void getSelectableIndex_verifyList() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
- mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
+ mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
+ Arrays.asList(mCodecConfigs));
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
List<Integer> indexList = new ArrayList<>();
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothChannelModeDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothChannelModeDialogPreferenceControllerTest.java
index 81fb3fe..75d8fc4 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothChannelModeDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothChannelModeDialogPreferenceControllerTest.java
@@ -44,6 +44,7 @@
import org.robolectric.RuntimeEnvironment;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
@@ -80,25 +81,23 @@
mPreference = new BluetoothChannelModeDialogPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
mController.displayPreference(mScreen);
- mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
- BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
- BluetoothCodecConfig.SAMPLE_RATE_NONE,
- BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
- BluetoothCodecConfig.CHANNEL_MODE_STEREO,
- 0, 0, 0, 0);
- mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
- BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
- BluetoothCodecConfig.SAMPLE_RATE_NONE,
- BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
- BluetoothCodecConfig.CHANNEL_MODE_MONO | BluetoothCodecConfig.CHANNEL_MODE_STEREO,
- 0, 0, 0, 0);
+ mCodecConfigAAC = new BluetoothCodecConfig.Builder()
+ .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
+ .setChannelMode(BluetoothCodecConfig.CHANNEL_MODE_STEREO)
+ .build();
+ mCodecConfigSBC = new BluetoothCodecConfig.Builder()
+ .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
+ .setChannelMode(BluetoothCodecConfig.CHANNEL_MODE_MONO
+ | BluetoothCodecConfig.CHANNEL_MODE_STEREO)
+ .build();
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
}
@Test
public void writeConfigurationValues_selectDefault_setHighest() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
- mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
+ mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null,
+ Arrays.asList(mCodecConfigs));
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
@@ -124,7 +123,8 @@
@Test
public void getSelectableIndex_verifyList() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
- mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
+ mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null,
+ Arrays.asList(mCodecConfigs));
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
List<Integer> indexList = new ArrayList<>();
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java
index 0f01e00..3a34aa0 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java
@@ -45,6 +45,9 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import java.util.Arrays;
+import java.util.List;
+
@RunWith(RobolectricTestRunner.class)
public class BluetoothCodecDialogPreferenceControllerTest {
@@ -85,29 +88,41 @@
mPreference = new BluetoothCodecDialogPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
mController.displayPreference(mScreen);
- mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
- BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST,
- BluetoothCodecConfig.SAMPLE_RATE_96000 | BluetoothCodecConfig.SAMPLE_RATE_176400,
- BluetoothCodecConfig.BITS_PER_SAMPLE_32,
- BluetoothCodecConfig.CHANNEL_MODE_MONO | BluetoothCodecConfig.CHANNEL_MODE_STEREO,
- 0, 0, 0, 0);
- mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
- BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST,
- BluetoothCodecConfig.SAMPLE_RATE_48000 | BluetoothCodecConfig.SAMPLE_RATE_88200,
- BluetoothCodecConfig.BITS_PER_SAMPLE_16 | BluetoothCodecConfig.BITS_PER_SAMPLE_24,
- BluetoothCodecConfig.CHANNEL_MODE_STEREO,
- 0, 0, 0, 0);
- mCodecConfigAPTX = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX);
- mCodecConfigAPTXHD = new BluetoothCodecConfig(
- BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD);
- mCodecConfigLDAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC);
+ mCodecConfigSBC = new BluetoothCodecConfig.Builder()
+ .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
+ .setCodecPriority(BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST)
+ .setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_96000
+ | BluetoothCodecConfig.SAMPLE_RATE_176400)
+ .setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_32)
+ .setChannelMode(BluetoothCodecConfig.CHANNEL_MODE_MONO
+ | BluetoothCodecConfig.CHANNEL_MODE_STEREO)
+ .build();
+ mCodecConfigAAC = new BluetoothCodecConfig.Builder()
+ .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
+ .setCodecPriority(BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST)
+ .setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_48000
+ | BluetoothCodecConfig.SAMPLE_RATE_88200)
+ .setBitsPerSample(BluetoothCodecConfig.BITS_PER_SAMPLE_16
+ | BluetoothCodecConfig.BITS_PER_SAMPLE_24)
+ .setChannelMode(BluetoothCodecConfig.CHANNEL_MODE_STEREO)
+ .build();
+ mCodecConfigAPTX = new BluetoothCodecConfig.Builder()
+ .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX)
+ .build();
+ mCodecConfigAPTXHD = new BluetoothCodecConfig.Builder()
+ .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD)
+ .build();
+ mCodecConfigLDAC = new BluetoothCodecConfig.Builder()
+ .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC)
+ .build();
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
}
@Test
public void writeConfigurationValues_selectDefault_setHighest() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
- mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
+ mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null,
+ Arrays.asList(mCodecConfigs));
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED);
@@ -121,7 +136,8 @@
public void writeConfigurationValues_checkCodec() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
- mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
+ mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null,
+ Arrays.asList(mCodecConfigs));
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
@@ -148,7 +164,8 @@
public void writeConfigurationValues_resetHighestConfig() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
- mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
+ mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
+ Arrays.asList(mCodecConfigs));
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.writeConfigurationValues(2);
@@ -178,7 +195,7 @@
@Test
public void onHDAudioEnabled_optionalCodecEnabled_setsCodecTypeAsAAC() {
- BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
+ List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigAAC, mCodecConfigSBC);
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC,
/* codecsLocalCapabilities= */ null,
mCodecConfigs);
@@ -194,7 +211,7 @@
}
@Test
public void onHDAudioEnabled_optionalCodecDisabled_setsCodecTypeAsSBC() {
- BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
+ List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigAAC, mCodecConfigSBC);
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC,
/* codecsLocalCapabilities= */ null,
mCodecConfigs);
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceControllerTest.java
index ef209a2..e50b716 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceControllerTest.java
@@ -43,6 +43,8 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import java.util.Arrays;
+
@RunWith(RobolectricTestRunner.class)
public class BluetoothQualityDialogPreferenceControllerTest {
@@ -77,18 +79,16 @@
mPreference = new BluetoothQualityDialogPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
mController.displayPreference(mScreen);
- mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
- BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
- BluetoothCodecConfig.SAMPLE_RATE_48000 | BluetoothCodecConfig.SAMPLE_RATE_88200,
- BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
- BluetoothCodecConfig.CHANNEL_MODE_NONE,
- 0, 0, 0, 0);
- mCodecConfigLDAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
- BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
- BluetoothCodecConfig.SAMPLE_RATE_96000,
- BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
- BluetoothCodecConfig.CHANNEL_MODE_NONE,
- 1001, 0, 0, 0);
+ mCodecConfigAAC = new BluetoothCodecConfig.Builder()
+ .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
+ .setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_48000
+ | BluetoothCodecConfig.SAMPLE_RATE_88200)
+ .build();
+ mCodecConfigLDAC = new BluetoothCodecConfig.Builder()
+ .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC)
+ .setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_96000)
+ .setCodecSpecific1(1001)
+ .build();
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
}
@@ -116,7 +116,8 @@
@Test
public void updateState_codeTypeIsLDAC_enablePreference() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC};
- mCodecStatus = new BluetoothCodecStatus(mCodecConfigLDAC, null, mCodecConfigs);
+ mCodecStatus = new BluetoothCodecStatus(mCodecConfigLDAC, null,
+ Arrays.asList(mCodecConfigs));
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.updateState(mPreference);
@@ -127,7 +128,8 @@
@Test
public void updateState_codeTypeAAC_disablePreference() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC};
- mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
+ mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
+ Arrays.asList(mCodecConfigs));
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.updateState(mPreference);
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java
index c649fdf..fca154d 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java
@@ -44,6 +44,7 @@
import org.robolectric.RuntimeEnvironment;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
@@ -81,26 +82,26 @@
mPreference = new BluetoothSampleRateDialogPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
mController.displayPreference(mScreen);
- mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
- BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
- BluetoothCodecConfig.SAMPLE_RATE_48000 | BluetoothCodecConfig.SAMPLE_RATE_88200,
- BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
- BluetoothCodecConfig.CHANNEL_MODE_NONE,
- 0, 0, 0, 0);
- mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
- BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
- BluetoothCodecConfig.SAMPLE_RATE_96000,
- BluetoothCodecConfig.BITS_PER_SAMPLE_NONE,
- BluetoothCodecConfig.CHANNEL_MODE_NONE,
- 0, 0, 0, 0);
+ mCodecConfigAAC = new BluetoothCodecConfig.Builder()
+ .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC)
+ .setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_48000
+ | BluetoothCodecConfig.SAMPLE_RATE_88200)
+ .build();
+ mCodecConfigSBC = new BluetoothCodecConfig.Builder()
+ .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
+ .setSampleRate(BluetoothCodecConfig.SAMPLE_RATE_96000)
+ .build();
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
}
@Test
public void writeConfigurationValues_selectDefault_setHighest() {
- mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC);
+ BluetoothCodecConfig mCodecConfigSBC = new BluetoothCodecConfig.Builder()
+ .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
+ .build();
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
- mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
+ mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null,
+ Arrays.asList(mCodecConfigs));
when(mBluetoothA2dp.getCodecStatus(
mActiveDevice)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
@@ -132,7 +133,10 @@
@Test
public void getSelectableIndex_verifyList() {
- BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
+ List<BluetoothCodecConfig> mCodecConfigs = new ArrayList() {{
+ add(mCodecConfigAAC);
+ add(mCodecConfigSBC);
+ }};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
when(mBluetoothA2dp.getCodecStatus(
mActiveDevice)).thenReturn(mCodecStatus);