[Audiosharing] Some UI tweaks (e.g, sort by RSSI)

Bug: 308368124
Test: manual
Change-Id: Ie066077f6ef47a57b9fb1c85bc7200498dcae093
This commit is contained in:
chelseahao
2024-01-23 19:38:59 +08:00
parent 8a3ebe25e0
commit 8b5da73e4d
10 changed files with 175 additions and 70 deletions

View File

@@ -17,7 +17,6 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
@@ -26,36 +25,22 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="3" android:layout_weight="3"
android:layout_marginBottom="35dp"> android:layout_marginBottom="55dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="40dp"
android:paddingEnd="40dp"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:gravity="center" android:gravity="center"
android:orientation="vertical"> android:orientation="vertical">
<ImageView
android:src="@drawable/ic_qr_code_scanner"
android:tint="?androidprv:attr/materialColorPrimaryContainer"
android:layout_width="@dimen/qrcode_icon_size"
android:layout_height="@dimen/qrcode_icon_size"
android:contentDescription="@null"/>
<TextView <TextView
style="@style/QrCodeScanner" style="@style/QrCodeScanner"
android:textSize="24sp" android:text="Scan an audio stream QR code to listen with the active LE device"
android:text="@string/bluetooth_find_broadcast_button_scan"
android:gravity="center" android:gravity="center"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="19dp"/> android:layout_marginTop="20dp"/>
<TextView
style="@style/QrCodeScanner"
android:text="@string/bt_le_audio_scan_qr_code_scanner"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View File

@@ -18,23 +18,31 @@
<PreferenceScreen <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto" xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/audio_streams_title"> android:title="Find an audio stream">
<Preference <com.android.settingslib.widget.TopIntroPreference
android:key="audio_streams_scan_qr_code" android:key="audio_streams_top_intro"
android:title="@string/bluetooth_find_broadcast_button_scan" android:title="Listen to a device that's sharing audio or to a nearby Auracast broadcast"
android:icon="@drawable/ic_add_24dp" settings:searchable="false"/>
android:summary="@string/audio_streams_qr_code_summary"
settings:controller="com.android.settings.connecteddevice.audiosharing.audiostreams.AudioStreamsScanQrCodeController" />
<Preference <Preference
android:key="audio_streams_active_device" android:key="audio_streams_active_device"
android:title="Listen with" android:title="Your audio device"
settings:controller="com.android.settings.connecteddevice.audiosharing.audiostreams.AudioStreamsActiveDeviceController" /> settings:controller="com.android.settings.connecteddevice.audiosharing.audiostreams.AudioStreamsActiveDeviceController" />
<com.android.settings.connecteddevice.audiosharing.audiostreams.AudioStreamsProgressCategoryPreference <com.android.settings.connecteddevice.audiosharing.audiostreams.AudioStreamsProgressCategoryPreference
android:key="audio_streams_nearby_category" android:key="audio_streams_nearby_category"
android:title="@string/audio_streams_pref_title" android:title="Audio streams nearby"
settings:controller="com.android.settings.connecteddevice.audiosharing.audiostreams.AudioStreamsProgressCategoryController" /> settings:controller="com.android.settings.connecteddevice.audiosharing.audiostreams.AudioStreamsProgressCategoryController">
<Preference
android:key="audio_streams_scan_qr_code"
android:title="Scan a QR code"
android:icon="@drawable/ic_add_24dp"
android:summary="Start listening by scanning a stream's QR code"
android:order="0"
settings:controller="com.android.settings.connecteddevice.audiosharing.audiostreams.AudioStreamsScanQrCodeController" />
</com.android.settings.connecteddevice.audiosharing.audiostreams.AudioStreamsProgressCategoryPreference>
</PreferenceScreen> </PreferenceScreen>

View File

