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(
|
ThreadUtils.postOnBackgroundThread(
|
||||||
() -> {
|
() -> {
|
||||||
if (mBroadcast != null) {
|
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);
|
mBroadcast.setProgramInfo((String) newValue);
|
||||||
if (isBroadcasting(mBtManager)) {
|
if (isBroadcasting(mBtManager)) {
|
||||||
mBroadcast.updateBroadcast();
|
mBroadcast.updateBroadcast();
|
||||||
@@ -242,7 +245,7 @@ public class AudioSharingNamePreferenceController extends BasePreferenceControll
|
|||||||
ThreadUtils.postOnBackgroundThread(
|
ThreadUtils.postOnBackgroundThread(
|
||||||
() -> {
|
() -> {
|
||||||
if (mBroadcast != null) {
|
if (mBroadcast != null) {
|
||||||
String name = mBroadcast.getProgramInfo();
|
String name = mBroadcast.getBroadcastName();
|
||||||
AudioSharingUtils.postOnMainThread(
|
AudioSharingUtils.postOnMainThread(
|
||||||
mContext,
|
mContext,
|
||||||
() -> {
|
() -> {
|
||||||
|
@@ -26,6 +26,7 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.preference.PreferenceViewHolder;
|
import androidx.preference.PreferenceViewHolder;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settingslib.utils.ThreadUtils;
|
||||||
import com.android.settingslib.widget.TwoTargetPreference;
|
import com.android.settingslib.widget.TwoTargetPreference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,6 +75,9 @@ class AudioStreamPreference extends TwoTargetPreference {
|
|||||||
void setAudioStreamMetadata(BluetoothLeBroadcastMetadata metadata) {
|
void setAudioStreamMetadata(BluetoothLeBroadcastMetadata metadata) {
|
||||||
if (mAudioStream != null) {
|
if (mAudioStream != null) {
|
||||||
mAudioStream.setMetadata(metadata);
|
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
|
@Override
|
||||||
public void onSourceFound(BluetoothLeBroadcastMetadata source) {
|
public void onSourceFound(BluetoothLeBroadcastMetadata source) {
|
||||||
if (DEBUG) {
|
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) {
|
static String getBroadcastName(BluetoothLeBroadcastMetadata source) {
|
||||||
// TODO(b/331547596): prioritize broadcastName
|
String broadcastName = source.getBroadcastName();
|
||||||
Optional<String> optionalProgramInfo =
|
if (broadcastName != null && !broadcastName.isEmpty()) {
|
||||||
source.getSubgroups().stream()
|
return broadcastName;
|
||||||
.map(subgroup -> subgroup.getContentMetadata().getProgramInfo())
|
}
|
||||||
.filter(programInfo -> !Strings.isNullOrEmpty(programInfo))
|
return source.getSubgroups().stream()
|
||||||
.findFirst();
|
.map(subgroup -> subgroup.getContentMetadata().getProgramInfo())
|
||||||
|
.filter(programInfo -> !Strings.isNullOrEmpty(programInfo))
|
||||||
return optionalProgramInfo.orElseGet(
|
.findFirst()
|
||||||
() -> {
|
.orElse("Broadcast Id: " + source.getBroadcastId());
|
||||||
String broadcastName = source.getBroadcastName();
|
|
||||||
if (broadcastName != null && !broadcastName.isEmpty()) {
|
|
||||||
return broadcastName;
|
|
||||||
} else {
|
|
||||||
return "Broadcast Id: " + source.getBroadcastId();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getBroadcastName(BluetoothLeBroadcastReceiveState state) {
|
static String getBroadcastName(BluetoothLeBroadcastReceiveState state) {
|
||||||
|
@@ -21,8 +21,6 @@ import android.bluetooth.BluetoothLeBroadcastMetadata;
|
|||||||
import android.bluetooth.BluetoothLeBroadcastReceiveState;
|
import android.bluetooth.BluetoothLeBroadcastReceiveState;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class AudioStreamsProgressCategoryCallback extends AudioStreamsBroadcastAssistantCallback {
|
public class AudioStreamsProgressCategoryCallback extends AudioStreamsBroadcastAssistantCallback {
|
||||||
private static final String TAG = "AudioStreamsProgressCategoryCallback";
|
private static final String TAG = "AudioStreamsProgressCategoryCallback";
|
||||||
|
|
||||||
@@ -48,8 +46,7 @@ public class AudioStreamsProgressCategoryCallback extends AudioStreamsBroadcastA
|
|||||||
@Override
|
@Override
|
||||||
public void onSearchStartFailed(int reason) {
|
public void onSearchStartFailed(int reason) {
|
||||||
super.onSearchStartFailed(reason);
|
super.onSearchStartFailed(reason);
|
||||||
mCategoryController.showToast(
|
mCategoryController.showToast("Failed to start scanning. Try again.");
|
||||||
String.format(Locale.US, "Failed to start scanning, reason %d", reason));
|
|
||||||
mCategoryController.setScanning(false);
|
mCategoryController.setScanning(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,8 +63,7 @@ public class AudioStreamsProgressCategoryCallback extends AudioStreamsBroadcastA
|
|||||||
@Override
|
@Override
|
||||||
public void onSearchStopFailed(int reason) {
|
public void onSearchStopFailed(int reason) {
|
||||||
super.onSearchStopFailed(reason);
|
super.onSearchStopFailed(reason);
|
||||||
mCategoryController.showToast(
|
mCategoryController.showToast("Failed to stop scanning. Try again.");
|
||||||
String.format(Locale.US, "Failed to stop scanning, reason %d", reason));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,12 +102,7 @@ public class AudioStreamsProgressCategoryCallback extends AudioStreamsBroadcastA
|
|||||||
@Override
|
@Override
|
||||||
public void onSourceRemoveFailed(BluetoothDevice sink, int sourceId, int reason) {
|
public void onSourceRemoveFailed(BluetoothDevice sink, int sourceId, int reason) {
|
||||||
super.onSourceRemoveFailed(sink, sourceId, reason);
|
super.onSourceRemoveFailed(sink, sourceId, reason);
|
||||||
mCategoryController.showToast(
|
mCategoryController.showToast("Failed to remove source.");
|
||||||
String.format(
|
|
||||||
Locale.US,
|
|
||||||
"Failed to remove source %d for sink %s",
|
|
||||||
sourceId,
|
|
||||||
sink.getAddress()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user