diff options
| author | 2025-01-06 02:18:32 -0800 | |
|---|---|---|
| committer | 2025-01-06 02:18:32 -0800 | |
| commit | 425e809e482036df49c9c3844da16339c75ee8a5 (patch) | |
| tree | 231951f1e5cd8b6d8445127c573b21e1a24847f8 | |
| parent | a5a6973f92e72bf1ccb5d0a13cd697dda8fb47df (diff) | |
| parent | 26c9f1fe39b9aa2474947fb842677fb3192f17e0 (diff) | |
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
3 files changed, 35 insertions, 0 deletions
diff --git a/packages/SettingsLib/aconfig/settingslib.aconfig b/packages/SettingsLib/aconfig/settingslib.aconfig index 2f91097b04a6..bbe08f254283 100644 --- a/packages/SettingsLib/aconfig/settingslib.aconfig +++ b/packages/SettingsLib/aconfig/settingslib.aconfig @@ -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 + } +} diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java index 3c36c4438bca..145b62cd12b5 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java @@ -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); + } } diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java index ab9f871444b4..d49447f05011 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java @@ -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(); + } } |