From 882f7c4aba536ecf8660964a8260be64f67752da Mon Sep 17 00:00:00 2001 From: Zoey Chen Date: Tue, 29 Mar 2022 17:44:43 +0800 Subject: [PATCH] [LeAudio] New QR code scanner UIs and modify local API Bug: 214340362 Test: manual Change-Id: I6f654d808dbcb92c99eaad9507b6328a80a0d5f4 Merged-In: I6f654d808dbcb92c99eaad9507b6328a80a0d5f4 --- .../res/drawable/ic_qr_code_scanner.xml | 23 +++++ .../res/layout/qrcode_scan_mode_activity.xml | 30 ++++++ .../res/layout/qrcode_scanner_fragment.xml | 97 +++++++++++++++++++ packages/SettingsLib/res/values/dimens.xml | 5 + packages/SettingsLib/res/values/strings.xml | 7 ++ packages/SettingsLib/res/values/styles.xml | 12 +++ .../bluetooth/BluetoothBroadcastUtils.java | 27 +++++- .../LocalBluetoothLeBroadcastAssistant.java | 37 ++++++- .../LocalBluetoothLeBroadcastMetadata.java | 3 + 9 files changed, 238 insertions(+), 3 deletions(-) create mode 100644 packages/SettingsLib/res/drawable/ic_qr_code_scanner.xml create mode 100644 packages/SettingsLib/res/layout/qrcode_scan_mode_activity.xml create mode 100644 packages/SettingsLib/res/layout/qrcode_scanner_fragment.xml diff --git a/packages/SettingsLib/res/drawable/ic_qr_code_scanner.xml b/packages/SettingsLib/res/drawable/ic_qr_code_scanner.xml new file mode 100644 index 0000000000000..f6f63c5ae7fa9 --- /dev/null +++ b/packages/SettingsLib/res/drawable/ic_qr_code_scanner.xml @@ -0,0 +1,23 @@ + + + + + + \ No newline at end of file diff --git a/packages/SettingsLib/res/layout/qrcode_scan_mode_activity.xml b/packages/SettingsLib/res/layout/qrcode_scan_mode_activity.xml new file mode 100644 index 0000000000000..f0a182b3d67b2 --- /dev/null +++ b/packages/SettingsLib/res/layout/qrcode_scan_mode_activity.xml @@ -0,0 +1,30 @@ + + + + + + + + diff --git a/packages/SettingsLib/res/layout/qrcode_scanner_fragment.xml b/packages/SettingsLib/res/layout/qrcode_scanner_fragment.xml new file mode 100644 index 0000000000000..bf225989112a2 --- /dev/null +++ b/packages/SettingsLib/res/layout/qrcode_scanner_fragment.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/SettingsLib/res/values/dimens.xml b/packages/SettingsLib/res/values/dimens.xml index c439cf040cf28..328527bf9690e 100644 --- a/packages/SettingsLib/res/values/dimens.xml +++ b/packages/SettingsLib/res/values/dimens.xml @@ -98,4 +98,9 @@ 300dp + + 360dp + 40dp + 30dp + 27dp diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml index 6ca15c1f3fc3f..7299e4e762cf0 100644 --- a/packages/SettingsLib/res/values/strings.xml +++ b/packages/SettingsLib/res/values/strings.xml @@ -1531,4 +1531,11 @@ No calling. + + + Scan QR code + + To start listening, center the QR code below + + QR code isn\u0027t a valid format diff --git a/packages/SettingsLib/res/values/styles.xml b/packages/SettingsLib/res/values/styles.xml index 015f52cde7896..28cd27bf0cadc 100644 --- a/packages/SettingsLib/res/values/styles.xml +++ b/packages/SettingsLib/res/values/styles.xml @@ -27,4 +27,16 @@ @*android:drawable/btn_borderless_rect center + + + + diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothBroadcastUtils.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothBroadcastUtils.java index 3ce7a0e4efa5f..1f7260972f24d 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothBroadcastUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothBroadcastUtils.java @@ -18,7 +18,32 @@ package com.android.settingslib.bluetooth; public final class BluetoothBroadcastUtils { - static final String SCHEME_BT_BROADCAST_METADATA = "BT:"; + /** + * The fragment tag specified to FragmentManager for container activities to manage fragments. + */ + public static final String TAG_FRAGMENT_QR_CODE_SCANNER = "qr_code_scanner_fragment"; + + /** + * Action for launching qr code scanner activity. + */ + public static final String ACTION_BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER = + "android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER"; + + /** + * Extra for {@link android.bluetooth.BluetoothDevice}. + */ + public static final String EXTRA_BLUETOOTH_DEVICE_SINK = "bluetooth_device_sink"; + + /** + * Extra for checking the {@link android.bluetooth.BluetoothLeBroadcastAssistant} should perform + * this operation for all coordinated set members throughout one session or not. + */ + public static final String EXTRA_BLUETOOTH_SINK_IS_GROUP = "bluetooth_sink_is_group"; + + /** + * Bluetooth scheme. + */ + public static final String SCHEME_BT_BROADCAST_METADATA = "BT:"; // BluetoothLeBroadcastMetadata static final String PREFIX_BT_ADDRESS_TYPE = "T:"; diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastAssistant.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastAssistant.java index d904265efda9f..60632b677d1bb 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastAssistant.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastAssistant.java @@ -19,7 +19,6 @@ package com.android.settingslib.bluetooth; import android.annotation.NonNull; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; -import android.bluetooth.BluetoothLeBroadcast; import android.bluetooth.BluetoothLeBroadcastAssistant; import android.bluetooth.BluetoothLeBroadcastMetadata; import android.bluetooth.BluetoothLeBroadcastReceiveState; @@ -71,7 +70,7 @@ public class LocalBluetoothLeBroadcastAssistant implements } }; - LocalBluetoothLeBroadcastAssistant(Context context, + public LocalBluetoothLeBroadcastAssistant(Context context, LocalBluetoothProfileManager profileManager) { mProfileManager = profileManager; BluetoothAdapter.getDefaultAdapter(). @@ -80,6 +79,40 @@ public class LocalBluetoothLeBroadcastAssistant implements mBuilder = new BluetoothLeBroadcastMetadata.Builder(); } + /** + * Add a Broadcast Source to the Broadcast Sink with {@link BluetoothLeBroadcastMetadata}. + * + * @param sink Broadcast Sink to which the Broadcast Source should be added + * @param metadata Broadcast Source metadata to be added to the Broadcast Sink + * @param isGroupOp {@code true} if Application wants to perform this operation for all + * coordinated set members throughout this session. Otherwise, caller + * would have to add, modify, and remove individual set members. + */ + public void addSource(BluetoothDevice sink, BluetoothLeBroadcastMetadata metadata, + boolean isGroupOp) { + mBluetoothLeBroadcastAssistant.addSource(sink, metadata, isGroupOp); + } + + /** + * Add a Broadcast Source to the Broadcast Sink with the information which are separated from + * the qr code string. + * + * @param sink Broadcast Sink to which the Broadcast Source should be added + * @param sourceAddressType hardware MAC Address of the device. See + * {@link BluetoothDevice.AddressType}. + * @param presentationDelayMicros presentation delay of this Broadcast Source in microseconds. + * @param sourceAdvertisingSid 1-byte long Advertising_SID of the Broadcast Source. + * @param broadcastId 3-byte long Broadcast_ID of the Broadcast Source. + * @param paSyncInterval Periodic Advertising Sync interval of the broadcast Source, + * {@link BluetoothLeBroadcastMetadata#PA_SYNC_INTERVAL_UNKNOWN} if + * unknown. + * @param isEncrypted whether the Broadcast Source is encrypted. + * @param broadcastCode Broadcast Code for this Broadcast Source, null if code is not required. + * @param sourceDevice source advertiser address. + * @param isGroupOp {@code true} if Application wants to perform this operation for all + * coordinated set members throughout this session. Otherwise, caller + * would have to add, modify, and remove individual set members. + */ public void addSource(@NonNull BluetoothDevice sink, int sourceAddressType, int presentationDelayMicros, int sourceAdvertisingSid, int broadcastId, int paSyncInterval, boolean isEncrypted, byte[] broadcastCode, diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastMetadata.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastMetadata.java index cf4ba8b46c7a5..5b1fefb249a36 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastMetadata.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastMetadata.java @@ -83,6 +83,9 @@ public class LocalBluetoothLeBroadcastMetadata { mSubgroupList = metadata.getSubgroups(); } + public LocalBluetoothLeBroadcastMetadata() { + } + public void setBroadcastCode(byte[] code) { mBroadcastCode = code; }