@@ -16,6 +16,7 @@
--> -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@@ -23,70 +24,78 @@
android:id="@+id/dialog_bg" android:id="@+id/dialog_bg"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingStart="25dp"
android:paddingEnd="25dp"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/broadcast_dialog_margin" android:layout_marginBottom="25dp"
android:orientation="vertical"> android:orientation="vertical">
<ImageView <ImageView
android:id="@+id/dialog_icon" android:id="@+id/dialog_icon"
android:layout_width="36dp" android:layout_width="30dp"
android:layout_height="36dp" android:layout_height="30dp"
android:layout_marginTop="@dimen/broadcast_dialog_icon_margin_top" android:layout_marginTop="24dp"
android:layout_marginBottom="@dimen/broadcast_dialog_title_img_margin_top"
android:layout_gravity="center" android:layout_gravity="center"
android:src="@drawable/ic_bt_audio_sharing"/> android:src="@drawable/ic_bt_audio_sharing"/>
<TextView <TextView
style="@style/BroadcastDialogTitleStyle"
android:id="@+id/dialog_title" android:id="@+id/dialog_title"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Headline"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:gravity="center" android:gravity="center"
android:layout_gravity="center"/> android:layout_gravity="center"/>
<TextView <TextView
style="@style/BroadcastDialogBodyStyle"
android:id="@+id/dialog_subtitle" android:id="@+id/dialog_subtitle"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small"
android:textStyle="bold"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:gravity="center" android:gravity="center"
android:layout_gravity="center" android:layout_gravity="center"
android:visibility="gone"/> android:visibility="gone"/>
<TextView <TextView
style="@style/BroadcastDialogBodyStyle"
android:id="@+id/dialog_subtitle_2" android:id="@+id/dialog_subtitle_2"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:gravity="center" android:gravity="center"
android:layout_gravity="center" android:layout_gravity="center"
android:visibility="gone"/> android:visibility="gone"/>
</LinearLayout> </LinearLayout>
<LinearLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/broadcast_dialog_margin" android:layout_marginBottom="@dimen/broadcast_dialog_margin">
android:orientation="horizontal">
<Button <Button
android:id="@+id/left_button" android:id="@+id/left_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="16dp" android:visibility="gone"
android:layout_weight="1" app:layout_constraintBottom_toBottomOf="parent"
android:visibility="invisible"/> app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
style="@style/BroadcastActionButton"/>
<Button <Button
android:id="@+id/right_button" android:id="@+id/right_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:visibility="gone"
android:layout_marginRight="16dp" app:layout_constraintBottom_toBottomOf="parent"
android:visibility="invisible"/> app:layout_constraintEnd_toEndOf="parent"
</LinearLayout> app:layout_constraintTop_toTopOf="parent"
style="@style/BroadcastActionButton"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>

View File

@@ -36,7 +36,7 @@
android:gravity="start" android:gravity="start"
android:textSize="15sp" android:textSize="15sp"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:text="Scan this QR code with another device connected to LE audio headphones to start sharing audio"/> android:text="To listen to this audio stream, other people can connect compatible headphones to their Android device. They can then scan this QR code."/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -50,6 +50,13 @@
android:layout_width="@dimen/qrcode_size" android:layout_width="@dimen/qrcode_size"
android:layout_height="@dimen/qrcode_size" android:layout_height="@dimen/qrcode_size"
android:src="@android:color/transparent"/> android:src="@android:color/transparent"/>
<TextView
android:id="@+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textColor="?android:attr/textColorPrimary"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View File

