From f57f720c38d34cca6d93568af228359552517e64 Mon Sep 17 00:00:00 2001 From: Alice Kuo Date: Fri, 29 Jan 2021 15:37:39 +0800 Subject: [PATCH] Add the pairing string for CSIP supported device Show the pairing dialog with the hint message that pairing this device will pair all of the set member of a coordinated set. If the device supports CSIP, the message will be shown. Screenshot: https://screenshot.googleplex.com/8WcrdgBoLRgJjHs Bug: 178981521 Test: make RunSettingsRoboTests ROBOTEST_FILTER=BlueotohPairingDialog Change-Id: I5432b7264652dd4485e2669f6004caa4f7459238 Merged-In: I5432b7264652dd4485e2669f6004caa4f7459238 --- res/layout/bluetooth_pin_confirm.xml | 12 ++++++++ res/values/strings.xml | 3 ++ .../bluetooth/BluetoothPairingController.java | 15 ++++++++++ .../BluetoothPairingDialogFragment.java | 3 ++ .../bluetooth/BluetoothPairingDialogTest.java | 28 +++++++++++++++++++ 5 files changed, 61 insertions(+) diff --git a/res/layout/bluetooth_pin_confirm.xml b/res/layout/bluetooth_pin_confirm.xml index 48912755890..28ad1f62920 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" /> + + To pair with:<br><b>%1$s</b><br><br>Make sure it is showing this passkey:<br><b>%2$s</b> + + Confirm to pair with the coordinated set + From:<br><b>%1$s</b><br><br>Pair with this device? diff --git a/src/com/android/settings/bluetooth/BluetoothPairingController.java b/src/com/android/settings/bluetooth/BluetoothPairingController.java index ca3dda67384..ec5c8ddf912 100644 --- a/src/com/android/settings/bluetooth/BluetoothPairingController.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingController.java @@ -28,6 +28,7 @@ import androidx.annotation.VisibleForTesting; 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 @@ public class BluetoothPairingController implements OnCheckedChangeListener, private String mDeviceName; private LocalBluetoothProfile mPbapClientProfile; private boolean mPbapAllowed; + private boolean mIsCoordinatedSetMember; /** * Creates an instance of a BluetoothPairingController. @@ -90,6 +92,10 @@ public class BluetoothPairingController implements OnCheckedChangeListener, 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 @@ -155,6 +161,15 @@ public class BluetoothPairingController implements OnCheckedChangeListener, return mDeviceName; } + /** + * 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. * diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java index d38302d8830..9e3624732d0 100644 --- a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java @@ -344,6 +344,9 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i 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/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java index be733ec97d4..a53e693976e 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 @@ public class BluetoothPairingDialogTest { 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.