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

Commit 15e0f885 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

LeAudioTestApp: Add button to trigget set active group

This is needed for PTS

Bug: 238171211
Test: tested manually with PTS
Tag: #feature
Merged-In: I72de83488e8714359be113c25f459e8de2dcda37
Change-Id: I72de83488e8714359be113c25f459e8de2dcda37
(cherry picked from commit edc55d33)
parent 08852175
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1219,6 +1219,15 @@ public class BluetoothProxy {
        return true;
    }

    public boolean hapSetActivePresetForGroup(BluetoothDevice device, int preset_index) {
        if (bluetoothHapClient == null)
            return false;

        int groupId = bluetoothLeAudio.getGroupId(device);
        bluetoothHapClient.selectPresetForGroup(groupId, preset_index);
        return true;
    }

    public boolean hapChangePresetName(BluetoothDevice device, int preset_index, String name) {
        if (bluetoothHapClient == null)
            return false;
+20 −0
Original line number Diff line number Diff line
@@ -890,6 +890,8 @@ public class LeAudioRecycleViewAdapter

        void onSetActivePresetClicked(BluetoothDevice device, int preset_index);

        void onSetActivePresetForGroupClicked(BluetoothDevice device, int preset_index);

        void onNextDevicePresetClicked(BluetoothDevice device);

        void onPreviousDevicePresetClicked(BluetoothDevice device);
@@ -947,6 +949,7 @@ public class LeAudioRecycleViewAdapter
        private Spinner leAudioHapPresetsSpinner;
        private Button leAudioHapChangePresetNameButton;
        private Button leAudioHapSetActivePresetButton;
        private Button leAudioHapSetActivePresetForGroupButton;
        private Button leAudioHapReadPresetInfoButton;
        private Button leAudioHapNextDevicePresetButton;
        private Button leAudioHapPreviousDevicePresetButton;
@@ -1041,6 +1044,8 @@ public class LeAudioRecycleViewAdapter
                    itemView.findViewById(R.id.hap_change_preset_name_button);
            leAudioHapSetActivePresetButton =
                    itemView.findViewById(R.id.hap_set_active_preset_button);
            leAudioHapSetActivePresetForGroupButton =
                    itemView.findViewById(R.id.hap_set_active_preset_for_group_button);
            leAudioHapReadPresetInfoButton =
                    itemView.findViewById(R.id.hap_read_preset_info_button);
            leAudioHapNextDevicePresetButton =
@@ -1110,6 +1115,21 @@ public class LeAudioRecycleViewAdapter
                }
            });

            leAudioHapSetActivePresetForGroupButton.setOnClickListener(view -> {
                if (hapInteractionListener != null) {
                    if (leAudioHapPresetsSpinner.getSelectedItem() == null) {
                        Toast.makeText(view.getContext(), "No known preset, please reconnect.",
                                Toast.LENGTH_SHORT).show();
                        return;
                    }

                    Integer index = Integer.valueOf(
                            leAudioHapPresetsSpinner.getSelectedItem().toString().split("\\s")[0]);
                    hapInteractionListener.onSetActivePresetForGroupClicked(
                            devices.get(ViewHolder.this.getAdapterPosition()).device, index);
                }
            });

            leAudioHapReadPresetInfoButton.setOnClickListener(view -> {
                if (hapInteractionListener != null) {
                    if (leAudioHapPresetsSpinner.getSelectedItem() == null) {
+4 −0
Original line number Diff line number Diff line
@@ -81,6 +81,10 @@ public class LeAudioViewModel extends AndroidViewModel {
        bluetoothProxy.hapSetActivePreset(device, preset_index);
    }

    public void hapSetActivePresetForGroup(BluetoothDevice device, int preset_index) {
        bluetoothProxy.hapSetActivePresetForGroup(device, preset_index);
    }

    public void hapChangePresetName(BluetoothDevice device, int preset_index, String name) {
        bluetoothProxy.hapChangePresetName(device, preset_index, name);
    }
+5 −0
Original line number Diff line number Diff line
@@ -521,6 +521,11 @@ public class MainActivity extends AppCompatActivity {
                        leAudioViewModel.hapSetActivePreset(device, preset_index);
                    }

                    @Override
                    public void onSetActivePresetForGroupClicked(BluetoothDevice device, int preset_index) {
                        leAudioViewModel.hapSetActivePresetForGroup(device, preset_index);
                    }

                    @Override
                    public void onChangePresetNameClicked(BluetoothDevice device, int preset_index,
                            String name) {
+8 −1
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Precious group preset" />
            android:text="Previous group preset" />

        <Button
            android:id="@+id/hap_next_group_preset_button"
@@ -168,5 +168,12 @@
            android:layout_weight="1"
            android:text="Next group preset" />

        <Button
            android:id="@+id/hap_set_active_preset_for_group_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Set group active" />

    </LinearLayout>
</LinearLayout>
 No newline at end of file