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

Commit b8918397 authored by Jack He's avatar Jack He
Browse files

Broadcast: Use subgroup information to derive whether channel preference

* No need to explicitly set channel preference
* Accumulating subgroup information to find out

Bug: 218683032
Test: make, cts
Tag: #feature
Change-Id: If61662e20f8dcfd0cf53d7d35b2fa580dc3e5bb7
parent 46657ebe
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -541,7 +541,7 @@ package android.bluetooth {
    method public long getCodecId();
    method @NonNull public android.bluetooth.BluetoothLeAudioCodecConfigMetadata getCodecSpecificConfig();
    method @NonNull public android.bluetooth.BluetoothLeAudioContentMetadata getContentMetadata();
    method public boolean isNoChannelPreference();
    method public boolean hasChannelPreference();
    field @NonNull public static final android.os.Parcelable.Creator<android.bluetooth.BluetoothLeBroadcastSubgroup> CREATOR;
  }

@@ -554,7 +554,6 @@ package android.bluetooth {
    method @NonNull public android.bluetooth.BluetoothLeBroadcastSubgroup.Builder setCodecId(long);
    method @NonNull public android.bluetooth.BluetoothLeBroadcastSubgroup.Builder setCodecSpecificConfig(@NonNull android.bluetooth.BluetoothLeAudioCodecConfigMetadata);
    method @NonNull public android.bluetooth.BluetoothLeBroadcastSubgroup.Builder setContentMetadata(@NonNull android.bluetooth.BluetoothLeAudioContentMetadata);
    method @NonNull public android.bluetooth.BluetoothLeBroadcastSubgroup.Builder setNoChannelPreference(boolean);
  }

  public final class BluetoothMap implements java.lang.AutoCloseable android.bluetooth.BluetoothProfile {
+7 −28
Original line number Diff line number Diff line
@@ -35,17 +35,15 @@ public final class BluetoothLeBroadcastSubgroup implements Parcelable {
    private final long mCodecId;
    private final BluetoothLeAudioCodecConfigMetadata mCodecSpecificConfig;
    private final BluetoothLeAudioContentMetadata mContentMetadata;
    private final boolean mNoChannelPreference;
    private final List<BluetoothLeBroadcastChannel> mChannels;

    private BluetoothLeBroadcastSubgroup(long codecId,
            BluetoothLeAudioCodecConfigMetadata codecSpecificConfig,
            BluetoothLeAudioContentMetadata contentMetadata, boolean noChannelPreference,
            BluetoothLeAudioContentMetadata contentMetadata,
            List<BluetoothLeBroadcastChannel> channels) {
        mCodecId = codecId;
        mCodecSpecificConfig = codecSpecificConfig;
        mContentMetadata = contentMetadata;
        mNoChannelPreference = noChannelPreference;
        mChannels = channels;
    }

@@ -91,16 +89,17 @@ public final class BluetoothLeBroadcastSubgroup implements Parcelable {
    }

    /**
     * Indicate if Broadcast Sink should have no Broadcast Channel (BIS) preference.
     * Indicate if Broadcast Sink should have a preferred Broadcast Channel (BIS).
     *
     * Only used by Broadcast Assistant and Sink. Ignored by Broadcast Source
     *
     * @return true if Broadcast Sink should have no Broadcast Channel (BIS) preference
     * @return true if Broadcast Sink has at least one preferred Broadcast Channel (BIS) as
     * indicated by {@link BluetoothLeBroadcastChannel#isSelected()}
     * @hide
     */
    @SystemApi
    public boolean isNoChannelPreference() {
        return mNoChannelPreference;
    public boolean hasChannelPreference() {
        return mChannels.stream().anyMatch(BluetoothLeBroadcastChannel::isSelected);
    }

    /**
@@ -136,7 +135,6 @@ public final class BluetoothLeBroadcastSubgroup implements Parcelable {
        out.writeLong(mCodecId);
        out.writeTypedObject(mCodecSpecificConfig, 0);
        out.writeTypedObject(mContentMetadata, 0);
        out.writeBoolean(mNoChannelPreference);
        out.writeTypedList(mChannels);
    }

@@ -152,7 +150,6 @@ public final class BluetoothLeBroadcastSubgroup implements Parcelable {
                    builder.setCodecId(in.readLong());
                    builder.setCodecSpecificConfig(in.readTypedObject(
                            BluetoothLeAudioCodecConfigMetadata.CREATOR));
                    builder.setNoChannelPreference(in.readBoolean());
                    List<BluetoothLeBroadcastChannel> channels = new ArrayList<>();
                    in.readTypedList(channels, BluetoothLeBroadcastChannel.CREATOR);
                    for (BluetoothLeBroadcastChannel channel : channels) {
@@ -177,7 +174,6 @@ public final class BluetoothLeBroadcastSubgroup implements Parcelable {
        private long mCodecId = UNKNOWN_VALUE_PLACEHOLDER;
        private BluetoothLeAudioCodecConfigMetadata mCodecSpecificConfig = null;
        private BluetoothLeAudioContentMetadata mContentMetadata = null;
        private boolean mNoChannelPreference = false;
        private List<BluetoothLeBroadcastChannel> mChannels = new ArrayList<>();

        /**
@@ -198,7 +194,6 @@ public final class BluetoothLeBroadcastSubgroup implements Parcelable {
            mCodecId = original.getCodecId();
            mCodecSpecificConfig = original.getCodecSpecificConfig();
            mContentMetadata = original.getContentMetadata();
            mNoChannelPreference = original.isNoChannelPreference();
            mChannels = original.getChannels();
        }

@@ -251,22 +246,6 @@ public final class BluetoothLeBroadcastSubgroup implements Parcelable {
            return this;
        }

        /**
         * Set if Broadcast Sink should have no Broadcast Channel (BIS) preference.
         *
         * Only used by Broadcast Assistant and Sink. Ignored by Broadcast Source
         *
         * @param isNoChannelPreference true if Broadcast Sink should have no Broadcast Channel
         *                              (BIS) preference
         * @return this builder
         * @hide
         */
        @SystemApi
        public @NonNull Builder setNoChannelPreference(boolean isNoChannelPreference) {
            mNoChannelPreference = isNoChannelPreference;
            return this;
        }

        /**
         * Add a Broadcast Channel to this Broadcast subgroup.
         *
@@ -316,7 +295,7 @@ public final class BluetoothLeBroadcastSubgroup implements Parcelable {
                throw new IllegalArgumentException("Must have at least one channel");
            }
            return new BluetoothLeBroadcastSubgroup(mCodecId, mCodecSpecificConfig,
                    mContentMetadata, mNoChannelPreference, mChannels);
                    mContentMetadata, mChannels);
        }
    }
}