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

Commit ced93469 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "LeAudioTestApp: Add basic metadata view to broadcaster" am: 03a86978...

Merge "LeAudioTestApp: Add basic metadata view to broadcaster" am: 03a86978 am: ef6ac8f8 am: d5e4f099

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2059949



Change-Id: I931c9569b4c7da1581135c649d7dd468a75ba59d
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 15a8e39b d5e4f099
Loading
Loading
Loading
Loading
+42 −1
Original line number Diff line number Diff line
@@ -17,12 +17,14 @@

package com.android.bluetooth.leaudio;

import android.bluetooth.BluetoothLeBroadcastMetadata;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AlertDialog;
@@ -82,7 +84,46 @@ public class BroadcasterActivity extends AppCompatActivity {
        final BroadcastItemsAdapter itemsAdapter = new BroadcastItemsAdapter();
        itemsAdapter.setOnItemClickListener(broadcastId -> {
            AlertDialog.Builder alert = new AlertDialog.Builder(this);
            alert.setTitle("Broadcast actions:");
            alert.setTitle("Broadcast Info:");

            // Load and fill in the metadata layout
            final View metaLayout =
                    getLayoutInflater().inflate(R.layout.broadcast_metadata, null);
            alert.setView(metaLayout);

            BluetoothLeBroadcastMetadata metadata = null;
            for (BluetoothLeBroadcastMetadata b : mViewModel.getAllBroadcastMetadata()) {
                if (b.getBroadcastId() == broadcastId) {
                    metadata = b;
                    break;
                }
            }

            if (metadata != null) {
                TextView addr_text = metaLayout.findViewById(R.id.device_addr_text);
                addr_text.setText("Device Address: " + metadata.getSourceDevice().toString());

                addr_text = metaLayout.findViewById(R.id.adv_sid_text);
                addr_text.setText("Advertising SID: " + metadata.getSourceAdvertisingSid());

                addr_text = metaLayout.findViewById(R.id.pasync_interval_text);
                addr_text.setText("Pa Sync Interval: " + metadata.getPaSyncInterval());

                addr_text = metaLayout.findViewById(R.id.is_encrypted_text);
                addr_text.setText("Is Encrypted: " + metadata.isEncrypted());

                byte[] code = metadata.getBroadcastCode();
                addr_text = metaLayout.findViewById(R.id.broadcast_code_text);
                if (code != null) {
                    addr_text.setText("Broadcast Code: " + metadata.getBroadcastCode().toString());
                } else {
                    addr_text.setVisibility(View.INVISIBLE);
                }

                addr_text = metaLayout.findViewById(R.id.presentation_delay_text);
                addr_text.setText(
                        "Presentation Delay: " + metadata.getPresentationDelayMicros() + " [us]");
            }

            alert.setNeutralButton("Stop", (dialog, which) -> {
                mViewModel.stopBroadcast(broadcastId);
+51 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/broadcast_metadata_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="4dp"
    android:padding="4dp"
    android:orientation="vertical">

    <TextView
        android:id="@+id/device_addr_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="" />

    <TextView
        android:id="@+id/adv_sid_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="" />

    <TextView
        android:id="@+id/pasync_interval_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="" />

    <TextView
        android:id="@+id/is_encrypted_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="" />

    <TextView
        android:id="@+id/broadcast_code_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="" />

    <TextView
        android:id="@+id/presentation_delay_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="" />
</LinearLayout>