[LE Audio] To fix the condition of the broadcast icon display
- The broadcast icon will be displayed when the device is connected to the LE Audio device. - The broadcast option dialog will show the "Broadcast" option when the media is streaming. Otherwise, it will not show. Bug: 235923182 Test: manual test Test: make RunSettingsRoboTests ROBOTEST_FILTER=MediaVolumePreferenceControllerTest Change-Id: Ib225d185b6f15463f4fae809e0cdaa25920d52af
This commit is contained in:
@@ -41,15 +41,18 @@ import com.android.settingslib.media.MediaOutputConstants;
|
||||
* nearby broadcast sources.
|
||||
*/
|
||||
public class BluetoothBroadcastDialog extends InstrumentedDialogFragment {
|
||||
|
||||
public static final String KEY_APP_LABEL = "app_label";
|
||||
public static final String KEY_DEVICE_ADDRESS =
|
||||
BluetoothFindBroadcastsFragment.KEY_DEVICE_ADDRESS;
|
||||
public static final String KEY_MEDIA_STREAMING = "media_streaming";
|
||||
|
||||
private static final String TAG = "BTBroadcastsDialog";
|
||||
private static final CharSequence UNKNOWN_APP_LABEL = "unknown";
|
||||
private Context mContext;
|
||||
private CharSequence mCurrentAppLabel = UNKNOWN_APP_LABEL;
|
||||
private String mDeviceAddress;
|
||||
private boolean mIsMediaStreaming;
|
||||
private LocalBluetoothManager mLocalBluetoothManager;
|
||||
private AlertDialog mAlertDialog;
|
||||
|
||||
@@ -59,6 +62,7 @@ public class BluetoothBroadcastDialog extends InstrumentedDialogFragment {
|
||||
mContext = getActivity();
|
||||
mCurrentAppLabel = getActivity().getIntent().getCharSequenceExtra(KEY_APP_LABEL);
|
||||
mDeviceAddress = getActivity().getIntent().getStringExtra(KEY_DEVICE_ADDRESS);
|
||||
mIsMediaStreaming = getActivity().getIntent().getBooleanExtra(KEY_MEDIA_STREAMING, false);
|
||||
mLocalBluetoothManager = Utils.getLocalBtManager(mContext);
|
||||
setShowsDialog(true);
|
||||
}
|
||||
@@ -75,16 +79,21 @@ public class BluetoothBroadcastDialog extends InstrumentedDialogFragment {
|
||||
mContext.getString(R.string.bluetooth_broadcast_dialog_broadcast_message));
|
||||
|
||||
Button broadcastBtn = layout.findViewById(com.android.settingslib.R.id.positive_btn);
|
||||
if (TextUtils.isEmpty(mCurrentAppLabel)) {
|
||||
broadcastBtn.setText(mContext.getString(R.string.bluetooth_broadcast_dialog_title));
|
||||
} else {
|
||||
broadcastBtn.setText(mContext.getString(
|
||||
if (isBroadcastSupported() && mIsMediaStreaming) {
|
||||
broadcastBtn.setVisibility(View.VISIBLE);
|
||||
if (TextUtils.isEmpty(mCurrentAppLabel)) {
|
||||
broadcastBtn.setText(mContext.getString(R.string.bluetooth_broadcast_dialog_title));
|
||||
} else {
|
||||
broadcastBtn.setText(mContext.getString(
|
||||
R.string.bluetooth_broadcast_dialog_broadcast_app,
|
||||
String.valueOf(mCurrentAppLabel)));
|
||||
}
|
||||
broadcastBtn.setOnClickListener((view) -> {
|
||||
launchMediaOutputBroadcastDialog();
|
||||
});
|
||||
} else {
|
||||
broadcastBtn.setVisibility(View.GONE);
|
||||
}
|
||||
broadcastBtn.setOnClickListener((view) -> {
|
||||
launchMediaOutputBroadcastDialog();
|
||||
});
|
||||
|
||||
Button findBroadcastBtn = layout.findViewById(com.android.settingslib.R.id.negative_btn);
|
||||
findBroadcastBtn.setText(mContext.getString(R.string.bluetooth_find_broadcast));
|
||||
@@ -169,4 +178,10 @@ public class BluetoothBroadcastDialog extends InstrumentedDialogFragment {
|
||||
.setPackage(MediaOutputConstants.SETTINGS_PACKAGE_NAME)
|
||||
.setAction(MediaOutputConstants.ACTION_CLOSE_PANEL));
|
||||
}
|
||||
|
||||
boolean isBroadcastSupported() {
|
||||
LocalBluetoothLeBroadcast broadcast =
|
||||
mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastProfile();
|
||||
return broadcast != null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user