Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d77a47c authored by Jakub Tyszkowski's avatar Jakub Tyszkowski
Browse files

LeAudioTestApp/Bass: Fix not being able to scan for sources

There is no need to know the remotes bass sources states to
perform the scan for nearby broadcast sources.

Bug: 240145685
Test: recompile the app and tested manually
Change-Id: Ib0642250edac64fcd62beb80c7e58c57ffb0e41c
parent a1b6ad48
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -416,10 +416,6 @@ public class BluetoothProxy {
                LeAudioDeviceStateWrapper valid_device = valid_device_opt.get();
                LeAudioDeviceStateWrapper.BassData svc_data = valid_device.bassData;

                // TODO: Is the receiver_id same with BluetoothLeBroadcastReceiveState.getSourceId()?
                //       If not, find getSourceId() usages and fix the issues.
//                rstate.receiver_id = intent.getIntExtra(
//                        BluetoothBroadcastAudioScan.EXTRA_BASS_RECEIVER_ID, -1);
                /**
                 * From "Introducing-Bluetooth-LE-Audio-book" 8.6.3.1:
                 *
@@ -435,8 +431,6 @@ public class BluetoothProxy {
                 */

                /**
                 * From BluetoothBroadcastAudioScan.EXTRA_BASS_RECEIVER_ID:
                 *
                 * Broadcast receiver's endpoint identifier.
                 */
                synchronized(this) {
+0 −5
Original line number Diff line number Diff line
@@ -42,11 +42,6 @@ import java.util.List;


public class BroadcastScanActivity extends AppCompatActivity {
    // Integer key used for sending/receiving receiver ID.
    public static final String EXTRA_BASS_RECEIVER_ID = "receiver_id";

    private static final int BIS_ALL = 0xFFFFFFFF;

    private BluetoothDevice device;
    private BroadcastScanViewModel mViewModel;
    private BroadcastItemsAdapter adapter;
+9 −18
Original line number Diff line number Diff line
@@ -26,8 +26,6 @@ import static android.bluetooth.BluetoothLeBroadcastReceiveState.PA_SYNC_STATE_I
import static android.bluetooth.BluetoothLeBroadcastReceiveState.PA_SYNC_STATE_SYNCHRONIZED;
import static android.bluetooth.BluetoothLeBroadcastReceiveState.PA_SYNC_STATE_SYNCINFO_REQUEST;

import static com.android.bluetooth.leaudio.BroadcastScanActivity.EXTRA_BASS_RECEIVER_ID;

import android.animation.ObjectAnimator;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHapClient;
@@ -1810,27 +1808,27 @@ public class LeAudioRecycleViewAdapter
                    alert.setTitle("Scan and add a source or remove the currently set one.");

                    BluetoothDevice device = devices.get(ViewHolder.this.getAdapterPosition()).device;
                    if (bassReceiverIdSpinner.getSelectedItem() == null) {
                        Toast.makeText(view.getContext(), "Not available",
                                Toast.LENGTH_SHORT).show();
                        return;
                    int receiver_id = -1;
                    if (bassReceiverIdSpinner.getSelectedItem() != null) {
                        receiver_id = Integer.parseInt(bassReceiverIdSpinner.getSelectedItem().toString());
                    }
                    int receiver_id = Integer.parseInt(bassReceiverIdSpinner.getSelectedItem().toString());

                    alert.setPositiveButton("Scan", (dialog, whichButton) -> {
                        // Scan for new announcements
                        Intent intent = new Intent(this.itemView.getContext(), BroadcastScanActivity.class);
                        intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                        intent.putExtra(EXTRA_BASS_RECEIVER_ID, receiver_id);
                        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, devices.get(ViewHolder.this.getAdapterPosition()).device);
                        parent.startActivityForResult(intent, 666);
                    });
                    alert.setNeutralButton("Cancel", (dialog, whichButton) -> {
                        // Do nothing
                    });
                    if (receiver_id != -1) {
                        final int remove_receiver_id = receiver_id;
                        alert.setNegativeButton("Remove", (dialog, whichButton) -> {
                        bassInteractionListener.onRemoveSourceReq(device, receiver_id);
                            bassInteractionListener.onRemoveSourceReq(device, remove_receiver_id);
                        });
                    }
                    alert.show();

                } else if (bassReceiverStateText.getText().equals(res.getString(R.string.broadcast_state_code_required))) {
@@ -1887,16 +1885,9 @@ public class LeAudioRecycleViewAdapter
                    AlertDialog.Builder alert = new AlertDialog.Builder(itemView.getContext());
                    alert.setTitle("Retry broadcast audio announcement scan?");

                    if (bassReceiverIdSpinner.getSelectedItem() == null) {
                        Toast.makeText(view.getContext(), "Not available",
                                Toast.LENGTH_SHORT).show();
                        return;
                    }
                    int receiver_id = Integer.parseInt(bassReceiverIdSpinner.getSelectedItem().toString());
                    alert.setPositiveButton("Yes", (dialog, whichButton) -> {
                        // Scan for new announcements
                        Intent intent = new Intent(view.getContext(), BroadcastScanActivity.class);
                        intent.putExtra(EXTRA_BASS_RECEIVER_ID, receiver_id);
                        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, devices.get(ViewHolder.this.getAdapterPosition()).device);
                        parent.startActivityForResult(intent, 666);
                    });