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

Commit 2e2df9dd authored by Chelsea Hao's avatar Chelsea Hao Committed by Android (Google) Code Review
Browse files

Merge "Add getSourceMetadata() in LocalBluetoothLeBroadcastAssistant." into main

parents 98d2c580 4930578b
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
     *