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

Commit 425e809e authored by Ze Li's avatar Ze Li Committed by Android (Google) Code Review
Browse files

Merge changes from topic "tempBonding" into main

* changes:
  [Temp bonding] Add flag to change temp bond UI
  [Temp bonding] Function to verify if the device is temporary bonding
parents a5a6973f 26c9f1fe
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -209,3 +209,13 @@ flag {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "enable_temporary_bond_devices_ui"
    namespace: "cross_device_experiences"
    description: "UI changes for temporary bond devices in audio sharing."
    bug: "362859132"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+14 −0
Original line number Diff line number Diff line
@@ -74,6 +74,9 @@ public class BluetoothUtils {
            ImmutableSet.of(
                    BluetoothProfile.A2DP, BluetoothProfile.LE_AUDIO, BluetoothProfile.HEARING_AID);

    private static final String TEMP_BOND_TYPE = "TEMP_BOND_TYPE";
    private static final String TEMP_BOND_DEVICE_METADATA_VALUE = "le_audio_sharing";

    private static ErrorListener sErrorListener;

    public static int getConnectionStateSummary(int connectionState) {
@@ -1138,4 +1141,15 @@ public class BluetoothUtils {
        }
        return saDevice;
    }

    /**
     * Verifies if the device is temporary bond in audio sharing.
     *
     * @param bluetoothDevice the BluetoothDevice to verify
     * @return if the device is temporary bond
     */
    public static boolean isTemporaryBondDevice(@Nullable BluetoothDevice bluetoothDevice) {
        String metadataValue = getFastPairCustomizedField(bluetoothDevice, TEMP_BOND_TYPE);
        return Objects.equals(metadataValue, TEMP_BOND_DEVICE_METADATA_VALUE);
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ public class BluetoothUtilsTest {
    private Context mContext;
    private ShadowBluetoothAdapter mShadowBluetoothAdapter;
    private static final String STRING_METADATA = "string_metadata";
    private static final String LE_AUDIO_SHARING_METADATA = "le_audio_sharing";
    private static final String BOOL_METADATA = "true";
    private static final String INT_METADATA = "25";
    private static final int METADATA_FAST_PAIR_CUSTOMIZED_FIELDS = 25;
@@ -104,6 +105,8 @@ public class BluetoothUtilsTest {
            "<HEARABLE_CONTROL_SLICE_WITH_WIDTH>"
                    + STRING_METADATA
                    + "</HEARABLE_CONTROL_SLICE_WITH_WIDTH>";
    private static final String TEMP_BOND_METADATA =
            "<TEMP_BOND_TYPE>" + LE_AUDIO_SHARING_METADATA + "</TEMP_BOND_TYPE>";
    private static final String TEST_EXCLUSIVE_MANAGER_PACKAGE = "com.test.manager";
    private static final String TEST_EXCLUSIVE_MANAGER_COMPONENT = "com.test.manager/.component";
    private static final int TEST_BROADCAST_ID = 25;
@@ -1303,4 +1306,12 @@ public class BluetoothUtilsTest {

        assertThat(BluetoothUtils.isAudioSharingHysteresisModeFixAvailable(mContext)).isTrue();
    }

    @Test
    public void isTemporaryBondDevice_hasMetadata_returnsTrue() {
        when(mBluetoothDevice.getMetadata(METADATA_FAST_PAIR_CUSTOMIZED_FIELDS))
                .thenReturn(TEMP_BOND_METADATA.getBytes());

        assertThat(BluetoothUtils.isTemporaryBondDevice(mBluetoothDevice)).isTrue();
    }
}