@@ -104,7 +104,7 @@ public class AudioStreamConfirmDialog extends InstrumentedDialogFragment {
private Dialog getErrorDialog() { private Dialog getErrorDialog() {
return new AudioStreamsDialogFragment.DialogBuilder(mActivity) return new AudioStreamsDialogFragment.DialogBuilder(mActivity)
.setTitle("Can't listen to audio stream") .setTitle("Can't listen to audio stream")
.setSubTitle1("Can't play this audio stream. Learn more") .setSubTitle2("Can't play this audio stream. Learn more")
.setRightButtonText("Close") .setRightButtonText("Close")
.setRightButtonOnClickListener( .setRightButtonOnClickListener(
unused -> { unused -> {

View File

@@ -21,8 +21,10 @@ import android.bluetooth.BluetoothLeBroadcastMetadata;
import android.bluetooth.BluetoothLeBroadcastReceiveState; import android.bluetooth.BluetoothLeBroadcastReceiveState;
import android.content.Context; import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.preference.PreferenceViewHolder;
import com.android.settings.R; import com.android.settings.R;
import com.android.settingslib.widget.TwoTargetPreference; import com.android.settingslib.widget.TwoTargetPreference;
@@ -56,7 +58,6 @@ class AudioStreamPreference extends TwoTargetPreference {
} }
mIsConnected = isConnected; mIsConnected = isConnected;
setSummary(summary); setSummary(summary);
setOrder(isConnected ? 0 : 1);
setOnPreferenceClickListener(onPreferenceClickListener); setOnPreferenceClickListener(onPreferenceClickListener);
notifyChanged(); notifyChanged();
} }
@@ -70,6 +71,10 @@ class AudioStreamPreference extends TwoTargetPreference {
mAudioStream.setState(state); mAudioStream.setState(state);
} }
int getAudioStreamRssi() {
return mAudioStream.getRssi();
}
AudioStreamsProgressCategoryController.AudioStreamState getAudioStreamState() { AudioStreamsProgressCategoryController.AudioStreamState getAudioStreamState() {
return mAudioStream.getState(); return mAudioStream.getState();
} }
@@ -84,13 +89,26 @@ class AudioStreamPreference extends TwoTargetPreference {
return R.layout.preference_widget_lock; return R.layout.preference_widget_lock;
} }
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
View divider =
holder.findViewById(
com.android.settingslib.widget.preference.twotarget.R.id
.two_target_divider);
if (divider != null) {
divider.setVisibility(View.GONE);
}
}
static AudioStreamPreference fromMetadata( static AudioStreamPreference fromMetadata(
Context context, Context context,
BluetoothLeBroadcastMetadata source, BluetoothLeBroadcastMetadata source,
AudioStreamsProgressCategoryController.AudioStreamState streamState) { AudioStreamsProgressCategoryController.AudioStreamState streamState) {
AudioStreamPreference preference = new AudioStreamPreference(context, /* attrs= */ null); AudioStreamPreference preference = new AudioStreamPreference(context, /* attrs= */ null);
preference.setTitle(getBroadcastName(source)); preference.setTitle(getBroadcastName(source));
preference.setAudioStream(new AudioStream(source.getBroadcastId(), streamState)); preference.setAudioStream(
new AudioStream(source.getBroadcastId(), streamState, source.getRssi()));
return preference; return preference;
} }
@@ -129,12 +147,16 @@ class AudioStreamPreference extends TwoTargetPreference {
private static final class AudioStream { private static final class AudioStream {
private int mSourceId; private int mSourceId;
private int mBroadcastId; private int mBroadcastId;
private int mRssi = Integer.MIN_VALUE;
private AudioStreamsProgressCategoryController.AudioStreamState mState; private AudioStreamsProgressCategoryController.AudioStreamState mState;
private AudioStream( private AudioStream(
int broadcastId, AudioStreamsProgressCategoryController.AudioStreamState state) { int broadcastId,
AudioStreamsProgressCategoryController.AudioStreamState state,
int rssi) {
mBroadcastId = broadcastId; mBroadcastId = broadcastId;
mState = state; mState = state;
mRssi = rssi;
} }
private AudioStream( private AudioStream(
@@ -156,6 +178,10 @@ class AudioStreamPreference extends TwoTargetPreference {
return mBroadcastId; return mBroadcastId;
} }
private int getRssi() {
return mRssi;
}
private AudioStreamsProgressCategoryController.AudioStreamState getState() { private AudioStreamsProgressCategoryController.AudioStreamState getState() {
return mState; return mState;
} }

View File

@@ -53,6 +53,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.utils.ThreadUtils; import com.android.settingslib.utils.ThreadUtils;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Comparator;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@@ -88,6 +89,15 @@ public class AudioStreamsProgressCategoryController extends BasePreferenceContro
SOURCE_ADDED, SOURCE_ADDED,
} }
private final Comparator<AudioStreamPreference> mComparator =
Comparator.<AudioStreamPreference, Boolean>comparing(
p ->
p.getAudioStreamState()
== AudioStreamsProgressCategoryController
.AudioStreamState.SOURCE_ADDED)
.thenComparingInt(AudioStreamPreference::getAudioStreamRssi)
.reversed();
private final Executor mExecutor; private final Executor mExecutor;
private final AudioStreamsProgressCategoryCallback mBroadcastAssistantCallback; private final AudioStreamsProgressCategoryCallback mBroadcastAssistantCallback;
private final AudioStreamsHelper mAudioStreamsHelper; private final AudioStreamsHelper mAudioStreamsHelper;
@@ -338,7 +348,7 @@ public class AudioStreamsProgressCategoryController extends BasePreferenceContro
ThreadUtils.postOnMainThread( ThreadUtils.postOnMainThread(
() -> { () -> {
if (mCategoryPreference != null) { if (mCategoryPreference != null) {
mCategoryPreference.removeAll(); mCategoryPreference.removeAudioStreamPreferences();
mCategoryPreference.setVisible(hasActive); mCategoryPreference.setVisible(hasActive);
} }
}); });
@@ -423,7 +433,7 @@ public class AudioStreamsProgressCategoryController extends BasePreferenceContro
getPreferenceSummary(state), getPreferenceSummary(state),
onClickListener); onClickListener);
if (mCategoryPreference != null) { if (mCategoryPreference != null) {
mCategoryPreference.addPreference(preference); mCategoryPreference.addAudioStreamPreference(preference, mComparator);
} }
}); });
} }
@@ -492,7 +502,7 @@ public class AudioStreamsProgressCategoryController extends BasePreferenceContro
private AudioStreamsDialogFragment.DialogBuilder getNoLeDeviceDialog() { private AudioStreamsDialogFragment.DialogBuilder getNoLeDeviceDialog() {
return new AudioStreamsDialogFragment.DialogBuilder(mContext) return new AudioStreamsDialogFragment.DialogBuilder(mContext)
.setTitle("Connect compatible headphones") .setTitle("Connect compatible headphones")
.setSubTitle1( .setSubTitle2(
"To listen to an audio stream, first connect headphones that support LE" "To listen to an audio stream, first connect headphones that support LE"
+ " Audio to this device. Learn more") + " Audio to this device. Learn more")
.setLeftButtonText("Close") .setLeftButtonText("Close")

View File

@@ -19,9 +19,15 @@ package com.android.settings.connecteddevice.audiosharing.audiostreams;
import android.content.Context; import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import androidx.annotation.NonNull;
import com.android.settings.ProgressCategory; import com.android.settings.ProgressCategory;
import com.android.settings.R; import com.android.settings.R;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
public class AudioStreamsProgressCategoryPreference extends ProgressCategory { public class AudioStreamsProgressCategoryPreference extends ProgressCategory {
public AudioStreamsProgressCategoryPreference(Context context) { public AudioStreamsProgressCategoryPreference(Context context) {
@@ -46,6 +52,37 @@ public class AudioStreamsProgressCategoryPreference extends ProgressCategory {
init(); init();
} }
void addAudioStreamPreference(
@NonNull AudioStreamPreference preference,
Comparator<AudioStreamPreference> comparator) {
super.addPreference(preference);
List<AudioStreamPreference> preferences = getAllAudioStreamPreferences();
preferences.sort(comparator);
for (int i = 0; i < preferences.size(); i++) {
// setOrder to i + 1, since the order 0 preference should always be the
// "audio_streams_scan_qr_code"
preferences.get(i).setOrder(i + 1);
}
}
void removeAudioStreamPreferences() {
List<AudioStreamPreference> streams = getAllAudioStreamPreferences();
for (var toRemove : streams) {
removePreference(toRemove);
}
}
private List<AudioStreamPreference> getAllAudioStreamPreferences() {
List<AudioStreamPreference> streams = new ArrayList<>();
for (int i = 0; i < getPreferenceCount(); i++) {
if (getPreference(i) instanceof AudioStreamPreference) {
streams.add((AudioStreamPreference) getPreference(i));
}
}
return streams;
}
private void init() { private void init() {
setEmptyTextRes(R.string.audio_streams_empty); setEmptyTextRes(R.string.audio_streams_empty);
} }

View File

@@ -24,6 +24,9 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.bluetooth.Utils; import com.android.settings.bluetooth.Utils;
@@ -34,6 +37,7 @@ import com.android.settingslib.qrcode.QrCodeGenerator;
import com.google.zxing.WriterException; import com.google.zxing.WriterException;
import java.nio.charset.StandardCharsets;
import java.util.Optional; import java.util.Optional;
public class AudioStreamsQrCodeFragment extends InstrumentedFragment { public class AudioStreamsQrCodeFragment extends InstrumentedFragment {
@@ -49,30 +53,47 @@ public class AudioStreamsQrCodeFragment extends InstrumentedFragment {
public final View onCreateView( public final View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.xml.bluetooth_audio_streams_qr_code, container, false); View view = inflater.inflate(R.xml.bluetooth_audio_streams_qr_code, container, false);
getQrCodeBitmap()
.ifPresent( BluetoothLeBroadcastMetadata broadcastMetadata = getBroadcastMetadata();
bm ->
if (broadcastMetadata != null) {
getQrCodeBitmap(broadcastMetadata)
.ifPresent(
bm -> {
((ImageView) view.requireViewById(R.id.qrcode_view)) ((ImageView) view.requireViewById(R.id.qrcode_view))
.setImageBitmap(bm)); .setImageBitmap(bm);
((TextView) view.requireViewById(R.id.password))
.setText(
"Password: "
+ new String(
broadcastMetadata
.getBroadcastCode(),
StandardCharsets.UTF_8));
});
}
return view; return view;
} }
private Optional<Bitmap> getQrCodeBitmap() { private Optional<Bitmap> getQrCodeBitmap(@Nullable BluetoothLeBroadcastMetadata metadata) {
String broadcastMetadata = getBroadcastMetadataQrCode(); if (metadata == null) {
if (broadcastMetadata.isEmpty()) {
Log.d(TAG, "onCreateView: broadcastMetadata is empty!"); Log.d(TAG, "onCreateView: broadcastMetadata is empty!");
return Optional.empty(); return Optional.empty();
} }
String metadataStr = BluetoothLeBroadcastMetadataExt.INSTANCE.toQrCodeString(metadata);
if (metadataStr.isEmpty()) {
Log.d(TAG, "onCreateView: metadataStr is empty!");
return Optional.empty();
}
Log.d("chelsea", metadataStr);
try { try {
int qrcodeSize = getContext().getResources().getDimensionPixelSize(R.dimen.qrcode_size); int qrcodeSize = getContext().getResources().getDimensionPixelSize(R.dimen.qrcode_size);
Bitmap bitmap = QrCodeGenerator.encodeQrCode(broadcastMetadata, qrcodeSize); Bitmap bitmap = QrCodeGenerator.encodeQrCode(metadataStr, qrcodeSize);
return Optional.of(bitmap); return Optional.of(bitmap);
} catch (WriterException e) { } catch (WriterException e) {
Log.d( Log.d(
TAG, TAG,
"onCreateView: broadcastMetadata " "onCreateView: broadcastMetadata "
+ broadcastMetadata + metadata
+ " qrCode generation exception " + " qrCode generation exception "
+ e); + e);
} }
@@ -80,23 +101,24 @@ public class AudioStreamsQrCodeFragment extends InstrumentedFragment {
return Optional.empty(); return Optional.empty();
} }
private String getBroadcastMetadataQrCode() { @Nullable
private BluetoothLeBroadcastMetadata getBroadcastMetadata() {
LocalBluetoothLeBroadcast localBluetoothLeBroadcast = LocalBluetoothLeBroadcast localBluetoothLeBroadcast =
Utils.getLocalBtManager(getActivity()) Utils.getLocalBtManager(getActivity())
.getProfileManager() .getProfileManager()
.getLeAudioBroadcastProfile(); .getLeAudioBroadcastProfile();
if (localBluetoothLeBroadcast == null) { if (localBluetoothLeBroadcast == null) {
Log.d(TAG, "getBroadcastMetadataQrCode: localBluetoothLeBroadcast is null!"); Log.d(TAG, "getBroadcastMetadataQrCode: localBluetoothLeBroadcast is null!");
return ""; return null;
} }
BluetoothLeBroadcastMetadata metadata = BluetoothLeBroadcastMetadata metadata =
localBluetoothLeBroadcast.getLatestBluetoothLeBroadcastMetadata(); localBluetoothLeBroadcast.getLatestBluetoothLeBroadcastMetadata();
if (metadata == null) { if (metadata == null) {
Log.d(TAG, "getBroadcastMetadataQrCode: metadata is null!"); Log.d(TAG, "getBroadcastMetadataQrCode: metadata is null!");
return ""; return null;
} }
return BluetoothLeBroadcastMetadataExt.INSTANCE.toQrCodeString(metadata); return metadata;
} }
} }

View File

@@ -229,6 +229,7 @@ public class QrCodeScanModeFragment extends InstrumentedFragment
} }
mErrorMessage.setVisibility(View.INVISIBLE); mErrorMessage.setVisibility(View.INVISIBLE);
mTextureView.setVisibility(View.INVISIBLE);
triggerVibrationForQrCodeRecognition(getContext()); triggerVibrationForQrCodeRecognition(getContext());