Use broadcast name instead of program info.
Bug: 331547596 Test: atest Change-Id: Ie5c35484367a32daeb5020fd03e8653e8c70b4be
This commit is contained in:
@@ -214,6 +214,9 @@ public class AudioSharingNamePreferenceController extends BasePreferenceControll
|
||||
ThreadUtils.postOnBackgroundThread(
|
||||
() -> {
|
||||
if (mBroadcast != null) {
|
||||
mBroadcast.setBroadcastName((String) newValue);
|
||||
// We currently don't have a UI field for program info so we keep it
|
||||
// consistent with broadcast name.
|
||||
mBroadcast.setProgramInfo((String) newValue);
|
||||
if (isBroadcasting(mBtManager)) {
|
||||
mBroadcast.updateBroadcast();
|
||||
@@ -242,7 +245,7 @@ public class AudioSharingNamePreferenceController extends BasePreferenceControll
|
||||
ThreadUtils.postOnBackgroundThread(
|
||||
() -> {
|
||||
if (mBroadcast != null) {
|
||||
String name = mBroadcast.getProgramInfo();
|
||||
String name = mBroadcast.getBroadcastName();
|
||||
AudioSharingUtils.postOnMainThread(
|
||||
mContext,
|
||||
() -> {
|
||||
|
@@ -26,6 +26,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
import com.android.settingslib.widget.TwoTargetPreference;
|
||||
|
||||
/**
|
||||
@@ -74,6 +75,9 @@ class AudioStreamPreference extends TwoTargetPreference {
|
||||
void setAudioStreamMetadata(BluetoothLeBroadcastMetadata metadata) {
|
||||
if (mAudioStream != null) {
|
||||
mAudioStream.setMetadata(metadata);
|
||||
// Update title based on the metadata
|
||||
String broadcastName = AudioStreamsHelper.getBroadcastName(metadata);
|
||||
ThreadUtils.postOnMainThread(() -> setTitle(broadcastName));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -101,7 +101,12 @@ public class AudioStreamsBroadcastAssistantCallback
|
||||
@Override
|
||||
public void onSourceFound(BluetoothLeBroadcastMetadata source) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onSourceFound() broadcastId : " + source.getBroadcastId());
|
||||
Log.d(
|
||||
TAG,
|
||||
"onSourceFound() broadcastId : "
|
||||
+ source.getBroadcastId()
|
||||
+ " broadcastName : "
|
||||
+ source.getBroadcastName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -314,22 +314,15 @@ public class AudioStreamsHelper {
|
||||
}
|
||||
|
||||
static String getBroadcastName(BluetoothLeBroadcastMetadata source) {
|
||||
// TODO(b/331547596): prioritize broadcastName
|
||||
Optional<String> optionalProgramInfo =
|
||||
source.getSubgroups().stream()
|
||||
.map(subgroup -> subgroup.getContentMetadata().getProgramInfo())
|
||||
.filter(programInfo -> !Strings.isNullOrEmpty(programInfo))
|
||||
.findFirst();
|
||||
|
||||
return optionalProgramInfo.orElseGet(
|
||||
() -> {
|
||||
String broadcastName = source.getBroadcastName();
|
||||
if (broadcastName != null && !broadcastName.isEmpty()) {
|
||||
return broadcastName;
|
||||
} else {
|
||||
return "Broadcast Id: " + source.getBroadcastId();
|
||||
}
|
||||
});
|
||||
String broadcastName = source.getBroadcastName();
|
||||
if (broadcastName != null && !broadcastName.isEmpty()) {
|
||||
return broadcastName;
|
||||
}
|
||||
return source.getSubgroups().stream()
|
||||
.map(subgroup -> subgroup.getContentMetadata().getProgramInfo())
|
||||
.filter(programInfo -> !Strings.isNullOrEmpty(programInfo))
|
||||
.findFirst()
|
||||
.orElse("Broadcast Id: " + source.getBroadcastId());
|
||||
}
|
||||
|
||||
static String getBroadcastName(BluetoothLeBroadcastReceiveState state) {
|
||||
|
@@ -21,8 +21,6 @@ import android.bluetooth.BluetoothLeBroadcastMetadata;
|
||||
import android.bluetooth.BluetoothLeBroadcastReceiveState;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class AudioStreamsProgressCategoryCallback extends AudioStreamsBroadcastAssistantCallback {
|
||||
private static final String TAG = "AudioStreamsProgressCategoryCallback";
|
||||
|
||||
@@ -48,8 +46,7 @@ public class AudioStreamsProgressCategoryCallback extends AudioStreamsBroadcastA
|
||||
@Override
|
||||
public void onSearchStartFailed(int reason) {
|
||||
super.onSearchStartFailed(reason);
|
||||
mCategoryController.showToast(
|
||||
String.format(Locale.US, "Failed to start scanning, reason %d", reason));
|
||||
mCategoryController.showToast("Failed to start scanning. Try again.");
|
||||
mCategoryController.setScanning(false);
|
||||
}
|
||||
|
||||
@@ -66,8 +63,7 @@ public class AudioStreamsProgressCategoryCallback extends AudioStreamsBroadcastA
|
||||
@Override
|
||||
public void onSearchStopFailed(int reason) {
|
||||
super.onSearchStopFailed(reason);
|
||||
mCategoryController.showToast(
|
||||
String.format(Locale.US, "Failed to stop scanning, reason %d", reason));
|
||||
mCategoryController.showToast("Failed to stop scanning. Try again.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,12 +102,7 @@ public class AudioStreamsProgressCategoryCallback extends AudioStreamsBroadcastA
|
||||
@Override
|
||||
public void onSourceRemoveFailed(BluetoothDevice sink, int sourceId, int reason) {
|
||||
super.onSourceRemoveFailed(sink, sourceId, reason);
|
||||
mCategoryController.showToast(
|
||||
String.format(
|
||||
Locale.US,
|
||||
"Failed to remove source %d for sink %s",
|
||||
sourceId,
|
||||
sink.getAddress()));
|
||||
mCategoryController.showToast("Failed to remove source.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user