Merge changes I9f6bb947,Iff72dbea into main

* changes:
  AIDL API Review changes
  A2DP HAL Reference Implementation: remove static object's
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecParameters.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecParameters.aidl
index 60cf82a..ac63c28 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecParameters.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecParameters.aidl
@@ -39,7 +39,7 @@
   int bitdepth;
   int minBitrate;
   int maxBitrate;
-  boolean lowLatency;
-  boolean lossless;
+  boolean lowLatency = false;
+  boolean lossless = false;
   byte[] vendorSpecificParameters;
 }
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
index 3a2dcef..8d46c01 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
@@ -41,7 +41,7 @@
   void updateAudioConfiguration(in android.hardware.bluetooth.audio.AudioConfiguration audioConfig);
   void setLowLatencyModeAllowed(in boolean allowed);
   android.hardware.bluetooth.audio.A2dpStatus parseA2dpConfiguration(in android.hardware.bluetooth.audio.CodecId codecId, in byte[] configuration, out android.hardware.bluetooth.audio.CodecParameters codecParameters);
-  @nullable android.hardware.bluetooth.audio.A2dpConfiguration getA2dpConfiguration(in List<android.hardware.bluetooth.audio.A2dpRemoteCapabilities> remoteA2dpCapabilities, in android.hardware.bluetooth.audio.A2dpConfigurationHint hint);
+  @nullable android.hardware.bluetooth.audio.A2dpConfiguration getA2dpConfiguration(in android.hardware.bluetooth.audio.A2dpRemoteCapabilities[] remoteA2dpCapabilities, in android.hardware.bluetooth.audio.A2dpConfigurationHint hint);
   void setCodecPriority(in android.hardware.bluetooth.audio.CodecId codecId, int priority);
   android.hardware.bluetooth.audio.IBluetoothAudioProvider.LeAudioAseConfigurationSetting[] getLeAudioAseConfiguration(in @nullable android.hardware.bluetooth.audio.IBluetoothAudioProvider.LeAudioDeviceCapabilities[] remoteSinkAudioCapabilities, in @nullable android.hardware.bluetooth.audio.IBluetoothAudioProvider.LeAudioDeviceCapabilities[] remoteSourceAudioCapabilities, in android.hardware.bluetooth.audio.IBluetoothAudioProvider.LeAudioConfigurationRequirement[] requirements);
   android.hardware.bluetooth.audio.IBluetoothAudioProvider.LeAudioAseQosConfigurationPair getLeAudioAseQosConfiguration(in android.hardware.bluetooth.audio.IBluetoothAudioProvider.LeAudioAseQosConfigurationRequirement qosRequirement);
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/A2dpConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/A2dpConfiguration.aidl
index a7fd9ff..db5212f 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/A2dpConfiguration.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/A2dpConfiguration.aidl
@@ -26,6 +26,7 @@
 parcelable A2dpConfiguration {
     /**
      * Remote Stream Endpoint Identifier
+     * This matches `A2dpRemoteCapabilities.seid` given by the framework.
      */
     int remoteSeid;
 
@@ -35,7 +36,7 @@
      * `configuration`. Using `id.a2dp`, the format is given by the `Codec
      * Specific Information Elements` [A2DP - 4.3-6.2], and using `id.vendor`,
      * by `Vendor Specific Value` [A2DP - 4.7.2].
-     * In any case, this byte array is limited by the framework to 128 Bytes.
+     * In any case, this byte array must be limited to 128 bytes.
      */
     CodecId id;
     CodecParameters parameters;
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/A2dpRemoteCapabilities.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/A2dpRemoteCapabilities.aidl
index 87277f1..224bb60 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/A2dpRemoteCapabilities.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/A2dpRemoteCapabilities.aidl
@@ -25,6 +25,8 @@
 parcelable A2dpRemoteCapabilities {
     /**
      * Remote Stream Endpoint identifier
+     * Allocated by the remote device to identify a specific codec and capabilities,
+     * in the meaning of the AVDTP standard.
      */
     int seid;
 
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/A2dpStreamConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/A2dpStreamConfiguration.aidl
index 2a0c4d8..b8521f4 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/A2dpStreamConfiguration.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/A2dpStreamConfiguration.aidl
@@ -21,7 +21,9 @@
 @VintfStability
 parcelable A2dpStreamConfiguration {
     /**
-     * Peer MTU (16 bits)
+     * Peer Maximum Transfer Unit (MTU), 16 bits value [Core - 3.A.5.1]
+     * It's the remote device indication of the maximum amount of data that
+     * can be received on the AVDTP Stream Channel.
      */
     int peerMtu;
 
@@ -29,6 +31,7 @@
      * Optional SCMS-T Content Protection header
      * that precedes audio content when enabled [A2DP - 3.2.1-2].
      * The content protection byte is defined by [Assigned Number - 6.3.2].
+     * When the content protection is not enabled, this field should be left `null`.
      */
     @nullable byte[1] cpHeaderScmst;
 
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecParameters.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecParameters.aidl
index b6f8a94..37f8942 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecParameters.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecParameters.aidl
@@ -35,24 +35,29 @@
     int bitdepth;
 
     /**
-     * Encoding parameters:
-     *
-     * - Bitrate limits on a frame basis, defined in bits per second.
-     *   The encoder bitrate mode can be encoded following this rule:
-     *     . minBitrate equals to maxBitrate for constant bitrate
-     *     . minBitrate set to 0, for VBR with peak bitrate at maxBitratre value.
-     *     . minBitrate greater than 0, for ABR, the bitrate of the stream varies
-     *       between minBitrate to maxBitrate according to link quality.
-     *   The 0 value for both means "undefined" or "don't care".
-     *
-     * - Low-latency configuration privileged
-     * - Lossless effort indication. The 'False' value can be used as "don't care"
+     * Bitrate limits on a frame basis, defined in bits per second.
+     * The encoder bitrate mode can be encoded following this rule:
+     *   . minBitrate equals to maxBitrate for constant bitrate
+     *   . minBitrate set to 0, for VBR with peak bitrate at maxBitratre value.
+     *   . minBitrate greater than 0, for ABR, the bitrate of the stream varies
+     *     between minBitrate to maxBitrate according to link quality.
+     * The 0 value for both means "undefined" or "don't care".
      */
     int minBitrate;
     int maxBitrate;
 
-    boolean lowLatency;
-    boolean lossless;
+    /**
+     * Low-latency configuration. The interpretation is vendor specific.
+     * When returned to the client, the assessment of the low latency configuration is left
+     * to the vendor's discretion. When set by the client, it indicates that we are entering
+     * a low-latency context (e.g. gaming), and such a configuration should be privileged.
+     */
+    boolean lowLatency = false;
+
+    /**
+     * Lossless effort indication. The 'False' value can be used as "don't care"
+     */
+    boolean lossless = false;
 
     /**
      * Vendor specific parameters, inserted in the Vendor Specific HCI Command
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
index 1424431..33af8a4 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
@@ -133,7 +133,7 @@
      *         when no suitable configuration has been found.
      */
     @nullable A2dpConfiguration getA2dpConfiguration(
-            in List<A2dpRemoteCapabilities> remoteA2dpCapabilities, in A2dpConfigurationHint hint);
+            in A2dpRemoteCapabilities[] remoteA2dpCapabilities, in A2dpConfigurationHint hint);
 
     /**
      * Predefined values for the codec priority, used by `setCodecPriority()`.
diff --git a/bluetooth/audio/aidl/default/A2dpOffloadAudioProvider.cpp b/bluetooth/audio/aidl/default/A2dpOffloadAudioProvider.cpp
index ba7a89d..c7761c5 100644
--- a/bluetooth/audio/aidl/default/A2dpOffloadAudioProvider.cpp
+++ b/bluetooth/audio/aidl/default/A2dpOffloadAudioProvider.cpp
@@ -23,7 +23,6 @@
 #include <android-base/logging.h>
 
 #include "A2dpOffloadCodecAac.h"
-#include "A2dpOffloadCodecFactory.h"
 #include "A2dpOffloadCodecSbc.h"
 
 namespace aidl {
@@ -32,17 +31,21 @@
 namespace bluetooth {
 namespace audio {
 
-A2dpOffloadEncodingAudioProvider::A2dpOffloadEncodingAudioProvider()
-    : A2dpOffloadAudioProvider() {
+A2dpOffloadEncodingAudioProvider::A2dpOffloadEncodingAudioProvider(
+    const A2dpOffloadCodecFactory& codec_factory)
+    : A2dpOffloadAudioProvider(codec_factory) {
   session_type_ = SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH;
 }
 
-A2dpOffloadDecodingAudioProvider::A2dpOffloadDecodingAudioProvider()
-    : A2dpOffloadAudioProvider() {
+A2dpOffloadDecodingAudioProvider::A2dpOffloadDecodingAudioProvider(
+    const A2dpOffloadCodecFactory& codec_factory)
+    : A2dpOffloadAudioProvider(codec_factory) {
   session_type_ = SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH;
 }
 
-A2dpOffloadAudioProvider::A2dpOffloadAudioProvider() {}
+A2dpOffloadAudioProvider::A2dpOffloadAudioProvider(
+    const A2dpOffloadCodecFactory& codec_factory)
+    : codec_factory_(codec_factory) {}
 
 bool A2dpOffloadAudioProvider::isValid(const SessionType& session_type) {
   return (session_type == session_type_);
@@ -56,17 +59,29 @@
     auto a2dp_config = audio_config.get<AudioConfiguration::Tag::a2dp>();
     A2dpStatus a2dp_status = A2dpStatus::NOT_SUPPORTED_CODEC_TYPE;
 
-    if (a2dp_config.codecId ==
-        A2dpOffloadCodecSbc::GetInstance()->GetCodecId()) {
-      SbcParameters sbc_parameters;
-      a2dp_status = A2dpOffloadCodecSbc::GetInstance()->ParseConfiguration(
-          a2dp_config.configuration, &sbc_parameters);
+    auto codec = codec_factory_.GetCodec(a2dp_config.codecId);
+    if (!codec) {
+      LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_)
+                << " - CodecId=" << a2dp_config.codecId.toString()
+                << " is not found";
+      return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+    }
 
-    } else if (a2dp_config.codecId ==
-               A2dpOffloadCodecAac::GetInstance()->GetCodecId()) {
+    if (codec->info.id == CodecId(CodecId::A2dp::SBC)) {
+      SbcParameters sbc_parameters;
+
+      auto codec_sbc =
+          std::static_pointer_cast<const A2dpOffloadCodecSbc>(codec);
+      a2dp_status = codec_sbc->ParseConfiguration(a2dp_config.configuration,
+                                                  &sbc_parameters);
+
+    } else if (codec->info.id == CodecId(CodecId::A2dp::AAC)) {
       AacParameters aac_parameters;
-      a2dp_status = A2dpOffloadCodecAac::GetInstance()->ParseConfiguration(
-          a2dp_config.configuration, &aac_parameters);
+
+      auto codec_aac =
+          std::static_pointer_cast<const A2dpOffloadCodecAac>(codec);
+      a2dp_status = codec_aac->ParseConfiguration(a2dp_config.configuration,
+                                                  &aac_parameters);
     }
     if (a2dp_status != A2dpStatus::OK) {
       LOG(WARNING) << __func__ << " - Invalid Audio Configuration="
@@ -105,7 +120,7 @@
 ndk::ScopedAStatus A2dpOffloadAudioProvider::parseA2dpConfiguration(
     const CodecId& codec_id, const std::vector<uint8_t>& configuration,
     CodecParameters* codec_parameters, A2dpStatus* _aidl_return) {
-  auto codec = A2dpOffloadCodecFactory::GetInstance()->GetCodec(codec_id);
+  auto codec = codec_factory_.GetCodec(codec_id);
   if (!codec) {
     LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_)
               << " - CodecId=" << codec_id.toString() << " is not found";
@@ -124,8 +139,8 @@
   *_aidl_return = std::nullopt;
   A2dpConfiguration avdtp_configuration;
 
-  if (A2dpOffloadCodecFactory::GetInstance()->GetConfiguration(
-          remote_a2dp_capabilities, hint, &avdtp_configuration))
+  if (codec_factory_.GetConfiguration(remote_a2dp_capabilities, hint,
+                                      &avdtp_configuration))
     *_aidl_return =
         std::make_optional<A2dpConfiguration>(std::move(avdtp_configuration));
 
diff --git a/bluetooth/audio/aidl/default/A2dpOffloadAudioProvider.h b/bluetooth/audio/aidl/default/A2dpOffloadAudioProvider.h
index 7cc6dee..a2d03fe 100644
--- a/bluetooth/audio/aidl/default/A2dpOffloadAudioProvider.h
+++ b/bluetooth/audio/aidl/default/A2dpOffloadAudioProvider.h
@@ -16,6 +16,7 @@
 
 #pragma once
 
+#include "A2dpOffloadCodecFactory.h"
 #include "BluetoothAudioProvider.h"
 
 namespace aidl {
@@ -26,8 +27,6 @@
 
 class A2dpOffloadAudioProvider : public BluetoothAudioProvider {
  public:
-  A2dpOffloadAudioProvider();
-
   bool isValid(const SessionType& session_type) override;
 
   ndk::ScopedAStatus startSession(
@@ -45,18 +44,23 @@
       const A2dpConfigurationHint& hint,
       std::optional<audio::A2dpConfiguration>* _aidl_return) override;
 
+ protected:
+  A2dpOffloadAudioProvider(const A2dpOffloadCodecFactory&);
+
  private:
+  const A2dpOffloadCodecFactory& codec_factory_;
+
   ndk::ScopedAStatus onSessionReady(DataMQDesc* _aidl_return) override;
 };
 
 class A2dpOffloadEncodingAudioProvider : public A2dpOffloadAudioProvider {
  public:
-  A2dpOffloadEncodingAudioProvider();
+  A2dpOffloadEncodingAudioProvider(const A2dpOffloadCodecFactory&);
 };
 
 class A2dpOffloadDecodingAudioProvider : public A2dpOffloadAudioProvider {
  public:
-  A2dpOffloadDecodingAudioProvider();
+  A2dpOffloadDecodingAudioProvider(const A2dpOffloadCodecFactory&);
 };
 
 }  // namespace audio
diff --git a/bluetooth/audio/aidl/default/A2dpOffloadCodec.h b/bluetooth/audio/aidl/default/A2dpOffloadCodec.h
index 7ed5872..2f51c73 100644
--- a/bluetooth/audio/aidl/default/A2dpOffloadCodec.h
+++ b/bluetooth/audio/aidl/default/A2dpOffloadCodec.h
@@ -18,10 +18,9 @@
 
 #include <aidl/android/hardware/bluetooth/audio/A2dpStatus.h>
 #include <aidl/android/hardware/bluetooth/audio/ChannelMode.h>
+#include <aidl/android/hardware/bluetooth/audio/CodecInfo.h>
 #include <aidl/android/hardware/bluetooth/audio/CodecParameters.h>
 
-#include "BluetoothAudioProviderFactory.h"
-
 namespace aidl::android::hardware::bluetooth::audio {
 
 class A2dpOffloadCodec {
diff --git a/bluetooth/audio/aidl/default/A2dpOffloadCodecAac.cpp b/bluetooth/audio/aidl/default/A2dpOffloadCodecAac.cpp
index 0f5533a..1570cd8 100644
--- a/bluetooth/audio/aidl/default/A2dpOffloadCodecAac.cpp
+++ b/bluetooth/audio/aidl/default/A2dpOffloadCodecAac.cpp
@@ -194,11 +194,6 @@
  * AAC Class implementation
  */
 
-const A2dpOffloadCodecAac* A2dpOffloadCodecAac::GetInstance() {
-  static A2dpOffloadCodecAac instance;
-  return &instance;
-}
-
 A2dpOffloadCodecAac::A2dpOffloadCodecAac()
     : A2dpOffloadCodec(info_),
       info_({.id = CodecId(CodecId::A2dp::AAC), .name = "AAC"}) {
diff --git a/bluetooth/audio/aidl/default/A2dpOffloadCodecAac.h b/bluetooth/audio/aidl/default/A2dpOffloadCodecAac.h
index eefa89b..65e927d 100644
--- a/bluetooth/audio/aidl/default/A2dpOffloadCodecAac.h
+++ b/bluetooth/audio/aidl/default/A2dpOffloadCodecAac.h
@@ -29,14 +29,12 @@
 class A2dpOffloadCodecAac : public A2dpOffloadCodec {
   CodecInfo info_;
 
-  A2dpOffloadCodecAac();
-
   A2dpStatus ParseConfiguration(const std::vector<uint8_t>& configuration,
                                 CodecParameters* codec_parameters,
                                 AacParameters* aac_parameters) const;
 
  public:
-  static const A2dpOffloadCodecAac* GetInstance();
+  A2dpOffloadCodecAac();
 
   A2dpStatus ParseConfiguration(
       const std::vector<uint8_t>& configuration,
diff --git a/bluetooth/audio/aidl/default/A2dpOffloadCodecFactory.cpp b/bluetooth/audio/aidl/default/A2dpOffloadCodecFactory.cpp
index 73d8fb1..658073c 100644
--- a/bluetooth/audio/aidl/default/A2dpOffloadCodecFactory.cpp
+++ b/bluetooth/audio/aidl/default/A2dpOffloadCodecFactory.cpp
@@ -37,20 +37,18 @@
  * Class implementation
  */
 
-const A2dpOffloadCodecFactory* A2dpOffloadCodecFactory::GetInstance() {
-  static A2dpOffloadCodecFactory instance;
-  return &instance;
-}
-
 A2dpOffloadCodecFactory::A2dpOffloadCodecFactory()
     : name("Offload"), codecs(ranked_codecs_) {
   ranked_codecs_.reserve(kEnableAac + kEnableSbc);
 
-  if (kEnableAac) ranked_codecs_.push_back(A2dpOffloadCodecAac::GetInstance());
-  if (kEnableSbc) ranked_codecs_.push_back(A2dpOffloadCodecSbc::GetInstance());
+  if (kEnableAac)
+    ranked_codecs_.push_back(std::make_shared<A2dpOffloadCodecAac>());
+  if (kEnableSbc)
+    ranked_codecs_.push_back(std::make_shared<A2dpOffloadCodecSbc>());
 }
 
-const A2dpOffloadCodec* A2dpOffloadCodecFactory::GetCodec(CodecId id) const {
+std::shared_ptr<const A2dpOffloadCodec> A2dpOffloadCodecFactory::GetCodec(
+    CodecId id) const {
   auto codec = std::find_if(begin(ranked_codecs_), end(ranked_codecs_),
                             [&](auto c) { return id == c->info.id; });
 
diff --git a/bluetooth/audio/aidl/default/A2dpOffloadCodecFactory.h b/bluetooth/audio/aidl/default/A2dpOffloadCodecFactory.h
index 3fb5b1d..1546cc4 100644
--- a/bluetooth/audio/aidl/default/A2dpOffloadCodecFactory.h
+++ b/bluetooth/audio/aidl/default/A2dpOffloadCodecFactory.h
@@ -16,22 +16,26 @@
 
 #pragma once
 
+#include <aidl/android/hardware/bluetooth/audio/A2dpConfiguration.h>
+#include <aidl/android/hardware/bluetooth/audio/A2dpConfigurationHint.h>
+#include <aidl/android/hardware/bluetooth/audio/A2dpRemoteCapabilities.h>
+
+#include <memory>
+
 #include "A2dpOffloadCodec.h"
 
 namespace aidl::android::hardware::bluetooth::audio {
 
 class A2dpOffloadCodecFactory {
-  std::vector<const A2dpOffloadCodec*> ranked_codecs_;
-
-  A2dpOffloadCodecFactory();
+  std::vector<std::shared_ptr<const A2dpOffloadCodec>> ranked_codecs_;
 
  public:
   const std::string name;
-  const std::vector<const A2dpOffloadCodec*>& codecs;
+  const std::vector<std::shared_ptr<const A2dpOffloadCodec>>& codecs;
 
-  static const A2dpOffloadCodecFactory* GetInstance();
+  A2dpOffloadCodecFactory();
 
-  const A2dpOffloadCodec* GetCodec(CodecId id) const;
+  std::shared_ptr<const A2dpOffloadCodec> GetCodec(CodecId id) const;
 
   bool GetConfiguration(const std::vector<A2dpRemoteCapabilities>&,
                         const A2dpConfigurationHint& hint,
diff --git a/bluetooth/audio/aidl/default/A2dpOffloadCodecSbc.cpp b/bluetooth/audio/aidl/default/A2dpOffloadCodecSbc.cpp
index 36d8f72..6b9046c 100644
--- a/bluetooth/audio/aidl/default/A2dpOffloadCodecSbc.cpp
+++ b/bluetooth/audio/aidl/default/A2dpOffloadCodecSbc.cpp
@@ -257,11 +257,6 @@
  * SBC Class implementation
  */
 
-const A2dpOffloadCodecSbc* A2dpOffloadCodecSbc::GetInstance() {
-  static A2dpOffloadCodecSbc instance;
-  return &instance;
-}
-
 A2dpOffloadCodecSbc::A2dpOffloadCodecSbc()
     : A2dpOffloadCodec(info_),
       info_({.id = CodecId(CodecId::A2dp::SBC), .name = "SBC"}) {
diff --git a/bluetooth/audio/aidl/default/A2dpOffloadCodecSbc.h b/bluetooth/audio/aidl/default/A2dpOffloadCodecSbc.h
index c380850..a39d779 100644
--- a/bluetooth/audio/aidl/default/A2dpOffloadCodecSbc.h
+++ b/bluetooth/audio/aidl/default/A2dpOffloadCodecSbc.h
@@ -33,14 +33,12 @@
 class A2dpOffloadCodecSbc : public A2dpOffloadCodec {
   CodecInfo info_;
 
-  A2dpOffloadCodecSbc();
-
   A2dpStatus ParseConfiguration(const std::vector<uint8_t>& configuration,
                                 CodecParameters* codec_parameters,
                                 SbcParameters* sbc_parameters) const;
 
  public:
-  static const A2dpOffloadCodecSbc* GetInstance();
+  A2dpOffloadCodecSbc();
 
   A2dpStatus ParseConfiguration(
       const std::vector<uint8_t>& configuration,
diff --git a/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.cpp b/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.cpp
index e55a434..c7c6e6d 100644
--- a/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.cpp
+++ b/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.cpp
@@ -22,7 +22,6 @@
 #include <android-base/logging.h>
 
 #include "A2dpOffloadAudioProvider.h"
-#include "A2dpOffloadCodecFactory.h"
 #include "A2dpSoftwareAudioProvider.h"
 #include "BluetoothAudioProvider.h"
 #include "HearingAidAudioProvider.h"
@@ -53,7 +52,8 @@
       provider = ndk::SharedRefBase::make<A2dpSoftwareEncodingAudioProvider>();
       break;
     case SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH:
-      provider = ndk::SharedRefBase::make<A2dpOffloadEncodingAudioProvider>();
+      provider = ndk::SharedRefBase::make<A2dpOffloadEncodingAudioProvider>(
+          a2dp_offload_codec_factory_);
       break;
     case SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH:
       provider = ndk::SharedRefBase::make<HearingAidAudioProvider>();
@@ -82,7 +82,8 @@
       provider = ndk::SharedRefBase::make<A2dpSoftwareDecodingAudioProvider>();
       break;
     case SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH:
-      provider = ndk::SharedRefBase::make<A2dpOffloadDecodingAudioProvider>();
+      provider = ndk::SharedRefBase::make<A2dpOffloadDecodingAudioProvider>(
+          a2dp_offload_codec_factory_);
       break;
     case SessionType::HFP_SOFTWARE_ENCODING_DATAPATH:
       provider = ndk::SharedRefBase::make<HfpSoftwareOutputAudioProvider>();
@@ -160,8 +161,8 @@
       session_type == SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH) {
     auto& provider_info = _aidl_return->emplace();
 
-    provider_info.name = A2dpOffloadCodecFactory::GetInstance()->name;
-    for (auto codec : A2dpOffloadCodecFactory::GetInstance()->codecs)
+    provider_info.name = a2dp_offload_codec_factory_.name;
+    for (auto codec : a2dp_offload_codec_factory_.codecs)
       provider_info.codecInfos.push_back(codec->info);
   }
 
diff --git a/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.h b/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.h
index 1afae64..6931884 100644
--- a/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.h
+++ b/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.h
@@ -18,6 +18,8 @@
 
 #include <aidl/android/hardware/bluetooth/audio/BnBluetoothAudioProviderFactory.h>
 
+#include "A2dpOffloadCodecFactory.h"
+
 namespace aidl {
 namespace android {
 namespace hardware {
@@ -25,6 +27,8 @@
 namespace audio {
 
 class BluetoothAudioProviderFactory : public BnBluetoothAudioProviderFactory {
+  const A2dpOffloadCodecFactory a2dp_offload_codec_factory_;
+
  public:
   BluetoothAudioProviderFactory();