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

Commit 4930578b authored by chelseahao's avatar chelseahao Committed by Chelsea Hao
Browse files

Add getSourceMetadata() in LocalBluetoothLeBroadcastAssistant.

Test: NA
Bug: 381944659
Flag: com.android.bluetooth.flags.leaudio_broadcast_api_get_local_metadata
Change-Id: Ieaf89b1fea5f3bcd0ff4528dc0fb473c9b74b5a4
parent 827b8386
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -32,7 +32,9 @@ import android.content.Context;
import android.os.Build;
import android.util.Log;

import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;

import com.android.settingslib.R;
@@ -371,6 +373,27 @@ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile
        return mService.getAllSources(sink);
    }

    /**
     * Gets the {@link BluetoothLeBroadcastMetadata} of a specified source added to this sink.
     *
     * @param sink Broadcast Sink device
     * @param sourceId Broadcast source id
     * @return metadata {@link BluetoothLeBroadcastMetadata} associated with the specified source.
     */
    public @Nullable BluetoothLeBroadcastMetadata getSourceMetadata(
            @NonNull BluetoothDevice sink, @IntRange(from = 0x00, to = 0xFF) int sourceId) {
        if (mService == null) {
            Log.d(TAG, "The BluetoothLeBroadcastAssistant is null");
            return null;
        }
        try {
            return mService.getSourceMetadata(sink, sourceId);
        } catch (IllegalArgumentException | NoSuchMethodError e) {
            Log.w(TAG, "Error calling getSourceMetadata()", e);
        }
        return null;
    }

    /**
     * Register Broadcast Assistant Callbacks to track its state and receivers
     *