Loading packages/SettingsLib/aconfig/settingslib.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -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 } } packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java +14 −0 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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); } } packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java +11 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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(); } } Loading
packages/SettingsLib/aconfig/settingslib.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -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 } }
packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java +14 −0 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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); } }
packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java +11 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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(); } }