Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2135db2e authored by Alice Kuo's avatar Alice Kuo Committed by Automerger Merge Worker
Browse files

Add the pairing string for CSIP supported device am: f57f720c am: 5d1aee76

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/1903830

Change-Id: I51ff75f8a8005985a9696616edd1c8c5cdd651fe
parents d36b37ab 5d1aee76
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -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"
+3 −0
Original line number Diff line number Diff line
@@ -1843,6 +1843,9 @@
    <!-- Message for confirmation of passkey to complete pairing. [CHAR LIMIT=NONE] -->
    <string name="bluetooth_confirm_passkey_msg">To pair with:&lt;br>&lt;b><xliff:g id="device_name">%1$s</xliff:g>&lt;/b>&lt;br>&lt;br>Make sure it is showing this passkey:&lt;br>&lt;b><xliff:g id="passkey">%2$s</xliff:g>&lt;/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:&lt;br>&lt;b><xliff:g id="device_name">%1$s</xliff:g>&lt;/b>&lt;br>&lt;br>Pair with this device?</string>
+15 −0
Original line number Diff line number Diff line
@@ -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.
     *
+3 −0
Original line number Diff line number Diff line
@@ -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;
    }

+28 −0
Original line number Diff line number Diff line
@@ -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.